[gecode-users] Generating constraints
Max
chaosangel at gmx.de
Tue Oct 28 15:51:00 CET 2008
126 Gecode::MiniModel::LinExpr<IntVar>
GecodeSolver::SearchSpace::generateVariable(CSPConstraint c)
127 {
...
135 CSPConstraint* a,*b;
136 switch(c.getOperator(a,b))
137 {
138 case CSPConstraint::PLUS:
139 return generateVariable(*a) + generateVariable(*b);
140 case CSPConstraint::MINUS:
141 return generateVariable(*a) - generateVariable(*b);
142 case CSPConstraint::TIMES:
143 return generateVariable(*a) * generateVariable(*b);
144 case CSPConstraint::DIVIDE:
145 return generateVariable(*a) / generateVariable(*b);
146 case CSPConstraint::ABS:
147 assert(false);
148
149 }
...
151 else
152 if (c.getType() == CSPConstraint::INTEGER)
153 {
154 return c.getInteger();
155 }
This way not supporting the conversion, i need an if/else for each call
of generateVariable, (32cases).
Max
Guido Tack wrote:
> Max wrote:
>
>> But, with this code written i do get some errors, because the rel
>> method
>> is not defined for constants
>> as:
>> - both arguments
>> - first argument
>>
>> so i can not write
>>
>> rel(this, 5, IRT_GR, x, b);
>>
>> Why?
>> Do i have manually to flip the operands ?
>>
>
> You could also use the post functions from minimodel here:
> post(this, tt(eqv(~(5 > x), b)));
>
> They should accept constants in all positions (and if not, we'll have
> to fix it).
>
> Cheers,
> Guido
>
>
> _______________________________________________
> Gecode users mailing list
> users at gecode.org
> https://www.gecode.org/mailman/listinfo/gecode-users
>
>
More information about the gecode-users
mailing list