Bonmin 1.8.9
Loading...
Searching...
No Matches
BonIpoptSolver.hpp
Go to the documentation of this file.
1// (C) Copyright International Business Machines (IBM) 2005, 2007
2// All Rights Reserved.
3// This code is published under the Eclipse Public License.
4//
5// Authors :
6// Pierre Bonami, IBM
7//
8// Date : 26/09/2006
9
10#ifndef IpoptSolver_HPP
11#define IpoptSolver_HPP
12#include "BonTNLPSolver.hpp"
14
15
16namespace Bonmin
17{
18 class IpoptSolver: public TNLPSolver
19 {
20 public:
22 {
23 public:
26 std::string name):
27 TNLPSolver::UnsolvedError(errorNum, problem, name)
28 {}
29 virtual const std::string& errorName() const;
30
31 virtual const std::string& solverName() const;
33 {}
34 private:
35 static std::string errorNames [17];
36 static std::string solverName_;
37 };
38
41 std::string name)
42 {
43 return new UnsolvedIpoptError(num, problem, name);
44 }
45
46
47
49 IpoptSolver(bool createEmpty = false);
50
55 const std::string & prefix);
56
61
63 IpoptSolver(const IpoptSolver &other);
64
67
69 virtual ~IpoptSolver();
70
73 virtual bool Initialize(std::string params_file);
74
77 virtual bool Initialize(std::istream& is);
78
83
86
88 virtual bool setWarmStart(const CoinWarmStart * warm,
90
93
94
97
99
101 virtual bool warmStartIsValid(const CoinWarmStart * ws) const;
102
104 virtual void enableWarmStart();
105
107 virtual void disableWarmStart();
108
110
112 virtual double CPUTime();
113
115 virtual int IterationCount();
116
118 virtual void setOutputToDefault();
120 virtual void forceSolverOutput(int log_level);
121
123 virtual std::string & solverName()
124 {
125 return solverName_;
126 }
127
133
134
135
137 Ipopt::ApplicationReturnStatus getOptStatus() const
138 {
139 return optimizationStatus_;
140 }
141
143 {
144 return *app_;
145 }
146
147 virtual int errorCode() const
148 {
149 return (int) optimizationStatus_;
150 }
151 private:
153 void setMinlpDefaults(Ipopt::SmartPtr< Ipopt::OptionsList> Options);
154
156 TNLPSolver::ReturnStatus solverReturnStatus(Ipopt::ApplicationReturnStatus optimization_status) const;
157
161 Ipopt::ApplicationReturnStatus optimizationStatus_;
163
164
166 bool problemHadZeroDimension_;
167
175 int warmStartStrategy_;
176
178 bool enable_warm_start_;
179
182 bool optimized_before_;
183 //name of solver (Ipopt)
184 static std::string solverName_;
185 };
186}
187#endif
188
virtual const std::string & solverName() const
Return the name of the solver.
virtual const std::string & errorName() const
Get the string corresponding to error.
UnsolvedIpoptError(int errorNum, Ipopt::SmartPtr< TMINLP2TNLP > problem, std::string name)
virtual bool Initialize(std::istream &is)
Initialize the TNLPSolver (read options from istream is)
virtual int errorCode() const
Error code (solver specific).
virtual TNLPSolver::ReturnStatus ReOptimizeTNLP(const Ipopt::SmartPtr< Ipopt::TNLP > &tnlp)
Resolves a problem expresses as a TNLP.
virtual void forceSolverOutput(int log_level)
turn on all output from the solver
virtual bool setWarmStart(const CoinWarmStart *warm, Ipopt::SmartPtr< TMINLP2TNLP > tnlp)
Set the warm start in the solver.
IpoptSolver(bool createEmpty=false)
Constructor.
IpoptSolver(const IpoptSolver &other)
Copy constructor.
virtual UnsolvedError * newUnsolvedError(int num, Ipopt::SmartPtr< TMINLP2TNLP > problem, std::string name)
Ipopt::IpoptApplication & getIpoptApp()
virtual CoinWarmStart * getUsedWarmStart(Ipopt::SmartPtr< TMINLP2TNLP > tnlp) const
Get warm start used in last optimization.
virtual bool Initialize(std::string params_file)
Initialize the TNLPSolver (read options from params_file)
virtual Ipopt::SmartPtr< TNLPSolver > clone()
virtual copy constructor
virtual std::string & solverName()
Get the solver name.
static void RegisterOptions(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions)
Register this solver options into passed roptions.
virtual int IterationCount()
Get the iteration count of the last optimization.
virtual CoinWarmStart * getEmptyWarmStart() const
virtual void disableWarmStart()
Disable the warm start options in the solver.
virtual void setOutputToDefault()
turn off all output from the solver
virtual TNLPSolver::ReturnStatus OptimizeTNLP(const Ipopt::SmartPtr< Ipopt::TNLP > &tnlp)
Solves a problem expresses as a TNLP.
Ipopt::ApplicationReturnStatus getOptStatus() const
Return status of last optimization.
virtual CoinWarmStart * getWarmStart(Ipopt::SmartPtr< Bonmin::TMINLP2TNLP > tnlp) const
Get the warm start form the solver.
virtual bool warmStartIsValid(const CoinWarmStart *ws) const
Check that warm start object is valid.
virtual double CPUTime()
Get the CpuTime of the last optimization.
IpoptSolver(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions, Ipopt::SmartPtr< Ipopt::OptionsList > options, Ipopt::SmartPtr< Ipopt::Journalist > journalist)
Constructor with Passed in journalist, registered options, options.
virtual ~IpoptSolver()
Virtual destructor.
IpoptSolver(Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions, Ipopt::SmartPtr< Ipopt::OptionsList > options, Ipopt::SmartPtr< Ipopt::Journalist > journalist, const std::string &prefix)
Constructor with Passed in journalist, registered options, options.
virtual void enableWarmStart()
Enable the warm start options in the solver.
We will throw this error when a problem is not solved.
int errorNum() const
Return error number.
This is a generic class for calling an NLP solver to solve a TNLP.
ReturnStatus
Standard return statuses for a solver.
Ipopt::SmartPtr< Ipopt::Journalist > journalist()
Get a pointer to a journalist.
Ipopt::SmartPtr< const Ipopt::OptionsList > options() const
Get the options (for getting their values).
Ipopt::SmartPtr< Bonmin::RegisteredOptions > roptions()
Get a pointer to RegisteredOptions (generally used to add new ones)
const char * prefix()
Get the prefix.
static void RegisterAllIpoptOptions(const SmartPtr< RegisteredOptions > &roptions)
(C) Copyright International Business Machines Corporation 2007
U * GetRawPtr(const SmartPtr< U > &smart_ptr)