Generated on Wed Mar 13 11:48:15 2013 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: 2013-02-20 20:15:12 +0100 (Wed, 20 Feb 2013) $ by $Author: schulte $
00011  *     $Revision: 13352 $
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     /*
00046      * String option
00047      *
00048      */
00049     inline const char*
00050     StringValueOption::value(void) const {
00051       return cur;
00052     }
00053 
00054     /*
00055      * String option
00056      *
00057      */
00058     inline
00059     StringOption::StringOption(const char* o, const char* e, int v)
00060       : BaseOption(o,e), cur(v), fst(NULL), lst(NULL) {}
00061     inline void
00062     StringOption::value(int v) {
00063       cur = v;
00064     }
00065     inline int
00066     StringOption::value(void) const {
00067       return cur;
00068     }
00069     
00070     /*
00071      * Integer option
00072      *
00073      */
00074     inline
00075     IntOption::IntOption(const char* o, const char* e, int v)
00076       : BaseOption(o,e), cur(v) {}
00077     inline void
00078     IntOption::value(int v) {
00079       cur = v;
00080     }
00081     inline int
00082     IntOption::value(void) const {
00083       return cur;
00084     }
00085 
00086     /*
00087      * Unsigned integer option
00088      *
00089      */
00090     inline
00091     UnsignedIntOption::UnsignedIntOption(const char* o, const char* e,
00092                                          unsigned int v)
00093       : BaseOption(o,e), cur(v) {}
00094     inline void
00095     UnsignedIntOption::value(unsigned int v) {
00096       cur = v;
00097     }
00098     inline unsigned int
00099     UnsignedIntOption::value(void) const {
00100       return cur;
00101     }
00102 
00103     /*
00104      * Double option
00105      *
00106      */
00107     inline
00108     DoubleOption::DoubleOption(const char* o, const char* e,
00109                                double v)
00110       : BaseOption(o,e), cur(v) {}
00111     inline void
00112     DoubleOption::value(double v) {
00113       cur = v;
00114     }
00115     inline double
00116     DoubleOption::value(void) const {
00117       return cur;
00118     }
00119 
00120     /*
00121      * Bool option
00122      *
00123      */
00124     inline
00125     BoolOption::BoolOption(const char* o, const char* e, bool v) 
00126       : BaseOption(o,e), cur(v) {}
00127     inline void
00128     BoolOption::value(bool v) {
00129       cur = v;
00130     }
00131     inline bool
00132     BoolOption::value(void) const {
00133       return cur;
00134     }
00135 
00136 
00137   }
00138   
00139   /*
00140    * Options
00141    *
00142    */
00143   inline const char*
00144   BaseOptions::name(void) const {
00145     return _name;
00146   }
00147 
00148 
00149 
00150   /*
00151    * Model options
00152    *
00153    */
00154   inline void
00155   Options::model(int v) {
00156     _model.value(v);
00157   }
00158   inline void
00159   Options::model(int v, const char* o, const char* h) {
00160     _model.add(v,o,h);
00161   }
00162   inline int
00163   Options::model(void) const {
00164     return _model.value();
00165   }
00166   
00167   inline void
00168   Options::symmetry(int v) {
00169     _symmetry.value(v);
00170   }
00171   inline void
00172   Options::symmetry(int v, const char* o, const char* h) {
00173     _symmetry.add(v,o,h);
00174   }
00175   inline int
00176   Options::symmetry(void) const {
00177     return _symmetry.value();
00178   }
00179   
00180   inline void
00181   Options::propagation(int v) {
00182     _propagation.value(v);
00183   }
00184   inline void
00185   Options::propagation(int v, const char* o, const char* h) {
00186     _propagation.add(v,o,h);
00187   }
00188   inline int
00189   Options::propagation(void) const {
00190     return _propagation.value();
00191   }
00192   
00193   inline void
00194   Options::icl(IntConLevel i) {
00195     _icl.value(i);
00196   }
00197   inline IntConLevel
00198   Options::icl(void) const {
00199     return static_cast<IntConLevel>(_icl.value());
00200   }
00201   
00202   inline void
00203   Options::branching(int v) {
00204     _branching.value(v);
00205   }
00206   inline void
00207   Options::branching(int v, const char* o, const char* h) {
00208     _branching.add(v,o,h);
00209   }
00210   inline int
00211   Options::branching(void) const {
00212     return _branching.value();
00213   }
00214 
00215   inline void
00216   Options::decay(double d) {
00217     _decay.value(d);
00218   }
00219   inline double
00220   Options::decay(void) const {
00221     return _decay.value();
00222   }
00223   
00224   
00225   /*
00226    * Search options
00227    *
00228    */
00229   inline void
00230   Options::search(int v) {
00231     _search.value(v);
00232   }
00233   inline void
00234   Options::search(int v, const char* o, const char* h) {
00235     _search.add(v,o,h);
00236   }
00237   inline int
00238   Options::search(void) const {
00239     return _search.value();
00240   }
00241   
00242   inline void
00243   Options::solutions(unsigned int n) {
00244     _solutions.value(n);
00245   }
00246   inline unsigned int
00247   Options::solutions(void) const {
00248     return _solutions.value();
00249   }
00250   
00251   inline void
00252   Options::threads(double n) {
00253     _threads.value(n);
00254   }
00255   inline double
00256   Options::threads(void) const {
00257     return _threads.value();
00258   }
00259   
00260   inline void
00261   Options::c_d(unsigned int d) {
00262     _c_d.value(d);
00263   }
00264   inline unsigned int
00265   Options::c_d(void) const {
00266     return _c_d.value();
00267   }
00268   
00269   inline void
00270   Options::a_d(unsigned int d) {
00271     _a_d.value(d);
00272   }
00273   inline unsigned int
00274   Options::a_d(void) const {
00275     return _a_d.value();
00276   }
00277   
00278   inline void
00279   Options::node(unsigned int n) {
00280     _node.value(n);
00281   }
00282   inline unsigned int
00283   Options::node(void) const {
00284     return _node.value();
00285   }
00286   
00287   inline void
00288   Options::fail(unsigned int n) {
00289     _fail.value(n);
00290   }
00291   inline unsigned int
00292   Options::fail(void) const {
00293     return _fail.value();
00294   }
00295   
00296   inline void
00297   Options::time(unsigned int t) {
00298     _time.value(t);
00299   }
00300   inline unsigned int
00301   Options::time(void) const {
00302     return _time.value();
00303   }
00304 
00305   inline void
00306   Options::restart(RestartMode rm) {
00307     _restart.value(rm);
00308   }
00309   inline RestartMode
00310   Options::restart(void) const {
00311     return static_cast<RestartMode>(_restart.value());
00312   }
00313   
00314   inline void
00315   Options::restart_base(double n) {
00316     _r_base.value(n);
00317   }
00318   inline double
00319   Options::restart_base(void) const {
00320     return _r_base.value();
00321   }
00322   
00323   inline void
00324   Options::restart_scale(unsigned int n) {
00325     _r_scale.value(n);
00326   }
00327   inline unsigned int
00328   Options::restart_scale(void) const {
00329     return _r_scale.value();
00330   }
00331   
00332   
00333   inline void
00334   Options::interrupt(bool b) {
00335     _interrupt.value(b);
00336   }
00337   inline bool
00338   Options::interrupt(void) const {
00339     return _interrupt.value();
00340   }
00341   
00342   
00343   /*
00344    * Execution options
00345    *
00346    */
00347   inline void
00348   Options::mode(ScriptMode sm) {
00349     _mode.value(sm);
00350   }
00351   inline ScriptMode
00352   Options::mode(void) const {
00353     return static_cast<ScriptMode>(_mode.value());
00354   }
00355   
00356   inline void
00357   Options::samples(unsigned int s) {
00358     _samples.value(s);
00359   }
00360   inline unsigned int
00361   Options::samples(void) const {
00362     return _samples.value();
00363   }
00364 
00365   inline void
00366   Options::iterations(unsigned int i) {
00367     _iterations.value(i);
00368   }
00369   inline unsigned int
00370   Options::iterations(void) const {
00371     return _iterations.value();
00372   }
00373   
00374   inline void
00375   Options::print_last(bool p) {
00376     _print_last.value(p);
00377   }
00378   inline bool
00379   Options::print_last(void) const {
00380     return _print_last.value();
00381   }
00382 
00383   inline void
00384   Options::out_file(const char *f) {
00385     _out_file.value(f);
00386   }
00387 
00388   inline const char*
00389   Options::out_file(void) const {
00390     return _out_file.value();
00391   }
00392 
00393   inline void
00394   Options::log_file(const char* f) {
00395     _log_file.value(f);
00396   }
00397 
00398   inline const char*
00399   Options::log_file(void) const {
00400     return _log_file.value();
00401   }
00402 
00403 #ifdef GECODE_HAS_GIST
00404   forceinline
00405   Options::_I::_I(void) : _click(heap,1), n_click(0),
00406     _solution(heap,1), n_solution(0), _move(heap,1), n_move(0),
00407     _compare(heap,1), n_compare(0) {}
00408 
00409   forceinline void
00410   Options::_I::click(Gist::Inspector* i) {
00411     _click[static_cast<int>(n_click++)] = i;
00412   }
00413   forceinline void
00414   Options::_I::solution(Gist::Inspector* i) {
00415     _solution[static_cast<int>(n_solution++)] = i;
00416   }
00417   forceinline void
00418   Options::_I::move(Gist::Inspector* i) {
00419     _move[static_cast<int>(n_move++)] = i;
00420   }
00421   forceinline void
00422   Options::_I::compare(Gist::Comparator* i) {
00423     _compare[static_cast<int>(n_compare++)] = i;
00424   }
00425   forceinline Gist::Inspector*
00426   Options::_I::click(unsigned int i) const {
00427     return (i < n_click) ? _click[i] : NULL;
00428   }
00429   forceinline Gist::Inspector*
00430   Options::_I::solution(unsigned int i) const {
00431     return (i < n_solution) ? _solution[i] : NULL;
00432   }
00433   forceinline Gist::Inspector*
00434   Options::_I::move(unsigned int i) const {
00435     return (i < n_move) ? _move[i] : NULL;
00436   }
00437   forceinline Gist::Comparator*
00438   Options::_I::compare(unsigned int i) const {
00439     return (i < n_compare) ? _compare[i] : NULL;
00440   }
00441 #endif
00442 
00443   /*
00444    * Options with additional size argument
00445    *
00446    */
00447   inline void
00448   SizeOptions::size(unsigned int s) {
00449     _size = s;
00450   }
00451   inline unsigned int
00452   SizeOptions::size(void) const {
00453     return _size;
00454   }
00455   
00456   /*
00457    * Options with additional string argument
00458    *
00459    */
00460   inline const char*
00461   InstanceOptions::instance(void) const {
00462     return _inst;
00463   }
00464   
00465 }
00466 
00467 // STATISTICS: driver-any