hi Guido, Thanks for your reply! 1. The second question is not a problem to me now, for your reminding. Yes. As you said, if i want to multiply two variables, mult constraint is a choose. Because of carelessness, i have to study manual of Gecode well again. 2. But i still not understand your reply well about the first question. whether your means are that distinct constraint is only used for IntVarArgs, as written in the manual of Gecode --- " void Gecode::distinct<mk:@MSITStore:D:\Program%20Files\Gecode\doc\GecodeReference.chm::/group__TaskModelIntDistinct.html#g5f4f4006b72f95618b3030815a8718a5>(Space &home, const IntVarArgs & x<mk:@MSITStore:D:\Program%20Files\Gecode\doc\GecodeReference.chm::/kakuro_8cpp.html#e928e6fd222358d27be0a56a8ade81ce>, IntConLevel icl=ICL_DEF)" But i found that i can also use IntVarArray in distinct constraint through testing, and also see it in the example "money.cpp" supplied by the manual of Gecode 3.1.0. As follows: " IntVarArray le; distinct(*this, le, opt.icl()) " I know they are Array, from their definition i have no idea to understand the reason why they can all be used in distinct constraint . Look forward to your reply. Thanks Kayler
2009/8/2 Guido Tack <t...@ps.uni-sb.de> > 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 us...@gecode.org https://www.gecode.org/mailman/listinfo/gecode-users