OS  2.9.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OSCsdpSolver.h
Go to the documentation of this file.
1 /* $Id: OSCsdpSolver.h 4562 2013-01-02 12:31:12Z Gassmann $ */
15 #ifndef CSDPSOLVER_H
16 #define CSDPSOLVER_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 /*
38  * Include CSDP declarations so that we'll know the calling interfaces.
39  */
40 
41 extern "C"
42 {
43 #include "declarations.h"
44 }
45 
46 
47 #include <cstddef>
48 #include <cstdlib>
49 #include <cctype>
50 #include <cassert>
51 #include <stack>
52 #include <string>
53 #include <iostream>
54 #include <vector>
55 #include <map>
56 
57 
58 #if 0
59 class IpoptProblem : public Ipopt::TNLP
60 {
61 public:
62 
64  IpoptProblem(OSInstance *osinstance_ , OSOption *osoption_, OSResult *osresult_, std::string *ipoptErrorMsg_);
65 
67  virtual ~IpoptProblem();
68 
69 
71 
73 
75 
76  std::string *ipoptErrorMsg;
77 
79  virtual bool get_nlp_info(Ipopt::Index& n, Ipopt::Index& m, Ipopt::Index& nnz_jac_g,
80  Ipopt::Index& nnz_h_lag, IndexStyleEnum& index_style);
81 
83  virtual bool get_bounds_info(Ipopt::Index n, Ipopt::Number* x_l, Ipopt::Number* x_u,
84  Ipopt::Index m, Ipopt::Number* g_l, Ipopt::Number* g_u);
85 
87  virtual bool get_starting_point(Ipopt::Index n, bool init_x, Ipopt::Number* x,
88  bool init_z, Ipopt::Number* z_L, Ipopt::Number* z_U,
89  Ipopt::Index m, bool init_lambda,
90  Ipopt::Number* lambda);
91 
93  virtual bool eval_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number& obj_value);
94 
96  virtual bool eval_grad_f(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Number* grad_f);
97 
99  virtual bool eval_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x, Ipopt::Index m, Ipopt::Number* g);
100 
105  virtual bool eval_jac_g(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
106  Ipopt::Index m, Ipopt::Index nele_jac, Ipopt::Index* iRow, Ipopt::Index *jCol,
107  Ipopt::Number* values);
108 
113  virtual bool eval_h(Ipopt::Index n, const Ipopt::Number* x, bool new_x,
114  Ipopt::Number obj_factor, Ipopt::Index m, const Ipopt::Number* lambda,
115  bool new_lambda, Ipopt::Index nele_hess, Ipopt::Index* iRow,
116  Ipopt::Index* jCol, Ipopt::Number* values);
117 
119 
120 
121  virtual bool get_scaling_parameters(Ipopt::Number& obj_scaling,
122  bool& use_x_scaling, Ipopt::Index n,
123  Ipopt::Number* x_scaling,
124  bool& use_g_scaling, Ipopt::Index m,
125  Ipopt::Number* g_scaling);
126 
130  virtual void finalize_solution(Ipopt::SolverReturn status,
131  Ipopt::Index n, const Ipopt::Number* x, const Ipopt::Number* z_L, const Ipopt::Number* z_U,
132  Ipopt::Index m, const Ipopt::Number* g, const Ipopt::Number* lambda,
133  Ipopt::Number obj_value,
134  const Ipopt::IpoptData* ip_data,
135  Ipopt::IpoptCalculatedQuantities* ip_cq);
137 
138 
139 
140 private:
152  // HS071_NLP();
153  IpoptProblem(const IpoptProblem&);
154  IpoptProblem& operator=(const IpoptProblem&);
156 };
157 #endif
158 
159 
173 class CsdpSolver : public DefaultSolver
174 {
175 public:
176 
178  CsdpSolver();
179 
181  ~CsdpSolver();
182 
185  virtual void solve() throw (ErrorClass) ;
186 
191  virtual void buildSolverInstance() throw(ErrorClass);
192 
197  virtual void setSolverOptions() throw(ErrorClass);
198 
204  void verifyForm() throw(ErrorClass);
205 
211  void dataEchoCheck();
212 
218 
224 
225 
226 private:
227  OSrLWriter *osrlwriter;
228 
240  // CsdpSolver();
241  //CsdpSolver(const CsdpSolver&);
242  //CsdpSolver& operator=(const CsdpSolver&);
244  //std::string csdpErrorMsg;
245  std::string *csdpErrorMsg;
246 };
247 
248 
249 #endif /*CSDPSOLVER_H*/
The CsdpSolver class solves problems using Csdp.
Definition: OSCsdpSolver.h:173
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 &quot;values&quot; is NULL) 2) The valu...
virtual bool eval_f(Ipopt::Index n, const Ipopt::Number *x, bool new_x, Ipopt::Number &obj_value)
Method to return the objective value.
used for throwing exceptions.
Definition: OSErrorClass.h:31
OSResult * osresult
Definition: OSIpoptSolver.h:67
CsdpSolver()
the CsdpSolver class constructor
The Option Class.
Definition: OSOption.h:3564
Take an OSResult object and write a string that validates against OSrL.
Definition: OSrLWriter.h:30
OSiLReader * m_osilreader
m_osilreader is an OSiLReader object used to create an osinstance from an osil string if needed ...
Definition: OSCsdpSolver.h:217
virtual ~IpoptProblem()
the IpoptProblem class destructor
virtual void buildSolverInstance()
The implementation of the virtual functions.
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(OSInstance *osinstance_, OSOption *osoption_, OSResult *osresult_, std::string *ipoptErrorMsg_)
the IpoptProblemclass constructor
OSInstance * osinstance
Definition: OSIpoptSolver.h:63
The in-memory representation of an OSiL instance.
Definition: OSInstance.h:2241
Used to read an OSiL string.
Definition: OSiLReader.h:37
std::string * ipoptErrorMsg
Definition: OSIpoptSolver.h:69
Used to read an OSoL string.
Definition: OSoLReader.h:37
~CsdpSolver()
the CsdpSolver class destructor
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.
OSoLReader * m_osolreader
m_osolreader is an OSoLReader object used to create an osoption from an osol string if needed ...
Definition: OSCsdpSolver.h:223
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)
This file defines the OSInstance class along with its supporting classes.
OSOption * osoption
Definition: OSIpoptSolver.h:65
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 &quot;values&quot; is NULL) 2) The values of the jacobia...
virtual void setSolverOptions()
The implementation of the virtual functions.
This file defines the OSnLNode class along with its derived classes.
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.
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...
The Default Solver Class.
void dataEchoCheck()
use this for debugging, print out the instance that the solver thinks it has and compare this with th...
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.
void verifyForm()
Use to verify that the solver is appropriate CSDP requires a very special type of problem...
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.
The Result Class.
Definition: OSResult.h:2312
virtual void solve()
solve results in an instance being read into the Csdp data structures and optimize ...