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;
42 const std::string &
prefix):
43 TNLPSolver(roptions, options, journalist, prefix),
44 problemHadZeroDimension_(false),
45 warmStartStrategy_(1),
46 enable_warm_start_(false),
47 optimized_before_(false)
50 app_ =
new Ipopt::IpoptApplication(
GetRawPtr(roptions), options, journalist);
57 TNLPSolver(roptions, options, journalist,
"bonmin."),
58 problemHadZeroDimension_(false),
59 warmStartStrategy_(1),
60 enable_warm_start_(false),
61 optimized_before_(false)
64 app_ =
new Ipopt::IpoptApplication(
GetRawPtr(roptions), options, journalist);
72 optimizationStatus_(other.optimizationStatus_),
73 problemHadZeroDimension_(other.problemHadZeroDimension_),
74 warmStartStrategy_(other.warmStartStrategy_),
75 enable_warm_start_(false),
76 optimized_before_(false){
85 retval->app_->Initialize(
"");
94 Ipopt::ApplicationReturnStatus status =
95 app_->Initialize(params_file);
96 if (status != Ipopt::Solve_Succeeded) {
108 Ipopt::ApplicationReturnStatus status =
109 app_->Initialize(is);
110 if (status != Ipopt::Solve_Succeeded) {
123 printf(
"Global Time limit set to %g\n",
time_limit_);
126 printf(
"Time limit set to %g\n", local_time_limit);
127 if(local_time_limit <= 0.){
136 options_->SetNumericValue(
"max_cpu_time", local_time_limit,
168 printf(
"Global Time limit set to %g\n",
time_limit_);
171 printf(
"Time limit set to %g\n", local_time_limit);
172 if(local_time_limit <= 0.){
181 options_->SetNumericValue(
"max_cpu_time",
182 std::max(0., local_time_limit),
217 return stats->TotalCpuTime();
220 app_->Jnlst()->Printf(Ipopt::J_WARNING, Ipopt::J_STATISTICS,
"No statistics available from Ipopt in Bonmin::IpoptSolver::CPUTime\n");
237 return stats->IterationCount();
240 app_->Jnlst()->Printf(Ipopt::J_WARNING, Ipopt::J_STATISTICS,
"No statistics available from Ipopt in Bonmin::IpoptSolver::IterationCount\n");
255 set = Options->GetNumericValue(
"gamma_phi", dummy_dbl,
"");
257 Options->SetNumericValue(
"gamma_phi", 1
e-8,
true,
true);
258 set = Options->GetNumericValue(
"gamma_theta", dummy_dbl,
"");
260 Options->SetNumericValue(
"gamma_theta", 1
e-4,
true,
true);
261 set = Options->GetNumericValue(
"required_infeasibility_reduction", dummy_dbl,
"");
263 Options->SetNumericValue(
"required_infeasibility_reduction", 0.1,
true,
true);
264 set = Options->GetEnumValue(
"expect_infeasible_problem",dummy_int,
"");
266 Options->SetStringValue(
"expect_infeasible_problem",
"yes",
true,
true);
267 set = Options->GetEnumValue(
"mu_strategy", dummy_int,
"");
269 Options->SetStringValue(
"mu_strategy",
"adaptive",
true,
true);
270 set = Options->GetEnumValue(
"mu_oracle",dummy_int,
"");
272 Options->SetStringValue(
"mu_oracle",
"probing",
true,
true);
275 Options->SetIntegerValue(
"print_level",1,
true,
true);
287 switch (optimization_status) {
288 case Ipopt::Maximum_Iterations_Exceeded:
289 case Ipopt::User_Requested_Stop:
290 case Ipopt::Restoration_Failed:
292 case Ipopt::Error_In_Step_Computation:
293 case Ipopt::Unrecoverable_Exception:
294 case Ipopt::Insufficient_Memory:
296 case Ipopt::Not_Enough_Degrees_Of_Freedom:
298 case Ipopt::Invalid_Problem_Definition:
300 case Ipopt::Invalid_Option:
301 case Ipopt::Invalid_Number_Detected:
303 case Ipopt::NonIpopt_Exception_Thrown:
305 case Ipopt::Internal_Error:
307 case Ipopt::Solve_Succeeded:
308 case Ipopt::Feasible_Point_Found:
310 case Ipopt::Search_Direction_Becomes_Too_Small:
312 case Ipopt::Solved_To_Acceptable_Level:
314 case Ipopt::Infeasible_Problem_Detected:
316 case Ipopt::Diverging_Iterates:
318 case Ipopt::Maximum_CpuTime_Exceeded:
329 if(tnlp->x_init() == NULL || tnlp->duals_init() == NULL)
332 2*tnlp->num_variables() +
333 tnlp->num_constraints(),
334 tnlp->x_init(), tnlp->duals_init());
356 if(ws == NULL)
return 0;
362 if(ws->dualSize() > 0){
363 tnlp->setDualsInit(ws->dualSize(), ws->dual());
369 int numcols = tnlp->num_variables();
370 int numrows = tnlp->num_constraints();
373 assert(numcols == ws->primalSize());
374 assert(2*numcols + numrows == ws->dualSize());
375 tnlp->setxInit(ws->primalSize(), ws->primal());
386 if (iws && !iws->
empty()) {
402 options_->SetStringValue(
"warm_start_init_point",
"yes");
409 options_->SetStringValue(
"warm_start_init_point",
"no");
423 options_->SetIntegerValue(
"print_level", log_level,
true,
true);
433 "Solved to acceptable level",
434 "Infeasible problem detected",
435 "Search direction becomes too small",
436 "Diverging iterates",
437 "User requested stop",
438 "Maximum iterations exceeded",
439 "Restoration failed",
440 "Error in step computation",
441 "Not enough degrees of freedom",
442 "Invalid problem definition",
444 "Invalid number detected",
445 "Unrecoverable exception",
446 "NonIpopt exception thrown",
447 "Insufficient memory",
466 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.