Kayler Yao wrote:
> 1. the difference bettween IntVarArray and IntVarArgs ,and how to
> use them
> As explained in the manual of Gecode, IntVarArgs is Argument
> array which is just good enough for passing arguments with automatic
> memory management. IntVarArray is Variable array which can store
> variables and be used for storing the variables being part of a
> solution (script).
> From these description,i can see that IntVarArgs can be used when i
> need automatic memory management.But When i need automatic memory
> management, i don't know. If you give me an simple example, i maybe
> can understand it.
Take sudoku as an example. It has 81 variables, one for each field,
so you have an IntVarArray x for these variables. Now you want to
post the constraint that the first row, x[0],...,x[8] must be
distinct. So you create an IntVarArgs containing those variables and
pass it to the distinct constraint. You don't have to worry about
memory management for that array.
> 2. how to post the constraint ----multiplication of two variable?
> For instance ,
> IntVarArry x;
> x(*this,4,1,6);
> I want to have a constraint " x[0] * x[1] = x[2] ".when i
> write " post(*this, x[0] * x[1] == x[2],o pt.icl( ) );" in my
> test program, errors come out. I began to doubt that whether you
> can use the sign of " * ". After testing " post(*this, 2 * x[1]
> == x[2],o pt.icl( ) );", i have know that i can use " * ". So, I
> doubt that we can't multiply two variable with the sign " * ". Who
> can tell me how to add this constraint ?
The minimodel library (which contains the post(...) functions) only
supports linear expressions, i.e. multiplication with constants. To
multiply two variables, use the mult constraint.
Cheers,
Guido
_______________________________________________
Gecode users mailing list
[email protected]
https://www.gecode.org/mailman/listinfo/gecode-users