Ipopt Documentation  
IpMa77SolverInterface.hpp
Go to the documentation of this file.
1 // Copyright (C) 2009, Jonathan Hogg <jdh41.at.cantab.net>
2 // Copyright (C) 2004, 2007 International Business Machines and others.
3 // All Rights Reserved.
4 // This code is published under the Eclipse Public License.
5 //
6 // Authors: Jonathan Hogg STFC 2013-30-05
7 // Jonathan Hogg 2009-07-29
8 // Carl Laird, Andreas Waechter IBM 2004-03-17
9 
10 #ifndef __IPMA77SOLVERINTERFACE_HPP__
11 #define __IPMA77SOLVERINTERFACE_HPP__
12 
14 #include "IpLibraryLoader.hpp"
15 #include "IpTypes.h"
16 
17 extern "C"
18 {
19 #ifdef IPOPT_SINGLE
20 #include "hsl_ma77s.h"
21 #else
22 #include "hsl_ma77d.h"
23 #endif
24 #include "hsl_mc68i.h"
25 }
26 
28 #define IPOPT_DECL_MA77_DEFAULT_CONTROL(x) void (x)( \
29  struct ma77_control* control \
30 )
31 
33 #define IPOPT_DECL_MA77_OPEN_NELT(x) void (x)( \
34  const int n, \
35  const char* fname1, \
36  const char* fname2, \
37  const char* fname3, \
38  const char* fname4, \
39  void** keep, \
40  const struct ma77_control* control,\
41  struct ma77_info* info, \
42  const int nelt \
43 )
44 
46 #define IPOPT_DECL_MA77_OPEN(x) void (x)( \
47  const int n, \
48  const char* fname1, \
49  const char* fname2, \
50  const char* fname3, \
51  const char* fname4, \
52  void** keep, \
53  const struct ma77_control* control,\
54  struct ma77_info* info \
55 )
56 
58 #define IPOPT_DECL_MA77_INPUT_VARS(x) void (x)( \
59  const int idx, \
60  const int nvar, \
61  const int list[], \
62  void** keep, \
63  const struct ma77_control* control,\
64  struct ma77_info* info \
65 )
66 
68 #define IPOPT_DECL_MA77_INPUT_REALS(x) void (x)( \
69  const int idx, \
70  const int length, \
71  const ipnumber reals[],\
72  void** keep, \
73  const struct ma77_control* control,\
74  struct ma77_info* info \
75 )
76 
78 #define IPOPT_DECL_MA77_ANALYSE(x) void (x)( \
79  const int order[], \
80  void** keep, \
81  const struct ma77_control* control, \
82  struct ma77_info* info \
83 )
84 
86 #define IPOPT_DECL_MA77_FACTOR(x) void (x)( \
87  const int posdef, \
88  void** keep, \
89  const struct ma77_control* control,\
90  struct ma77_info* info, \
91  const ipnumber* scale \
92 )
93 
95 #define IPOPT_DECL_MA77_FACTOR_SOLVE(x) void (x)( \
96  const int posdef, \
97  void** keep, \
98  const struct ma77_control* control,\
99  struct ma77_info* info, \
100  const ipnumber* scale, \
101  const int nrhs, \
102  const int lx, \
103  ipnumber rhs[] \
104 )
105 
107 #define IPOPT_DECL_MA77_SOLVE(x) void (x)( \
108  const int job, \
109  const int nrhs, \
110  const int lx, \
111  ipnumber xx[], \
112  void** keep, \
113  const struct ma77_control* control,\
114  struct ma77_info* info, \
115  const ipnumber* scale \
116 )
117 
119 #define IPOPT_DECL_MA77_RESID(x) void (x)( \
120  const int nrhs, \
121  const int lx, \
122  const ipnumber xx[], \
123  const int lresid, \
124  ipnumber resid[], \
125  void** keep, \
126  const struct ma77_control* control, \
127  struct ma77_info* info, \
128  ipnumber* anorm_bnd\
129 )
130 
132 #define IPOPT_DECL_MA77_SCALE(x) void (x)( \
133  ipnumber scale[], \
134  void** keep, \
135  const struct ma77_control* control, \
136  struct ma77_info* info, \
137  ipnumber* anorm \
138 )
139 
141 #define IPOPT_DECL_MA77_ENQUIRE_POSDEF(x) void (x)( \
142  ipnumber d[], \
143  void** keep, \
144  const struct ma77_control* control,\
145  struct ma77_info* info \
146 )
147 
149 #define IPOPT_DECL_MA77_ENQUIRE_INDEF(x) void (x)( \
150  int piv_order[], \
151  ipnumber d[], \
152  void** keep, \
153  const struct ma77_control* control, \
154  struct ma77_info* info \
155 )
156 
158 #define IPOPT_DECL_MA77_ALTER(x) void (x)( \
159  const ipnumber d[], \
160  void** keep, \
161  const struct ma77_control* control, \
162  struct ma77_info* info \
163 )
164 
166 #define IPOPT_DECL_MA77_RESTART(x) void (x)( \
167  const char* restart_file, \
168  const char* fname1, \
169  const char* fname2, \
170  const char* fname3, \
171  const char* fname4, \
172  void** keep, \
173  const struct ma77_control* control, \
174  struct ma77_info* info \
175 )
176 
178 #define IPOPT_DECL_MA77_FINALISE(x) void (x)( \
179  void** keep, \
180  const struct ma77_control* control,\
181  struct ma77_info* info \
182 )
183 
185 #define IPOPT_DECL_MC68_DEFAULT_CONTROL(x) void (x)( \
186  struct mc68_control* control \
187 )
188 
190 #define IPOPT_DECL_MC68_ORDER(x) void (x)( \
191  int ord, \
192  int n, \
193  const int ptr[], \
194  const int row[], \
195  int perm[], \
196  const struct mc68_control* control,\
197  struct mc68_info* info \
198 )
199 
200 namespace Ipopt
201 {
202 
204 {
205 private:
207  {
210  };
211 
212  int ndim_;
214  int numneg_;
215  void* keep_;
217 
218  /* Options */
222 
227 
247 
248 public:
249 
251  SmartPtr<LibraryLoader> hslloader_
252  ) : val_(NULL),
253  keep_(NULL),
254  pivtol_changed_(false),
255  hslloader(hslloader_),
256  ma77_default_control(NULL),
257  ma77_open_nelt(NULL),
258  ma77_open(NULL),
259  ma77_input_vars(NULL),
260  ma77_input_reals(NULL),
261  ma77_analyse(NULL),
262  ma77_factor(NULL),
263  ma77_factor_solve(NULL),
264  ma77_solve(NULL),
265  ma77_resid(NULL),
266  ma77_scale(NULL),
267  ma77_enquire_posdef(NULL),
268  ma77_enquire_indef(NULL),
269  ma77_alter(NULL),
270  ma77_restart(NULL),
271  ma77_finalise(NULL),
272  mc68_default_control(NULL),
273  mc68_order(NULL)
274  { }
275 
277 
278  static void RegisterOptions(
280  );
281 
284  static void SetFunctions(
303  );
304 
305  bool InitializeImpl(
306  const OptionsList& options,
307  const std::string& prefix
308  );
309 
313  Index dim,
314  Index nonzeros,
315  const Index* ia,
316  const Index* ja
317  );
318 
320  {
321  return val_;
322  }
323 
325  bool new_matrix,
326  const Index* ia,
327  const Index* ja,
328  Index nrhs,
329  Number* rhs_vals,
330  bool check_NegEVals,
331  Index numberOfNegEVals
332  );
333 
335  {
336  return numneg_;
337  }
339 
340  //* @name Options of Linear solver */
342  bool IncreaseQuality();
343 
344  bool ProvidesInertia() const
345  {
346  return true;
347  }
348 
350  {
352  }
354 
357  bool ProvidesDegeneracyDetection() const
359  {
360  return false;
361  }
362 
364  const Index* /*ia*/,
365  const Index* /*ja*/,
366  std::list<Index>& /*c_deps*/
367  )
368  {
369  return SYMSOLVER_FATAL_ERROR;
370  }
371 };
372 
373 } // namespace Ipopt
374 
375 #endif
#define IPOPT_DECL_MA77_FINALISE(x)
int ndim_
Number of dimensions.
IPOPT_DECL_MA77_FACTOR_SOLVE * ma77_factor_solve
IPOPT_DECL_MA77_OPEN * ma77_open
ESymSolverStatus
Enum to report outcome of a linear solve.
IPOPT_DECL_MA77_SOLVE * ma77_solve
#define IPOPT_DECL_MA77_ENQUIRE_INDEF(x)
#define IPOPT_DECL_MA77_FACTOR_SOLVE(x)
#define IPOPT_DECL_MA77_SCALE(x)
Base class for interfaces to symmetric indefinite linear solvers for sparse matrices.
#define IPOPT_DECL_MA77_ENQUIRE_POSDEF(x)
#define IPOPT_DECL_MA77_DEFAULT_CONTROL(x)
ESymSolverStatus DetermineDependentRows(const Index *, const Index *, std::list< Index > &)
This method determines the list of row indices of the linearly dependent rows.
IPOPT_DECL_MC68_DEFAULT_CONTROL * mc68_default_control
#define IPOPT_DECL_MC68_DEFAULT_CONTROL(x)
#define IPOPT_DECL_MA77_SOLVE(x)
#define IPOPT_DECL_MA77_INPUT_VARS(x)
IPOPT_DECL_MA77_OPEN_NELT * ma77_open_nelt
IPOPT_DECL_MA77_ANALYSE * ma77_analyse
IPOPT_DECL_MA77_ENQUIRE_POSDEF * ma77_enquire_posdef
static void SetFunctions(IPOPT_DECL_MA77_DEFAULT_CONTROL(*ma77_default_control), IPOPT_DECL_MA77_OPEN_NELT(*ma77_open_nelt), IPOPT_DECL_MA77_OPEN(*ma77_open), IPOPT_DECL_MA77_INPUT_VARS(*ma77_input_vars), IPOPT_DECL_MA77_INPUT_REALS(*ma77_input_reals), IPOPT_DECL_MA77_ANALYSE(*ma77_analyse), IPOPT_DECL_MA77_FACTOR(*ma77_factor), IPOPT_DECL_MA77_FACTOR_SOLVE(*ma77_factor_solve), IPOPT_DECL_MA77_SOLVE(*ma77_solve), IPOPT_DECL_MA77_RESID(*ma77_resid), IPOPT_DECL_MA77_SCALE(*ma77_scale), IPOPT_DECL_MA77_ENQUIRE_POSDEF(*ma77_enquire_posdef), IPOPT_DECL_MA77_ENQUIRE_INDEF(*ma77_enquire_indef), IPOPT_DECL_MA77_ALTER(*ma77_alter), IPOPT_DECL_MA77_RESTART(*ma77_restart), IPOPT_DECL_MA77_FINALISE(*ma77_finalise), IPOPT_DECL_MC68_DEFAULT_CONTROL(*mc68_default_control),)
set MA77 and MC68 functions to use for every instantiation of this class
#define IPOPT_DECL_MA77_FACTOR(x)
#define IPOPT_DECL_MA77_RESTART(x)
Index NumberOfNegEVals() const
Number of negative eigenvalues detected during last factorization.
IPOPT_DECL_MA77_RESTART * ma77_restart
bool ProvidesDegeneracyDetection() const
Query whether the indices of linearly dependent rows/columns can be determined by this linear solver...
ipindex Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:20
IPOPT_DECL_MA77_INPUT_REALS * ma77_input_reals
This file contains a base class for all exceptions and a set of macros to help with exceptions...
int numneg_
Number of negative pivots in last factorization.
Number * GetValuesArrayPtr()
Method returning an internal array into which the nonzero elements (in the same order as ja) will be ...
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:164
Number * val_
Storage for variables.
This class stores a list of user set options.
IPOPT_DECL_MA77_DEFAULT_CONTROL * ma77_default_control
ESymSolverStatus InitializeStructure(Index dim, Index nonzeros, const Index *ia, const Index *ja)
Method for initializing internal structures.
IPOPT_DECL_MA77_ALTER * ma77_alter
#define IPOPT_DECL_MA77_INPUT_REALS(x)
IPOPT_DECL_MC68_ORDER * mc68_order
#define IPOPT_DECL_MA77_RESID(x)
ipnumber Number
Type of all numbers.
Definition: IpTypes.hpp:17
EMatrixFormat MatrixFormat() const
Query of requested matrix type that the linear solver understands.
bool pivtol_changed_
indicates if pivtol has been changed
#define IPOPT_DECL_MA77_OPEN(x)
static void RegisterOptions(SmartPtr< RegisteredOptions > roptions)
bool InitializeImpl(const OptionsList &options, const std::string &prefix)
Implementation of the initialization method that has to be overloaded by for each derived class...
IPOPT_DECL_MA77_ENQUIRE_INDEF * ma77_enquire_indef
bool IncreaseQuality()
Request to increase quality of solution for next solve.
#define IPOPT_DECL_MA77_ALTER(x)
#define IPOPT_DECL_MC68_ORDER(x)
Unrecoverable error in linear solver occurred.
EMatrixFormat
Enum to specify sparse matrix format.
IPOPT_DECL_MA77_FINALISE * ma77_finalise
Ma77SolverInterface(SmartPtr< LibraryLoader > hslloader_)
#define IPOPT_DECL_MA77_OPEN_NELT(x)
bool ProvidesInertia() const
Query whether inertia is computed by linear solver.
ESymSolverStatus MultiSolve(bool new_matrix, const Index *ia, const Index *ja, Index nrhs, Number *rhs_vals, bool check_NegEVals, Index numberOfNegEVals)
Solve operation for multiple right hand sides.
void * keep_
Stores pointer to factors (only understood by Fortran code!)
#define IPOPT_DECL_MA77_ANALYSE(x)
IPOPT_DECL_MA77_SCALE * ma77_scale
IPOPT_DECL_MA77_RESID * ma77_resid
Compressed sparse row format for both lwr and upr parts, with 1 offset.
SmartPtr< LibraryLoader > hslloader
IPOPT_DECL_MA77_INPUT_VARS * ma77_input_vars
#define ma77_control
Definition: hsl_ma77d.h:44
IPOPT_DECL_MA77_FACTOR * ma77_factor