-
Notifications
You must be signed in to change notification settings - Fork 6
/
sdpa_newton.h
231 lines (187 loc) · 6.71 KB
/
sdpa_newton.h
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
/* -------------------------------------------------------------
This file is a component of SDPA
Copyright (C) 2004 SDPA Project
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
------------------------------------------------------------- */
#ifndef __sdpa_newton_h__
#define __sdpa_newton_h__
#include <sdpa_dataset.h>
#include <sdpa_chordal.h>
#define SparseCholesky 1
namespace sdpa {
class Newton;
class Solutions;
class InputData;
class Residuals;
class WorkVariables;
class ComputeTime;
class Parameter;
class StepLength;
class DirectionParameter;
class Switch;
class RatioInitResCurrentRes;
class SolveInfo;
class Phase;
class AverageComplementarity;
class Newton
{
public:
enum bMat_Sp_De {SPARSE, DENSE};
bMat_Sp_De bMat_type;
SparseMatrix sparse_bMat;
DenseMatrix bMat; // the coefficent of Schur complement
Vector gVec; // the right hand side of Schur complement
DenseLinearSpace DxMat;
Vector DyVec;
DenseLinearSpace DzMat;
DenseLinearSpace r_zinvMat;
DenseLinearSpace x_rd_zinvMat;
enum FormulaType {F1,F2,F3};
FormulaType* useFormula;
// Caution:
// if SDPA doesn't use sparse bMat, following variables are indefinite.
//
// nBLock : number of block
// nConstraint[k]: number of combination of nonzero matrices in k-th block
// when A[k].block[i] and A[k].block[j] are nonzero matrices,
// i <-> constraint1[k][t]
// j <-> constraint2[k][t]
// A[k].block[i] <-> A[k].sp_block[blockIndex1[k][t]]
// A[k].block[j] <-> A[k].sp_block[blockIndex2[k][t]]
// B_{ij} <-> sparse_bMat.sp_ele[location_sparse_bMat[k][t]]
int SDP_nBlock; int* SDP_number;
int** SDP_constraint1; int** SDP_constraint2;
int** SDP_blockIndex1; int** SDP_blockIndex2;
int** SDP_location_sparse_bMat;
int SOCP_nBlock; int* SOCP_number;
int** SOCP_constraint1; int** SOCP_constraint2;
int** SOCP_blockIndex1; int** SOCP_blockIndex2;
int** SOCP_location_sparse_bMat;
int LP_nBlock; int* LP_number;
int** LP_constraint1; int** LP_constraint2;
int** LP_blockIndex1; int** LP_blockIndex2;
int** LP_location_sparse_bMat;
// from index of aggrigate sparsity pattern to index of sparse_bMat
// B_{ii} <-> sparse_bMat[diagonalIndex[i]]
int* diagonalIndex;
// j = ordering[i] means that ith index of bMat <-> F_j
int* ordering;
// i = ordering[j] means that ith index of bMat <-> F_j
int* reverse_ordering;
Newton();
Newton(int m,
int SDP_nBlock,int* SDP_blockStruct,
int SOCP_nBlock,int* SOCP_blockStruct,
int LP_nBlock);
~Newton();
void initialize(int m,
int SDP_nBlock,int* SDP_blockStruct,
int SOCP_nBlock,int* SOCP_blockStruct,
int LP_nBlock);
void terminate();
void initialize_dense_bMat(int m);
// 2008/03/12 kazuhide nakata
void initialize_sparse_bMat(int m, IV *newToOldIV, IVL *symbfacIVL);
// 2008/03/12 kazuhide nakata
void initialize_bMat(int m, Chordal& chordal, InputData& inputData,
FILE* fpOut);
void make_aggrigateIndex_SDP(InputData& inputData);
void make_aggrigateIndex_SOCP(InputData& inputData);
void make_aggrigateIndex_LP(InputData& inputData);
void make_aggrigateIndex(InputData& inputData);
void computeFormula_SDP(InputData& inputData,
mpf_class DenseRatio,mpf_class Kappa);
enum WHICH_DIRECTION {PREDICTOR, CORRECTOR};
void compute_rMat(WHICH_DIRECTION direction,
AverageComplementarity& mu,
DirectionParameter& beta,
Solutions& cuurentPt,
WorkVariables& work);
void Make_gVec(Newton::WHICH_DIRECTION direction,
InputData& inputData,
Solutions& currentPt,
Residuals& currentRes,
AverageComplementarity& mu,
DirectionParameter& beta,
Phase& phase,
WorkVariables& work,
ComputeTime& com);
void calF1(mpf_class& ret, DenseMatrix& G,
SparseMatrix& Aj);
void calF2(mpf_class& ret, DenseMatrix& F, DenseMatrix& G,
DenseMatrix& X, SparseMatrix& Aj, bool& hasF2Gcal);
void calF3(mpf_class& ret,
DenseMatrix& F, DenseMatrix& G,
DenseMatrix& X, DenseMatrix& invZ,
SparseMatrix& Ai, SparseMatrix& Aj);
// B_{i,j} = (X A_i Z^{-1}) \bullet A_j
void compute_bMat_dense_SDP(InputData& inputData,
Solutions& currentPt,
WorkVariables& work,
ComputeTime& com);
// B_{i,j} = (X A_i Z^{-1}) \bullet A_j
void compute_bMat_sparse_SDP(InputData& inputData,
Solutions& currentPt,
WorkVariables& work,
ComputeTime& com);
void compute_bMat_dense_SOCP(InputData& inputData,
Solutions& currentPt,
WorkVariables& work,
ComputeTime& com);
void compute_bMat_sparse_SOCP(InputData& inputData,
Solutions& currentPt,
WorkVariables& work,
ComputeTime& com);
void compute_bMat_dense_LP(InputData& inputData,
Solutions& currentPt,
WorkVariables& work,
ComputeTime& com);
void compute_bMat_sparse_LP(InputData& inputData,
Solutions& currentPt,
WorkVariables& work,
ComputeTime& com);
void Make_bMat(InputData& inputData,
Solutions& currentPt,
WorkVariables& work,
ComputeTime& com);
void permuteMat(DenseMatrix& bMat, SparseMatrix& sparse_bMat);
void permuteVec(Vector& gVec, Vector& gVec2);
void reverse_permuteVec(Vector& DyVec2, Vector& DyVec);
bool compute_DyVec(Newton::WHICH_DIRECTION direction,
InputData& inputData,
Solutions& currentPt,
WorkVariables& work,
ComputeTime& com);
void compute_DzMat(InputData& inputData,
Residuals& currentRes,
Phase& phase,
ComputeTime& com);
void compute_DxMat(Solutions& currentPt,
WorkVariables& work,
ComputeTime& com);
bool Mehrotra(WHICH_DIRECTION direction,
InputData& inputData,
Solutions& currentPt,
Residuals& currentRes,
AverageComplementarity& mu,
DirectionParameter& beta,
Switch& reduction,
Phase& phase,
WorkVariables& work,
ComputeTime& com);
void display(FILE* fpout=stdout);
void display_index(FILE* fpout=stdout);
void display_sparse_bMat(FILE* fpout=stdout);
};
}
#endif // __sdpa_newton_h__