this repo has no description
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 * This file is part of Gecode, the generic constraint 10 * development environment: 11 * http://www.gecode.org 12 * 13 * 14 * Permission is hereby granted, free of charge, to any person obtaining 15 * a copy of this software and associated documentation files (the 16 * "Software"), to deal in the Software without restriction, including 17 * without limitation the rights to use, copy, modify, merge, publish, 18 * distribute, sublicense, and/or sell copies of the Software, and to 19 * permit persons to whom the Software is furnished to do so, subject to 20 * the following conditions: 21 * 22 * The above copyright notice and this permission notice shall be 23 * included in all copies or substantial portions of the Software. 24 * 25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 * 33 */ 34 35#include <cstring> 36 37namespace Gecode { 38 39 namespace Driver { 40 41 /* 42 * String option 43 * 44 */ 45 inline const char* 46 StringValueOption::value(void) const { 47 return cur; 48 } 49 50 /* 51 * String option 52 * 53 */ 54 inline 55 StringOption::StringOption(const char* o, const char* e, int v) 56 : BaseOption(o,e), cur(v), fst(nullptr), lst(nullptr) {} 57 inline void 58 StringOption::value(int v) { 59 cur = v; 60 } 61 inline int 62 StringOption::value(void) const { 63 return cur; 64 } 65 66 /* 67 * Integer option 68 * 69 */ 70 inline 71 IntOption::IntOption(const char* o, const char* e, int v) 72 : BaseOption(o,e), cur(v) {} 73 inline void 74 IntOption::value(int v) { 75 cur = v; 76 } 77 inline int 78 IntOption::value(void) const { 79 return cur; 80 } 81 82 /* 83 * Unsigned integer option 84 * 85 */ 86 inline 87 UnsignedIntOption::UnsignedIntOption(const char* o, const char* e, 88 unsigned int v) 89 : BaseOption(o,e), cur(v) {} 90 inline void 91 UnsignedIntOption::value(unsigned int v) { 92 cur = v; 93 } 94 inline unsigned int 95 UnsignedIntOption::value(void) const { 96 return cur; 97 } 98 99 /* 100 * Unsigned long long integer option 101 * 102 */ 103 inline 104 UnsignedLongLongIntOption::UnsignedLongLongIntOption 105 (const char* o, const char* e, unsigned long long int v) 106 : BaseOption(o,e), cur(v) {} 107 inline void 108 UnsignedLongLongIntOption::value(unsigned long long int v) { 109 cur = v; 110 } 111 inline unsigned long long int 112 UnsignedLongLongIntOption::value(void) const { 113 return cur; 114 } 115 116 /* 117 * Double option 118 * 119 */ 120 inline 121 DoubleOption::DoubleOption(const char* o, const char* e, 122 double v) 123 : BaseOption(o,e), cur(v) {} 124 inline void 125 DoubleOption::value(double v) { 126 cur = v; 127 } 128 inline double 129 DoubleOption::value(void) const { 130 return cur; 131 } 132 133 /* 134 * Bool option 135 * 136 */ 137 inline 138 BoolOption::BoolOption(const char* o, const char* e, bool v) 139 : BaseOption(o,e), cur(v) {} 140 inline void 141 BoolOption::value(bool v) { 142 cur = v; 143 } 144 inline bool 145 BoolOption::value(void) const { 146 return cur; 147 } 148 149 /* 150 * Integer propagation level option 151 * 152 */ 153 inline void 154 IplOption::value(IntPropLevel ipl) { 155 cur = ipl; 156 } 157 inline IntPropLevel 158 IplOption::value(void) const { 159 return cur; 160 } 161 162 163 /* 164 * Trace flag option 165 * 166 */ 167 inline void 168 TraceOption::value(int f) { 169 cur = f; 170 } 171 inline int 172 TraceOption::value(void) const { 173 return cur; 174 } 175 176 /* 177 * Profiler option 178 * 179 */ 180 inline 181 ProfilerOption::ProfilerOption(const char* o, const char* e, unsigned int p, int i) 182 : BaseOption(o,e), cur_port(p), cur_execution_id(i) {} 183 inline void ProfilerOption::port(unsigned int p) { cur_port = p; } 184 inline unsigned int ProfilerOption::port(void) const { return cur_port; } 185 inline void ProfilerOption::execution_id(int i) { cur_execution_id = i; } 186 inline int ProfilerOption::execution_id(void) const { return cur_execution_id; } 187 188 } 189 190 /* 191 * Options 192 * 193 */ 194 inline const char* 195 BaseOptions::name(void) const { 196 return _name; 197 } 198 199 200 201 /* 202 * Model options 203 * 204 */ 205 inline void 206 Options::model(int v) { 207 _model.value(v); 208 } 209 inline void 210 Options::model(int v, const char* o, const char* h) { 211 _model.add(v,o,h); 212 } 213 inline int 214 Options::model(void) const { 215 return _model.value(); 216 } 217 218 inline void 219 Options::symmetry(int v) { 220 _symmetry.value(v); 221 } 222 inline void 223 Options::symmetry(int v, const char* o, const char* h) { 224 _symmetry.add(v,o,h); 225 } 226 inline int 227 Options::symmetry(void) const { 228 return _symmetry.value(); 229 } 230 231 inline void 232 Options::propagation(int v) { 233 _propagation.value(v); 234 } 235 inline void 236 Options::propagation(int v, const char* o, const char* h) { 237 _propagation.add(v,o,h); 238 } 239 inline int 240 Options::propagation(void) const { 241 return _propagation.value(); 242 } 243 244 inline void 245 Options::ipl(IntPropLevel i) { 246 _ipl.value(i); 247 } 248 inline IntPropLevel 249 Options::ipl(void) const { 250 return _ipl.value(); 251 } 252 253 inline void 254 Options::branching(int v) { 255 _branching.value(v); 256 } 257 inline void 258 Options::branching(int v, const char* o, const char* h) { 259 _branching.add(v,o,h); 260 } 261 inline int 262 Options::branching(void) const { 263 return _branching.value(); 264 } 265 266 inline void 267 Options::decay(double d) { 268 _decay.value(d); 269 } 270 inline double 271 Options::decay(void) const { 272 return _decay.value(); 273 } 274 275 inline void 276 Options::seed(unsigned int s) { 277 _seed.value(s); 278 } 279 inline unsigned int 280 Options::seed(void) const { 281 return _seed.value(); 282 } 283 284 inline void 285 Options::step(double s) { 286 _step.value(s); 287 } 288 inline double 289 Options::step(void) const { 290 return _step.value(); 291 } 292 293 294 /* 295 * Search options 296 * 297 */ 298 inline void 299 Options::search(int v) { 300 _search.value(v); 301 } 302 inline void 303 Options::search(int v, const char* o, const char* h) { 304 _search.add(v,o,h); 305 } 306 inline int 307 Options::search(void) const { 308 return _search.value(); 309 } 310 311 inline void 312 Options::solutions(unsigned long long int n) { 313 _solutions.value(n); 314 } 315 inline unsigned long long int 316 Options::solutions(void) const { 317 return _solutions.value(); 318 } 319 320 inline void 321 Options::threads(double n) { 322 _threads.value(n); 323 } 324 inline double 325 Options::threads(void) const { 326 return _threads.value(); 327 } 328 329 inline void 330 Options::c_d(unsigned int d) { 331 _c_d.value(d); 332 } 333 inline unsigned int 334 Options::c_d(void) const { 335 return _c_d.value(); 336 } 337 338 inline void 339 Options::a_d(unsigned int d) { 340 _a_d.value(d); 341 } 342 inline unsigned int 343 Options::a_d(void) const { 344 return _a_d.value(); 345 } 346 347 inline void 348 Options::d_l(unsigned int d) { 349 _d_l.value(d); 350 } 351 inline unsigned int 352 Options::d_l(void) const { 353 return _d_l.value(); 354 } 355 356 inline void 357 Options::node(unsigned long long int n) { 358 _node.value(n); 359 } 360 inline unsigned long long int 361 Options::node(void) const { 362 return _node.value(); 363 } 364 365 inline void 366 Options::fail(unsigned long long int n) { 367 _fail.value(n); 368 } 369 inline unsigned long long int 370 Options::fail(void) const { 371 return _fail.value(); 372 } 373 374 inline void 375 Options::time(double t) { 376 _time.value(t); 377 } 378 inline double 379 Options::time(void) const { 380 return _time.value(); 381 } 382 383 inline void 384 Options::assets(unsigned int n) { 385 _assets.value(n); 386 } 387 inline unsigned int 388 Options::assets(void) const { 389 return _assets.value(); 390 } 391 392 inline void 393 Options::slice(unsigned int n) { 394 _slice.value(n); 395 } 396 inline unsigned int 397 Options::slice(void) const { 398 return _slice.value(); 399 } 400 401 inline void 402 Options::restart(RestartMode rm) { 403 _restart.value(rm); 404 } 405 inline RestartMode 406 Options::restart(void) const { 407 return static_cast<RestartMode>(_restart.value()); 408 } 409 410 inline void 411 Options::restart_base(double n) { 412 _r_base.value(n); 413 } 414 inline double 415 Options::restart_base(void) const { 416 return _r_base.value(); 417 } 418 419 inline void 420 Options::restart_scale(unsigned int n) { 421 _r_scale.value(n); 422 } 423 inline unsigned int 424 Options::restart_scale(void) const { 425 return _r_scale.value(); 426 } 427 428 inline void 429 Options::nogoods(bool b) { 430 _nogoods.value(b); 431 } 432 inline bool 433 Options::nogoods(void) const { 434 return _nogoods.value(); 435 } 436 437 inline void 438 Options::nogoods_limit(unsigned int l) { 439 _nogoods_limit.value(l); 440 } 441 inline unsigned int 442 Options::nogoods_limit(void) const { 443 return _nogoods_limit.value(); 444 } 445 446 inline void 447 Options::relax(double d) { 448 _relax.value(d); 449 } 450 inline double 451 Options::relax(void) const { 452 return _relax.value(); 453 } 454 455 456 457 inline void 458 Options::interrupt(bool b) { 459 _interrupt.value(b); 460 } 461 inline bool 462 Options::interrupt(void) const { 463 return _interrupt.value(); 464 } 465 466 467 /* 468 * Execution options 469 * 470 */ 471 inline void 472 Options::mode(ScriptMode sm) { 473 _mode.value(sm); 474 } 475 inline ScriptMode 476 Options::mode(void) const { 477 return static_cast<ScriptMode>(_mode.value()); 478 } 479 480 inline void 481 Options::samples(unsigned int s) { 482 _samples.value(s); 483 } 484 inline unsigned int 485 Options::samples(void) const { 486 return _samples.value(); 487 } 488 489 inline void 490 Options::iterations(unsigned int i) { 491 _iterations.value(i); 492 } 493 inline unsigned int 494 Options::iterations(void) const { 495 return _iterations.value(); 496 } 497 498 inline void 499 Options::print_last(bool p) { 500 _print_last.value(p); 501 } 502 inline bool 503 Options::print_last(void) const { 504 return _print_last.value(); 505 } 506 507 inline void 508 Options::out_file(const char *f) { 509 _out_file.value(f); 510 } 511 512 inline const char* 513 Options::out_file(void) const { 514 return _out_file.value(); 515 } 516 517 inline void 518 Options::log_file(const char* f) { 519 _log_file.value(f); 520 } 521 522 inline const char* 523 Options::log_file(void) const { 524 return _log_file.value(); 525 } 526 527 inline void 528 Options::trace(int f) { 529 _trace.value(f); 530 } 531 532 inline int 533 Options::trace(void) const { 534 return _trace.value(); 535 } 536 537#ifdef GECODE_HAS_CPPROFILER 538 539 /* 540 * Profiler options 541 * 542 */ 543 inline void 544 Options::profiler_id(int i) { 545 _profiler.execution_id(i); 546 } 547 inline int 548 Options::profiler_id(void) const { 549 return _profiler.execution_id(); 550 } 551 inline void 552 Options::profiler_port(unsigned int p) { 553 _profiler.port(p); 554 } 555 inline unsigned int 556 Options::profiler_port(void) const { 557 return _profiler.port(); 558 } 559#endif 560 561#ifdef GECODE_HAS_GIST 562 forceinline 563 Options::I_::I_(void) : _click(heap,1), n_click(0), 564 _solution(heap,1), n_solution(0), _move(heap,1), n_move(0), 565 _compare(heap,1), n_compare(0) {} 566 567 forceinline void 568 Options::I_::click(Gist::Inspector* i) { 569 _click[static_cast<int>(n_click++)] = i; 570 } 571 forceinline void 572 Options::I_::solution(Gist::Inspector* i) { 573 _solution[static_cast<int>(n_solution++)] = i; 574 } 575 forceinline void 576 Options::I_::move(Gist::Inspector* i) { 577 _move[static_cast<int>(n_move++)] = i; 578 } 579 forceinline void 580 Options::I_::compare(Gist::Comparator* i) { 581 _compare[static_cast<int>(n_compare++)] = i; 582 } 583 forceinline Gist::Inspector* 584 Options::I_::click(unsigned int i) const { 585 return (i < n_click) ? _click[i] : nullptr; 586 } 587 forceinline Gist::Inspector* 588 Options::I_::solution(unsigned int i) const { 589 return (i < n_solution) ? _solution[i] : nullptr; 590 } 591 forceinline Gist::Inspector* 592 Options::I_::move(unsigned int i) const { 593 return (i < n_move) ? _move[i] : nullptr; 594 } 595 forceinline Gist::Comparator* 596 Options::I_::compare(unsigned int i) const { 597 return (i < n_compare) ? _compare[i] : nullptr; 598 } 599#endif 600 601 /* 602 * Options with additional size argument 603 * 604 */ 605 inline void 606 SizeOptions::size(unsigned int s) { 607 _size = s; 608 } 609 inline unsigned int 610 SizeOptions::size(void) const { 611 return _size; 612 } 613 614 /* 615 * Options with additional string argument 616 * 617 */ 618 inline const char* 619 InstanceOptions::instance(void) const { 620 return _inst; 621 } 622 623} 624 625// STATISTICS: driver-any