Generated on Thu Mar 22 10:39:31 2012 for Gecode by doxygen 1.6.3

eq20.cpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2001
00008  *
00009  *  Last modified:
00010  *     $Date: 2010-10-07 11:52:01 +0200 (Thu, 07 Oct 2010) $ by $Author: schulte $
00011  *     $Revision: 11473 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 #include <gecode/driver.hh>
00039 #include <gecode/int.hh>
00040 
00041 using namespace Gecode;
00042 
00051 class Eq20 : public Script {
00052 private:
00054   static const int x_n = 7;
00056   static const int e_n = 20;
00058   IntVarArray x;
00059 public:
00061   Eq20(const Options& opt)
00062     : x(*this,x_n,0,10) {
00063     // Coefficients and constants for the equations
00064     int eqs[e_n][x_n+1] = {
00065       {876370, -16105, 62397, -6704, 43340, 95100, -68610, 58301},
00066       {533909, 51637, 67761, 95951, 3834, -96722, 59190, 15280},
00067       {915683, 1671, -34121, 10763, 80609, 42532, 93520, -33488},
00068       {129768, 71202, -11119, 73017, -38875, -14413, -29234, 72370},
00069       {752447, 8874, -58412, 73947, 17147, 62335, 16005, 8632},
00070       {90614, 85268, 54180, -18810, -48219, 6013, 78169, -79785},
00071       {1198280, -45086, 51830, -4578, 96120, 21231, 97919, 65651},
00072       {18465, -64919, 80460, 90840, -59624, -75542, 25145, -47935},
00073       {1503588, -43277, 43525, 92298, 58630, 92590, -9372, -60227},
00074       {1244857, -16835, 47385, 97715, -12640, 69028, 76212, -81102},
00075       {1410723, -60301, 31227, 93951, 73889, 81526, -72702, 68026},
00076       {25334, 94016, -82071, 35961, 66597, -30705, -44404, -38304},
00077       {277271, -67456, 84750, -51553, 21239, 81675, -99395, -4254},
00078       {249912, -85698, 29958, 57308, 48789, -78219, 4657, 34539},
00079       {373854, 85176, -95332, -1268, 57898, 15883, 50547, 83287},
00080       {740061, -10343, 87758, -11782, 19346, 70072, -36991, 44529},
00081       {146074, 49149, 52871, -7132, 56728, -33576, -49530, -62089},
00082       {251591, -60113, 29475, 34421, -76870, 62646, 29278, -15212},
00083       {22167, 87059, -29101, -5513, -21219, 22128, 7276, 57308},
00084       {821228, -76706, 98205, 23445, 67921, 24111, -48614, -41906}
00085     };
00086     // Post equation constraints
00087     for (int i = e_n; i--; ) {
00088       IntArgs c(x_n, eqs[i][1],eqs[i][2],eqs[i][3],eqs[i][4],
00089                      eqs[i][5],eqs[i][6],eqs[i][7]);
00090       linear(*this, c, x, IRT_EQ, eqs[i][0], opt.icl());
00091     }
00092     branch(*this, x, INT_VAR_NONE, INT_VAL_MIN);
00093   }
00094 
00096   Eq20(bool share, Eq20& s) : Script(share,s) {
00097     x.update(*this, share, s.x);
00098   }
00100   virtual Space*
00101   copy(bool share) {
00102     return new Eq20(share,*this);
00103   }
00105   virtual void
00106   print(std::ostream& os) const {
00107     os << "\tx[] = " << x << std::endl;
00108   }
00109 
00110 };
00111 
00115 int
00116 main(int argc, char* argv[]) {
00117   Options opt("Eq20");
00118   opt.solutions(0);
00119   opt.iterations(1000);
00120   opt.parse(argc,argv);
00121   Script::run<Eq20,DFS,Options>(opt);
00122   return 0;
00123 }
00124 
00125 
00126 
00127 // STATISTICS: example-any
00128