22 #include "CoinTime.hpp"
30 #ifdef COIN_HAS_FILTERSQP
36 #include "OsiBranchingObject.hpp"
37 #include "OsiRowCutDebugger.hpp"
43 using namespace Ipopt;
53 roptions->SetRegisteringCategory(
"NLP interface", RegisteredOptions::BonminCategory);
54 roptions->AddStringOption3(
"nlp_solver",
55 "Choice of the solver for local optima of continuous NLP's",
57 "Ipopt",
"Interior Point OPTimizer (https://projects.coin-or.org/Ipopt)",
58 "filterSQP",
"Sequential quadratic programming trust region "
59 "algorithm (http://www-unix.mcs.anl.gov/~leyffer/solvers.html)",
60 "all",
"run all available solvers at each node",
61 "Note that option will work only if the specified solver has been installed. Ipopt will usually be installed with Bonmin by default. For FilterSQP please see http://www-unix.mcs.anl.gov/~leyffer/solvers.html on how to obtain it and https://projects.coin-or.org/Bonmin/wiki/HintTricks on how to configure Bonmin to use it.");
62 roptions->setOptionExtraInfo(
"nlp_solver",127);
64 roptions->AddStringOption4(
"warm_start",
65 "Select the warm start method",
67 "none",
"No warm start, just start NLPs from optimal solution of the root relaxation",
68 "fake_basis",
"builds fake basis, useful for cut management in Cbc (warm start is the same as in none)",
69 "optimum",
"Warm start with direct parent optimum",
70 "interior_point",
"Warm start with an interior point of direct parent",
71 "This will affect the function getWarmStart(), and as a consequence the warm starting in the various algorithms.");
72 roptions->setOptionExtraInfo(
"warm_start",8);
74 roptions->SetRegisteringCategory(
"Output and Loglevel", RegisteredOptions::BonminCategory);
76 roptions->AddBoundedIntegerOption(
"nlp_log_level",
77 "specify NLP solver interface log level (independent from ipopt print_level).",
79 "Set the level of output of the OsiTMINLPInterface : "
80 "0 - none, 1 - normal, 2 - verbose"
82 roptions->setOptionExtraInfo(
"nlp_log_level",127);
84 roptions->AddStringOption2(
"file_solution",
85 "Write a file bonmin.sol with the solution",
89 roptions->setOptionExtraInfo(
"file_solution",127);
91 roptions->SetRegisteringCategory(
"NLP solution robustness", RegisteredOptions::BonminCategory);
93 roptions->AddLowerBoundedNumberOption(
"max_random_point_radius",
94 "Set max value r for coordinate of a random point.",
96 "When picking a random point, coordinate i will be in the interval [min(max(l,-r),u-r), max(min(u,r),l+r)] "
97 "(where l is the lower bound for the variable and u is its upper bound)");
98 roptions->setOptionExtraInfo(
"max_random_point_radius",8);
100 roptions->AddStringOption3(
"random_point_type",
"method to choose a random starting point",
102 "Jon",
"Choose random point uniformly between the bounds",
103 "Andreas",
"perturb the starting point of the problem within a prescribed interval",
104 "Claudia",
"perturb the starting point using the perturbation radius suffix information",
106 roptions->setOptionExtraInfo(
"random_point_type",8);
108 roptions->AddLowerBoundedNumberOption(
"random_point_perturbation_interval",
109 "Amount by which starting point is perturbed when choosing to pick random point by perturbing starting point",
112 roptions->setOptionExtraInfo(
"random_point_perturbation_interval",8);
115 roptions->AddLowerBoundedIntegerOption
116 (
"num_iterations_suspect",
117 "Number of iterations over which a node is considered \"suspect\" (for debugging purposes only, see detailed documentation).",
119 "When the number of iterations to solve a node is above this number, the subproblem at this"
120 " node is considered to be suspect and it will be written into a file (set to -1 to deactivate this).");
121 roptions->setOptionExtraInfo(
"num_iterations_suspect",127);
125 roptions->AddLowerBoundedIntegerOption(
"num_retry_unsolved_random_point",
126 "Number $k$ of times that the algorithm will try to resolve an unsolved NLP with a random starting point "
127 "(we call unsolved an NLP for which Ipopt is not "
128 "able to guarantee optimality within the specified tolerances).",
130 "When Ipopt fails to solve a continuous NLP sub-problem, if $k > 0$, the algorithm will "
131 "try again to solve the failed NLP with $k$ new randomly chosen starting points "
132 " or until the problem is solved with success.");
133 roptions->setOptionExtraInfo(
"num_retry_unsolved_random_point",127);
135 roptions->AddLowerBoundedNumberOption(
"resolve_on_small_infeasibility",
136 "If a locally infeasible problem is infeasible by less than this, resolve it "
137 "with initial starting point.",
139 "It is set to 0 by default with Ipopt. "
140 "When using FilterSQP, Bonmin sets it to a small value.");
141 roptions->setOptionExtraInfo(
"resolve_on_small_infeasibility",8);
144 roptions->SetRegisteringCategory(
"Nonconvex problems", RegisteredOptions::BonminCategory);
147 roptions->AddLowerBoundedIntegerOption(
"num_resolve_at_root",
148 "Number $k$ of tries to resolve the root node with different starting points.",
150 "The algorithm will solve the root node with $k$ random starting points"
151 " and will keep the best local optimum found.");
152 roptions->setOptionExtraInfo(
"num_resolve_at_root",8);
154 roptions->AddLowerBoundedIntegerOption(
"num_resolve_at_node",
155 "Number $k$ of tries to resolve a node (other than the root) of the tree with different starting point.",
157 "The algorithm will solve all the nodes with $k$ different random starting points "
158 "and will keep the best local optimum found.");
159 roptions->setOptionExtraInfo(
"num_resolve_at_node",8);
161 roptions->AddLowerBoundedIntegerOption(
"num_resolve_at_infeasibles",
162 "Number $k$ of tries to resolve an infeasible node (other than the root) of the tree with different starting point.",
164 "The algorithm will solve all the infeasible nodes with $k$ different random starting points "
165 "and will keep the best local optimum found.");
166 roptions->setOptionExtraInfo(
"num_resolve_at_infeasibles",8);
169 roptions->AddStringOption2(
"dynamic_def_cutoff_decr",
170 "Do you want to define the parameter cutoff_decr dynamically?",
174 roptions->setOptionExtraInfo(
"dynamic_def_cutoff_decr",8);
176 roptions->AddLowerBoundedNumberOption(
"coeff_var_threshold",
177 "Coefficient of variation threshold (for dynamic definition of cutoff_decr).",
181 roptions->setOptionExtraInfo(
"coeff_var_threshold",8);
183 roptions->AddNumberOption(
"first_perc_for_cutoff_decr",
184 "The percentage used when, the coeff of variance is smaller than the threshold, to compute the cutoff_decr dynamically.",
186 roptions->setOptionExtraInfo(
"first_perc_for_cutoff_decr",8);
188 roptions->AddNumberOption(
"second_perc_for_cutoff_decr",
189 "The percentage used when, the coeff of variance is greater than the threshold, to compute the cutoff_decr dynamically.",
191 roptions->setOptionExtraInfo(
"second_perc_for_cutoff_decr",8);
200 roptions->SetRegisteringCategory(
"Outer Approximation strengthening", RegisteredOptions::UndocumentedCategory);
201 roptions->AddStringOption2(
"disjunctive_cut_type",
202 "Determine if and what kind of disjunctive cuts should be computed.",
204 "none",
"No disjunctive cuts.",
205 "most-fractional",
"If discrete variables present, compute disjunction for most-fractional variable");
206 roptions->setOptionExtraInfo(
"disjunctive_cut_type",119);
211 roptions->AddStringOption4(
"cut_strengthening_type",
212 "Determines if and what kind of cut strengthening should be performed.",
214 "none",
"No strengthening of cuts.",
215 "sglobal",
"Strengthen global cuts.",
216 "uglobal-slocal",
"Unstrengthened global and strengthened local cuts",
217 "sglobal-slocal",
"Strengthened global and strengthened local cuts",
219 roptions->setOptionExtraInfo(
"cut_strengthening_type",119);
221 roptions->SetRegisteringCategory(
"Outer Approximation cuts generation", RegisteredOptions::BonminCategory);
223 roptions->AddStringOption2(
"oa_cuts_scope",
"Specify if OA cuts added are to be set globally or locally valid",
225 "local",
"Cuts are treated as locally valid",
226 "global",
"Cuts are treated as globally valid",
228 roptions->setOptionExtraInfo(
"oa_cuts_scope",119);
230 roptions->AddStringOption2(
"add_only_violated_oa",
"Do we add all OA cuts or only the ones violated by current point?",
233 "yes",
"Add only violated cuts",
"");
234 roptions->setOptionExtraInfo(
"add_only_violated_oa",119);
237 roptions->AddLowerBoundedNumberOption(
"tiny_element",
"Value for tiny element in OA cut",
239 "We will remove \"cleanly\" (by relaxing cut) an element lower"
241 roptions->setOptionExtraInfo(
"tiny_element",119);
243 roptions->AddLowerBoundedNumberOption(
"very_tiny_element",
"Value for very tiny element in OA cut",
245 "Algorithm will take the risk of neglecting an element lower"
247 roptions->setOptionExtraInfo(
"very_tiny_element",119);
249 roptions->AddLowerBoundedNumberOption(
"oa_rhs_relax",
"Value by which to relax OA cut",
251 "RHS of OA constraints will be relaxed by this amount times the absolute value of the initial rhs if it is >= 1 (otherwise by this amount)."
253 roptions->setOptionExtraInfo(
"oa_rhs_relax",119);
255 roptions->SetRegisteringCategory(
"Output and Loglevel", RegisteredOptions::BonminCategory);
257 roptions->AddLowerBoundedIntegerOption(
"oa_cuts_log_level",
258 "level of log when generating OA cuts.",
260 "0: outputs nothing,\n"
261 "1: when a cut is generated, its violation and index of row from which it originates,\n"
262 "2: always output violation of the cut.\n"
263 "3: output generated cuts incidence vectors.");
264 roptions->setOptionExtraInfo(
"oa_cuts_log_level",119);
271 OsiTMINLPInterface::registerOptions
279 #ifdef COIN_HAS_FILTERSQP
280 FilterSolver::RegisterOptions(roptions);
282 IpoptSolver::RegisterOptions(roptions);
284 catch(RegisteredOptions::OPTION_ALREADY_REGISTERED) {
296 OsiTMINLPInterface::Messages::Messages
297 ():CoinMessages((
int)OSITMINLPINTERFACE_DUMMY_END)
299 strcpy(source_ ,
"NLP");
301 "After %d tries found a solution of %g (previous best %g).");
304 "After %d tries found an solution of %g infeasible problem.");
307 "After %d tries found an solution of %g unsolved problem.");
309 "Problem not solved with warm start but solved without");
312 "Trying to resolve NLP with different starting point (%d attempts).");
314 "Problem initially not solved but solved with a random starting point (success on %d attempt)");
316 "Warning : continuing branching, while there are unrecovered failures at nodes");
318 ADD_MSG(SUSPECT_PROBLEM,
std_m, 2,
"NLP number %d is suspect (see bounds and start file)");
319 ADD_MSG(IPOPT_SUMMARY,
std_m, 2,
"Ipopt return (for %s): status %2d, iter count %4d, time %g");
320 ADD_MSG(BETTER_SOL,
std_m, 2,
"Solution of value %g found on %d'th attempt");
324 " Num Status Obj It time Location");
326 "%c %8d %11s %g %8d %g %20s");
328 ADD_MSG(ALTERNATE_OBJECTIVE,
std_m, 1,
"Objective value recomputed with alternate objective: %g.");
331 "resolve called before any call to initialSol can not use warm starts.");
332 ADD_MSG(ERROR_NO_TNLPSOLVER,
warn_m, 1,
"Can not parse options when no IpApplication has been created");
334 "OA on non-convex constraint is very experimental.");
335 ADD_MSG(SOLVER_DISAGREE_STATUS,
warn_m, 1,
"%s says problem %s, %s says %s.");
336 ADD_MSG(SOLVER_DISAGREE_VALUE,
warn_m, 1,
"%s gives objective %.16g, %s gives %.16g.");
342 OsiTMINLPInterface::OaMessageHandler::print(OsiRowCut &row){
343 FILE * fp = filePointer();
344 const int &
n = row.row().getNumElements();
345 fprintf(fp,
"Row cut has %d elements. Lower bound: %g, upper bound %g.\n", n, row.lb(), row.ub());
346 const int * idx = row.row().getIndices();
347 const double * val = row.row().getElements();
348 for(
int i = 0 ; i <
n ; i++){
349 fprintf(fp,
"%g, x%d",val[i], idx[i]);
355 OsiTMINLPInterface::OaMessages::OaMessages(): CoinMessages((
int) OA_MESSAGES_DUMMY_END){
356 strcpy(source_,
"OaCg");
357 ADD_MSG(VIOLATED_OA_CUT_GENERATED,
std_m, 1,
"Row %d, cut violation is %g: Outer approximation cut generated.");
359 ADD_MSG(CUT_NOT_VIOLATED_ENOUGH,
std_m, 2,
"Row %d, cut violation is %g: Outer approximation cut not generated.");
361 ADD_MSG(OA_CUT_GENERATED,
std_m, 1,
"Row %d: Outer approximation cut not generated.");
363 bool OsiTMINLPInterface::hasPrintedOptions=0;
370 OsiSolverInterface(),
373 problem_to_optimize_(NULL),
374 feasibility_mode_(false),
383 OsiDualObjectiveLimit_(1e200),
384 hasVarNamesFile_(true),
385 nCallOptimizeTNLP_(0),
386 totalNlpSolveTime_(0),
388 maxRandomRadius_(1e08),
389 randomGenerationType_(0),
390 max_perturbation_(COIN_DBL_MAX),
392 numRetryInitial_(-1),
393 numRetryResolve_(-1),
394 numRetryInfeasibles_(-1),
395 numRetryUnsolved_(1),
396 infeasibility_epsilon_(0),
398 coeff_var_threshold_(0.1),
399 first_perc_for_cutoff_decr_(-0.02),
400 second_perc_for_cutoff_decr_(-0.05),
402 pretendFailIsInfeasible_(0),
403 pretendSucceededNext_(0),
404 hasContinuedAfterNlpFailure_(false),
405 numIterationSuspect_(-1),
406 hasBeenOptimized_(false),
408 feasibilityProblem_(NULL),
419 warmStartMode_(
None),
421 cutStrengthener_(NULL),
424 newCutoffDecr(COIN_DBL_MAX)
427 oaHandler_ =
new OaMessageHandler;
428 oaHandler_->setLogLevel(0);
435 const std::string &
prefix,
438 createApplication(roptions, options, journalist, prefix);
451 const std::string &
prefix
456 options->GetEnumValue(
"nlp_solver", ival, prefix.c_str());
459 testOthers_ =
false;;
460 #ifdef COIN_HAS_FILTERSQP
463 throw SimpleError(
"createApplication",
464 "Bonmin not configured to run with FilterSQP.");
467 debug_apps_.push_back(
new IpoptSolver(roptions, options, journalist, prefix));
471 app_ =
new IpoptSolver(roptions, options, journalist, prefix);
473 #ifdef COIN_HAS_FILTERSQP
478 #ifdef COIN_HAS_FILTERSQP
481 throw SimpleError(
"createApplication",
482 "Bonmin not configured to run with Ipopt.");
484 debug_apps_.push_back(
new IpoptSolver(roptions, options, journalist, prefix));
487 if (!app_->Initialize(
"")) {
488 throw CoinError(
"Error during initialization of app_",
"createApplication",
"OsiTMINLPInterface");
491 i != debug_apps_.end() ; i++){
492 (*i)->Initialize(
"");
494 extractInterfaceParams();
507 if(feasibility_mode_){
508 problem_to_optimize_ =
GetRawPtr(feasibilityProblem_);
511 problem_to_optimize_ =
GetRawPtr(problem_);
522 if (fileName !=
"") {
524 is.open(fileName.c_str());
526 catch(std::bad_alloc) {
527 throw CoinError(
"Not enough memory to open option file.\n",
"readOptionFile",
"OsiTMINLPInterface");
530 options()->ReadFromStream(*app_->journalist(), is);
531 extractInterfaceParams();
537 OsiSolverInterface(source),
538 tminlp_(source.tminlp_),
540 problem_to_optimize_(NULL),
541 feasibility_mode_(source.feasibility_mode_),
546 OsiDualObjectiveLimit_(source.OsiDualObjectiveLimit_),
547 hasVarNamesFile_(source.hasVarNamesFile_),
548 nCallOptimizeTNLP_(0),
549 totalNlpSolveTime_(0),
551 maxRandomRadius_(source.maxRandomRadius_),
552 randomGenerationType_(source.randomGenerationType_),
553 max_perturbation_(source.max_perturbation_),
554 pushValue_(source.pushValue_),
555 numRetryInitial_(source.numRetryInitial_),
556 numRetryResolve_(source.numRetryResolve_),
557 numRetryInfeasibles_(source.numRetryInfeasibles_),
558 numRetryUnsolved_(source.numRetryUnsolved_),
559 infeasibility_epsilon_(source.infeasibility_epsilon_),
560 dynamicCutOff_(source.dynamicCutOff_),
561 coeff_var_threshold_(source.coeff_var_threshold_),
562 first_perc_for_cutoff_decr_(source.first_perc_for_cutoff_decr_),
563 second_perc_for_cutoff_decr_(source.second_perc_for_cutoff_decr_),
565 pretendFailIsInfeasible_(source.pretendFailIsInfeasible_),
566 pretendSucceededNext_(source.pretendSucceededNext_),
567 hasContinuedAfterNlpFailure_(source.hasContinuedAfterNlpFailure_),
568 numIterationSuspect_(source.numIterationSuspect_),
569 hasBeenOptimized_(source.hasBeenOptimized_),
571 feasibilityProblem_(NULL),
575 nnz_jac(source.nnz_jac),
580 veryTiny_(source.veryTiny_),
581 rhsRelax_(source.rhsRelax_),
582 infty_(source.infty_),
583 warmStartMode_(source.warmStartMode_),
585 cutStrengthener_(source.cutStrengthener_),
588 newCutoffDecr(source.newCutoffDecr),
589 strong_branching_solver_(source.strong_branching_solver_)
592 problem_ = source.problem_->
clone();
595 if(feasibility_mode_)
596 problem_to_optimize_ =
GetRawPtr(feasibilityProblem_);
598 problem_to_optimize_ =
GetRawPtr(problem_);
599 pretendFailIsInfeasible_ = source.pretendFailIsInfeasible_;
600 pretendSucceededNext_ = source.pretendSucceededNext_;
602 setAuxiliaryInfo(source.getAuxiliaryInfo());
604 app_ = source.app_->
clone();
606 i != source.debug_apps_.end() ; i++){
607 debug_apps_.push_back((*i)->clone());
609 testOthers_ = source.testOthers_;
612 throw SimpleError(
"Don't know how to copy an empty IpoptInterface.",
616 warmstart_ = source.warmstart_ ? source.warmstart_->
clone() : NULL;
620 CoinCopyN(source.obj_, source.
getNumCols(), obj_);
624 oaHandler_ =
new OaMessageHandler(*source.oaHandler_);;
640 OsiSolverInterface::operator=(rhs);
641 OsiDualObjectiveLimit_ = rhs.OsiDualObjectiveLimit_;
642 nCallOptimizeTNLP_ = rhs.nCallOptimizeTNLP_;
643 totalNlpSolveTime_ = rhs.nCallOptimizeTNLP_;
644 totalIterations_ = rhs.totalIterations_;
645 maxRandomRadius_ = rhs.maxRandomRadius_;
646 hasVarNamesFile_ = rhs.hasVarNamesFile_;
647 pushValue_ = rhs.pushValue_;
654 tminlp_ = rhs.tminlp_;
656 problem_to_optimize_ =
GetRawPtr(problem_);
657 app_ = rhs.app_->
clone();
659 warmstart_ = rhs.warmstart_ ? rhs.warmstart_->
clone() : NULL;
663 nnz_jac = rhs.nnz_jac;
665 if(constTypes_ != NULL) {
666 delete [] constTypes_;
669 if(rhs.constTypes_ != NULL) {
670 constTypes_ =
new TNLP::LinearityType[
getNumRows()];
671 CoinCopyN(rhs.constTypes_,
getNumRows(), constTypes_);
683 if(rhs.jValues_!=NULL && rhs.jRow_ != NULL && rhs.jCol_ != NULL && nnz_jac>0) {
684 jValues_ =
new double [nnz_jac];
685 jCol_ =
new Index [nnz_jac];
686 jRow_ =
new Index [nnz_jac];
687 CoinCopyN(rhs.jValues_ , nnz_jac,jValues_ );
688 CoinCopyN(rhs.jCol_ , nnz_jac,jCol_ );
689 CoinCopyN(rhs.jRow_ , nnz_jac,jRow_ );
691 else if(nnz_jac > 0) {
692 throw CoinError(
"Arrays for storing jacobian are inconsistant.",
697 veryTiny_ = rhs.veryTiny_;
698 rhsRelax_ = rhs.rhsRelax_;
700 warmStartMode_ = rhs.warmStartMode_;
701 newCutoffDecr = rhs.newCutoffDecr;
708 feasibilityProblem_ = NULL;
721 hasVarNamesFile_ = rhs.hasVarNamesFile_;
723 nCallOptimizeTNLP_ = rhs.nCallOptimizeTNLP_;
724 totalNlpSolveTime_ = rhs.totalNlpSolveTime_;
725 totalIterations_ = rhs.totalIterations_;
726 maxRandomRadius_ = rhs.maxRandomRadius_;
727 pushValue_ = rhs.pushValue_;
728 numRetryInitial_ = rhs.numRetryInitial_;
729 numRetryResolve_ = rhs.numRetryResolve_;
730 numRetryInfeasibles_ = rhs.numRetryInfeasibles_;
731 numRetryUnsolved_ = rhs.numRetryUnsolved_;
732 infeasibility_epsilon_ = rhs.infeasibility_epsilon_;
733 pretendFailIsInfeasible_ = rhs.pretendFailIsInfeasible_;
734 pretendSucceededNext_ = rhs.pretendSucceededNext_;
735 numIterationSuspect_ = rhs.numIterationSuspect_;
737 hasBeenOptimized_ = rhs.hasBeenOptimized_;
738 cutStrengthener_ = rhs.cutStrengthener_;
741 oaHandler_ =
new OaMessageHandler(*rhs.oaHandler_);
742 strong_branching_solver_ = rhs.strong_branching_solver_;
744 dynamicCutOff_ = rhs.dynamicCutOff_;
745 coeff_var_threshold_ = rhs.coeff_var_threshold_;
746 first_perc_for_cutoff_decr_ = rhs.first_perc_for_cutoff_decr_;
747 second_perc_for_cutoff_decr_ = rhs.second_perc_for_cutoff_decr_;
761 return app_->options();
771 return app_->options();
781 delete [] constTypes_;
788 OsiTMINLPInterface::freeCachedColRim()
790 if(reducedCosts_!=NULL) {
791 delete [] reducedCosts_;
792 reducedCosts_ = NULL;
798 OsiTMINLPInterface::freeCachedRowRim()
800 if(rowsense_!=NULL) {
808 if(rowrange_!=NULL) {
819 OsiTMINLPInterface::freeCachedData()
825 const char * OsiTMINLPInterface::OPT_SYMB=
"OPT";
826 const char * OsiTMINLPInterface::FAILED_SYMB=
"FAILED";
827 const char * OsiTMINLPInterface::UNBOUND_SYMB=
"UNBOUNDED";
828 const char * OsiTMINLPInterface::INFEAS_SYMB=
"INFEAS";
829 const char * OsiTMINLPInterface::TIME_SYMB=
"TIME";
844 double * of_current = (numsolve > 0) ?
new double[numsolve]: NULL;
845 int num_failed, num_infeas;
846 double mean, std_dev, var_coeff;
847 double min = DBL_MAX;
848 double max = -DBL_MAX;
850 Coin::SmartPtr<SimpleReferencedPtr<CoinWarmStart> > ws_backup = NULL;
851 if(warmStartMode_ <=
Optimum && keepWarmStart){
880 for(
int f = 0;
f < numsolve ;
f++) {
883 <<
f+1<< CoinMessageEol ;
885 solveAndCheckErrors(0,0,
"resolve cost");
900 savedStatus = optimizationStatus_;
903 messageHandler()->message(
LOG_LINE, messages_)
904 <<c<<
f+1<<statusAsString()<<
getObjValue()<<app_->IterationCount()<<app_->CPUTime()<<
"resolve cost"<<CoinMessageEol;
929 if(of_current != NULL){
933 mean=mean+of_current[
f];
934 if (of_current[
f] < min)
936 else if (of_current[
f] > max)
947 if(of_current != NULL){
949 mean=mean/(numsolve-num_failed-num_infeas);
954 for(
int i=0; i<numsolve; i++)
957 std_dev=std_dev+pow(of_current[i]-mean,2);
959 std_dev=pow((std_dev/(numsolve-num_failed-num_infeas)),0.5);
962 var_coeff=std_dev/mean;
979 problem_->set_obj_value(bestBound);
980 optimizationStatus_ = savedStatus;
981 hasBeenOptimized_ =
true;
983 if(warmStartMode_ <
Optimum && keepWarmStart) {
984 app_->setWarmStart(ws_backup->ptr(), problem_);
998 CoinWarmStart * ws_backup = NULL;
1002 ws_backup = app_->getUsedWarmStart(problem_);
1006 app_->disableWarmStart();
1010 <<1<< CoinMessageEol ;
1011 solveAndCheckErrors(0,0,
"resolve robustness");
1018 messageHandler()->message(
LOG_LINE, messages_)
1019 <<c<<1<<statusAsString()<<
getObjValue()<<app_->IterationCount()<<
1020 app_->CPUTime()<<
"resolve robustness"<<CoinMessageEol;
1024 messageHandler()->message(
WARN_SUCCESS_WS, messages_) << CoinMessageEol ;
1026 app_->enableWarmStart();
1027 if (warmStartMode_ <
Optimum) {
1028 app_->setWarmStart(ws_backup, problem_);
1035 for(
int f = 0;
f < numsolve ;
f++) {
1038 <<
f+2<< CoinMessageEol ;
1041 solveAndCheckErrors(0,0,
"resolve robustness");
1045 <<
"resolveForRobustness"<<optimizationStatus_<<app_->IterationCount()<<app_->CPUTime()<<CoinMessageEol;
1052 messageHandler()->message(
LOG_LINE, messages_)
1054 <<app_->IterationCount()<<app_->CPUTime()<<
"resolve robustness"<<CoinMessageEol;
1059 <<
f+2 << CoinMessageEol ;
1061 app_->enableWarmStart();
1062 if (warmStartMode_ <
Optimum) {
1063 app_->setWarmStart(ws_backup, problem_);
1073 app_->setWarmStart(ws_backup, problem_);
1076 if(pretendFailIsInfeasible_) {
1077 pretendSucceededNext_ =
true;
1078 if(pretendFailIsInfeasible_ == 1) {
1082 hasContinuedAfterNlpFailure_ = 1;
1087 std::string probName;
1102 return problem_->num_variables();
1110 return problem_->num_constraints();
1116 return problem_->x_l();
1122 return problem_->x_u();
1129 const OsiSolverInterface::OsiNameVec&
1131 return getColNames();
1136 void OsiTMINLPInterface::extractSenseRhsAndRange()
const
1138 assert(rowsense_==NULL&&rhs_==NULL&&rowrange_==NULL);
1139 int numrows = problem_->num_constraints();
1140 if(numrows == 0)
return;
1143 rowsense_ =
new char [numrows];
1144 rhs_ =
new double [numrows];
1145 rowrange_ =
new double [numrows];
1146 for(
int i = 0 ; i < numrows ; i++) {
1148 convertBoundToSense(rowLower[i], rowUpper[i], rowsense_[i], rhs_[i], rowrange_[i]);
1164 if(rowsense_==NULL) {
1165 extractSenseRhsAndRange();
1182 extractSenseRhsAndRange();
1198 if(rowrange_==NULL) {
1199 extractSenseRhsAndRange();
1207 return problem_->g_l();
1213 return problem_->g_u();
1259 return COIN_DBL_MAX;
1266 if(hasBeenOptimized_)
1267 return problem_->x_sol();
1269 return problem_->x_init();
1276 if(hasBeenOptimized_)
1277 return problem_->duals_sol();
1279 return problem_->duals_init();
1286 (*handler_)<<
"WARNING : trying to access reduced cost in Ipopt always retrun 0"<<CoinMessageEol;
1287 if(reducedCosts_==NULL) {
1291 return reducedCosts_;
1299 return problem_->g_sol();
1308 return app_->IterationCount();
1318 problem_->SetVariableLowerBound(elementIndex,elementValue);
1319 hasBeenOptimized_ =
false;
1328 problem_->SetVariableUpperBound(elementIndex,elementValue);
1329 hasBeenOptimized_ =
false;
1337 problem_->SetVariablesLowerBounds(problem_->num_variables(),
1339 hasBeenOptimized_ =
false;
1347 problem_->SetVariablesUpperBounds(problem_->num_variables(),
1349 hasBeenOptimized_ =
false;
1357 throw SimpleError(
"Not implemented yet but should be if necessary.",
1359 hasBeenOptimized_ =
false;
1367 throw SimpleError(
"Not implemented yet but should be if necessary.",
1369 hasBeenOptimized_ =
false;
1377 throw SimpleError(
"Not implemented yet but should be if necessary.",
1379 hasBeenOptimized_ =
false;
1388 throw SimpleError(
"Can not change objective sense of an Ipopt problem.",
1390 hasBeenOptimized_ =
false;
1408 problem_->resetStartingPoint();
1409 hasBeenOptimized_ =
false;
1426 hasBeenOptimized_ =
false;
1437 {
return app_->getEmptyWarmStart();}
1443 if (warmStartMode_ >=
Optimum) {
1444 return internal_getWarmStart();;
1447 return build_fake_basis();
1458 if (warmStartMode_ >=
Optimum) {
1459 return internal_setWarmStart(ws);
1467 #define EPSILON 1e-4
1470 OsiTMINLPInterface::build_fake_basis()
const{
1471 CoinWarmStartBasis * r_val =
new CoinWarmStartBasis();
1472 int n_con = problem_->num_constraints();
1473 r_val->setSize(problem_->num_variables(), n_con);
1474 const double * act = problem_->g_sol();
1475 const double * lb = problem_->g_l();
1476 const double * ub = problem_->g_u();
1477 for(
int i = 0 ; i < n_con ; i++){
1479 r_val->setArtifStatus(i, CoinWarmStartBasis::isFree);
1482 r_val->setArtifStatus(i, CoinWarmStartBasis::atLowerBound);
1484 else if(act[i] < lb[i] +
EPSILON){
1485 r_val->setArtifStatus(i, CoinWarmStartBasis::atLowerBound);
1488 r_val->setArtifStatus(i, CoinWarmStartBasis::basic);
1496 OsiTMINLPInterface::internal_getWarmStart()
const
1498 if (warmStartMode_ >=
Optimum && warmstart_) {
1499 return warmstart_->clone();
1508 OsiTMINLPInterface::internal_setWarmStart(
const CoinWarmStart*
ws)
1512 hasBeenOptimized_ =
false;
1513 if (warmStartMode_ >=
Optimum) {
1517 if(app_->warmStartIsValid(ws)) {
1518 warmstart_ = ws->clone();
1523 const CoinWarmStartPrimalDual* pdws =
1524 dynamic_cast<const CoinWarmStartPrimalDual*
>(
ws);
1528 warmstart_ =
new IpoptWarmStart(*pdws);
1543 hasBeenOptimized_ =
false;
1550 hasBeenOptimized_ =
false;
1557 return problem_->obj_value();
1569 bool retval =
false;
1571 case OsiMaxNumIteration:
1574 case OsiMaxNumIterationHotStart:
1581 case OsiLastIntParam:
1586 (*handler_)<<
"Unhandled case in setIntParam\n"<<CoinMessageEol;
1599 bool retval =
false;
1601 case OsiDualObjectiveLimit:
1602 OsiDualObjectiveLimit_ = value;
1605 case OsiPrimalObjectiveLimit:
1606 (*handler_)<<
"Can not set primal objective limit parameter"<<CoinMessageEol;
1609 case OsiDualTolerance:
1610 (*handler_)<<
"Can not set dual tolerance parameter"<<CoinMessageEol;
1613 case OsiPrimalTolerance:
1614 (*handler_)<<
"Can not set primal tolerance parameter"<<CoinMessageEol;
1617 retval = OsiSolverInterface::setDblParam(key,value);
1619 case OsiLastDblParam:
1624 (*handler_) <<
"Unhandled case in setDblParam"<<CoinMessageEol;
1641 OsiSolverInterface::setStrParam(key,value);
1642 return retval =
true;
1645 case OsiLastStrParam:
1658 value = -COIN_INT_MAX;
1659 bool retval =
false;
1661 case OsiMaxNumIteration:
1664 case OsiMaxNumIterationHotStart:
1667 case OsiLastIntParam:
1672 (*handler_) <<
"Unhandled case in setIntParam"<<CoinMessageEol;
1684 bool retval =
false;
1686 case OsiDualObjectiveLimit:
1687 value = OsiDualObjectiveLimit_;
1690 case OsiPrimalObjectiveLimit:
1694 case OsiDualTolerance:
1697 case OsiPrimalTolerance:
1698 options()->GetNumericValue(
"tol", value,
"");
1703 retval = OsiSolverInterface::getDblParam(key, value);
1705 case OsiLastDblParam:
1722 OsiSolverInterface::getStrParam(key, value);
1727 case OsiLastStrParam:
1737 linearizer_ = linearizer->clone();
1738 linearizer_->set_tols(tiny_, veryTiny_, rhsRelax_, infty_);
1739 linearizer_->set_model(
GetRawPtr(problem_));
1743 OsiTMINLPInterface::linearizer(){
1754 double * sol =
new double[numcols];
1755 const Number * x_init = problem_->x_init_user();
1756 const double* perturb_radius = NULL;
1757 if (randomGenerationType_ == perturb_suffix) {
1762 if (!perturb_radius) {
1763 throw SimpleError(
"Can't use perturb_radius if no radii are given.",
1764 "randomStartingPoint");
1767 for(
int i = 0 ; i < numcols ; i++) {
1768 if(randomGenerationType_ == uniform || x_init[i] < colLower[i] || x_init[i] > colUpper[i]) {
1769 double lower = std::min(-maxRandomRadius_,colUpper[i] - maxRandomRadius_);
1770 lower = std::max(colLower[i], lower);
1771 double upper = std::max(maxRandomRadius_,colLower[i] + maxRandomRadius_);
1772 upper = std::min(colUpper[i],upper);
1773 lower = std::min(upper,lower);
1774 upper = std::max(upper, lower);
1775 double interval = upper - lower;
1776 sol[i] = CoinDrand48()*(interval) + lower;
1778 else if (randomGenerationType_ == perturb) {
1779 const double lower = std::max(x_init[i] - max_perturbation_, colLower[i]);
1780 const double upper = std::min(x_init[i] + max_perturbation_, colUpper[i]);
1781 const double interval = upper - lower;
1782 sol[i] = lower + CoinDrand48()*(interval);
1784 else if (randomGenerationType_ == perturb_suffix) {
1785 const double radius = perturb_radius[i];
1786 const double lower = std::max(x_init[i] - radius*max_perturbation_, colLower[i]);
1787 const double upper = std::min(x_init[i] + radius*max_perturbation_, colUpper[i]);
1788 const double interval = upper - lower;
1789 sol[i] = lower + CoinDrand48()*(interval);
1792 app_->disableWarmStart();
1800 int OsiTMINLPInterface::initializeJacobianArrays()
1802 Index
n,
m, nnz_h_lag;
1803 TNLP::IndexStyleEnum index_style;
1804 problem_to_optimize_->get_nlp_info( n, m, nnz_jac, nnz_h_lag, index_style);
1806 if(jRow_ != NULL)
delete [] jRow_;
1807 if(jCol_ != NULL)
delete [] jCol_;
1808 if(jValues_ != NULL)
delete [] jValues_;
1810 jRow_ =
new Index[nnz_jac];
1811 jCol_ =
new Index[nnz_jac];
1812 jValues_ =
new Number[nnz_jac];
1813 problem_to_optimize_->eval_jac_g(n, NULL, 0, m, nnz_jac, jRow_, jCol_, NULL);
1814 if(index_style == Ipopt::TNLP::FORTRAN_STYLE)
1816 for(
int i = 0 ; i < nnz_jac ; i++){
1822 if(constTypes_ != NULL)
delete [] constTypes_;
1825 constTypes_ =
new TNLP::LinearityType[
getNumRows()];
1826 problem_to_optimize_->get_constraints_linearity(
getNumRows(), constTypes_);
1829 if(constTypes_[i]==TNLP::NON_LINEAR) {
1839 OsiTMINLPInterface::getConstraintsViolation(
const double *
x,
double &obj)
1843 double *
g =
new double[numrows];
1844 tminlp_->eval_g(numcols, x, 1, numrows, g);
1850 for(
int i = 0; i< numrows ; i++) {
1851 if(!constTypes_ || constTypes_[i] == TNLP::NON_LINEAR) {
1852 double rowViolation = 0;
1853 if(rowLower[i] > -1e10)
1854 rowViolation = std::max(0.,rowLower[i] - g[i]);
1856 if(rowUpper[i] < 1e10);
1857 rowViolation = std::max(rowViolation, g[i] - rowUpper[i]);
1859 norm = rowViolation > norm ? rowViolation : norm;
1862 tminlp_->eval_f(numcols, x, 1, obj);
1869 OsiTMINLPInterface::getNonLinearitiesViolation(
const double *x,
const double obj)
1872 double norm = getConstraintsViolation(x, f);
1873 assert((f - obj) > -1
e-08);
1874 norm = (f - obj) > norm ? f - obj : norm;
1882 bool cleanNnz(
double &value,
double colLower,
double colUpper,
1883 double rowLower,
double rowUpper,
double colsol,
1884 double & lb,
double &ub,
double tiny,
double veryTiny,
1888 if(fabs(value)>= tiny)
return 1;
1890 if(fabs(value)<veryTiny)
return 0;
1893 bool colUpBounded = colUpper <
infty;
1894 bool colLoBounded = colLower > -
infty;
1895 bool rowNotLoBounded = rowLower <= -
infty;
1896 bool rowNotUpBounded = rowUpper >=
infty;
1897 bool pos = value > 0;
1898 if(colUpBounded && pos && rowNotUpBounded) {
1899 lb += value * (colsol - colUpper);
1903 if(colUpBounded && !pos && rowNotLoBounded) {
1904 ub += value * (colsol - colUpper);
1908 if(colLoBounded && !pos && rowNotUpBounded) {
1909 lb += value * (colsol - colLower);
1913 if(colLoBounded && pos && rowNotLoBounded) {
1914 ub += value * (colsol - colLower);
1925 int getObj,
const double *
x2,
1926 double theta,
bool global)
1928 if(
IsValid(linearizer_) && x2 == NULL){
1929 linearizer_->get_oas(cs, x, getObj, global);
1932 int n,
m, nnz_jac_g, nnz_h_lag;
1933 TNLP::IndexStyleEnum index_style;
1934 problem_to_optimize_->get_nlp_info( n, m, nnz_jac_g, nnz_h_lag, index_style);
1935 if(jRow_ == NULL || jCol_ == NULL || jValues_ == NULL)
1936 initializeJacobianArrays();
1937 assert(jRow_ != NULL);
1938 assert(jCol_ != NULL);
1940 problem_to_optimize_->eval_jac_g(n, x, 1, m, nnz_jac_g, NULL, NULL, jValues_);
1941 problem_to_optimize_->eval_g(n,x,1,m,
g());
1957 for(
int rowIdx = 0; rowIdx <
m ; rowIdx++) {
1958 if(constTypes_[rowIdx] == TNLP::NON_LINEAR) {
1959 row2cutIdx[rowIdx] = numCuts;
1960 if(rowLower[rowIdx] > - infty_)
1961 lb[numCuts] = rowLower[rowIdx] - g[rowIdx];
1963 lb[numCuts] = -
infty;
1964 if(rowUpper[rowIdx] < infty_)
1965 ub[numCuts] = rowUpper[rowIdx] - g[rowIdx];
1967 ub[numCuts] =
infty;
1968 if(rowLower[rowIdx] > -infty && rowUpper[rowIdx] < infty)
1970 if(duals[rowIdx] >= 0)
1971 lb[numCuts] = -
infty;
1972 if(duals[rowIdx] <= 0)
1973 ub[numCuts] =
infty;
1981 for(
int i = 0 ; i < nnz_jac_g ; i++) {
1982 const int &rowIdx = jRow_[i];
1983 const int & cutIdx = row2cutIdx[ rowIdx ];
1985 const int &colIdx = jCol_[i];
1987 if(
cleanNnz(jValues_[i],colLower[colIdx], colUpper[colIdx],
1988 rowLower[rowIdx], rowUpper[rowIdx],
1991 ub[cutIdx], tiny_, veryTiny_, infty_)) {
1992 cuts[cutIdx].insert(colIdx,jValues_[i]);
1993 if(lb[cutIdx] > - infty)
1994 lb[cutIdx] += jValues_[i] * x[colIdx];
1995 if(ub[cutIdx] < infty)
1996 ub[cutIdx] += jValues_[i] * x[colIdx];
2002 if (
IsValid(cutStrengthener_) || oaHandler_->logLevel() > 0) {
2003 cut2rowIdx.resize(numCuts);
2004 for(
int rowIdx = 0 ; rowIdx <
m ; rowIdx++){
2005 if(row2cutIdx[rowIdx] >= 0){
2006 cut2rowIdx[row2cutIdx[rowIdx]] = rowIdx;
2011 for(
int cutIdx = 0; cutIdx < numCuts; cutIdx++) {
2014 double rhs = cuts[cutIdx].dotProduct(x2);
2015 double violation = 0.;
2016 violation = std::max(violation, rhs - ub[cutIdx]);
2017 violation = std::max(violation, lb[cutIdx] - rhs);
2018 if(violation < theta && oaHandler_->logLevel() > 0) {
2019 oaHandler_->message(CUT_NOT_VIOLATED_ENOUGH, oaMessages_)<<cut2rowIdx[cutIdx]<<violation<<CoinMessageEol;
2021 if(oaHandler_->logLevel() > 0)
2022 oaHandler_->message(VIOLATED_OA_CUT_GENERATED, oaMessages_)<<cut2rowIdx[cutIdx]<<violation<<CoinMessageEol;
2027 if (
IsValid(cutStrengthener_)) {
2028 const int& rowIdx = cut2rowIdx[cutIdx];
2030 cutStrengthener_->ComputeCuts(cs,
GetRawPtr(tminlp_),
2032 cuts[cutIdx], lb[cutIdx], ub[cutIdx], g[rowIdx],
2033 rowLower[rowIdx], rowUpper[rowIdx],
2036 (*messageHandler()) <<
"error in cutStrengthener_->ComputeCuts\n";
2041 newCut.setGloballyValidAsInteger(1);
2043 if(lb[cutIdx] > infty) lb[cutIdx] -= rhsRelax_*std::max(fabs(lb[cutIdx]), 1.);
2044 if(ub[cutIdx] < infty) ub[cutIdx] += rhsRelax_*std::max(fabs(ub[cutIdx]), 1.);
2045 newCut.setLb(lb[cutIdx]);
2046 newCut.setUb(ub[cutIdx]);
2047 newCut.setRow(cuts[cutIdx]);
2048 if(oaHandler_->logLevel()>2){
2049 oaHandler_->print(newCut);}
2053 if(getObj == 2 || (getObj && !problem_->hasLinearObjective())) {
2055 problem_to_optimize_->eval_grad_f(n, x, 1,obj());
2057 problem_to_optimize_->eval_f(n, x, 1, f);
2061 lb[nNonLinear_] = -
f;
2062 ub[nNonLinear_] = -
f;
2064 for(
int i = 0; i<
n ; i++) {
2065 if(
cleanNnz(obj[i],colLower[i], colUpper[i],
2069 ub[nNonLinear_],tiny_, 1
e-15, infty_)) {
2071 lb[nNonLinear_] += obj[i] * x[i];
2072 ub[nNonLinear_] += obj[i] * x[i];
2079 double rhs = v.dotProduct(x2);
2080 double violation = std::max(0., rhs - ub[nNonLinear_]);
2081 if(violation < theta) genCut =
false;
2084 if (
IsValid(cutStrengthener_)) {
2085 lb[nNonLinear_] = -
infty;
2087 cutStrengthener_->ComputeCuts(cs,
GetRawPtr(tminlp_),
2089 v, lb[nNonLinear_], ub[nNonLinear_],
2090 ub[nNonLinear_], -infty, 0.,
2093 (*handler_)<<
"error in cutStrengthener_->ComputeCuts"<<CoinMessageEol;
2099 newCut.setGloballyValidAsInteger(1);
2102 newCut.setLb(-COIN_DBL_MAX);
2103 newCut.setUb(ub[nNonLinear_]);
2113 int n,
m, nnz_jac_g, nnz_h_lag;
2114 TNLP::IndexStyleEnum index_style;
2115 problem_to_optimize_->get_nlp_info( n, m, nnz_jac_g, nnz_h_lag, index_style);
2116 if(jRow_ == NULL || jCol_ == NULL || jValues_ == NULL)
2117 initializeJacobianArrays();
2118 assert(jRow_ != NULL);
2119 assert(jCol_ != NULL);
2122 problem_to_optimize_->eval_jac_g(n, x, 1, m, nnz_jac_g, NULL, NULL, jValues_);
2123 problem_to_optimize_->eval_g(n,x,1,m,
g());
2137 for(
int rowIdx = 0; rowIdx <
m ; rowIdx++) {
2138 if(constTypes_[rowIdx] == TNLP::NON_LINEAR && fabs(duals[rowIdx]) > 1
e-06)
2140 const double &
lam = duals[rowIdx];
2141 keep[rowIdx] =
true;
2142 assert(lam < 0 || rowUpper[rowIdx] < 1e10);
2143 assert(lam > 0 || rowLower[rowIdx] > -1e10);
2145 assert(rowLower[rowIdx] > -1e10);
2146 ub += lam*(rowLower[rowIdx] -g[rowIdx]);
2149 assert(rowUpper[rowIdx] < 1e10);
2150 ub += lam*(rowUpper[rowIdx] -g[rowIdx]);
2156 for(
int i = 0 ; i < nnz_jac_g ; i++) {
2157 const int &rowIdx = jRow_[i];
2158 if (!keep[rowIdx])
continue;
2159 const int &colIdx = jCol_[i];
2161 const double &
lam = duals[rowIdx];
2162 double coeff = lam*jValues_[i];
2163 if(
cleanNnz(coeff,colLower[colIdx], colUpper[colIdx],
2164 rowLower[rowIdx], rowUpper[rowIdx], x[colIdx], lb,
2165 ub, tiny_, veryTiny_, infty_)) {
2166 cut[colIdx] += coeff;
2167 ub += coeff * x[colIdx];
2172 if(!problem_->hasLinearObjective() &&
2175 problem_to_optimize_->eval_grad_f(n, x, 1,obj());
2177 problem_to_optimize_->eval_f(n, x, 1, f);
2181 for(
int i = 0; i<
n ; i++) {
2183 x[i], lb, ub,tiny_, 1
e-15, infty_)) {
2185 ub += obj[i] * x[i];
2190 for(
int i = 0 ; i <
n ; i++){
2191 if(fabs(cut[i])>1
e-020){
2192 v.insert(i, cut[i]);
2197 newCut.setGloballyValidAsInteger(1);
2198 newCut.setLb(-COIN_DBL_MAX);
2209 const double *
x2,
bool global)
2215 problem_->eval_grad_gi(
getNumCols(), x, 1, rowIdx, nnz, indices, values);
2216 problem_->eval_gi(
getNumCols(),x,1, rowIdx, g);
2218 CoinPackedVector cut;
2230 if(rowLower > - infty_)
2234 if(rowUpper < infty_)
2238 if(rowLower > -infty && rowUpper < infty)
2246 for(
int i = 0 ; i <
nnz; i++) {
2247 const int &colIdx = indices[i];
2249 if(
cleanNnz(values[i],colLower[colIdx], colUpper[colIdx],
2253 ub, tiny_, veryTiny_, infty_)) {
2254 cut.insert(colIdx,values[i]);
2256 lb += values[i] * x[colIdx];
2258 ub += values[i] * x[colIdx];
2265 newCut.setGloballyValidAsInteger(1);
2278 OsiTMINLPInterface::switchToFeasibilityProblem(
size_t n,
const double * x_bar,
const int *inds,
2279 double a,
double s,
int L){
2280 if(!
IsValid(feasibilityProblem_)) {
2281 throw SimpleError(
"No feasibility problem",
"getFeasibilityOuterApproximation");
2283 feasibilityProblem_->set_use_feasibility_pump_objective(
true);
2284 feasibilityProblem_->set_dist_to_point_obj(n,(
const Number *) x_bar,(
const Index *) inds);
2285 feasibilityProblem_->setLambda(a);
2286 feasibilityProblem_->setSigma(s);
2287 feasibilityProblem_->setNorm(L);
2288 feasibilityProblem_->set_use_cutoff_constraint(
false);
2289 feasibilityProblem_->set_use_local_branching_constraint(
false);
2290 problem_to_optimize_ =
GetRawPtr(feasibilityProblem_);
2291 feasibility_mode_ =
true;
2295 OsiTMINLPInterface::switchToFeasibilityProblem(
size_t n,
const double * x_bar,
const int *inds,
2296 double rhs_local_branching_constraint){
2297 if(!
IsValid(feasibilityProblem_)) {
2298 throw SimpleError(
"No feasibility problem",
"getFeasibilityOuterApproximation");
2300 feasibilityProblem_->set_use_feasibility_pump_objective(
false);
2301 feasibilityProblem_->set_dist_to_point_obj(n,(
const Number *) x_bar,(
const Index *) inds);
2302 feasibilityProblem_->set_use_cutoff_constraint(
false);
2303 feasibilityProblem_->set_use_local_branching_constraint(
true);
2304 feasibilityProblem_->set_rhs_local_branching_constraint(rhs_local_branching_constraint);
2305 problem_to_optimize_ =
GetRawPtr(feasibilityProblem_);
2306 feasibility_mode_ =
true;
2310 OsiTMINLPInterface::switchToOriginalProblem(){
2311 problem_to_optimize_ =
GetRawPtr(problem_);
2312 feasibility_mode_ =
false;
2317 double a,
double s,
int L)
2319 if(!
IsValid(feasibilityProblem_)) {
2320 throw SimpleError(
"No feasibility problem",
"getFeasibilityOuterApproximation");
2322 feasibilityProblem_->set_use_feasibility_pump_objective(
true);
2323 feasibilityProblem_->set_dist_to_point_obj(n,(
const Number *) x_bar,(
const Index *) inds);
2324 feasibilityProblem_->setLambda(a);
2325 feasibilityProblem_->setSigma(s);
2326 feasibilityProblem_->setNorm(L);
2327 feasibilityProblem_->set_use_cutoff_constraint(
false);
2328 feasibilityProblem_->set_use_local_branching_constraint(
false);
2329 nCallOptimizeTNLP_++;
2330 totalNlpSolveTime_-=CoinCpuTime();
2332 app2->options()->SetIntegerValue(
"print_level", (Index) 0);
2333 optimizationStatus_ = app2->OptimizeTNLP(
GetRawPtr(feasibilityProblem_));
2334 totalNlpSolveTime_+=CoinCpuTime();
2335 hasBeenOptimized_=
true;
2341 int L,
double cutoff)
2343 if(!
IsValid(feasibilityProblem_)) {
2344 throw SimpleError(
"No feasibility problem",
"getFeasibilityOuterApproximation");
2346 feasibilityProblem_->set_use_feasibility_pump_objective(
true);
2347 feasibilityProblem_->set_dist_to_point_obj(n,(
const Number *) x_bar,(
const Index *) inds);
2348 feasibilityProblem_->setLambda(1.0);
2349 feasibilityProblem_->setSigma(0.0);
2350 feasibilityProblem_->setNorm(L);
2351 feasibilityProblem_->set_use_cutoff_constraint(
true);
2352 feasibilityProblem_->set_cutoff(cutoff);
2353 feasibilityProblem_->set_use_local_branching_constraint(
false);
2354 nCallOptimizeTNLP_++;
2355 totalNlpSolveTime_-=CoinCpuTime();
2357 app2->options()->SetIntegerValue(
"print_level", (Index) 0);
2358 optimizationStatus_ = app2->OptimizeTNLP(
GetRawPtr(feasibilityProblem_));
2359 totalNlpSolveTime_+=CoinCpuTime();
2360 hasBeenOptimized_=
true;
2366 OsiTMINLPInterface::getFeasibilityOuterApproximation(
int n,
const double * x_bar,
const int *inds, OsiCuts &cs,
bool addOnlyViolated,
bool global)
2379 const double * x,
bool getObj
2383 linearizer_->extract(&si, x, getObj);
2390 TNLP::IndexStyleEnum index_style;
2392 problem_to_optimize_->get_nlp_info( n, m, nnz_jac_g, nnz_h_lag, index_style);
2396 initializeJacobianArrays();
2399 problem_to_optimize_->eval_jac_g(n, x, 1, m, nnz_jac_g, NULL, NULL, jValues_);
2403 problem_to_optimize_->eval_g(n, x, 1, m,
g());
2408 int numNonBindings = 0;
2417 double infty = si.getInfinity();
2418 for(
int i = 0 ; i <
m ; i++) {
2419 if(constTypes_[i] == TNLP::NON_LINEAR) {
2421 if(rowLower[i] > -infty_ && rowUpper[i] < infty_ && fabs(duals[i]) == 0.)
2423 nonBindings[numNonBindings++] = i;
2427 if(rowLower[i] > - infty_){
2428 rowLow[i] = (rowLower[i] - g[i]) - 1
e-07;
2435 rowLow[i] = -
infty;
2436 if(rowUpper[i] < infty_)
2437 rowUp[i] = (rowUpper[i] - g[i]) + 1
e-07;
2442 if(rowLower[i] > -infty_ && rowUpper[i] < infty_)
2445 rowLow[i] = -
infty;
2451 if(rowLower[i] > -infty_){
2452 rowLow[i] = (rowLower[i]);
2455 rowLow[i] = -
infty;
2456 if(rowUpper[i] < infty_){
2457 rowUp[i] = (rowUpper[i]);
2468 for(
int i = 0 ; i < nnz_jac_g ; i++) {
2471 cleanNnz(jValues_[i],colLower[jCol_[i]], colUpper[jCol_[i]],
2472 rowLower[jRow_[i]], rowUpper[jRow_[i]],
2475 rowUp[jRow_[i]], tiny_, veryTiny_, infty_)) {
2476 if(rowLow[jRow_[i]] > - infty)
2477 rowLow[jRow_[i]] += jValues_[i] * x[jCol_ [i]];
2478 if(rowUp[jRow_[i]] < infty)
2479 rowUp[jRow_[i]] += jValues_[i] *x[jCol_[i]];
2490 CoinPackedMatrix mat(
true, jRow_, jCol_, jValues_, nnz_jac_g);
2491 mat.setDimensions(m,n);
2494 mat.deleteRows(numNonBindings, nonBindings());
2498 for(
int i = 0 ; i < numcols ; i++){
2500 if(colLower[i] <= - infty_) colLower[i] = -
infty;
2501 if(colUpper[i] >= infty_) colUpper[i] =
infty;
2506 for(
size_t i = 0 ; i < rowLow.size() ; i++){
2507 if(rowLow[i] > infty) rowLow[i] -= rhsRelax_*std::max(fabs(rowLow[i]), 1.);
2508 if(rowUp[i] < infty) rowUp[i] += rhsRelax_*std::max(fabs(rowUp[i]), 1.);
2511 si.loadProblem(mat, colLower(), colUpper(), obj(), rowLow(), rowUp());
2512 for(
int i = 0 ; i < numcols ; i++) {
2517 bool addObjVar =
false;
2518 if(problem_->hasLinearObjective()){
2521 problem_to_optimize_->eval_f(n,
x0(), 1, zero);
2522 si.setDblParam(OsiObjOffset, -zero);
2524 problem_to_optimize_->eval_grad_f(n, x, 1,obj());
2525 si.setObjective(obj());
2545 assert(numcols == si.getNumCols() );
2547 problem_to_optimize_->eval_grad_f(numcols, x, 1,obj());
2551 si.addCol(a,-si.getInfinity(), si.getInfinity(), 1.);
2556 problem_to_optimize_->eval_f(numcols, x, 1, ub);
2559 CoinPackedVector objCut;
2560 CoinPackedVector * v = &objCut;
2561 v->reserve(numcols+1);
2562 for(
int i = 0; i<numcols ; i++) {
2565 if(
cleanNnz(obj[i],colLower[i], colUpper[i],
2569 ub, tiny_, veryTiny_, infty_)) {
2570 v->insert(i,obj[i]);
2571 lb += obj[i] * x[i];
2572 ub += obj[i] * x[i];
2577 if(
cleanNnz(obj[i],colLower[i], colUpper[i],
2581 ub, 1
e-03, 1
e-08, infty_)) {
2582 v->insert(i,obj[i]);
2583 lb += obj[i] * x[i];
2584 ub += obj[i] * x[i];
2588 v->insert(numcols,-1);
2589 si.addRow(objCut, lb, ub);
2594 OsiTMINLPInterface::applyRowCuts(
int numberCuts,
const OsiRowCut * cuts)
2598 const OsiRowCut ** cutsPtrs =
new const OsiRowCut*[numberCuts];
2599 for(
int i = 0 ; i < numberCuts ; i++)
2601 cutsPtrs[i] = &cuts[i];
2603 problem_->addCuts(numberCuts, cutsPtrs);
2608 OsiTMINLPInterface::solveAndCheckErrors(
bool warmStarted,
bool throwOnFailure,
2609 const char * whereFrom)
2612 totalNlpSolveTime_-=CoinCpuTime();
2614 optimizationStatus_ = app_->ReOptimizeTNLP(
GetRawPtr(problem_to_optimize_));
2616 optimizationStatus_ = app_->OptimizeTNLP(
GetRawPtr(problem_to_optimize_));
2617 totalNlpSolveTime_+=CoinCpuTime();
2618 nCallOptimizeTNLP_++;
2619 hasBeenOptimized_ =
true;
2621 if(getRowCutDebugger()){
2624 std::string probName;
2626 fprintf(stderr,
"Problem on optimal path is infeasible!\n");
2632 if(!hasPrintedOptions) {
2633 hasPrintedOptions = 1;
2635 app_->options()->SetStringValue(
"print_user_options",
"no",
false,
true);
2638 bool otherDisagree = false ;
2639 if(!app_->isRecoverable(optimizationStatus_))
2641 std::string probName;
2645 else if(testOthers_ && !app_->isError(optimizationStatus_)){
2650 i != debug_apps_.end() ; i++){
2652 messageHandler()->message(
LOG_LINE, messages_)
2653 <<
'd'<<f++<<statusAsString(otherStatus)<<problem_copy->obj_value()
2654 <<(*i)->IterationCount()<<(*i)->CPUTime()<<
"retry with "+(*i)->solverName()<<CoinMessageEol;
2655 if(!(*i)->isError(otherStatus)){
2656 CoinRelFltEq eq(1
e-05);
2657 if(otherStatus != optimizationStatus_){
2658 otherDisagree =
true;
2660 <<app_->solverName()<<statusAsString()
2661 <<(*i)->solverName()<<statusAsString(otherStatus)<<CoinMessageEol;
2663 else if(
isProvenOptimal() && !eq(problem_->obj_value(),problem_copy->obj_value()))
2665 otherDisagree =
true;
2667 <<app_->solverName()<<problem_->obj_value()
2668 <<(*i)->solverName()<<problem_copy->obj_value()<<CoinMessageEol;
2673 else if(app_->isError(optimizationStatus_) && ! debug_apps_.empty()){
2676 i != debug_apps_.end() && app_->isError(optimizationStatus_) ; i++){
2677 optimizationStatus_ = (*i)->OptimizeTNLP(
GetRawPtr(problem_));
2678 messageHandler()->message(
LOG_LINE, messages_)
2679 <<
'd'<<f++<<statusAsString(optimizationStatus_)<<problem_->obj_value()
2680 <<(*i)->IterationCount()<<(*i)->CPUTime()<<
"retry with "+(*i)->solverName()<<CoinMessageEol;
2684 totalIterations_ += app_->IterationCount();
2686 catch(SimpleError &E)
2690 throw SimpleError(
"No statistics available from Ipopt",whereFrom);
2696 if(problem_->hasUpperBoundingObjective()){
2698 bool integerSol =
true;
2699 double intTol = 1
e-08;
2701 int nObjects = numberObjects();
2702 OsiObject **
object = objects();
2703 for(
int i = 0 ; i< nObjects ; i++){
2705 if(
object[i]->infeasibility(
this,dummy) > intTol)
2714 for(
int i = 0 ; i < numcols ; i++){
2716 if(fabs(sol[i] - floor(sol[i]+0.5)) > intTol){
2724 double help= problem_->evaluateUpperBoundingFunction(sol);
2727 OsiAuxInfo * auxInfo = getAuxiliaryInfo();
2732 if(help<bonInfo->bestObj2())
2738 <<help<<CoinMessageEol;
2742 printf(
"\nWARNING: the algorithm selected does not consider the second objective function\n");
2748 <<whereFrom<<optimizationStatus_<<app_->IterationCount()<<app_->CPUTime()<<CoinMessageEol;
2750 if((nCallOptimizeTNLP_ % 20) == 1)
2751 messageHandler()->message(
LOG_HEAD, messages_)<<CoinMessageEol;
2757 messages_)<<nCallOptimizeTNLP_<<CoinMessageEol;
2758 std::string subProbName;
2760 std::ostringstream os;
2761 os<<
"_"<<nCallOptimizeTNLP_;
2762 subProbName+=os.str();
2763 problem_->outputDiffs(subProbName, NULL);
2789 if(!hasPrintedOptions) {
2791 app_->options()->GetEnumValue(
"print_user_options",printOptions,app_->prefix());
2793 app_->options()->SetStringValue(
"print_user_options",
"yes",
true,
true);
2796 app_->disableWarmStart();
2797 solveAndCheckErrors(0,1,
"initialSolve");
2800 if(!hasPrintedOptions) {
2801 hasPrintedOptions = 1;
2802 app_->options()->SetStringValue(
"print_user_options",
"no");
2803 app_->options()->SetIntegerValue(
"print_level",0);
2806 messageHandler()->message(
LOG_LINE, messages_)<<
' '<<nCallOptimizeTNLP_
2809 <<app_->IterationCount()
2811 <<whereFrom<<CoinMessageEol;
2816 int numRetry = firstSolve_ ? numRetryInitial_ : numRetryResolve_;
2825 numRetryInitial_ = 0;
2827 firstSolve_ =
false;
2832 if (warmStartMode_ >=
Optimum) {
2833 warmstart_ = app_->getWarmStart(problem_);
2851 int has_warmstart = warmstart_ == NULL ? 0 : 1;
2852 if(warmstart_ == NULL) has_warmstart = 0;
2853 else if(!app_->warmStartIsValid(warmstart_)) has_warmstart = 1;
2854 else has_warmstart = 2;
2855 if (has_warmstart < 2) {
2860 app_->setWarmStart(warmstart_, problem_);
2865 app_->options()->SetStringValue(
"warm_start_same_structure",
"yes");
2868 app_->options()->SetStringValue(
"warm_start_same_structure",
"no");
2871 if(problem_->duals_init() != NULL)
2872 app_->enableWarmStart();
2873 else app_->disableWarmStart();
2874 solveAndCheckErrors(1,1,
"resolve");
2876 messageHandler()->message(
LOG_LINE, messages_)<<
' '<<nCallOptimizeTNLP_
2879 <<app_->IterationCount()
2889 else if(numRetryResolve_ ||
2891 resolveForCost(std::max(numRetryResolve_, numRetryInfeasibles_), 0);
2896 if (warmStartMode_ >=
Optimum) {
2897 warmstart_ = app_->getWarmStart(problem_);
2909 if (pretendSucceededNext_)
2911 pretendSucceededNext_ =
false;
2941 (*handler_)<<
"Warning : isPrimalObjectiveLimitReached not implemented yet"<<CoinMessageEol;
2958 OsiTMINLPInterface::extractInterfaceParams()
2962 app_->options()->GetIntegerValue(
"nlp_log_level", logLevel,app_->prefix());
2963 messageHandler()->setLogLevel(logLevel);
2965 #ifdef COIN_HAS_FILTERSQP
2970 app_->
options()->GetNumericValue(
"max_random_point_radius",maxRandomRadius_,app_->prefix());
2972 #ifdef COIN_HAS_FILTERSQP
2973 if(filter && !is_given){
2975 maxRandomRadius_ = 10.;
2979 int oaCgLogLevel = 0;
2980 app_->options()->GetIntegerValue(
"oa_cuts_log_level", oaCgLogLevel,app_->prefix());
2981 oaHandler_->setLogLevel(oaCgLogLevel);
2984 app_->options()->GetEnumValue(
"warm_start", buffy, app_->prefix());
2987 app_->options()->GetIntegerValue(
"num_retry_unsolved_random_point", numRetryUnsolved_,app_->prefix());
2988 app_->options()->GetIntegerValue(
"num_resolve_at_root", numRetryInitial_,app_->prefix());
2989 app_->options()->GetIntegerValue(
"num_resolve_at_node", numRetryResolve_,app_->prefix());
2990 app_->options()->GetIntegerValue(
"num_resolve_at_infeasibles", numRetryInfeasibles_,app_->prefix());
2991 app_->options()->GetIntegerValue(
"num_iterations_suspect", numIterationSuspect_,app_->prefix());
2992 app_->options()->GetEnumValue(
"nlp_failure_behavior",pretendFailIsInfeasible_,app_->prefix());
2993 app_->options()->GetNumericValue
2994 (
"warm_start_bound_frac" ,pushValue_,app_->prefix());
2995 app_->options()->GetNumericValue(
"tiny_element",tiny_,app_->prefix());
2996 app_->options()->GetNumericValue(
"very_tiny_element",veryTiny_,app_->prefix());
2997 app_->options()->GetNumericValue(
"oa_rhs_relax",rhsRelax_,app_->prefix());
2998 app_->options()->GetNumericValue(
"random_point_perturbation_interval",max_perturbation_,app_->prefix());
2999 app_->options()->GetEnumValue(
"random_point_type",randomGenerationType_,app_->prefix());
3000 int cut_strengthening_type;
3001 app_->options()->GetEnumValue(
"cut_strengthening_type", cut_strengthening_type,app_->prefix());
3002 double lo_inf, up_inf;
3003 app_->options()->GetNumericValue(
"nlp_lower_bound_inf",lo_inf, app_->prefix());
3004 app_->options()->GetNumericValue(
"nlp_upper_bound_inf",up_inf, app_->prefix());
3005 infty_ = std::min(fabs(lo_inf), fabs(up_inf));
3007 #ifdef COIN_HAS_FILTERSQP
3010 app_->options()->GetNumericValue(
"resolve_on_small_infeasibility", infeasibility_epsilon_, app_->prefix());
3012 #ifdef COIN_HAS_FILTERSQP
3013 if(filter && !is_given){
3015 infeasibility_epsilon_ = 1
e-06;
3016 std::string o_name = app_->prefix();
3017 o_name +=
"resolve_on_small_infeasibility";
3018 app_->options()->SetNumericValue(o_name.c_str(), infeasibility_epsilon_,
true,
true);
3021 if (cut_strengthening_type !=
CS_None) {
3023 cutStrengthener_ =
new CutStrengthener(app_->clone(), app_->options());
3031 strong_branching_solver_ = strong_branching_solver;
3035 #ifdef STRONG_COMPARE
3036 static double objorig;
3040 OsiTMINLPInterface::markHotStart()
3042 if (
IsValid(strong_branching_solver_)) {
3043 #ifdef STRONG_COMPARE
3045 OsiSolverInterface::markHotStart();
3048 optimizationStatusBeforeHotStart_ = optimizationStatus_;
3049 strong_branching_solver_->markHotStart(
this);
3053 OsiSolverInterface::markHotStart();
3058 OsiTMINLPInterface::solveFromHotStart()
3060 if (
IsValid(strong_branching_solver_)) {
3061 #ifdef STRONG_COMPARE
3063 OsiSolverInterface::solveFromHotStart();
3066 optimizationStatus_ = strong_branching_solver_->solveFromHotStart(
this);
3067 hasBeenOptimized_ =
true;
3068 #ifdef STRONG_COMPARE
3070 printf(
"AWDEBUG: Strong Branching results: NLP = %15.8e Other = %15.8e\n",
3071 obj_nlp, obj_other);
3076 OsiSolverInterface::solveFromHotStart();
3081 OsiTMINLPInterface::unmarkHotStart()
3083 if (
IsValid(strong_branching_solver_)) {
3084 #ifdef STRONG_COMPARE
3086 OsiSolverInterface::unmarkHotStart();
3088 strong_branching_solver_->unmarkHotStart(
this);
3089 optimizationStatus_ = optimizationStatusBeforeHotStart_;
3093 OsiSolverInterface::unmarkHotStart();
3102 obj_ =
new double[
n];
3105 const double* x_sol = problem_->x_sol();
3106 bool retval = problem_->eval_grad_f(n, x_sol, new_x, obj_);
3110 fprintf(stderr,
"ERROR WHILE EVALUATING GRAD_F in OsiTMINLPInterface::getObjCoefficients()\n");
3121 problem_ = tminlp2tnlp;
3122 problem_to_optimize_ =
GetRawPtr(problem_);
3123 feasibilityProblem_->use(
GetRawPtr(tminlp2tnlp));}
bool getIntParam(OsiIntParam key, int &value) const
TNLPSolver::UnsolvedError * newUnsolvedError(int num, Ipopt::SmartPtr< TMINLP2TNLP > problem, std::string name)
virtual double getInfinity() const
Get solver's value for infinity.
virtual bool isAbandoned() const
Are there a numerical difficulties?
virtual void setRowLower(int elementIndex, double elementValue)
Set a single row lower bound.
void getOuterApproximation(OsiCuts &cs, int getObj, const double *x2, bool global)
Get the outer approximation constraints at the current optimal point.
void resetStartingPoint()
reset the starting point to original one.
void setBestSolution2(int n, double *d)
Solver
Solvers for solving nonlinear programs.
virtual const double * getColLower() const
Get pointer to array[getNumCols()] of column lower bounds.
filterSQP Sequential Quadratic Programming algorithm.
pos
position where the operator should be printed when printing the expression
Output the number of the problem.
virtual bool isPrimalObjectiveLimitReached() const
Is the given primal objective limit reached?
const TMINLP2TNLP * problem() const
get pointer to the TMINLP2TNLP adapter
const Ipopt::SmartPtr< Ipopt::OptionsList > options() const
Retrieve OsiTMINLPApplication option list.
This is class provides an Osi interface for a Mixed Integer Linear Program expressed as a TMINLP (so ...
virtual bool isInteger(int columnNumber) const
Return true if column is integer.
void fint fint fint real * a
OsiSolverInterface * clone(bool copyData=true) const
Virtual copy constructor.
bool IsValid(const OSSmartPtr< U > &smart_ptr)
virtual int getNumRows() const
Get number of rows.
Head of "civilized" log.
void use(Ipopt::SmartPtr< TMINLP2TNLP > tminlp2tnlp)
Sets the TMINLP2TNLP to be used by the interface.
virtual CoinWarmStart * getEmptyWarmStart() const
Get an empty warm start object.
void setBestObj2(double o)
Set an alternate objective value.
virtual void setContinuous(int index)
Set the index-th variable to be a continuous variable.
virtual void resolveForCost(int numretry, bool keepWs)
Resolve the problem with different random starting points to try to find a better solution (only make...
Different solver gives different status for problem.
The IpoptSolver class solves problems using Ipopt.
virtual int getNumCols() const
Get number of columns.
virtual bool isProvenOptimal() const
Is optimality proven?
virtual void initialSolve()
Solve initial continuous relaxation.
virtual double getObjValue() const
Get objective function value (can't use default)
Warn that a problem is resolved.
void fint fint fint real fint real real real real * f
virtual const double * getObjCoefficients() const
This returns the objective function gradient at the current point.
SimpleReferenced< X > * make_referenced(X other)
double solveFeasibilityProblem(size_t n, const double *x_bar, const int *ind, double a, double s, int L)
Given a point x_bar this solves the problem of finding the point which minimize a convex combination ...
virtual bool isProvenPrimalInfeasible() const
Is primal infeasiblity proven?
virtual const double * getColSolution() const
Get pointer to array[getNumCols()] of primal solution vector.
void fint fint fint real fint real real real real real real real real real * e
const double * GetPerturbationArray() const
Method for getting the array for the perturbation radii in order to use the values.
Error class to throw exceptions from OsiTMINLPInterface.
virtual void setColUpper(int elementIndex, double elementValue)
Set a single column upper bound.
bool getStrParam(OsiStrParam key, std::string &value) const
void getBendersCut(OsiCuts &cs, bool global)
Get a benders cut from solution.
found a feasible solution
virtual void getConstraintOuterApproximation(OsiCuts &cs, int constraintNumber, const double *x, const double *x2, bool global)
Get the outer approximation at provided point for given constraint.
virtual void resolve()
Resolve the continuous relaxation after problem modification.
void readOptionFile(const std::string &fileName)
Read parameter file.
void setSolver(Ipopt::SmartPtr< TNLPSolver > app)
Set the solver to be used by interface.
virtual void setRowUpper(int elementIndex, double elementValue)
Set a single row upper bound.
virtual void setColSolution(const double *colsol)
Set the primal solution variable values Set the values for the starting point.
virtual void setRowType(int index, char sense, double rightHandSide, double range)
Set the type of a single row.
virtual bool isFreeBinary(int columnNumber) const
Return true if column is binary and not fixed at either bound.
bool setStrParam(OsiStrParam key, const std::string &value)
Found a better solution with random values.
virtual const double * getRowUpper() const
Get pointer to array[getNumRows()] of row upper bounds.
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real * s
virtual bool isIterationLimitReached() const
Iteration limit reached?
virtual const double * getReducedCost() const
Get a pointer to array[getNumCols()] of reduced costs.
virtual const double * getRightHandSide() const
Get pointer to array[getNumRows()] of rows right-hand sides.
virtual bool isProvenDualInfeasible() const
Is dual infeasiblity proven?
virtual bool isDualObjectiveLimitReached() const
Is the given dual objective limit reached?
static bool WarnedForNonConvexOa
U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real * ws
virtual bool isContinuous(int colNumber) const
Return true if column is continuous.
virtual const char * getRowSense() const
Get pointer to array[getNumRows()] of row constraint senses.
virtual int getIterationCount() const
Get how many iterations it took to solve the problem (whatever "iteration" mean to the solver...
virtual bool isIntegerNonBinary(int columnNumber) const
Return true if column is general integer.
Recomputed integer feasible with alternate objective function.
void setModel(Ipopt::SmartPtr< TMINLP > tminlp)
Set the model to be solved by interface.
ReturnStatus
Standard return statuses for a solver.
standard line (retry solving) of log.
virtual void setObjSense(double s)
Set the objective function sense (disabled).
virtual const double * getRowRange() const
Get pointer to array[getNumRows()] of row ranges.
void setNewCutoffDecr(double d)
Are there a numerical difficulties?
virtual CoinWarmStart * getWarmStart() const
Get warmstarting information.
static bool cleanNnz(double &value, double colLower, double colUpper, double rowLower, double rowUpper, double colsol, double &lb, double &ub, double tiny, double veryTiny)
Ipopt::SmartPtr< const Ipopt::OptionsList > options() const
Get the options (for getting their values).
#define ADD_MSG(Id, Type, Level, MSG)
Warn that there are equality or ranged constraints and OA may works bad.
found an infeasible problem
virtual const double * getRowPrice() const
Get pointer to array[getNumRows()] of dual prices.
virtual ~OsiTMINLPInterface()
Destructor.
void fint fint fint fint fint fint fint fint fint fint real real real real real real real real real fint real fint real * lam
virtual void setRowPrice(const double *rowprice)
Set dual solution variable values.
static void register_OA_options(SmartPtr< RegisteredOptions > roptions)
virtual const double * getRowActivity() const
Get pointer to array[getNumRows()] of row activity levels (constraint matrix times the solution vecto...
virtual const double * getColUpper() const
Get pointer to array[getNumCols()] of column upper bounds.
virtual void addObjectiveFunction(OsiSolverInterface &si, const double *x)
Add constraint corresponding to objective function.
virtual void setInteger(int index)
Set the index-th variable to be an integer variable.
void fint fint fint real fint real real real real real real * g
virtual const double * getRowLower() const
Get pointer to array[getNumRows()] of row lower bounds.
bool setIntParam(OsiIntParam key, int value)
virtual void resolveForRobustness(int numretry)
Method to be called when a problem has failed to be solved.
void randomStartingPoint()
Get an empty warm start object.
Trying to access non-existent TNLPSolver.
virtual bool isBinary(int columnNumber) const
Return true if column is binary.
OsiTMINLPInterface & operator=(const OsiTMINLPInterface &rhs)
Assignment operator.
bool setDblParam(OsiDblParam key, double value)
virtual bool setWarmStart(const CoinWarmStart *warmstart)
Set warmstarting information.
int nnz
ATTENTION: Filter expect the jacobian to be ordered by row.
This is an adapter class that converts a TMINLP to a TNLP to be solved by Ipopt.
found an unsolved problem
static void register_general_options(SmartPtr< RegisteredOptions > roptions)
Register options.
Class to store perturbation radii for variables in the model.
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 void setColLower(int elementIndex, double elementValue)
Set a single column lower bound.
a failure occured but is continuing
OsiTMINLPInterface()
Default Constructor.
const OsiSolverInterface::OsiNameVec & getVarNames()
get name of variables
This is an adapter class to convert an NLP to a Feasibility Pump NLP by changing the objective functi...
Subproblem not solve with warm start but solved with random point.
virtual void extractLinearRelaxation(OsiSolverInterface &si, const double *x, bool getObj=1)
Extract a linear relaxation of the MINLP.
Bonmin class for passing info between components of branch-and-cuts.
Output summary statistics on Ipopt solution.
Problem not solved with warm start but solved without.
Different solver gives different optimal value for problem.
bool getDblParam(OsiDblParam key, double &value) const
void fint fint fint real fint real * x