Hi, I wrote you a new test.cpp file. I found very basic mistakes in your file. Please read Gecode documentation and try a little harder, you would have probably found these errors yourself.
Best regards, Vincent 2013/7/6 manel askri <askri.man...@gmail.com> > hi evry one ! > > i have modified a littel bit my code but i still get the same error : no > solution > > so i have a question : because i work with two solvers gecode and choco : > is it necessairy if choco finds a solution for a problem gecode will to???? > ( because my code here does have a solution with choco but with gecode no > and i dont know if is it because my code is incorrect or what ????,,) > > See the test.cpp attached files > > so if any one have any idea about my question i will be so greatful > > Thanks very much > > ASKRI MAnel > > > 2013/7/4 Vincent Barichard <vincent.barich...@univ-angers.fr> > >> You should read the files in the "examples" directory. >> By making your example inherits from Script, you see that it has no >> solution. >> See the test.cpp attached file. >> >> Vincent >> >> >> 2013/7/4 Christian Schulte <cschu...@kth.se> >> >>> Please read MPG, at least the introductory material (especially Chapter >>> 3 answers your question). This mailing list assumes that you read the >>> documentation and not that it is being spoon-fed to you on the users >>> mailing list.**** >>> >>> ** ** >>> >>> Christian**** >>> >>> ** ** >>> >>> --**** >>> >>> Christian Schulte, Professor of Computer Science, KTH, >>> www.ict.kth.se/~cschulte/**** >>> >>> ** ** >>> >>> *From:* users-boun...@gecode.org [mailto:users-boun...@gecode.org] *On >>> Behalf Of *manel askri >>> *Sent:* Thursday, July 04, 2013 4:21 AM >>> *To:* users@gecode.org; users-requ...@gecode.org; users-ow...@gecode.org >>> *Subject:* [gecode-users] generation of a solution with success but no >>> display at the console**** >>> >>> ** ** >>> >>> hi every one!**** >>> >>> ** ** >>> >>> i m new with gecode and this is my first model, it consists in >>> displaying the following result :**** >>> >>> ** ** >>> >>> 2 19 22 12 10**** >>> >>> 11 13 18 17 6**** >>> >>> 21 16 1 7 20**** >>> >>> 8 14 15 24 4**** >>> >>> 23 3 9 5 25**** >>> >>> CSTE_65:65 **** >>> >>> ** ** >>> >>> so this is my code :**** >>> >>> #include <gecode/int.hh>**** >>> >>> #include <gecode/driver.hh>**** >>> >>> #include <gecode/minimodel.hh>**** >>> >>> #include <gecode/search.hh>**** >>> >>> ** ** >>> >>> using namespace Gecode;**** >>> >>> ** ** >>> >>> class E1 : public Space {**** >>> >>> private :**** >>> >>> **** >>> >>> static const int n =5;**** >>> >>> protected:**** >>> >>> ** ** >>> >>> IntVarArray v1;**** >>> >>> ** ** >>> >>> IntVar v2;**** >>> >>> ** ** >>> >>> public:**** >>> >>> ** ** >>> >>> E1(void) : v1(*this, n*n,1,n*n), >>> v2(*this,n*(n*n+1)/2,n*(n*n+1)/2){**** >>> >>> **** >>> >>> distinct (*this, v1);**** >>> >>> IntVarArgs rowArray (*this,n , 1, n);**** >>> >>> IntVarArgs colArray (*this,n , 1, n);**** >>> >>> IntVarArgs diag1Array (*this,n , 1, n);**** >>> >>> IntVarArgs diag2Array (*this,n , 1, n);**** >>> >>> ** ** >>> >>> **** >>> >>> **** >>> >>> //IntVarArgs sumConstraints ;**** >>> >>> ** ** >>> >>> for (int i =0; i<n;i++)**** >>> >>> {**** >>> >>> for (int j=0; j<n; j++)**** >>> >>> {**** >>> >>> rowArray[j]= v1[i*n+1];* >>> *** >>> >>> colArray[j]= v1[j*n+1];* >>> *** >>> >>> }**** >>> >>> **** >>> >>> // rel (*this, sum(rowArray),IRT_EQ, v2);**** >>> >>> // rel ( *this , sum(colArray), IRT_EQ ,v2);**** >>> >>> ** ** >>> >>> linear( *this , rowArray, IRT_EQ, v2);**** >>> >>> linear( *this , colArray, IRT_EQ, v2);**** >>> >>> diag1Array[i]=v1[i * n + i];**** >>> >>> diag2Array[i]= v1[i*n+n-i-1];**** >>> >>> }**** >>> >>> ** ** >>> >>> //rel(*this , sum(diag1Array), IRT_EQ,v2);**** >>> >>> //rel(*this, sum(diag2Array), IRT_EQ,v2);**** >>> >>> ** ** >>> >>> **** >>> >>> linear( *this , diag1Array, IRT_EQ, v2);**** >>> >>> linear( *this , diag2Array, IRT_EQ, v2);**** >>> >>> ** ** >>> >>> ** ** >>> >>> // post branching**** >>> >>> branch(*this, v1, INT_VAR_SIZE_MIN(), >>> INT_VAL_MIN());**** >>> >>> ** ** >>> >>> }**** >>> >>> // search support**** >>> >>> E1(bool share, E1& s) : Space(share, s) {**** >>> >>> v1.update(*this, share, s.v1);**** >>> >>> **** >>> >>> }**** >>> >>> ** ** >>> >>> virtual Space* copy(bool share) {**** >>> >>> return new E1(share,*this);**** >>> >>> }**** >>> >>> ** ** >>> >>> // print solution**** >>> >>> void print(void) const {**** >>> >>> for(int i = 0; i < n; i++) {**** >>> >>> for(int j = 0; j < n; j++) {**** >>> >>> v1[i * n + j];**** >>> >>> std::cout << v1[i * n + >>> j] << std::endl;**** >>> >>> **** >>> >>> }**** >>> >>> }**** >>> >>> }**** >>> >>> ** ** >>> >>> };**** >>> >>> // main function**** >>> >>> int main(int argc, char* argv[]) {**** >>> >>> // create model and search engine**** >>> >>> E1* m = new E1;**** >>> >>> DFS<E1> e(m);**** >>> >>> delete m;**** >>> >>> // search and print all solutions**** >>> >>> while (E1* s = e.next()) {**** >>> >>> s->print(); delete s;**** >>> >>> }**** >>> >>> return 0;**** >>> >>> }**** >>> >>> ** ** >>> >>> my problem is that when i generat the solution i do it successfly but >>> when i use the command prompt to execute the executable the console >>> displays nothing**** >>> >>> so please if any one have any idea obout this i will be so greatful **** >>> >>> ** ** >>> >>> thanks very much for any help**** >>> >>> ** ** >>> >>> ASKRI Manel**** >>> >>> ** ** >>> >>> **** >>> >>> ** ** >>> >>> ** ** >>> >>> _______________________________________________ >>> Gecode users mailing list >>> users@gecode.org >>> https://www.gecode.org/mailman/listinfo/gecode-users >>> >>> >> >> >> -- >> Vincent Barichard Université d'Angers (LERIA) >> Tel: 02 41 73 52 06 Département Informatique >> Fax: 02 41 73 50 73 H203 >> > > -- Vincent Barichard Université d'Angers (LERIA) Tel: 02 41 73 52 06 Département Informatique Fax: 02 41 73 50 73 H203
#include <gecode/int.hh> #include <gecode/driver.hh> #include <gecode/minimodel.hh> #include <gecode/search.hh> using namespace Gecode; class E1 : public Script { private : static const int n =5; protected: IntVarArray X; public: E1(const Options&) : X(*this, n*n,1,n*n) { distinct (*this, X); int y = n*(n*n+1)/2; for (int i=0;i<n;i++) { IntVarArgs row = X.slice(i*n, 1, n); IntVarArgs col = X.slice(i, n, n); linear( *this, row, IRT_EQ, y); linear( *this, col, IRT_EQ, y); } IntVarArgs diag1 = X.slice(0, n+1, n); IntVarArgs diag2 = X.slice(n-1, n-1, n); linear( *this, diag1, IRT_EQ, y); linear( *this, diag2, IRT_EQ, y); // post branching branch(*this, X, INT_VAR_SIZE_MAX(), INT_VAL_MAX()); } // search support E1(bool share, E1& s) : Script(share, s) { X.update(*this, share, s.X); } virtual Space* copy(bool share) { return new E1(share,*this); } // print solution void print(std::ostream& os) const { std::cout << "Value: " << n*(n*n+1)/2 << std::endl; for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) os << std::setw(4) << X[i * n + j]; os << std::endl; } } }; // main function int main(int argc, char* argv[]) { Options opt("Test Problem"); opt.parse(argc,argv); Script::run<E1,DFS,Options>(opt); return 0; }
_______________________________________________ Gecode users mailing list users@gecode.org https://www.gecode.org/mailman/listinfo/gecode-users