[gecode-users] newbie's question about distribution

volpadri at alice.it volpadri at alice.it
Tue Sep 18 21:33:42 CEST 2007


Hi to you all,

I am playing with the Eclipse + Jython environment and setup the simple
problem:

==================================================================

from org.gecode import *

class MySpace(Space):
    def __init__(self):
        self.vars = VarArray()
    def copy(self,share):
        new = MySpace()
        new.vars = VarArray(new,share,self.vars)
        return new
    def intVar(self, fromto):
        v = IntVar(self, fromto[0], fromto[1])
        self.vars.add(v)
        return v
    def intVarList(self,n,fromto):
        lst = map(lambda i:  self.intVar(fromto), range(n))
        return lst
    def linear_eq(self,vlst,term):
        varray = VarArray(vlst)
        Gecode.linear(self,varray,IntRelType.IRT_EQ,term)
    def dom(self,v,lo,hi):
        Gecode.dom(self,v,lo,hi)

###############################################################################

if __name__ == "__main__":
    s = MySpace()
    v1 = s.intVar((0,9))
    v2 = s.intVar((0,9))
    s.linear_eq([v1,v2],2 )        # v1 + v2 := 2
    s.dom(v1,1,2)
    search = DFSSearch(s)
    sol = search.next()
    while sol:
        print sol.vars
        sol = search.next()

==================================================================
the result is:

>>> [[1..2],[0..1]]

but at this point I can't understand how to distribute on the vars.

Can you help me?

Thanks,

Adriano Volpones 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20070918/1a735e95/attachment.htm>


More information about the gecode-users mailing list