11 #ifdef COIN_HAS_FILTERSQP
56 nonlinearSolver_(NULL),
57 continuousSolver_(NULL),
61 branchingMethod_(NULL),
62 nodeComparisonMethod_(),
63 treeTraversalMethod_(),
69 messageHandler_(NULL),
79 nonlinearSolver_(NULL),
80 continuousSolver_(NULL),
81 linearizer_(other.linearizer_),
84 branchingMethod_(NULL),
85 nodeComparisonMethod_(other.nodeComparisonMethod_),
86 treeTraversalMethod_(other.treeTraversalMethod_),
87 objects_(other.objects_),
88 journalist_(other.journalist_),
90 roptions_(other.roptions_),
91 readOptions_(other.readOptions_),
92 messageHandler_(NULL),
93 prefix_(other.prefix_)
112 heuristics_.back().heuristic = i->heuristic->clone();
123 for (
unsigned int i = 0 ; i <
objects_.size() ; i++) {
131 nonlinearSolver_(NULL),
132 continuousSolver_(NULL),
133 linearizer_(other.linearizer_),
136 branchingMethod_(NULL),
137 nodeComparisonMethod_(other.nodeComparisonMethod_),
138 treeTraversalMethod_(other.treeTraversalMethod_),
139 objects_(other.objects_),
140 journalist_(other.journalist_),
142 roptions_(other.roptions_),
143 readOptions_(other.readOptions_),
144 messageHandler_(NULL),
145 prefix_(other.prefix_)
164 heuristics_.back().heuristic = i->heuristic->clone();
175 for (
unsigned int i = 0 ; i <
objects_.size() ; i++) {
182 const std::string &
prefix):
183 nonlinearSolver_(other.nonlinearSolver_),
184 continuousSolver_(NULL),
185 linearizer_(other.linearizer_),
188 branchingMethod_(NULL),
189 nodeComparisonMethod_(),
190 treeTraversalMethod_(),
191 objects_(other.objects_),
192 journalist_(other.journalist_),
194 roptions_(other.roptions_),
195 readOptions_(other.readOptions_),
196 messageHandler_(NULL),
211 for (
unsigned int i = 0 ; i <
objects_.size() ; i++) {
217 nonlinearSolver_(NULL),
218 continuousSolver_(NULL),
222 branchingMethod_(NULL),
223 nodeComparisonMethod_(),
224 treeTraversalMethod_(),
227 messageHandler_(NULL),
240 throw(CoinError(
"BabSetupBase",
"CloneWithOtherNlp",
"Not implemented"));
251 options_->GetEnumValue(
"enable_dynamic_nlp", ival,
"bonmin.");
252 if(ival && ! tminlp->hasLinearObjective()){
269 nonlinearSolver_(NULL),
270 continuousSolver_(NULL),
274 branchingMethod_(NULL),
275 nodeComparisonMethod_(),
276 treeTraversalMethod_(),
282 messageHandler_(NULL),
303 nonlinearSolver_(NULL),
304 continuousSolver_(NULL),
308 branchingMethod_(NULL),
309 nodeComparisonMethod_(),
310 treeTraversalMethod_(),
312 journalist_(app->journalist()),
313 options_(app->options()),
314 roptions_(app->roptions()),
316 messageHandler_(NULL),
340 for (
unsigned int i = 0 ; i <
objects_.size() ; i++) {
377 ival = options->GetIntegerValue(
"random_generator_seed",seed,
prefix_.c_str());
379 CoinSeedRandom((
int)CoinGetTimeOfDay());
380 else if (ival != 0) CoinSeedRandom(seed);
382 options->GetEnumValue(
"node_comparison",ival,
prefix_.c_str());
385 options->GetEnumValue(
"tree_search_strategy", ival,
prefix_.c_str());
389 options->GetEnumValue(
"variable_selection",varSelection,
prefix_.c_str());
412 OsiTMINLPInterface::registerOptions(roptions);
416 roptions->AddBoundedIntegerOption(
"bb_log_level",
417 "specify main branch-and-bound log level.",
419 "Set the level of output of the branch-and-bound : "
420 "0 - none, 1 - minimal, 2 - normal low, 3 - normal high"
422 roptions->setOptionExtraInfo(
"bb_log_level", 127);
424 roptions->AddLowerBoundedIntegerOption(
"bb_log_interval",
425 "Interval at which node level output is printed.",
427 "Set the interval (in terms of number of nodes) at which "
428 "a log on node resolutions (consisting of lower and upper bounds) is given.");
429 roptions->setOptionExtraInfo(
"bb_log_interval", 127);
431 roptions->AddBoundedIntegerOption(
"lp_log_level",
432 "specify LP log level.",
434 "Set the level of output of the linear programming sub-solver in B-Hyb or B-QG : "
435 "0 - none, 1 - minimal, 2 - normal low, 3 - normal high, 4 - verbose"
437 roptions->setOptionExtraInfo(
"lp_log_level", 119);
439 roptions->AddBoundedIntegerOption(
"nlp_log_at_root",
"specify a different log level "
440 "for root relaxation.",
443 roptions->setOptionExtraInfo(
"nlp_log_at_root",63);
447 roptions->AddLowerBoundedIntegerOption
448 (
"random_generator_seed",
449 "Set seed for random number generator (a value of -1 sets seeds to time since Epoch).",
452 roptions->setOptionExtraInfo(
"random_generator_seed",127);
454 roptions->AddLowerBoundedNumberOption(
"time_limit",
455 "Set the global maximum computation time (in secs) for the algorithm.",
458 roptions->setOptionExtraInfo(
"time_limit", 127);
460 roptions->AddLowerBoundedIntegerOption(
"node_limit",
461 "Set the maximum number of nodes explored in the branch-and-bound search.",
464 roptions->setOptionExtraInfo(
"node_limit", 127);
466 roptions->AddLowerBoundedIntegerOption(
"iteration_limit",
467 "Set the cumulative maximum number of iteration in the algorithm used to process nodes continuous relaxations in the branch-and-bound.",
469 "value 0 deactivates option.");
470 roptions->setOptionExtraInfo(
"iteration_limit", 127);
472 roptions->AddLowerBoundedIntegerOption(
"solution_limit",
473 "Abort after that much integer feasible solution have been found by algorithm",
475 "value 0 deactivates option");
476 roptions->setOptionExtraInfo(
"solution_limit", 127);
478 roptions->AddLowerBoundedNumberOption(
"integer_tolerance",
479 "Set integer tolerance.",
481 "Any number within that value of an integer is considered integer.");
482 roptions->setOptionExtraInfo(
"integer_tolerance", 127);
484 roptions->AddBoundedNumberOption(
"allowable_gap",
485 "Specify the value of absolute gap under which the algorithm stops.",
487 "Stop the tree search when the gap between the objective value of the best known solution"
488 " and the best bound on the objective of any solution is less than this.");
489 roptions->setOptionExtraInfo(
"allowable_gap", 127);
491 roptions->AddBoundedNumberOption(
"allowable_fraction_gap",
492 "Specify the value of relative gap under which the algorithm stops.",
493 -1.e20,0,1.e20,0,0.0,
494 "Stop the tree search when the gap between the objective value of the best known solution "
495 "and the best bound on the objective of any solution is less than this "
496 "fraction of the absolute value of the best known solution value.");
497 roptions->setOptionExtraInfo(
"allowable_fraction_gap", 127);
499 roptions->AddBoundedNumberOption(
"cutoff",
500 "Specify cutoff value.",
501 -1e100,0,1e100,0,1e100,
502 "cutoff should be the value of a feasible solution known by the user "
503 "(if any). The algorithm will only look for solutions better than cutoff.");
504 roptions->setOptionExtraInfo(
"cutoff", 127);
507 roptions->AddBoundedNumberOption(
"cutoff_decr",
508 "Specify cutoff decrement.",
509 -1e10,0,1e10,0,1
e-05,
510 "Specify the amount by which cutoff is decremented below "
511 "a new best upper-bound"
512 " (usually a small positive value but in non-convex problems it may be a negative value).");
513 roptions->setOptionExtraInfo(
"cutoff_decr", 127);
516 roptions->AddStringOption5(
"node_comparison",
517 "Choose the node selection strategy.",
519 "best-bound",
"choose node with the smallest bound,",
520 "depth-first",
"Perform depth first search,",
521 "breadth-first",
"Perform breadth first search,",
522 "dynamic",
"Cbc dynamic strategy (starts with a depth first search and turn to best bound after 3 "
523 "integer feasible solutions have been found).",
524 "best-guess",
"choose node with smallest guessed integer solution",
525 "Choose the strategy for selecting the next node to be processed.");
526 roptions->setOptionExtraInfo(
"node_comparison", 63);
528 roptions->AddStringOption5(
"tree_search_strategy",
529 "Pick a strategy for traversing the tree",
531 "top-node",
" Always pick the top node as sorted by the node comparison function",
532 "dive",
"Dive in the tree if possible, otherwise pick top node as sorted by the tree comparison function.",
533 "probed-dive",
"Dive in the tree exploring two children before continuing the dive at each level.",
534 "dfs-dive",
"Dive in the tree if possible doing a depth first search. "
535 "Backtrack on leaves or when a prescribed depth is attained or "
536 "when estimate of best possible integer feasible solution in subtree "
537 "is worst than cutoff. "
538 "Once a prescribed limit of backtracks is attained pick top node "
539 "as sorted by the tree comparison function",
540 "dfs-dive-dynamic",
"Same as dfs-dive but once enough solution are found switch to best-bound and if too many nodes switch to depth-first.",
541 "All strategies can be used in conjunction with any of the node comparison functions. "
542 "Options which affect dfs-dive are max-backtracks-in-dive and max-dive-depth. "
543 "The dfs-dive won't work in a non-convex problem where objective does not decrease down branches."
545 roptions->setOptionExtraInfo(
"tree_search_strategy", 63);
547 roptions->AddLowerBoundedIntegerOption(
"number_strong_branch",
548 "Choose the maximum number of variables considered for strong branching.",
550 "Set the number of variables on which to do strong branching.");
551 roptions->setOptionExtraInfo(
"number_strong_branch", 127);
554 roptions->AddLowerBoundedIntegerOption
555 (
"number_before_trust",
556 "Set the number of branches on a variable before its pseudo costs are to be believed "
557 "in dynamic strong branching.",
559 "A value of 0 disables pseudo costs.");
560 roptions->setOptionExtraInfo(
"number_before_trust", 127);
562 roptions->AddStringOption2(
"nlp_failure_behavior",
563 "Set the behavior when an NLP or a series of NLP are unsolved by Ipopt (we call unsolved an NLP for which Ipopt is not "
564 "able to guarantee optimality within the specified tolerances).",
566 "stop",
"Stop when failure happens.",
567 "fathom",
"Continue when failure happens.",
568 "If set to \"fathom\", the algorithm will fathom the node when Ipopt fails to find a solution to the nlp "
569 "at that node within the specified tolerances. "
570 "The algorithm then becomes a heuristic, and the user will be warned that the solution might not be optimal.");
571 roptions->setOptionExtraInfo(
"nlp_failure_behavior", 8);
573 roptions->AddStringOption2(
"sos_constraints",
574 "Whether or not to activate SOS constraints.",
578 "(only type 1 SOS are supported at the moment)");
579 roptions->setOptionExtraInfo(
"sos_constraints", 63);
581 #ifdef BONMIN_CURVATURE_BRANCHING
582 roptions->AddStringOption10(
"variable_selection",
584 roptions->AddStringOption9(
"variable_selection",
586 "Chooses variable selection strategy",
588 "most-fractional",
"Choose most fractional variable",
589 "strong-branching",
"Perform strong branching",
590 "reliability-branching",
"Use reliability branching",
591 #ifdef BONMIN_CURVATURE_BRANCHING
592 "curvature-estimator",
"Use curvature estimation to select branching variable",
594 "qp-strong-branching",
"Perform strong branching with QP approximation",
595 "lp-strong-branching",
"Perform strong branching with LP approximation",
596 "nlp-strong-branching",
"Perform strong branching with NLP approximation",
597 "osi-simple",
"Osi method to do simple branching",
598 "osi-strong",
"Osi method to do strong branching",
599 "random",
"Method to choose branching variable randomly");
601 roptions->setOptionExtraInfo(
"variable_selection", 27);
603 roptions->AddLowerBoundedIntegerOption(
"num_cut_passes",
604 "Set the maximum number of cut passes at regular nodes of the branch-and-cut.",
607 roptions->setOptionExtraInfo(
"num_cut_passes", 19);
609 roptions->AddLowerBoundedIntegerOption(
"num_cut_passes_at_root",
610 "Set the maximum number of cut passes at regular nodes of the branch-and-cut.",
613 roptions->setOptionExtraInfo(
"num_cut_passes_at_root", 19);
615 roptions->AddStringOption2(
"enable_dynamic_nlp",
616 "Enable dynamic linear and quadratic rows addition in nlp",
621 roptions->setOptionExtraInfo(
"enable_dynamic_nlp", 19);
625 roptions->AddStringOption2(
"read_solution_file",
626 "Read a file with the optimal solution to test if algorithms cuts it.",
630 "For Debugging purposes only.");
631 roptions->setOptionExtraInfo(
"enable_dynamic_nlp", 8);
636 #ifdef COIN_HAS_FILTERSQP
650 options_ =
new Ipopt::OptionsList();
657 journalist_->AddFileJournal(
"console",
"stdout", Ipopt::J_ITERSUMMARY);
662 catch (Ipopt::IpoptException &E) {
666 catch (std::bad_alloc) {
667 journalist_->Printf(Ipopt::J_ERROR, Ipopt::J_MAIN,
"\n Not enough memory .... EXIT\n");
672 Ipopt::IpoptException E(
"Uncaught exception in FilterSolver::FilterSolver()",
673 "BonFilterSolver.cpp",-1);
688 if (fileName !=
"") {
690 is.open(fileName.c_str());
692 catch (std::bad_alloc) {
693 journalist_->Printf(Ipopt::J_SUMMARY, Ipopt::J_MAIN,
"\nEXIT: Not enough memory.\n");
698 Ipopt::IpoptException E(
"Unknown Exception caught in ipopt",
"Unknown File", -1);
716 std::stringstream is(opt_string.c_str());
730 catch (Ipopt::IpoptException &E) {
743 bool print_options_documentation;
744 options_->GetBoolValue(
"print_options_documentation",
745 print_options_documentation,
"");
746 if (print_options_documentation) {
747 std::list<std::string> categories;
748 categories.push_back(
"Algorithm choice");
749 categories.push_back(
"Branch-and-bound options");
750 categories.push_back(
"ECP cuts generation");
751 categories.push_back(
"Feasibility checker using OA cuts");
752 categories.push_back(
"MILP Solver");
753 categories.push_back(
"MILP cutting planes in hybrid algorithm");
754 categories.push_back(
"Primal Heuristics");
755 categories.push_back(
"NLP interface");
756 categories.push_back(
"NLP solution robustness");
757 categories.push_back(
"NLP solves in hybrid algorithm");
758 categories.push_back(
"Nonconvex problems");
759 categories.push_back(
"Outer Approximation Decomposition (B-OA)");
760 categories.push_back(
"Outer Approximation cuts generation");
761 categories.push_back(
"Output and Loglevel");
762 categories.push_back(
"Strong branching setup");
764 categories.push_back(
"Diving options");
765 categories.push_back(
"ECP based strong branching");
766 categories.push_back(
"Primal Heuristics (undocumented)");
767 categories.push_back(
"Outer Approximation strengthening");
768 #ifdef COIN_HAS_FILTERSQP
769 categories.push_back(
"FilterSQP options");
782 bool hasPseudo = (upPsCosts!=NULL);
783 if (priorities == NULL && directions && NULL && hasPseudo)
787 for (
int i = 0 ; i <
n; i++) {
788 OsiObject2 *
object =
dynamic_cast<OsiObject2 *
>(objects[i]);
789 int iCol = objects[i]->columnNumber();
791 throw CoinError(
"BabSetupBase",
"setPriorities",
792 "Don't know how to set priority for non-column object.");
795 objects[i]->setPriority(priorities[iCol]);
798 if (
object == NULL) {
799 throw CoinError(
"BabSetupBase",
"setPriorities",
800 "Don't know how to set preferred way for object.");
802 object->setPreferredWay(directions[iCol]);
805 throw CoinError(
"BabSetupBase",
"setPriorities",
806 "Can not handle user set pseudo-costs with OsiObjects\n"
807 "You should use one of the Cbc branching rules:\n"
808 "most-fractional or strong-branching.");
821 const int & numSos = sos->
num;
822 OsiObject **
objects =
new OsiObject*[numSos];
823 const int * starts = sos->
starts;
824 const int * indices = sos->
indices;
825 const char * types = sos->
types;
826 const double * weights = sos->
weights;
827 bool hasPriorities =
false;
832 for (
int i = 0 ; i < numberObjects ; i++) {
833 if (varPriorities[i]) {
834 hasPriorities =
true;
842 for (
int i = 0 ; i < numSos ; i++) {
843 if (sosPriorities[i]) {
844 hasPriorities =
true;
849 for (
int i = 0 ; i < numSos ; i++)
851 int start = starts[i];
852 int length = starts[i + 1] - start;
854 &weights[start], (
int) types[i]);
856 objects[i]->setPriority(10);
857 if (hasPriorities && sosPriorities && sosPriorities[i]) {
858 objects[i]->setPriority(sosPriorities[i]);
862 for (
int i = 0 ; i < numSos ; i++)
int getIntParameter(const IntParameter &p) const
Return value of integer parameter.
Behavior of the algorithm in the case of a failure.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
void readOptionsStream(std::istream &is)
Get the options from stream.
Max number of failures in a branch.
const vector< OsiObject * > & objects() const
Access to extra objects.
int intParam_[NumberIntParam]
storage of integer parameters.
CuttingMethods cutGenerators_
Cut generation methods.
Ipopt::SmartPtr< Ipopt::Journalist > journalist()
Get a pointer to a journalist.
virtual void registerOptions()
Register all the options for this algorithm instance.
int num
Number of SOS constraints.
void use(const OsiTMINLPInterface &nlp)
use existing TMINLP interface (containing the options).
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions()
Get a pointer to RegisteredOptions (generally used to add new ones)
const double * getUpPsCosts() const
Get number of columns.
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
Stop if relative gap is less than this.
virtual const SosInfo * sosConstraints() const =0
HeuristicMethods heuristics_
Heuristic methods.
vector< OsiObject * > objects_
Extra object to add to Cbc (not OsiObjects).
OsiSolverInterface * clone(bool copyData=true) const
Virtual copy constructor.
static double defaultDoubleParam_[NumberDoubleParam]
default values for double parameters.
bool IsValid(const OSSmartPtr< U > &smart_ptr)
Number of candidates for strong branching.
TreeTraversal treeTraversalMethod_
Tree traversal method.
void use(Ipopt::SmartPtr< TMINLP2TNLP > tminlp2tnlp)
Sets the TMINLP2TNLP to be used by the interface.
Class to store sos constraints for model.
bool readOptions_
flag to say if option file was read.
BabSetupBase(const CoinMessageHandler *handler=NULL)
Default constructor.
void setPriorities()
Set the priorities into OsiTMINLPInterface when needed.
const int * getBranchingDirections() const
get prefered branching directions
OsiTMINLPInterface * nonlinearSolver_
Storage of the non-linear solver used.
const int * getPriorities() const
Get priorities on integer variables.
Minimum reliability before trust pseudo-costs.
From a TMINLP, this class adapts to another TMINLP where the original objective is transformed into a...
const Bonmin::TNLPSolver * solver() const
OsiChooseVariable * branchingMethod_
Branching method.
int * starts
For 0 <= i < nums, start[i] gives the indice of indices and weights arrays at which the description o...
void fint fint fint real fint real real real real real real real real real * e
A class to have all elements necessary to setup a branch-and-bound.
limit on number of integer feasible solution.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register the options of the method.
NodeComparison nodeComparisonMethod_
Node comparison method.
static int defaultIntParam_[NumberIntParam]
default values for int parameters.
virtual BabSetupBase * clone() const =0
virtual copy constructor.
TreeTraversal
Strategies for traversing the tree.
void registerOptions()
Register this solver options into passed roptions.
int * priorities
priorities of sos constraints.
Display information every logIntervval nodes.
void addSos()
Add SOS constraints to OsiTMINLPInterface when needed.
Max number of consecutive infeasible problem in a branch before fathoming.
U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
Ipopt::SmartPtr< Ipopt::OptionsList > options_
List of Options.
Consider or not SOS constraints.
Log level for root relaxation.
void initializeOptionsAndJournalist()
Initialize the options and the journalist.
This is a derived class fro TMINLP2TNLP to handle adding quadratic cuts.
Number of cut passes at nodes.
static void registerAllOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register all the options for this algorithm instance.
double doubleParam_[NumberDoubleParam]
storage of double parameters.
NodeComparison
Strategies for comparing the nodes on the heap.
std::string prefix_
Prefix to use when reading options.
int * indices
indices of elements belonging to the SOS.
Ipopt::SmartPtr< Ipopt::Journalist > journalist_
Storage of Journalist for output.
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions_
Registered Options.
const TMINLP * model() const
Ipopt::SmartPtr< const Ipopt::OptionsList > options() const
Get the options (for getting their values).
OsiTMINLPInterface * nonlinearSolver()
Pointer to the non-linear solver used.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register the options of the method.
void gatherParametersValues()
Get the values of base parameters from the options stored.
void registerOptions()
Register this solver options into passed roptions.
Number of cut passes at nodes.
CoinMessageHandler * messageHandler_
separate message handler.
void initialize(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions, Ipopt::SmartPtr< Ipopt::OptionsList > options, Ipopt::SmartPtr< Ipopt::Journalist > journalist, const std::string &prefix, Ipopt::SmartPtr< TMINLP > tminlp)
Facilitator to initialize interface.
virtual ~BabSetupBase()
Virtual destructor.
static void registerOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
void mayPrintDoc()
May print documentation of options if options print_options_documentation is set to yes...
virtual void readOptionsFile()
Get the options from default text file (bonmin.opt) if don't already have them.
OsiSolverInterface * continuousSolver_
Storage of continuous solver.
const char * prefix() const
Get prefix to use for options.
Stop if absolute gap is less than this.
double * weights
weights of the elements of the SOS.
void readOptionsString(std::string opt_string)
Get the options from long string containing all.
Class to add a few more information to Ipopt::RegisteredOptions.