@@ -334,6 +334,7 @@ namespace Gecode {
334334 Driver::StringOption _branching; // /< Branching options
335335 Driver::DoubleOption _decay; // /< Decay option
336336 Driver::UnsignedIntOption _seed; // /< Seed option
337+ Driver::DoubleOption _step; // /< Step option
337338 // @}
338339
339340 // / \name Search options
@@ -412,6 +413,11 @@ namespace Gecode {
412413 void seed (unsigned int s);
413414 // / Return seed value
414415 unsigned int seed (void ) const ;
416+
417+ // / Set default step value
418+ void step (double s);
419+ // / Return step value
420+ double step (void ) const ;
415421 // @}
416422
417423 // / \name Search options
@@ -614,51 +620,80 @@ namespace Gecode {
614620
615621#include < gecode/driver/options.hpp>
616622
617- namespace Gecode {
623+ namespace Gecode { namespace Driver {
618624
619- namespace Driver {
620- /* *
621- * \brief Parametric base-class for scripts
625+ /* *
626+ * \brief Parametric base-class for scripts
627+ *
628+ * All scripts must inherit from this class
629+ * - adds printing and comparison for Gist to scripts
630+ * - run allows to execute scripts
631+ */
632+ template <class BaseSpace >
633+ class ScriptBase : public BaseSpace {
634+ public:
635+ // / Constructor
636+ ScriptBase (const Options& opt);
637+ // / Constructor used for cloning
638+ ScriptBase (bool share, ScriptBase& e);
639+ // / Print a solution to \a os
640+ virtual void print (std::ostream& os) const ;
641+ // / Compare with \a s
642+ virtual void compare (const Space& home, std::ostream& os) const ;
643+ // / Choose output stream according to \a name
644+ static std::ostream& select_ostream (const char * name, std::ofstream& ofs);
645+ /* * Run script with search engine \a Engine and options \a opt
646+ *
647+ * In the solution and stat modes, search can be aborted by sending
648+ * SIGINT to the process (i.e., pressing Ctrl-C on the command
649+ * line).
622650 *
623- * All scripts must inherit from this class
624- * - adds printing and comparison for Gist to scripts
625- * - run allows to execute scripts
651+ * In case \a s is different from NULL, the search engine uses
652+ * \a s as root of the search tree.
626653 */
627- template <class BaseSpace >
628- class ScriptBase : public BaseSpace {
629- public:
630- // / Default constructor
631- ScriptBase (void ) {}
632- // / Constructor used for cloning
633- ScriptBase (bool share, ScriptBase& e)
634- : BaseSpace(share,e) {}
635- // / Print a solution to \a os
636- virtual void print (std::ostream& os) const { (void ) os; }
637- // / Compare with \a s
638- virtual void compare (const Space&, std::ostream& os) const {
639- (void ) os;
640- }
641- // / Choose output stream according to \a name
642- static std::ostream& select_ostream (const char * name, std::ofstream& ofs);
643- /* * Run script with search engine \a Engine and options \a opt
644- *
645- * In the solution and stat modes, search can be aborted by sending
646- * SIGINT to the process (i.e., pressing Ctrl-C on the command
647- * line).
648- *
649- * In case \a s is different from NULL, the search engine uses
650- * \a s as root of the search tree.
651- */
652- template <class Script , template <class > class Engine , class Options >
653- static void run (const Options& opt, Script* s=NULL );
654- private:
655- template <class Script , template <class > class Engine , class Options ,
656- template <template <class > class ,class > class Meta >
657- static void runMeta (const Options& opt, Script* s);
658- // / Catch wrong definitions of copy constructor
659- explicit ScriptBase (ScriptBase& e);
660- };
661- }
654+ template <class Script , template <class > class Engine , class Options >
655+ static void run (const Options& opt, Script* s=NULL );
656+ private:
657+ template <class Script , template <class > class Engine , class Options ,
658+ template <template <class > class ,class > class Meta >
659+ static void runMeta (const Options& opt, Script* s);
660+ // / Catch wrong definitions of copy constructor
661+ explicit ScriptBase (ScriptBase& e);
662+ };
663+
664+ #ifdef GECODE_HAS_FLOAT_VARS
665+
666+ // / Class to extract the step option value
667+ template <class BaseSpace >
668+ class ExtractStepOption : public BaseSpace {
669+ public:
670+ // / Constructor that extracts the step value
671+ ExtractStepOption (const Options& opt)
672+ : BaseSpace(opt.step()) {}
673+ // / Constructor used for cloning
674+ ExtractStepOption (bool share, BaseSpace& e)
675+ : BaseSpace(share,e) {}
676+ };
677+
678+ #endif
679+
680+ // / Class to ignore the step option value
681+ template <class BaseSpace >
682+ class IgnoreStepOption : public BaseSpace {
683+ public:
684+ // / Constructor
685+ IgnoreStepOption (const Options& opt) {}
686+ // / Constructor used for cloning
687+ IgnoreStepOption (bool share, BaseSpace& e)
688+ : BaseSpace(share,e) {}
689+ };
690+
691+
692+ }}
693+
694+ #include < gecode/driver/script.hpp>
695+
696+ namespace Gecode {
662697
663698 /* *
664699 * \defgroup TaskDriverScript Script classes
@@ -669,47 +704,52 @@ namespace Gecode {
669704 * \brief Base-class for scripts
670705 * \ingroup TaskDriverScript
671706 */
672- typedef Driver::ScriptBase<Space> Script;
707+ typedef Driver::ScriptBase<Driver::IgnoreStepOption<Space> >
708+ Script;
673709 /* *
674710 * \brief Base-class for scripts for finding solution of lowest integer cost
675711 * \ingroup TaskDriverScript
676712 */
677- typedef Driver::ScriptBase<MinimizeSpace> MinimizeScript;
713+ typedef Driver::ScriptBase<Driver::IgnoreStepOption<MinimizeSpace> >
714+ MinimizeScript;
678715 /* *
679716 * \brief Base-class for scripts for finding solution of highest integer cost
680717 * \ingroup TaskDriverScript
681718 */
682- typedef Driver::ScriptBase<MaximizeSpace> MaximizeScript;
719+ typedef Driver::ScriptBase<Driver::IgnoreStepOption<MaximizeSpace> >
720+ MaximizeScript;
683721 /* *
684722 * \brief Base-class for scripts for finding solution of lowest integer cost
685723 * \ingroup TaskDriverScript
686724 */
687- typedef Driver::ScriptBase<IntMinimizeSpace> IntMinimizeScript;
725+ typedef Driver::ScriptBase<Driver::IgnoreStepOption<IntMinimizeSpace> >
726+ IntMinimizeScript;
688727 /* *
689728 * \brief Base-class for scripts for finding solution of highest integer cost
690729 * \ingroup TaskDriverScript
691730 */
692- typedef Driver::ScriptBase<IntMaximizeSpace> IntMaximizeScript;
731+ typedef Driver::ScriptBase<Driver::IgnoreStepOption<IntMaximizeSpace> >
732+ IntMaximizeScript;
693733
694734#ifdef GECODE_HAS_FLOAT_VARS
695735
696736 /* *
697737 * \brief Base-class for scripts for finding solution of lowest float cost
698738 * \ingroup TaskDriverScript
699739 */
700- typedef Driver::ScriptBase<FloatMinimizeSpace> FloatMinimizeScript;
740+ typedef Driver::ScriptBase<Driver::ExtractStepOption<FloatMinimizeSpace> >
741+ FloatMinimizeScript;
701742 /* *
702743 * \brief Base-class for scripts for finding solution of highest float cost
703744 * \ingroup TaskDriverScript
704745 */
705- typedef Driver::ScriptBase<FloatMaximizeSpace> FloatMaximizeScript;
746+ typedef Driver::ScriptBase<Driver::ExtractStepOption<FloatMaximizeSpace> >
747+ FloatMaximizeScript;
706748
707749#endif
708750
709751}
710752
711- #include < gecode/driver/script.hpp>
712-
713753#endif
714754
715755// STATISTICS: driver-any
0 commit comments