OMG, I checked the code for a long time before, but with no result. It was a logistic error.Thank you for reminding me.
Now the program runs Ok! Thanks again! Kayler 2009/8/10 Christian Schulte <[email protected]> > Your copy constructor is wrong: the second update should update from > s.mun and not from s.num. > > > > Christian > > > > -- > > Christian Schulte, www.ict.kth.se/~cschulte/ > > > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Kayler Yao > *Sent:* Monday, August 10, 2009 10:33 AM > *To:* [email protected] > *Subject:* [gecode-users] help--Question about Channel constraints > > > > hi, > > > > A question came out when i used Channel constraints. One type of > Channel constrains is for two integer variable arrays x and y of same size, > for example > > " > > channel(home, x, y); > > posts the constraint > Xi = j <==> Yj = i for 0 ≤ i, j < |x| > > " > > When i made a test , the result was not what it should to be. > > My tools are VS2008,Gecode 3.1.0. My test is > > > > " > > #include <gecode/driver.hh> > #include <gecode/int.hh> > > using namespace Gecode; > > > > class Fournum : public Script > { > protected: > > IntVarArray num; > IntVarArray mun; > > > public: > Fournum(const Options& opt) : num(*this,3,0,2),mun(*this,3,0,2) > { > > > channel(*this,num,mun); > branch(*this, num, INT_VAR_NONE, INT_VAL_MIN); > > branch(*this,mun, INT_VAR_NONE, INT_VAL_MIN); > } > > virtual void > print(std::ostream& os) const > { > os << "\t" << num<<"-------"<<mun<<std::endl; > } > > Fournum(bool share, Fournum& s) : Script(share,s) > { > num.update(*this, share, s.num); > mun.update(*this,share,s.num); > } > > virtual Space* copy(bool share) > { > return new Fournum(share,*this); > } > > > }; > > > > int main() > { > Options opt("\tJust for test"); > opt.solutions(0); > opt.iterations(20000); > Script::run<Fournum,DFS,Options>(opt); > system("pause"); > return 0; > } > > " > > The result is > > {0, 1, 2}-------{0, 1, 2} > {0, 2, 1}-------{0, 2, 1} > {1, 0, 2}-------{1, 0, 2} > {1, 2, 0}-------{1, 2, 0} > {2, 0, 1}-------{2, 0, 1} > {2, 1, 0}-------{2, 1, 0} > > You can see that the fourth and the fifth are not right . Who can tell me > why ? > > > > Look forward to your reply! > > > > Kayler. >
_______________________________________________ Gecode users mailing list [email protected] https://www.gecode.org/mailman/listinfo/gecode-users
