OS  2.10.2
OSIpoptSolver.h
Go to the documentation of this file.
1 /* $Id: OSIpoptSolver.h 5284 2017-12-08 13:52:50Z stefan $ */
15 #ifndef IPOPTSOLVER_H
16 #define IPOPTSOLVER_H
17 
18 #include "OSConfig.h"
19 #include "OSDefaultSolver.h"
20 #include "OSrLWriter.h"
21 #include "OSInstance.h"
22 #include "OSParameters.h"
23 #include "OSnLNode.h"
24 #include "OSiLReader.h"
25 #include "OSoLReader.h"
26 #include "OSInstance.h"
27 #include "OSExpressionTree.h"
28 #include "OSnLNode.h"
29 #include "OSGeneral.h"
30 #include "OSFileUtil.h"
31 #include "OSErrorClass.h"
32 
33 #include "OSResult.h"
34 #include "OSInstance.h"
35 #include "OSOption.h"
36 
37 #include <cstddef>
38 #include <cstdlib>
39 #include <cctype>
40 #include <cassert>
41 #include <stack>
42 #include <string>
43 #include <iostream>
44 #include <vector>
45 #include <map>
46 
47 
48 #include "IpTNLP.hpp"
49 #include "IpIpoptApplication.hpp"
50 
51 // for Stefan
52 class IpoptProblem : public Ipopt::TNLP
53 {
54 public:
55 
57  IpoptProblem(OSInstance *osinstance_ , OSOption *osoption_, OSResult *osresult_, std::string *ipoptErrorMsg_);
58 
60  virtual ~IpoptProblem();
61 
62 
64 
66 
68 
69  std::string *ipoptErrorMsg;
70 
72  virtual bool get_nlp_info(Ipopt::Index& n, Ipopt::Index& m, Ipopt::Index& nnz_jac_g,
73  Ipopt::Index& nnz_h_lag, IndexStyleEnum& index_style);
74 
78 
80  virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number* x,
81  bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
82  Ipopt::Index m, bool init_lambda,
83  Ipopt::Number* lambda);
84 
86  virtual bool eval_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number& obj_value);
87 
89  virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number* grad_f);
90 
92  virtual bool eval_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Index m, Ipopt::Number* g);
93 
98  virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
99  Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow, Ipopt::Index *jCol,
100  Ipopt::Number* values);
101 
106  virtual bool eval_h(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
107  Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number* lambda,
108  bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index* iRow,
109  Ipopt::Index* jCol, Ipopt::Number* values);
110 
112 
113 
114  virtual bool get_scaling_parameters(Ipopt::Number& obj_scaling,
115  bool& use_x_scaling, Ipopt::Index n,
116  Ipopt::Number* x_scaling,
117  bool& use_g_scaling, Ipopt::Index m,
118  Ipopt::Number* g_scaling);
119 
124  Ipopt::Index n, const Ipopt::Number* x, const Ipopt::Number* z_L, const Ipopt::Number* z_U,
125  Ipopt::Index m, const Ipopt::Number* g, const Ipopt::Number* lambda,
126  Ipopt::Number obj_value,
127  const Ipopt::IpoptData* ip_data,
130 
131 
132 
133 private:
145  // HS071_NLP();
146  IpoptProblem(const IpoptProblem&);
147  IpoptProblem& operator=(const IpoptProblem&);
149 
150 };
151 
152 
165 //class IpoptSolver : public DefaultSolver, public TNLP{
166 
168 {
169 public:
170 
173 
176 
178 
180 
181 
184  virtual void solve()
185 #if __cplusplus < 201100
186  throw(ErrorClass)
187 #endif
188  ;
189 
190 
195  virtual void buildSolverInstance()
196 #if __cplusplus < 201100
197  throw(ErrorClass)
198 #endif
199  ;
200 
205  virtual void setSolverOptions()
206 #if __cplusplus < 201100
207  throw(ErrorClass)
208 #endif
209  ;
210 
217 
223 
229 
230 
231 private:
232  OSrLWriter *osrlwriter;
233 
245  // IpoptSolver();
246  //IpoptSolver(const IpoptSolver&);
247  //IpoptSolver& operator=(const IpoptSolver&);
249  //std::string ipoptErrorMsg;
250  std::string *ipoptErrorMsg;
251 };
252 
253 
254 #endif /*IPOPTSOLVER_H*/
OSConfig.h
OSExpressionTree.h
IpoptProblem::eval_h
virtual bool eval_h(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number *lambda, bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
Method to return: 1) The structure of the hessian of the lagrangian (if "values" is NULL) 2) The valu...
OSiLReader
Used to read an OSiL string.
Definition: OSiLReader.h:38
IpIpoptApplication.hpp
Ipopt::IpoptData
OSErrorClass.h
IpoptSolver::app
Ipopt::SmartPtr< Ipopt::IpoptApplication > app
Definition: OSIpoptSolver.h:179
OSoLReader
Used to read an OSoL string.
Definition: OSoLReader.h:38
OSrLWriter.h
OSInstance
The in-memory representation of an OSiL instance..
Definition: OSInstance.h:2263
OSrLWriter
Take an OSResult object and write a string that validates against OSrL.
Definition: OSrLWriter.h:31
IpoptProblem::eval_grad_f
virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number *grad_f)
Method to return the gradient of the objective.
IpoptProblem::get_starting_point
virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number *x, bool init_z, Ipopt::Number *z_L, Ipopt::Number *z_U, Ipopt::Index m, bool init_lambda, Ipopt::Number *lambda)
Method to return the starting point for the algorithm.
Ipopt::IpoptCalculatedQuantities
OSResult.h
OSInstance.h
This file defines the OSInstance class along with its supporting classes.
Ipopt::Number
double Number
OSOption.h
IpoptProblem::osresult
OSResult * osresult
Definition: OSIpoptSolver.h:67
IpoptSolver::nlp
Ipopt::SmartPtr< Ipopt::TNLP > nlp
Definition: OSIpoptSolver.h:177
IpoptProblem::~IpoptProblem
virtual ~IpoptProblem()
the IpoptProblem class destructor
IpoptProblem::IpoptProblem
IpoptProblem(OSInstance *osinstance_, OSOption *osoption_, OSResult *osresult_, std::string *ipoptErrorMsg_)
the IpoptProblemclass constructor
IpoptSolver::solve
virtual void solve()
solve results in an instance being read into the Ipopt data structures and optimize
OSFileUtil.h
IpoptProblem::get_nlp_info
virtual bool get_nlp_info(Ipopt::Index &n, Ipopt::Index &m, Ipopt::Index &nnz_jac_g, Ipopt::Index &nnz_h_lag, IndexStyleEnum &index_style)
IPOpt specific methods for defining the nlp problem.
IpoptSolver::m_osilreader
OSiLReader * m_osilreader
m_osilreader is an OSiLReader object used to create an osinstance from an osil string if needed
Definition: OSIpoptSolver.h:222
OSoLReader.h
OSiLReader.h
Ipopt::Index
int Index
IpoptSolver::buildSolverInstance
virtual void buildSolverInstance()
The implementation of the virtual functions.
OSResult
The Result Class.
Definition: OSResult.h:2549
IpoptProblem::eval_jac_g
virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index *iRow, Ipopt::Index *jCol, Ipopt::Number *values)
Method to return: 1) The structure of the jacobian (if "values" is NULL) 2) The values of the jacobia...
OSDefaultSolver.h
Ipopt::SmartPtr< Ipopt::TNLP >
IpoptProblem::finalize_solution
virtual void finalize_solution(Ipopt::SolverReturn status, Ipopt::Index n, const Ipopt::Number *x, const Ipopt::Number *z_L, const Ipopt::Number *z_U, Ipopt::Index m, const Ipopt::Number *g, const Ipopt::Number *lambda, Ipopt::Number obj_value, const Ipopt::IpoptData *ip_data, Ipopt::IpoptCalculatedQuantities *ip_cq)
This method is called when the algorithm is complete so the TNLP can store/write the solution.
IpoptSolver::IpoptSolver
IpoptSolver()
the IpoptSolver class constructor
IpoptProblem::eval_g
virtual bool eval_g(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Index m, Ipopt::Number *g)
Method to return the constraint residuals.
IpoptSolver::setSolverOptions
virtual void setSolverOptions()
The implementation of the virtual functions.
ErrorClass
used for throwing exceptions.
Definition: OSErrorClass.h:32
IpoptSolver
The IpoptSolver class solves problems using Ipopt.
Definition: OSIpoptSolver.h:168
IpoptProblem::eval_f
virtual bool eval_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)
Method to return the objective value.
IpoptProblem::get_bounds_info
virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number *x_l, Ipopt::Number *x_u, Ipopt::Index m, Ipopt::Number *g_l, Ipopt::Number *g_u)
Method to return the bounds for my problem.
IpoptProblem::get_scaling_parameters
virtual bool get_scaling_parameters(Ipopt::Number &obj_scaling, bool &use_x_scaling, Ipopt::Index n, Ipopt::Number *x_scaling, bool &use_g_scaling, Ipopt::Index m, Ipopt::Number *g_scaling)
OSOption
The Option Class.
Definition: OSOption.h:3565
IpoptProblem
Definition: OSIpoptSolver.h:53
Ipopt::TNLP
OSGeneral.h
IpoptProblem::osoption
OSOption * osoption
Definition: OSIpoptSolver.h:65
IpoptProblem::osinstance
OSInstance * osinstance
Definition: OSIpoptSolver.h:63
Ipopt::TNLP::IndexStyleEnum
IndexStyleEnum
IpoptSolver::m_osolreader
OSoLReader * m_osolreader
m_osolreader is an OSoLReader object used to create an osoption from an osol string if needed
Definition: OSIpoptSolver.h:228
IpoptSolver::~IpoptSolver
~IpoptSolver()
the IpoptSolver class destructor
Ipopt::SolverReturn
SolverReturn
DefaultSolver
The Default Solver Class.
Definition: OSDefaultSolver.h:36
IpoptSolver::dataEchoCheck
void dataEchoCheck()
use this for debugging, print out the instance that the solver thinks it has and compare this with th...
OSParameters.h
IpTNLP.hpp
IpoptProblem::ipoptErrorMsg
std::string * ipoptErrorMsg
Definition: OSIpoptSolver.h:69
OSnLNode.h
This file defines the OSnLNode class along with its derived classes.