Generated on Wed Nov 1 15:04:27 2006 for Gecode by doxygen 1.4.5

eq20.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2001
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-03-09 11:12:26 +0100 (Thu, 09 Mar 2006) $ by $Author: zayenz $
00010  *     $Revision: 3063 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
00019  *
00020  */
00021 
00022 #include "examples/support.hh"
00023 
00032 class Eq20 : public Example {
00033 private:
00035   static const int x_n = 7;
00037   static const int e_n = 20;
00039   IntVarArray x;
00040 public:
00042   Eq20(const Options& opt)
00043     : x(this,x_n,0,10) {
00044     // Coefficients and constants for the equations
00045     int eqs[e_n][x_n+1] = {
00046       {876370, -16105, 62397, -6704, 43340, 95100, -68610, 58301},
00047       {533909, 51637, 67761, 95951, 3834, -96722, 59190, 15280},
00048       {915683, 1671, -34121, 10763, 80609, 42532, 93520, -33488},
00049       {129768, 71202, -11119, 73017, -38875, -14413, -29234, 72370},
00050       {752447, 8874, -58412, 73947, 17147, 62335, 16005, 8632},
00051       {90614, 85268, 54180, -18810, -48219, 6013, 78169, -79785},
00052       {1198280, -45086, 51830, -4578, 96120, 21231, 97919, 65651},
00053       {18465, -64919, 80460, 90840, -59624, -75542, 25145, -47935},
00054       {1503588, -43277, 43525, 92298, 58630, 92590, -9372, -60227},
00055       {1244857, -16835, 47385, 97715, -12640, 69028, 76212, -81102},
00056       {1410723, -60301, 31227, 93951, 73889, 81526, -72702, 68026},
00057       {25334, 94016, -82071, 35961, 66597, -30705, -44404, -38304},
00058       {277271, -67456, 84750, -51553, 21239, 81675, -99395, -4254},
00059       {249912, -85698, 29958, 57308, 48789, -78219, 4657, 34539},
00060       {373854, 85176, -95332, -1268, 57898, 15883, 50547, 83287},
00061       {740061, -10343, 87758, -11782, 19346, 70072, -36991, 44529},
00062       {146074, 49149, 52871, -7132, 56728, -33576, -49530, -62089},
00063       {251591, -60113, 29475, 34421, -76870, 62646, 29278, -15212},
00064       {22167, 87059, -29101, -5513, -21219, 22128, 7276, 57308},
00065       {821228, -76706, 98205, 23445, 67921, 24111, -48614, -41906}
00066     };
00067     // Post equation constraints
00068     for (int i = e_n; i--; ) {
00069       IntArgs c(7,eqs[i][1],eqs[i][2],eqs[i][3],eqs[i][4],
00070                 eqs[i][5],eqs[i][6],eqs[i][7]);
00071       linear(this, c, x, IRT_EQ, eqs[i][0], opt.icl);
00072     }
00073     branch(this, x, BVAR_NONE, BVAL_MIN);
00074   }
00075 
00077   Eq20(bool share, Eq20& s) : Example(share,s) {
00078     x.update(this, share, s.x);
00079   }
00081   virtual Space*
00082   copy(bool share) {
00083     return new Eq20(share,*this);
00084   }
00086   virtual void
00087   print(void) {
00088     std::cout << "\tx[] = {";
00089     for (int i = 0; i < x_n; i++)
00090       std::cout << x[i] << ((i<x_n-1)?",":"};\n");
00091   }
00092 
00093 };
00094 
00098 int
00099 main(int argc, char** argv) {
00100   Options opt("Eq20");
00101   opt.solutions  = 0;
00102   opt.iterations = 1000;
00103   opt.parse(argc,argv);
00104   Example::run<Eq20,DFS>(opt);
00105   return 0;
00106 }
00107 
00108 
00109 
00110 // STATISTICS: example-any
00111