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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
// Copyright (C) 2005, 2010 International Business Machines and others.
// All Rights Reserved.
// This code is published under the Eclipse Public License.
//
// Authors: Carl Laird, Andreas Waechter IBM 2005-03-17
#ifndef __IPWSMPSOLVERINTERFACE_HPP__
#define __IPWSMPSOLVERINTERFACE_HPP__
#include "IpSparseSymLinearSolverInterface.hpp"
#include "IpPardisoSolverInterface.hpp" // for IPOPT_DECL_SMAT_REORDERING_PARDISO_WSMP
#include "IpTypes.h"
namespace Ipopt
{
/** Interface to the linear solver Wsmp, derived from
* SparseSymLinearSolverInterface.
*/
class WsmpSolverInterface: public SparseSymLinearSolverInterface
{
public:
/** @name Constructor/Destructor */
///@{
/** Constructor */
WsmpSolverInterface(
#ifdef PARDISO_MATCHING_PREPROCESS
SmartPtr<LibraryLoader> pardisoloader_ ///< @since 3.14.0
#endif
);
/** Destructor */
virtual ~WsmpSolverInterface();
///@}
bool InitializeImpl(
const OptionsList& options,
const std::string& prefix
);
/** @name Methods for requesting solution of the linear system. */
///@{
virtual ESymSolverStatus InitializeStructure(
Index dim,
Index nonzeros,
const Index* ia,
const Index* ja
);
virtual double* GetValuesArrayPtr();
virtual ESymSolverStatus MultiSolve(
bool new_matrix,
const Index* ia,
const Index* ja,
Index nrhs,
double* rhs_vals,
bool check_NegEVals,
Index numberOfNegEVals
);
virtual Index NumberOfNegEVals() const;
///@}
//* @name Options of Linear solver */
///@{
virtual bool IncreaseQuality();
virtual bool ProvidesInertia() const
{
return true;
}
EMatrixFormat MatrixFormat() const
{
return CSR_Format_1_Offset;
}
///@}
///@{
static void RegisterOptions(
SmartPtr<RegisteredOptions> roptions
);
/// give WSMP version
static void GetVersion(
int& V,
int& R,
int& M
);
///@}
virtual bool ProvidesDegeneracyDetection() const;
virtual ESymSolverStatus DetermineDependentRows(
const Index* ia,
const Index* ja,
std::list<Index>& c_deps
);
private:
/**@name Default Compiler Generated Methods
* (Hidden to avoid implicit creation/calling).
* These methods are not implemented and
* we do not want the compiler to implement
* them for us, so we declare them private
* and do not define them. This ensures that
* they will not be implicitly created/called. */
///@{
/** Copy Constructor */
WsmpSolverInterface(
const WsmpSolverInterface&
);
/** Default Assignment Operator */
void operator=(
const WsmpSolverInterface&
);
///@}
/** @name Information about the matrix */
///@{
/** Number of rows and columns of the matrix */
Index dim_;
/** Number of nonzeros of the matrix in triplet representation. */
Index nonzeros_;
/** Array for storing the values of the matrix. */
double* a_;
#ifdef PARDISO_MATCHING_PREPROCESS
/** @name Arrays for storing the values of a second matrix that has been already reordered. */
///@{
Index* ia2;
Index* ja2;
double* a2_;
Index* perm2;
double* scale2;
///@}
#endif
///@}
/** @name Solver specific options */
///@{
/** Option that controls the matching strategy. */
Index wsmp_num_threads_;
/** Pivot tolerance */
Number wsmp_pivtol_;
/** Maximal pivot tolerance */
Number wsmp_pivtolmax_;
/** Indicating which of WSMP's scaling methods should be used. */
Index wsmp_scaling_;
/** WSMP's singularity threshold.
*
* The smaller this value the less likely a matrix is declared singular.
*/
Number wsmp_singularity_threshold_;
/** iteration number in which matrices are to be written out */
Index wsmp_write_matrix_iteration_;
/** Flag indicating if the inertia is always assumed to be correct. */
bool skip_inertia_check_;
/** Flag indicating whether the positive definite version of WSMP should be used */
bool wsmp_no_pivoting_;
///@}
/** Counter for matrix file numbers */
Index matrix_file_number_;
/** @name Information about most recent factorization/solve */
///@{
/** Number of negative eigenvalues */
Index negevals_;
///@}
/** @name Initialization flags */
///@{
/** Flag indicating if internal data is initialized.
*
* For initialization, this object needs to have seen a matrix.
*/
bool initialized_;
/** Flag indicating if we already printed how many threads are used by WSMP. */
bool printed_num_threads_;
/** Flag indicating if the matrix has to be refactorized because
* the pivot tolerance has been changed, or the computation of
* the ordering has been triggered with DPARNM[14].
*/
bool pivtol_changed_;
/** Flag indicating whether symbolic factorization and order has
* already been performed.
*/
bool have_symbolic_factorization_;
/** Counter indicating how many factorizations have been done sine
* the last recomputation of the ordering.
*/
Index factorizations_since_recomputed_ordering_;
///@}
/** @name Solver specific information */
///@{
/** Integer parameter array for WSSMP. */
Index* IPARM_;
/** Double precision parameter array for WSSMP. */
double* DPARM_;
/** WSSMP's permutation vector */
Index* PERM_;
/** WSSMP's inverse permutation vector */
Index* INVP_;
/** WSSMP's internal MRP array */
Index* MRP_;
///@}
/**@name PARDISO function pointer
* @{
*/
#ifdef PARDISO_MATCHING_PREPROCESS
SmartPtr<LibraryLoader> pardisoloader;
IPOPT_DECL_SMAT_REORDERING_PARDISO_WSMP(*smat_reordering_pardiso_wsmp);
#endif
/**@} */
/** @name Internal functions */
///@{
/** Call Wsmp to do the analysis phase. */
ESymSolverStatus SymbolicFactorization(
const Index* ia,
const Index* ja
);
/** Call Wsmp to really do the analysis phase. */
ESymSolverStatus InternalSymFact(
const Index* ia,
const Index* ja,
Index numberOfNegEVals
);
/** Call Wsmp to factorize the Matrix. */
ESymSolverStatus Factorization(
const Index* ia,
const Index* ja,
bool check_NegEVals,
Index numberOfNegEVals
);
/** Call Wsmp to do the Solve. */
ESymSolverStatus Solve(
const Index* ia,
const Index* ja,
Index nrhs,
double* rhs_vals
);
///@}
};
} // namespace Ipopt
#endif