Generated on Fri Oct 19 11:24:50 2018 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  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *
00013  *
00014  *  Permission is hereby granted, free of charge, to any person obtaining
00015  *  a copy of this software and associated documentation files (the
00016  *  "Software"), to deal in the Software without restriction, including
00017  *  without limitation the rights to use, copy, modify, merge, publish,
00018  *  distribute, sublicense, and/or sell copies of the Software, and to
00019  *  permit persons to whom the Software is furnished to do so, subject to
00020  *  the following conditions:
00021  *
00022  *  The above copyright notice and this permission notice shall be
00023  *  included in all copies or substantial portions of the Software.
00024  *
00025  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00026  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00027  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00028  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00029  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00030  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00031  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00032  *
00033  */
00034 
00035 #include <cstring>
00036 
00037 namespace Gecode {
00038 
00039   namespace Driver {
00040 
00041     /*
00042      * String option
00043      *
00044      */
00045     inline const char*
00046     StringValueOption::value(void) const {
00047       return cur;
00048     }
00049 
00050     /*
00051      * String option
00052      *
00053      */
00054     inline
00055     StringOption::StringOption(const char* o, const char* e, int v)
00056       : BaseOption(o,e), cur(v), fst(NULL), lst(NULL) {}
00057     inline void
00058     StringOption::value(int v) {
00059       cur = v;
00060     }
00061     inline int
00062     StringOption::value(void) const {
00063       return cur;
00064     }
00065 
00066     /*
00067      * Integer option
00068      *
00069      */
00070     inline
00071     IntOption::IntOption(const char* o, const char* e, int v)
00072       : BaseOption(o,e), cur(v) {}
00073     inline void
00074     IntOption::value(int v) {
00075       cur = v;
00076     }
00077     inline int
00078     IntOption::value(void) const {
00079       return cur;
00080     }
00081 
00082     /*
00083      * Unsigned integer option
00084      *
00085      */
00086     inline
00087     UnsignedIntOption::UnsignedIntOption(const char* o, const char* e,
00088                                          unsigned int v)
00089       : BaseOption(o,e), cur(v) {}
00090     inline void
00091     UnsignedIntOption::value(unsigned int v) {
00092       cur = v;
00093     }
00094     inline unsigned int
00095     UnsignedIntOption::value(void) const {
00096       return cur;
00097     }
00098 
00099     /*
00100      * Double option
00101      *
00102      */
00103     inline
00104     DoubleOption::DoubleOption(const char* o, const char* e,
00105                                double v)
00106       : BaseOption(o,e), cur(v) {}
00107     inline void
00108     DoubleOption::value(double v) {
00109       cur = v;
00110     }
00111     inline double
00112     DoubleOption::value(void) const {
00113       return cur;
00114     }
00115 
00116     /*
00117      * Bool option
00118      *
00119      */
00120     inline
00121     BoolOption::BoolOption(const char* o, const char* e, bool v)
00122       : BaseOption(o,e), cur(v) {}
00123     inline void
00124     BoolOption::value(bool v) {
00125       cur = v;
00126     }
00127     inline bool
00128     BoolOption::value(void) const {
00129       return cur;
00130     }
00131 
00132     /*
00133      * Integer propagation level option
00134      *
00135      */
00136     inline void
00137     IplOption::value(IntPropLevel ipl) {
00138       cur = ipl;
00139     }
00140     inline IntPropLevel
00141     IplOption::value(void) const {
00142       return cur;
00143     }
00144 
00145 
00146     /*
00147      * Trace flag option
00148      *
00149      */
00150     inline void
00151     TraceOption::value(int f) {
00152       cur = f;
00153     }
00154     inline int
00155     TraceOption::value(void) const {
00156       return cur;
00157     }
00158 
00159   }
00160 
00161   /*
00162    * Options
00163    *
00164    */
00165   inline const char*
00166   BaseOptions::name(void) const {
00167     return _name;
00168   }
00169 
00170 
00171 
00172   /*
00173    * Model options
00174    *
00175    */
00176   inline void
00177   Options::model(int v) {
00178     _model.value(v);
00179   }
00180   inline void
00181   Options::model(int v, const char* o, const char* h) {
00182     _model.add(v,o,h);
00183   }
00184   inline int
00185   Options::model(void) const {
00186     return _model.value();
00187   }
00188 
00189   inline void
00190   Options::symmetry(int v) {
00191     _symmetry.value(v);
00192   }
00193   inline void
00194   Options::symmetry(int v, const char* o, const char* h) {
00195     _symmetry.add(v,o,h);
00196   }
00197   inline int
00198   Options::symmetry(void) const {
00199     return _symmetry.value();
00200   }
00201 
00202   inline void
00203   Options::propagation(int v) {
00204     _propagation.value(v);
00205   }
00206   inline void
00207   Options::propagation(int v, const char* o, const char* h) {
00208     _propagation.add(v,o,h);
00209   }
00210   inline int
00211   Options::propagation(void) const {
00212     return _propagation.value();
00213   }
00214 
00215   inline void
00216   Options::ipl(IntPropLevel i) {
00217     _ipl.value(i);
00218   }
00219   inline IntPropLevel
00220   Options::ipl(void) const {
00221     return _ipl.value();
00222   }
00223 
00224   inline void
00225   Options::branching(int v) {
00226     _branching.value(v);
00227   }
00228   inline void
00229   Options::branching(int v, const char* o, const char* h) {
00230     _branching.add(v,o,h);
00231   }
00232   inline int
00233   Options::branching(void) const {
00234     return _branching.value();
00235   }
00236 
00237   inline void
00238   Options::decay(double d) {
00239     _decay.value(d);
00240   }
00241   inline double
00242   Options::decay(void) const {
00243     return _decay.value();
00244   }
00245 
00246   inline void
00247   Options::seed(unsigned int s) {
00248     _seed.value(s);
00249   }
00250   inline unsigned int
00251   Options::seed(void) const {
00252     return _seed.value();
00253   }
00254 
00255   inline void
00256   Options::step(double s) {
00257     _step.value(s);
00258   }
00259   inline double
00260   Options::step(void) const {
00261     return _step.value();
00262   }
00263 
00264 
00265   /*
00266    * Search options
00267    *
00268    */
00269   inline void
00270   Options::search(int v) {
00271     _search.value(v);
00272   }
00273   inline void
00274   Options::search(int v, const char* o, const char* h) {
00275     _search.add(v,o,h);
00276   }
00277   inline int
00278   Options::search(void) const {
00279     return _search.value();
00280   }
00281 
00282   inline void
00283   Options::solutions(unsigned int n) {
00284     _solutions.value(n);
00285   }
00286   inline unsigned int
00287   Options::solutions(void) const {
00288     return _solutions.value();
00289   }
00290 
00291   inline void
00292   Options::threads(double n) {
00293     _threads.value(n);
00294   }
00295   inline double
00296   Options::threads(void) const {
00297     return _threads.value();
00298   }
00299 
00300   inline void
00301   Options::c_d(unsigned int d) {
00302     _c_d.value(d);
00303   }
00304   inline unsigned int
00305   Options::c_d(void) const {
00306     return _c_d.value();
00307   }
00308 
00309   inline void
00310   Options::a_d(unsigned int d) {
00311     _a_d.value(d);
00312   }
00313   inline unsigned int
00314   Options::a_d(void) const {
00315     return _a_d.value();
00316   }
00317 
00318   inline void
00319   Options::d_l(unsigned int d) {
00320     _d_l.value(d);
00321   }
00322   inline unsigned int
00323   Options::d_l(void) const {
00324     return _d_l.value();
00325   }
00326 
00327   inline void
00328   Options::node(unsigned int n) {
00329     _node.value(n);
00330   }
00331   inline unsigned int
00332   Options::node(void) const {
00333     return _node.value();
00334   }
00335 
00336   inline void
00337   Options::fail(unsigned int n) {
00338     _fail.value(n);
00339   }
00340   inline unsigned int
00341   Options::fail(void) const {
00342     return _fail.value();
00343   }
00344 
00345   inline void
00346   Options::time(unsigned int t) {
00347     _time.value(t);
00348   }
00349   inline unsigned int
00350   Options::time(void) const {
00351     return _time.value();
00352   }
00353 
00354   inline void
00355   Options::assets(unsigned int n) {
00356     _assets.value(n);
00357   }
00358   inline unsigned int
00359   Options::assets(void) const {
00360     return _assets.value();
00361   }
00362 
00363   inline void
00364   Options::slice(unsigned int n) {
00365     _slice.value(n);
00366   }
00367   inline unsigned int
00368   Options::slice(void) const {
00369     return _slice.value();
00370   }
00371 
00372   inline void
00373   Options::restart(RestartMode rm) {
00374     _restart.value(rm);
00375   }
00376   inline RestartMode
00377   Options::restart(void) const {
00378     return static_cast<RestartMode>(_restart.value());
00379   }
00380 
00381   inline void
00382   Options::restart_base(double n) {
00383     _r_base.value(n);
00384   }
00385   inline double
00386   Options::restart_base(void) const {
00387     return _r_base.value();
00388   }
00389 
00390   inline void
00391   Options::restart_scale(unsigned int n) {
00392     _r_scale.value(n);
00393   }
00394   inline unsigned int
00395   Options::restart_scale(void) const {
00396     return _r_scale.value();
00397   }
00398 
00399   inline void
00400   Options::nogoods(bool b) {
00401     _nogoods.value(b);
00402   }
00403   inline bool
00404   Options::nogoods(void) const {
00405     return _nogoods.value();
00406   }
00407 
00408   inline void
00409   Options::nogoods_limit(unsigned int l) {
00410     _nogoods_limit.value(l);
00411   }
00412   inline unsigned int
00413   Options::nogoods_limit(void) const {
00414     return _nogoods_limit.value();
00415   }
00416 
00417   inline void
00418   Options::relax(double d) {
00419     _relax.value(d);
00420   }
00421   inline double
00422   Options::relax(void) const {
00423     return _relax.value();
00424   }
00425 
00426 
00427 
00428   inline void
00429   Options::interrupt(bool b) {
00430     _interrupt.value(b);
00431   }
00432   inline bool
00433   Options::interrupt(void) const {
00434     return _interrupt.value();
00435   }
00436 
00437 
00438   /*
00439    * Execution options
00440    *
00441    */
00442   inline void
00443   Options::mode(ScriptMode sm) {
00444     _mode.value(sm);
00445   }
00446   inline ScriptMode
00447   Options::mode(void) const {
00448     return static_cast<ScriptMode>(_mode.value());
00449   }
00450 
00451   inline void
00452   Options::samples(unsigned int s) {
00453     _samples.value(s);
00454   }
00455   inline unsigned int
00456   Options::samples(void) const {
00457     return _samples.value();
00458   }
00459 
00460   inline void
00461   Options::iterations(unsigned int i) {
00462     _iterations.value(i);
00463   }
00464   inline unsigned int
00465   Options::iterations(void) const {
00466     return _iterations.value();
00467   }
00468 
00469   inline void
00470   Options::print_last(bool p) {
00471     _print_last.value(p);
00472   }
00473   inline bool
00474   Options::print_last(void) const {
00475     return _print_last.value();
00476   }
00477 
00478   inline void
00479   Options::out_file(const char *f) {
00480     _out_file.value(f);
00481   }
00482 
00483   inline const char*
00484   Options::out_file(void) const {
00485     return _out_file.value();
00486   }
00487 
00488   inline void
00489   Options::log_file(const char* f) {
00490     _log_file.value(f);
00491   }
00492 
00493   inline const char*
00494   Options::log_file(void) const {
00495     return _log_file.value();
00496   }
00497 
00498   inline void
00499   Options::trace(int f) {
00500     _trace.value(f);
00501   }
00502 
00503   inline int
00504   Options::trace(void) const {
00505     return _trace.value();
00506   }
00507 
00508 #ifdef GECODE_HAS_CPPROFILER
00509 
00510   /*
00511    * Profiler options
00512    *
00513    */
00514   inline void
00515   Options::profiler_id(int i) {
00516     _profiler_id.value(i);
00517   }
00518   inline int
00519   Options::profiler_id(void) const {
00520     return _profiler_id.value();
00521   }
00522   inline void
00523   Options::profiler_port(unsigned int p) {
00524     _profiler_port.value(p);
00525   }
00526   inline unsigned int
00527   Options::profiler_port(void) const {
00528     return _profiler_port.value();
00529   }
00530   inline void
00531   Options::profiler_info(bool b) {
00532     _profiler_info.value(b);
00533   }
00534   inline bool
00535   Options::profiler_info(void) const {
00536     return _profiler_info.value();
00537   }
00538 
00539 #endif
00540 
00541 #ifdef GECODE_HAS_GIST
00542   forceinline
00543   Options::_I::_I(void) : _click(heap,1), n_click(0),
00544     _solution(heap,1), n_solution(0), _move(heap,1), n_move(0),
00545     _compare(heap,1), n_compare(0) {}
00546 
00547   forceinline void
00548   Options::_I::click(Gist::Inspector* i) {
00549     _click[static_cast<int>(n_click++)] = i;
00550   }
00551   forceinline void
00552   Options::_I::solution(Gist::Inspector* i) {
00553     _solution[static_cast<int>(n_solution++)] = i;
00554   }
00555   forceinline void
00556   Options::_I::move(Gist::Inspector* i) {
00557     _move[static_cast<int>(n_move++)] = i;
00558   }
00559   forceinline void
00560   Options::_I::compare(Gist::Comparator* i) {
00561     _compare[static_cast<int>(n_compare++)] = i;
00562   }
00563   forceinline Gist::Inspector*
00564   Options::_I::click(unsigned int i) const {
00565     return (i < n_click) ? _click[i] : NULL;
00566   }
00567   forceinline Gist::Inspector*
00568   Options::_I::solution(unsigned int i) const {
00569     return (i < n_solution) ? _solution[i] : NULL;
00570   }
00571   forceinline Gist::Inspector*
00572   Options::_I::move(unsigned int i) const {
00573     return (i < n_move) ? _move[i] : NULL;
00574   }
00575   forceinline Gist::Comparator*
00576   Options::_I::compare(unsigned int i) const {
00577     return (i < n_compare) ? _compare[i] : NULL;
00578   }
00579 #endif
00580 
00581   /*
00582    * Options with additional size argument
00583    *
00584    */
00585   inline void
00586   SizeOptions::size(unsigned int s) {
00587     _size = s;
00588   }
00589   inline unsigned int
00590   SizeOptions::size(void) const {
00591     return _size;
00592   }
00593 
00594   /*
00595    * Options with additional string argument
00596    *
00597    */
00598   inline const char*
00599   InstanceOptions::instance(void) const {
00600     return _inst;
00601   }
00602 
00603 }
00604 
00605 // STATISTICS: driver-any