Ipopt Documentation  
 
Loading...
Searching...
No Matches
IpMa97SolverInterface.hpp
Go to the documentation of this file.
1// Copyright (C) 2012, The Science and Technology Facilities Council (STFC)
2// Copyright (C) 2009, Jonathan Hogg <jdh41.at.cantab.net>
3// Copyright (C) 2004, 2007 International Business Machines and others.
4// All Rights Reserved.
5// This code is published under the Eclipse Public License.
6//
7// Authors: Jonathan Hogg STFC 2012-12-21
8// Jonathan Hogg 2009-07-29
9// Carl Laird, Andreas Waechter IBM 2004-03-17
10
11#ifndef __IPMA97SOLVERINTERFACE_HPP__
12#define __IPMA97SOLVERINTERFACE_HPP__
13
15#include "IpLibraryLoader.hpp"
16#include "IpTypes.h"
17
18extern "C"
19{
20#ifdef IPOPT_SINGLE
21#include "hsl_ma97s.h"
22#else
23#include "hsl_ma97d.h"
24#endif
25}
26
28#define IPOPT_DECL_MA97_DEFAULT_CONTROL(x) void (x)( \
29 struct ma97_control* control \
30)
31
33#define IPOPT_DECL_MA97_ANALYSE(x) void (x)( \
34 const int check, \
35 const int n, \
36 const int ptr[], \
37 const int row[], \
38 ipnumber val[], \
39 void** akeep, \
40 const struct ma97_control* control,\
41 struct ma97_info* info, \
42 int order[] \
43)
44
46#define IPOPT_DECL_MA97_FACTOR(x) void (x)( \
47 int matrix_type, \
48 const int ptr[], \
49 const int row[], \
50 const ipnumber val[], \
51 void** akeep, \
52 void** fkeep, \
53 const struct ma97_control* control, \
54 struct ma97_info* info, \
55 ipnumber scale[] \
56)
57
59#define IPOPT_DECL_MA97_FACTOR_SOLVE(x) void (x)( \
60 int matrix_type, \
61 const int ptr[], \
62 const int row[], \
63 const ipnumber val[], \
64 int nrhs, \
65 ipnumber xx[], \
66 int ldx, \
67 void** akeep, \
68 void** fkeep, \
69 const struct ma97_control* control, \
70 struct ma97_info* info, \
71 ipnumber scale[] \
72)
73
75#define IPOPT_DECL_MA97_SOLVE(x) void (x)( \
76 const int job, \
77 const int nrhs, \
78 ipnumber* xx, \
79 const int ldx, \
80 void** akeep, \
81 void** fkeep, \
82 const struct ma97_control* control, \
83 struct ma97_info* info \
84)
85
87#define IPOPT_DECL_MA97_FINALISE(x) void (x)( \
88 void** akeep, \
89 void** fkeep \
90)
91
93#define IPOPT_DECL_MA97_FREE_AKEEP(x) void (x)( \
94 void** akeep \
95)
96
97namespace Ipopt
98{
99
101{
102private:
125
126 int ndim_;
130 void* akeep_;
131 void* fkeep_;
133 bool rescale_;
136
137 /* Options */
145 bool dump_;
146
151
160
161public:
162
164 SmartPtr<LibraryLoader> hslloader_
165 ) : val_(NULL),
166 numdelay_(0),
167 akeep_(NULL),
168 fkeep_(NULL),
169 pivtol_changed_(false),
170 rescale_(false),
171 scaling_(NULL),
172 fctidx_(0),
173 scaling_type_(0),
174 dump_(false),
175 hslloader(hslloader_),
177 ma97_analyse(NULL),
178 ma97_factor(NULL),
179 ma97_factor_solve(NULL),
180 ma97_solve(NULL),
181 ma97_finalise(NULL),
182 ma97_free_akeep(NULL)
183 { }
184
186
187 static void RegisterOptions(
189 );
190
193 static void SetFunctions(
201 );
202
204 const OptionsList& options,
205 const std::string& prefix
206 );
207
211 Index dim,
212 Index nonzeros,
213 const Index* ia,
214 const Index* ja
215 );
216
218 {
219 return val_;
220 }
221
223 bool new_matrix,
224 const Index* ia,
225 const Index* ja,
226 Index nrhs,
227 Number* rhs_vals,
228 bool check_NegEVals,
229 Index numberOfNegEVals
230 );
231
233 {
234 return numneg_;
235 }
237
238 //* @name Options of Linear solver */
241
242 bool ProvidesInertia() const
243 {
244 return true;
245 }
246
248 {
249 return CSR_Format_1_Offset;
250 }
252
257 {
258 return false;
259 }
260
262 const Index* /*ia*/,
263 const Index* /*ja*/,
264 std::list<Index>& /*c_deps*/
265 )
266 {
268 }
270
272 static int ScaleNameToNum(
273 const std::string& name
274 );
275};
276
277} // namespace Ipopt
278
279#endif
#define IPOPT_DECL_MA97_FREE_AKEEP(x)
#define IPOPT_DECL_MA97_FINALISE(x)
#define IPOPT_DECL_MA97_SOLVE(x)
#define IPOPT_DECL_MA97_DEFAULT_CONTROL(x)
#define IPOPT_DECL_MA97_FACTOR_SOLVE(x)
#define IPOPT_DECL_MA97_ANALYSE(x)
#define IPOPT_DECL_MA97_FACTOR(x)
IPOPT_DECL_MA97_FACTOR_SOLVE * ma97_factor_solve
void * fkeep_
Stores pointer to factors (only understood Fortran code!)
static void SetFunctions(IPOPT_DECL_MA97_DEFAULT_CONTROL(*ma97_default_control), IPOPT_DECL_MA97_ANALYSE(*ma97_analyse), IPOPT_DECL_MA97_FACTOR(*ma97_factor), IPOPT_DECL_MA97_FACTOR_SOLVE(*ma97_factor_solve), IPOPT_DECL_MA97_SOLVE(*ma97_solve), IPOPT_DECL_MA97_FINALISE(*ma97_finalise),)
set MA97 functions to use for every instantiation of this class
Number * scaling_
Store scaling for reuse if doing dynamic scaling.
bool ProvidesInertia() const
Query whether inertia is computed by linear solver.
void * akeep_
Stores pointer to factors (only understood Fortran code!)
Number * GetValuesArrayPtr()
Method returning an internal array into which the nonzero elements (in the same order as ja) will be ...
IPOPT_DECL_MA97_FINALISE * ma97_finalise
ESymSolverStatus InitializeStructure(Index dim, Index nonzeros, const Index *ia, const Index *ja)
Method for initializing internal structures.
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.
IPOPT_DECL_MA97_SOLVE * ma97_solve
IPOPT_DECL_MA97_ANALYSE * ma97_analyse
bool IncreaseQuality()
Request to increase quality of solution for next solve.
int numneg_
Number of negative pivots in last factorization.
Ma97SolverInterface(SmartPtr< LibraryLoader > hslloader_)
static void RegisterOptions(SmartPtr< RegisteredOptions > roptions)
static int ScaleNameToNum(const std::string &name)
converts a scaling option name to its ma97 option number
IPOPT_DECL_MA97_FREE_AKEEP * ma97_free_akeep
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_MA97_FACTOR * ma97_factor
bool rescale_
Indicates if we should rescale next factorization.
ESymSolverStatus DetermineDependentRows(const Index *, const Index *, std::list< Index > &)
This method determines the list of row indices of the linearly dependent rows.
int fctidx_
Current factorization number to dump to.
int numdelay_
Number of delayed pivots last time we scaled.
bool ProvidesDegeneracyDetection() const
Query whether the indices of linearly dependent rows/columns can be determined by this linear solver.
Index NumberOfNegEVals() const
Number of negative eigenvalues detected during last factorization.
SmartPtr< LibraryLoader > hslloader
EMatrixFormat MatrixFormat() const
Query of requested matrix type that the linear solver understands.
bool pivtol_changed_
indicates if pivtol has been changed
Number * val_
Storage for variables.
IPOPT_DECL_MA97_DEFAULT_CONTROL * ma97_default_control
This class stores a list of user set options.
Template class for Smart Pointers.
Base class for interfaces to symmetric indefinite linear solvers for sparse matrices.
@ CSR_Format_1_Offset
Compressed sparse row format for upper triangular part, with 1 offset.
#define ma97_control
Definition hsl_ma97d.h:46
This file contains a base class for all exceptions and a set of macros to help with exceptions.
ESymSolverStatus
Enum to report outcome of a linear solve.
@ SYMSOLVER_FATAL_ERROR
Unrecoverable error in linear solver occurred.
ipindex Index
Type of all indices of vectors, matrices etc.
Definition IpTypes.hpp:20
ipnumber Number
Type of all numbers.
Definition IpTypes.hpp:17