[gecode-users] Gecode/J: What is Space abstract?

Mikael Zayenz Lagerkvist zayenz at gmail.com
Tue Nov 6 07:11:16 CET 2007


On 11/6/07, Malcolm Ryan <malcolmr at cse.unsw.edu.au> wrote:
> On 05/11/2007, at 2:57 PM, Mikael Zayenz Lagerkvist wrote:
>
> > On 11/5/07, Malcolm Ryan <malcolmr at cse.unsw.edu.au> wrote:
> >> What is the Space class abstract in Gecode/J when it doesn't have any
> >> abstract methods? Is there any harm in doing:
> >>
> >> Space space = new Space() {};
> >>
> >
> > While there is no harm in doing the above (as far as I can recall at
> > the moment), I'm not sure I see what the point would be. The only
> > information you would be able to get out of a problem set up in the
> > space-variable would be if there are any solutions, since you can not
> > access the variables of the problem.
>
> I'm writing JUnit tests, for my code to check that the system of
> constraints I am creating are valid. I want to do something like:
>
> Space space = new Space();
>
> // ... create vars in space ...
> IntVar x = new IntVar(space, ...)
> IntVar y = new IntVar(space, ...)
>
> // ... post constraints ...
> mySystem.postConstraints(space, x, y, ...)
>
> // propagate
> space.status();
>
> // test results
> assertTrue(x.assigned());
> assertEquals(0, x.val());
> // etc

Ok, if you do not want to do any search, I understand how can use it.

> What is the purpose of the copy constructor in the Queens.java
> example? Should every space have such a constructor? When is it called?

It is called when copying a Space during search, so if you want to
search for a solution you need to implement it. Anything that you want
to refer to in a solution needs to be updated here.

Cheers,
Mikael

PS. if you haven't seen it before,
http://www.gecode.org/gecodej/doc/PageGlossary.html has some short
descriptions of the terms often used for Gecode(/J).

-- 
Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/




More information about the gecode-users mailing list