[gecode-users] Generating constraints

Mikael Zayenz Lagerkvist zayenz at gmail.com
Tue Oct 28 13:26:19 CET 2008


Hi,

If you have a tree representing an expression, then you should write a
tree-analyzer (a tree-walker for example) that posts constraints that
correspond to the tree. This is how the linear expressions in Gecodes
MiniModel works. For more information on writing tree analyzers, see a
compiler text as it corresponds to instruction selection.

There is no way to undo a tell - you have to copy the space.

Cheers,
Mikael


On Tue, Oct 28, 2008 at 12:58 PM, Max <chaosangel at gmx.de> wrote:
> Hello all,
>
> i currently try to post constraints and need your help.
> I have my constraints not in a textual format, but in a self made tree
> structure of the form
>
>
>                              rel">="
>                             /         \
>                           op+      const=5
>                        /       \
>                var=x       const=7
>
>
> (i hope this is readable)
>
> Now i want to generate and post a gecode constraint of it.
> Is there an easy way to recursivly define a constraint, because it seems
> to me that there is no baseclass or something that can be used.
>
> I wanted to to something of the form
>
> GeCodeConstraint recursive_converter(MyConstraint)
> {
>       if "variable" return x;
>       if "constant" return 5;
>       if "op+" return recursive_converter(left_node) +
> recursive_converter(right_node);
>       if "rel>=" return recursive_converter(left_node) >=
> recursive_converter(right_node);
> }
>
>
> I i found for GeCodeConstraint was MiniModel::LinRel<>, is there
> something more uniform, because i want to use boolean and integer
> variables (reified constraints) and stuff.
> (the arithmetic functions seem very generic returning a variable, but
> then a lot of extra variables would have to be generated)
>
>
> Any ideas ?
>
> 2nd question:
>
> Is there a way to post the value of a variable not in form of a
> constraint, so "branch" on a boolean variable but being able to undo it so
>
> so
> b[0].set(0);
> //after some time
> b[0].set(1);
>
> without copying the whole space?
>
> Thank you a lot.
>
> Max
>
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
>



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




More information about the gecode-users mailing list