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

options.hpp

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, 2004
00008  *
00009  *  Last modified:
00010  *     $Date: 2011-02-22 13:52:12 +0100 (Tue, 22 Feb 2011) $ by $Author: schulte $
00011  *     $Revision: 11766 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *
00018  *  Permission is hereby granted, free of charge, to any person obtaining
00019  *  a copy of this software and associated documentation files (the
00020  *  "Software"), to deal in the Software without restriction, including
00021  *  without limitation the rights to use, copy, modify, merge, publish,
00022  *  distribute, sublicense, and/or sell copies of the Software, and to
00023  *  permit persons to whom the Software is furnished to do so, subject to
00024  *  the following conditions:
00025  *
00026  *  The above copyright notice and this permission notice shall be
00027  *  included in all copies or substantial portions of the Software.
00028  *
00029  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00030  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00031  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00032  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00033  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00034  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00035  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00036  *
00037  */
00038 
00039 #include <cstring>
00040 
00041 namespace Gecode {
00042 
00043   namespace Driver {
00044     /*
00045      * String option
00046      *
00047      */
00048     inline
00049     StringValueOption::StringValueOption(const char* o, const char* e, 
00050                                          const char* v)
00051       : BaseOption(o,e), cur(strdup(v)) {}
00052     inline void
00053     StringValueOption::value(const char* v) {
00054       strdel(cur);
00055       cur = strdup(v);
00056     }
00057     inline const char*
00058     StringValueOption::value(void) const {
00059       return cur;
00060     }
00061 
00062     /*
00063      * String option
00064      *
00065      */
00066     inline
00067     StringOption::StringOption(const char* o, const char* e, int v)
00068       : BaseOption(o,e), cur(v), fst(NULL), lst(NULL) {}
00069     inline void
00070     StringOption::value(int v) {
00071       cur = v;
00072     }
00073     inline int
00074     StringOption::value(void) const {
00075       return cur;
00076     }
00077     
00078     /*
00079      * Integer option
00080      *
00081      */
00082     inline
00083     IntOption::IntOption(const char* o, const char* e, int v)
00084       : BaseOption(o,e), cur(v) {}
00085     inline void
00086     IntOption::value(int v) {
00087       cur = v;
00088     }
00089     inline int
00090     IntOption::value(void) const {
00091       return cur;
00092     }
00093 
00094     /*
00095      * Unsigned integer option
00096      *
00097      */
00098     inline
00099     UnsignedIntOption::UnsignedIntOption(const char* o, const char* e,
00100                                          unsigned int v)
00101       : BaseOption(o,e), cur(v) {}
00102     inline void
00103     UnsignedIntOption::value(unsigned int v) {
00104       cur = v;
00105     }
00106     inline unsigned int
00107     UnsignedIntOption::value(void) const {
00108       return cur;
00109     }
00110 
00111     /*
00112      * Double option
00113      *
00114      */
00115     inline
00116     DoubleOption::DoubleOption(const char* o, const char* e,
00117                                unsigned int v)
00118       : BaseOption(o,e), cur(v) {}
00119     inline void
00120     DoubleOption::value(double v) {
00121       cur = v;
00122     }
00123     inline double
00124     DoubleOption::value(void) const {
00125       return cur;
00126     }
00127 
00128     /*
00129      * Bool option
00130      *
00131      */
00132     inline
00133     BoolOption::BoolOption(const char* o, const char* e) 
00134       : BaseOption(o,e), cur(false) {}
00135     inline void
00136     BoolOption::value(bool v) {
00137       cur = v;
00138     }
00139     inline bool
00140     BoolOption::value(void) const {
00141       return cur;
00142     }
00143 
00144 
00145   }
00146   
00147   /*
00148    * Options
00149    *
00150    */
00151   inline void
00152   BaseOptions::add(Driver::BaseOption& o) {
00153     o.next = NULL;
00154     if (fst == NULL) {
00155       fst=&o;
00156     } else {
00157       lst->next=&o;
00158     }
00159     lst=&o;
00160   }
00161   inline const char*
00162   BaseOptions::name(void) const {
00163     return _name;
00164   }
00165 
00166 
00167 
00168   /*
00169    * Model options
00170    *
00171    */
00172   inline void
00173   Options::model(int v) {
00174     _model.value(v);
00175   }
00176   inline void
00177   Options::model(int v, const char* o, const char* h) {
00178     _model.add(v,o,h);
00179   }
00180   inline int
00181   Options::model(void) const {
00182     return _model.value();
00183   }
00184   
00185   inline void
00186   Options::symmetry(int v) {
00187     _symmetry.value(v);
00188   }
00189   inline void
00190   Options::symmetry(int v, const char* o, const char* h) {
00191     _symmetry.add(v,o,h);
00192   }
00193   inline int
00194   Options::symmetry(void) const {
00195     return _symmetry.value();
00196   }
00197   
00198   inline void
00199   Options::propagation(int v) {
00200     _propagation.value(v);
00201   }
00202   inline void
00203   Options::propagation(int v, const char* o, const char* h) {
00204     _propagation.add(v,o,h);
00205   }
00206   inline int
00207   Options::propagation(void) const {
00208     return _propagation.value();
00209   }
00210   
00211   inline void
00212   Options::icl(IntConLevel i) {
00213     _icl.value(i);
00214   }
00215   inline IntConLevel
00216   Options::icl(void) const {
00217     return static_cast<IntConLevel>(_icl.value());
00218   }
00219   
00220   inline void
00221   Options::branching(int v) {
00222     _branching.value(v);
00223   }
00224   inline void
00225   Options::branching(int v, const char* o, const char* h) {
00226     _branching.add(v,o,h);
00227   }
00228   inline int
00229   Options::branching(void) const {
00230     return _branching.value();
00231   }
00232   
00233   /*
00234    * Search options
00235    *
00236    */
00237   inline void
00238   Options::search(int v) {
00239     _search.value(v);
00240   }
00241   inline void
00242   Options::search(int v, const char* o, const char* h) {
00243     _search.add(v,o,h);
00244   }
00245   inline int
00246   Options::search(void) const {
00247     return _search.value();
00248   }
00249   
00250   inline void
00251   Options::solutions(unsigned int n) {
00252     _solutions.value(n);
00253   }
00254   inline unsigned int
00255   Options::solutions(void) const {
00256     return _solutions.value();
00257   }
00258   
00259   inline void
00260   Options::threads(double n) {
00261     _threads.value(n);
00262   }
00263   inline double
00264   Options::threads(void) const {
00265     return _threads.value();
00266   }
00267   
00268   inline void
00269   Options::c_d(unsigned int d) {
00270     _c_d.value(d);
00271   }
00272   inline unsigned int
00273   Options::c_d(void) const {
00274     return _c_d.value();
00275   }
00276   
00277   inline void
00278   Options::a_d(unsigned int d) {
00279     _a_d.value(d);
00280   }
00281   inline unsigned int
00282   Options::a_d(void) const {
00283     return _a_d.value();
00284   }
00285   
00286   inline void
00287   Options::node(unsigned int n) {
00288     _node.value(n);
00289   }
00290   inline unsigned int
00291   Options::node(void) const {
00292     return _node.value();
00293   }
00294   
00295   inline void
00296   Options::fail(unsigned int n) {
00297     _fail.value(n);
00298   }
00299   inline unsigned int
00300   Options::fail(void) const {
00301     return _fail.value();
00302   }
00303   
00304   inline void
00305   Options::time(unsigned int t) {
00306     _time.value(t);
00307   }
00308   inline unsigned int
00309   Options::time(void) const {
00310     return _time.value();
00311   }
00312   
00313   inline void
00314   Options::interrupt(bool b) {
00315     _interrupt.value(b);
00316   }
00317   inline bool
00318   Options::interrupt(void) const {
00319     return static_cast<bool>(_interrupt.value());
00320   }
00321   
00322   
00323   /*
00324    * Execution options
00325    *
00326    */
00327   inline void
00328   Options::mode(ScriptMode sm) {
00329     _mode.value(sm);
00330   }
00331   inline ScriptMode
00332   Options::mode(void) const {
00333     return static_cast<ScriptMode>(_mode.value());
00334   }
00335   
00336   inline void
00337   Options::iterations(unsigned int i) {
00338     _iterations.value(i);
00339   }
00340   inline unsigned int
00341   Options::iterations(void) const {
00342     return _iterations.value();
00343   }
00344   
00345   inline void
00346   Options::samples(unsigned int s) {
00347     _samples.value(s);
00348   }
00349   inline unsigned int
00350   Options::samples(void) const {
00351     return _samples.value();
00352   }
00353 
00354 #ifdef GECODE_HAS_GIST
00355   forceinline
00356   Options::_I::_I(void) : _click(heap,1), n_click(0),
00357     _solution(heap,1), n_solution(0), _move(heap,1), n_move(0),
00358     _compare(heap,1), n_compare(0) {}
00359 
00360   forceinline void
00361   Options::_I::click(Gist::Inspector* i) {
00362     _click[static_cast<int>(n_click++)] = i;
00363   }
00364   forceinline void
00365   Options::_I::solution(Gist::Inspector* i) {
00366     _solution[static_cast<int>(n_solution++)] = i;
00367   }
00368   forceinline void
00369   Options::_I::move(Gist::Inspector* i) {
00370     _move[static_cast<int>(n_move++)] = i;
00371   }
00372   forceinline void
00373   Options::_I::compare(Gist::Comparator* i) {
00374     _compare[static_cast<int>(n_compare++)] = i;
00375   }
00376   forceinline Gist::Inspector*
00377   Options::_I::click(unsigned int i) const {
00378     return (i < n_click) ? _click[i] : NULL;
00379   }
00380   forceinline Gist::Inspector*
00381   Options::_I::solution(unsigned int i) const {
00382     return (i < n_solution) ? _solution[i] : NULL;
00383   }
00384   forceinline Gist::Inspector*
00385   Options::_I::move(unsigned int i) const {
00386     return (i < n_move) ? _move[i] : NULL;
00387   }
00388   forceinline Gist::Comparator*
00389   Options::_I::compare(unsigned int i) const {
00390     return (i < n_compare) ? _compare[i] : NULL;
00391   }
00392 #endif
00393 
00394   /*
00395    * Options with additional size argument
00396    *
00397    */
00398   inline void
00399   SizeOptions::size(unsigned int s) {
00400     _size = s;
00401   }
00402   inline unsigned int
00403   SizeOptions::size(void) const {
00404     return _size;
00405   }
00406   
00407   /*
00408    * Options with additional string argument
00409    *
00410    */
00411   inline const char*
00412   InstanceOptions::instance(void) const {
00413     return _inst;
00414   }
00415   
00416 }
00417 
00418 // STATISTICS: driver-any