Generated on Sat May 25 2013 18:00:32 for Gecode by doxygen 1.8.3.1
options.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2004
8  *
9  * Last modified:
10  * $Date: 2013-02-20 20:15:12 +0100 (Wed, 20 Feb 2013) $ by $Author: schulte $
11  * $Revision: 13352 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  *
18  * Permission is hereby granted, free of charge, to any person obtaining
19  * a copy of this software and associated documentation files (the
20  * "Software"), to deal in the Software without restriction, including
21  * without limitation the rights to use, copy, modify, merge, publish,
22  * distribute, sublicense, and/or sell copies of the Software, and to
23  * permit persons to whom the Software is furnished to do so, subject to
24  * the following conditions:
25  *
26  * The above copyright notice and this permission notice shall be
27  * included in all copies or substantial portions of the Software.
28  *
29  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
33  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
34  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
35  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36  *
37  */
38 
39 #include <cstring>
40 
41 namespace Gecode {
42 
43  namespace Driver {
44 
45  /*
46  * String option
47  *
48  */
49  inline const char*
51  return cur;
52  }
53 
54  /*
55  * String option
56  *
57  */
58  inline
59  StringOption::StringOption(const char* o, const char* e, int v)
60  : BaseOption(o,e), cur(v), fst(NULL), lst(NULL) {}
61  inline void
63  cur = v;
64  }
65  inline int
66  StringOption::value(void) const {
67  return cur;
68  }
69 
70  /*
71  * Integer option
72  *
73  */
74  inline
75  IntOption::IntOption(const char* o, const char* e, int v)
76  : BaseOption(o,e), cur(v) {}
77  inline void
79  cur = v;
80  }
81  inline int
82  IntOption::value(void) const {
83  return cur;
84  }
85 
86  /*
87  * Unsigned integer option
88  *
89  */
90  inline
91  UnsignedIntOption::UnsignedIntOption(const char* o, const char* e,
92  unsigned int v)
93  : BaseOption(o,e), cur(v) {}
94  inline void
95  UnsignedIntOption::value(unsigned int v) {
96  cur = v;
97  }
98  inline unsigned int
100  return cur;
101  }
102 
103  /*
104  * Double option
105  *
106  */
107  inline
108  DoubleOption::DoubleOption(const char* o, const char* e,
109  double v)
110  : BaseOption(o,e), cur(v) {}
111  inline void
113  cur = v;
114  }
115  inline double
116  DoubleOption::value(void) const {
117  return cur;
118  }
119 
120  /*
121  * Bool option
122  *
123  */
124  inline
125  BoolOption::BoolOption(const char* o, const char* e, bool v)
126  : BaseOption(o,e), cur(v) {}
127  inline void
129  cur = v;
130  }
131  inline bool
132  BoolOption::value(void) const {
133  return cur;
134  }
135 
136 
137  }
138 
139  /*
140  * Options
141  *
142  */
143  inline const char*
144  BaseOptions::name(void) const {
145  return _name;
146  }
147 
148 
149 
150  /*
151  * Model options
152  *
153  */
154  inline void
156  _model.value(v);
157  }
158  inline void
159  Options::model(int v, const char* o, const char* h) {
160  _model.add(v,o,h);
161  }
162  inline int
163  Options::model(void) const {
164  return _model.value();
165  }
166 
167  inline void
169  _symmetry.value(v);
170  }
171  inline void
172  Options::symmetry(int v, const char* o, const char* h) {
173  _symmetry.add(v,o,h);
174  }
175  inline int
176  Options::symmetry(void) const {
177  return _symmetry.value();
178  }
179 
180  inline void
182  _propagation.value(v);
183  }
184  inline void
185  Options::propagation(int v, const char* o, const char* h) {
186  _propagation.add(v,o,h);
187  }
188  inline int
189  Options::propagation(void) const {
190  return _propagation.value();
191  }
192 
193  inline void
195  _icl.value(i);
196  }
197  inline IntConLevel
198  Options::icl(void) const {
199  return static_cast<IntConLevel>(_icl.value());
200  }
201 
202  inline void
204  _branching.value(v);
205  }
206  inline void
207  Options::branching(int v, const char* o, const char* h) {
208  _branching.add(v,o,h);
209  }
210  inline int
211  Options::branching(void) const {
212  return _branching.value();
213  }
214 
215  inline void
216  Options::decay(double d) {
217  _decay.value(d);
218  }
219  inline double
220  Options::decay(void) const {
221  return _decay.value();
222  }
223 
224 
225  /*
226  * Search options
227  *
228  */
229  inline void
231  _search.value(v);
232  }
233  inline void
234  Options::search(int v, const char* o, const char* h) {
235  _search.add(v,o,h);
236  }
237  inline int
238  Options::search(void) const {
239  return _search.value();
240  }
241 
242  inline void
243  Options::solutions(unsigned int n) {
244  _solutions.value(n);
245  }
246  inline unsigned int
247  Options::solutions(void) const {
248  return _solutions.value();
249  }
250 
251  inline void
252  Options::threads(double n) {
253  _threads.value(n);
254  }
255  inline double
256  Options::threads(void) const {
257  return _threads.value();
258  }
259 
260  inline void
261  Options::c_d(unsigned int d) {
262  _c_d.value(d);
263  }
264  inline unsigned int
265  Options::c_d(void) const {
266  return _c_d.value();
267  }
268 
269  inline void
270  Options::a_d(unsigned int d) {
271  _a_d.value(d);
272  }
273  inline unsigned int
274  Options::a_d(void) const {
275  return _a_d.value();
276  }
277 
278  inline void
279  Options::node(unsigned int n) {
280  _node.value(n);
281  }
282  inline unsigned int
283  Options::node(void) const {
284  return _node.value();
285  }
286 
287  inline void
288  Options::fail(unsigned int n) {
289  _fail.value(n);
290  }
291  inline unsigned int
292  Options::fail(void) const {
293  return _fail.value();
294  }
295 
296  inline void
297  Options::time(unsigned int t) {
298  _time.value(t);
299  }
300  inline unsigned int
301  Options::time(void) const {
302  return _time.value();
303  }
304 
305  inline void
307  _restart.value(rm);
308  }
309  inline RestartMode
310  Options::restart(void) const {
311  return static_cast<RestartMode>(_restart.value());
312  }
313 
314  inline void
316  _r_base.value(n);
317  }
318  inline double
319  Options::restart_base(void) const {
320  return _r_base.value();
321  }
322 
323  inline void
324  Options::restart_scale(unsigned int n) {
325  _r_scale.value(n);
326  }
327  inline unsigned int
329  return _r_scale.value();
330  }
331 
332 
333  inline void
335  _interrupt.value(b);
336  }
337  inline bool
338  Options::interrupt(void) const {
339  return _interrupt.value();
340  }
341 
342 
343  /*
344  * Execution options
345  *
346  */
347  inline void
349  _mode.value(sm);
350  }
351  inline ScriptMode
352  Options::mode(void) const {
353  return static_cast<ScriptMode>(_mode.value());
354  }
355 
356  inline void
357  Options::samples(unsigned int s) {
358  _samples.value(s);
359  }
360  inline unsigned int
361  Options::samples(void) const {
362  return _samples.value();
363  }
364 
365  inline void
366  Options::iterations(unsigned int i) {
367  _iterations.value(i);
368  }
369  inline unsigned int
370  Options::iterations(void) const {
371  return _iterations.value();
372  }
373 
374  inline void
376  _print_last.value(p);
377  }
378  inline bool
379  Options::print_last(void) const {
380  return _print_last.value();
381  }
382 
383  inline void
384  Options::out_file(const char *f) {
385  _out_file.value(f);
386  }
387 
388  inline const char*
389  Options::out_file(void) const {
390  return _out_file.value();
391  }
392 
393  inline void
394  Options::log_file(const char* f) {
395  _log_file.value(f);
396  }
397 
398  inline const char*
399  Options::log_file(void) const {
400  return _log_file.value();
401  }
402 
403 #ifdef GECODE_HAS_GIST
405  Options::_I::_I(void) : _click(heap,1), n_click(0),
406  _solution(heap,1), n_solution(0), _move(heap,1), n_move(0),
407  _compare(heap,1), n_compare(0) {}
408 
409  forceinline void
410  Options::_I::click(Gist::Inspector* i) {
411  _click[static_cast<int>(n_click++)] = i;
412  }
413  forceinline void
414  Options::_I::solution(Gist::Inspector* i) {
415  _solution[static_cast<int>(n_solution++)] = i;
416  }
417  forceinline void
418  Options::_I::move(Gist::Inspector* i) {
419  _move[static_cast<int>(n_move++)] = i;
420  }
421  forceinline void
422  Options::_I::compare(Gist::Comparator* i) {
423  _compare[static_cast<int>(n_compare++)] = i;
424  }
425  forceinline Gist::Inspector*
426  Options::_I::click(unsigned int i) const {
427  return (i < n_click) ? _click[i] : NULL;
428  }
429  forceinline Gist::Inspector*
430  Options::_I::solution(unsigned int i) const {
431  return (i < n_solution) ? _solution[i] : NULL;
432  }
433  forceinline Gist::Inspector*
434  Options::_I::move(unsigned int i) const {
435  return (i < n_move) ? _move[i] : NULL;
436  }
437  forceinline Gist::Comparator*
438  Options::_I::compare(unsigned int i) const {
439  return (i < n_compare) ? _compare[i] : NULL;
440  }
441 #endif
442 
443  /*
444  * Options with additional size argument
445  *
446  */
447  inline void
448  SizeOptions::size(unsigned int s) {
449  _size = s;
450  }
451  inline unsigned int
452  SizeOptions::size(void) const {
453  return _size;
454  }
455 
456  /*
457  * Options with additional string argument
458  *
459  */
460  inline const char*
462  return _inst;
463  }
464 
465 }
466 
467 // STATISTICS: driver-any