12 #include "IpSolveStatistics.hpp"
13 #include "CoinError.hpp"
29 problemHadZeroDimension_(false),
30 warmStartStrategy_(1),
31 enable_warm_start_(false),
32 optimized_before_(false)
34 if (createEmpty)
return;
37 app_->RethrowNonIpoptException(
true);
45 const std::string &
prefix):
46 TNLPSolver(roptions, options, journalist, prefix),
47 problemHadZeroDimension_(false),
48 warmStartStrategy_(1),
49 enable_warm_start_(false),
50 optimized_before_(false)
53 app_ =
new Ipopt::IpoptApplication(
GetRawPtr(roptions), options, journalist);
55 app_->RethrowNonIpoptException(
true);
63 TNLPSolver(roptions, options, journalist,
"bonmin."),
64 problemHadZeroDimension_(false),
65 warmStartStrategy_(1),
66 enable_warm_start_(false),
67 optimized_before_(false)
70 app_ =
new Ipopt::IpoptApplication(
GetRawPtr(roptions), options, journalist);
72 app_->RethrowNonIpoptException(
true);
81 optimizationStatus_(other.optimizationStatus_),
82 problemHadZeroDimension_(other.problemHadZeroDimension_),
83 warmStartStrategy_(other.warmStartStrategy_),
84 enable_warm_start_(false),
85 optimized_before_(false){
88 app_->RethrowNonIpoptException(
true);
97 retval->app_->Initialize(
"");
106 Ipopt::ApplicationReturnStatus status =
107 app_->Initialize(params_file);
108 if (status != Ipopt::Solve_Succeeded) {
120 Ipopt::ApplicationReturnStatus status =
121 app_->Initialize(is);
122 if (status != Ipopt::Solve_Succeeded) {
135 printf(
"Global Time limit set to %g\n",
time_limit_);
138 printf(
"Time limit set to %g\n", local_time_limit);
139 if(local_time_limit <= 0.){
148 options_->SetNumericValue(
"max_cpu_time", local_time_limit,
180 printf(
"Global Time limit set to %g\n",
time_limit_);
183 printf(
"Time limit set to %g\n", local_time_limit);
184 if(local_time_limit <= 0.){
193 options_->SetNumericValue(
"max_cpu_time",
194 std::max(0., local_time_limit),
229 return stats->TotalCpuTime();
232 app_->Jnlst()->Printf(Ipopt::J_WARNING, Ipopt::J_STATISTICS,
"No statistics available from Ipopt in Bonmin::IpoptSolver::CPUTime\n");
249 return stats->IterationCount();
252 app_->Jnlst()->Printf(Ipopt::J_WARNING, Ipopt::J_STATISTICS,
"No statistics available from Ipopt in Bonmin::IpoptSolver::IterationCount\n");
267 set = Options->GetNumericValue(
"gamma_phi", dummy_dbl,
"");
269 Options->SetNumericValue(
"gamma_phi", 1
e-8,
true,
true);
270 set = Options->GetNumericValue(
"gamma_theta", dummy_dbl,
"");
272 Options->SetNumericValue(
"gamma_theta", 1
e-4,
true,
true);
273 set = Options->GetNumericValue(
"required_infeasibility_reduction", dummy_dbl,
"");
275 Options->SetNumericValue(
"required_infeasibility_reduction", 0.1,
true,
true);
276 set = Options->GetEnumValue(
"expect_infeasible_problem",dummy_int,
"");
278 Options->SetStringValue(
"expect_infeasible_problem",
"yes",
true,
true);
279 set = Options->GetEnumValue(
"mu_strategy", dummy_int,
"");
281 Options->SetStringValue(
"mu_strategy",
"adaptive",
true,
true);
282 set = Options->GetEnumValue(
"mu_oracle",dummy_int,
"");
284 Options->SetStringValue(
"mu_oracle",
"probing",
true,
true);
287 Options->SetIntegerValue(
"print_level",1,
true,
true);
299 switch (optimization_status) {
300 case Ipopt::Maximum_Iterations_Exceeded:
301 case Ipopt::User_Requested_Stop:
302 case Ipopt::Restoration_Failed:
304 case Ipopt::Error_In_Step_Computation:
305 case Ipopt::Unrecoverable_Exception:
306 case Ipopt::Insufficient_Memory:
308 case Ipopt::Not_Enough_Degrees_Of_Freedom:
310 case Ipopt::Invalid_Problem_Definition:
312 case Ipopt::Invalid_Option:
313 case Ipopt::Invalid_Number_Detected:
315 case Ipopt::NonIpopt_Exception_Thrown:
317 case Ipopt::Internal_Error:
319 case Ipopt::Solve_Succeeded:
320 case Ipopt::Feasible_Point_Found:
322 case Ipopt::Search_Direction_Becomes_Too_Small:
324 case Ipopt::Solved_To_Acceptable_Level:
326 case Ipopt::Infeasible_Problem_Detected:
328 case Ipopt::Diverging_Iterates:
330 case Ipopt::Maximum_CpuTime_Exceeded:
341 if(tnlp->x_init() == NULL || tnlp->duals_init() == NULL)
344 2*tnlp->num_variables() +
345 tnlp->num_constraints(),
346 tnlp->x_init(), tnlp->duals_init());
368 if(ws == NULL)
return 0;
374 if(ws->dualSize() > 0){
375 tnlp->setDualsInit(ws->dualSize(), ws->dual());
381 int numcols = tnlp->num_variables();
382 int numrows = tnlp->num_constraints();
385 assert(numcols == ws->primalSize());
386 assert(2*numcols + numrows == ws->dualSize());
387 tnlp->setxInit(ws->primalSize(), ws->primal());
398 if (iws && !iws->
empty()) {
414 options_->SetStringValue(
"warm_start_init_point",
"yes");
421 options_->SetStringValue(
"warm_start_init_point",
"no");
435 options_->SetIntegerValue(
"print_level", log_level,
true,
true);
445 "Solved to acceptable level",
446 "Infeasible problem detected",
447 "Search direction becomes too small",
448 "Diverging iterates",
449 "User requested stop",
450 "Maximum iterations exceeded",
451 "Restoration failed",
452 "Error in step computation",
453 "Not enough degrees of freedom",
454 "Invalid problem definition",
456 "Invalid number detected",
457 "Unrecoverable exception",
458 "NonIpopt exception thrown",
459 "Insufficient memory",
478 throw CoinError(
"UnsolvedError",
"UnsolvedError::errorName()",
"Unrecognized optimization status in ipopt.");
virtual ~IpoptSolver()
Virtual destructor.
int default_log_level_
To record default log level.
virtual void setOutputToDefault()
turn off all output from the solver
Ipopt::SmartPtr< Ipopt::Journalist > journalist_
Storage of Journalist for output.
Class for storing warm start informations for Ipopt.
virtual bool setWarmStart(const CoinWarmStart *warm, Ipopt::SmartPtr< TMINLP2TNLP > tnlp)
Set the warm start in the solver.
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions()
Get a pointer to RegisteredOptions (generally used to add new ones)
virtual void forceSolverOutput(int log_level)
turn on all output from the solver
virtual TNLPSolver::ReturnStatus OptimizeTNLP(const Ipopt::SmartPtr< Ipopt::TNLP > &tnlp)
Solves a problem expresses as a TNLP.
bool problemHadZeroDimension_
Flag to indicate if last problem solved had 0 dimension.
virtual int IterationCount()
Get the iteration count of the last optimization.
bool IsValid(const OSSmartPtr< U > &smart_ptr)
This is a generic class for calling an NLP solver to solve a TNLP.
virtual const std::string & solverName() const
Return the name of the solver.
Ipopt::SmartPtr< IpoptInteriorWarmStarter > warm_starter() const
Accessor to warm start information obecjt.
double start_time_
Global start time.
double time_limit_
Global time limit.
virtual CoinWarmStart * getEmptyWarmStart() const
Solves a problem expresses as a TNLP.
static std::string solverName_
virtual Ipopt::SmartPtr< TNLPSolver > clone()
virtual copy constructor
void setMinlpDefaults(Ipopt::SmartPtr< Ipopt::OptionsList > Options)
Set default Ipopt parameters for use in a MINLP.
void fint fint fint real fint real real real real real real real real real * e
TNLPSolver::ReturnStatus solverReturnStatus(Ipopt::ApplicationReturnStatus optimization_status) const
get Bonmin return status from Ipopt one.
int errorNum() const
Return error number.
virtual CoinWarmStart * getUsedWarmStart(Ipopt::SmartPtr< TMINLP2TNLP > tnlp) const
Get warm start used in last optimization.
virtual bool warmStartIsValid(const CoinWarmStart *ws) const
Check that warm start object is valid.
Ipopt::ApplicationReturnStatus optimizationStatus_
return status of last optimization.
virtual const std::string & errorName() const
Get the string corresponding to error.
Ipopt::SmartPtr< Ipopt::IpoptApplication > app_
Ipopt application.
virtual double CPUTime()
Get the CpuTime of the last optimization.
static std::string solverName_
bool enable_warm_start_
flag remembering if we want to use warm start option
U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions_
Registered Options.
void fint fint fint real fint real real real real real real real real real fint real fint fint fint real * ws
ReturnStatus
Standard return statuses for a solver.
bool optimized_before_
flag remembering if we have call the Optimize method of the IpoptInterface before ...
virtual void enableWarmStart()
Enable the warm start options in the solver.
IpoptSolver(bool createEmpty=false)
Constructor.
virtual CoinWarmStart * getWarmStart(Ipopt::SmartPtr< Bonmin::TMINLP2TNLP > tnlp) const
Get the warm start form the solver.
virtual TNLPSolver::ReturnStatus ReOptimizeTNLP(const Ipopt::SmartPtr< Ipopt::TNLP > &tnlp)
Resolves a problem expresses as a TNLP.
virtual bool Initialize(std::string params_file)
Initialize the TNLPSolver (read options from params_file)
static std::string errorNames[17]
bool empty() const
Is this an empty warm start?
bool zeroDimension(const Ipopt::SmartPtr< Ipopt::TNLP > &tnlp, ReturnStatus &optimization_status)
Determine if problem is of dimension zero and if it is check if solution is feasible.
int warmStartStrategy_
Warm start strategy :
virtual void disableWarmStart()
Disable the warm start options in the solver.
Ipopt::SmartPtr< Ipopt::OptionsList > options_
List of Options.
const char * prefix()
Get the prefix.