1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// Copyright (C) 2012, The Science and Technology Facilities Council (STFC)
// Copyright (C) 2009, Jonathan Hogg <jdh41.at.cantab.net>
// Copyright (C) 2004, 2007 International Business Machines and others.
// All Rights Reserved.
// This code is published under the Eclipse Public License.
//
// Authors: Byron Tasseff LANL 2020-03-21
// Jonathan Hogg STFC 2012-12-21
// Jonathan Hogg 2009-07-29
// Carl Laird, Andreas Waechter IBM 2004-03-17
#ifndef __IPSPRALSOLVERINTERFACE_HPP__
#define __IPSPRALSOLVERINTERFACE_HPP__
#include "IpSparseSymLinearSolverInterface.hpp"
extern "C"
{
#include "spral_ssids.h"
}
namespace Ipopt
{
/** Interface to the linear solver SPRAL.
* @since 3.14.0
*/
class SpralSolverInterface: public SparseSymLinearSolverInterface
{
private:
enum scaling_opts
{
SWITCH_NEVER,
SWITCH_AT_START,
SWITCH_AT_START_REUSE,
SWITCH_ON_DEMAND,
SWITCH_ON_DEMAND_REUSE,
SWITCH_NDELAY,
SWITCH_NDELAY_REUSE,
SWITCH_OD_ND,
SWITCH_OD_ND_REUSE
};
int ndim_; ///< Number of dimensions
double* val_; ///< Storage for variables
int numneg_; ///< Number of negative pivots in last factorization
int numdelay_; ///< Number of delayed pivots last time we scaled
void* akeep_; ///< Stores pointer to factors
void* fkeep_; ///< Stores pointer to factors
bool pivtol_changed_; ///< indicates if pivtol has been changed
bool rescale_; ///< Indicates if we should rescale next factorization
double* scaling_; ///< Store scaling for reuse if doing dynamic scaling
int fctidx_; ///< Current factorization number to dump to
/* Options */
struct spral_ssids_options control_;
double umax_;
int ordering_;
int scaling_type_;
enum scaling_opts switch_[3];
int scaling_val_[3];
int current_level_;
bool dump_;
public:
SpralSolverInterface()
: val_(NULL),
numdelay_(0),
akeep_(NULL),
fkeep_(NULL),
pivtol_changed_(false),
rescale_(false),
scaling_(NULL),
fctidx_(0),
scaling_type_(0),
dump_(false)
{ }
~SpralSolverInterface();
static void RegisterOptions(
SmartPtr<RegisteredOptions> roptions
);
/// give name of MUMPS with version info
static std::string GetName();
bool InitializeImpl(
const OptionsList& options,
const std::string& prefix
);
/** @name Methods for requesting solution of the linear system. */
///@{
ESymSolverStatus InitializeStructure(
Index dim,
Index nonzeros,
const Index* ia,
const Index* ja
);
double* GetValuesArrayPtr()
{
return val_;
}
ESymSolverStatus MultiSolve(
bool new_matrix,
const Index* ia,
const Index* ja,
Index nrhs,
double* rhs_vals,
bool check_NegEVals,
Index numberOfNegEVals
);
Index NumberOfNegEVals() const
{
return numneg_;
}
///@}
/** @name Options of Linear solver */
///@{
bool IncreaseQuality();
bool ProvidesInertia() const
{
return true;
}
EMatrixFormat MatrixFormat() const
{
return CSR_Format_1_Offset;
}
///@}
/** @name Methods related to the detection of linearly dependent
* rows in a matrix */
///@{
bool ProvidesDegeneracyDetection() const
{
return false;
}
ESymSolverStatus DetermineDependentRows(
const Index* /*ia*/,
const Index* /*ja*/,
std::list<Index>& /*c_deps*/
)
{
return SYMSOLVER_FATAL_ERROR;
}
///@}
/** converts a scaling option name to its spral option number */
static int ScaleNameToNum(
const std::string& name
);
/** converts a pivot method option name to its spral option number */
static int PivotMethodNameToNum(
const std::string& name
);
};
} // namespace Ipopt
#endif