On 27 Jun 2011, at 15:41, Dongrui She wrote:

> Hi All,
> 
> I am new to gecode and I have a question about how to model a constraint:
> sum{a_i*b_i}
> 
> where a is an integer variable array and b is a bool variable array.
> Basically I want to constrain the sum of some elements in a.
> 
> It seems that I cannot directly specify such constraint. Right now what I can
> think of is to use channel constraint to create an integer array with the same
> value as b and use it to specify the constraint I want.
> 
> Is this the right way to go?

You could do that, but I suspect it would be more efficient to introduce 
temporary integer variables c_i such that
b -> c_i = a_i
and
!b -> c_i = 0

and then use the sum of the c_i.

Cheers,
        Guido

-- 
Guido Tack, http://people.cs.kuleuven.be/~guido.tack/


_______________________________________________
Gecode users mailing list
[email protected]
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to