-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsdpa_parts.h
228 lines (192 loc) · 6.94 KB
/
sdpa_parts.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
/* -------------------------------------------------------------
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_parts_h__
#define __sdpa_parts_h__
#include <sdpa_newton.h>
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 ComputeTime {
public:
double Predictor;
double Corrector;
double StepPredictor;
double StepCorrector;
double xMatTime;
double zMatTime;
double invzMatTime;
double xMatzMatTime;
double EigxMatTime;
double EigzMatTime;
double EigxMatzMatTime;
double makerMat;
double makebMat;
double B_DIAG;
double B_F1;
double B_F2;
double B_F3;
double B_PRE;
double makegVecMul;
double makegVec;
double choleskybMat;
double solve;
double sumDz;
double makedX;
double symmetriseDx;
double makedXdZ;
double updateRes;
double MainLoop;
double FileRead;
double FileCheck;
double FileChange;
double TotalTime;
ComputeTime();
~ComputeTime();
void display(FILE *fpout = stdout);
};
class Parameter {
public:
enum parameterType { PARAMETER_DEFAULT, PARAMETER_UNSTABLE_BUT_FAST, PARAMETER_STABLE_BUT_SLOW };
int maxIteration;
int precision;
double epsilonStar;
double lambdaStar;
double omegaStar;
double lowerBound;
double upperBound;
double betaStar;
double betaBar;
double gammaStar;
double epsilonDash;
#define PRINT_DEFAULT_LENGTH 30
static char xPRINT_DEFAULT[PRINT_DEFAULT_LENGTH];
static char XPRINT_DEFAULT[PRINT_DEFAULT_LENGTH];
static char YPRINT_DEFAULT[PRINT_DEFAULT_LENGTH];
static char infPRINT_DEFAULT[PRINT_DEFAULT_LENGTH];
char xPrint[PRINT_DEFAULT_LENGTH];
char XPrint[PRINT_DEFAULT_LENGTH];
char YPrint[PRINT_DEFAULT_LENGTH];
char infPrint[PRINT_DEFAULT_LENGTH];
Parameter();
Parameter(FILE *parameterFile);
~Parameter();
void setDefaultParameter(parameterType type = PARAMETER_DEFAULT);
void readFile(FILE *parameterFile);
void display(FILE *fpout = stdout, const char *printFormat = infPRINT_DEFAULT);
};
class StepLength {
public:
mpf_class primal;
mpf_class dual;
StepLength();
StepLength(mpf_class alphaP, mpf_class alphaD, int nBlock, int *blockStruct);
~StepLength();
void initialize(mpf_class alphaP, mpf_class alphaD);
void terminate();
static mpf_class minBlockVector(BlockVector &aVec);
void computeStepLength(Solutions ¤tPt, Newton &newton, WorkVariables &work, ComputeTime &com);
void MehrotraPredictor(InputData &inputData, Solutions ¤tPt, Phase &phase, Newton &newton, WorkVariables &work, ComputeTime &com);
void MehrotraCorrector(InputData &inputData, Solutions ¤tPt, Phase &phase, Switch &reduction, Newton &newton, AverageComplementarity &mu, RatioInitResCurrentRes &theta, WorkVariables &work, Parameter ¶m, ComputeTime &com);
void display(FILE *fpout = stdout);
};
class DirectionParameter {
public:
mpf_class value;
DirectionParameter(mpf_class betaStar = 0.0);
~DirectionParameter();
void initialize(mpf_class betaStar = 0.0);
void MehrotraPredictor(Phase &phase, Switch &reduction, Parameter ¶m);
void MehrotraCorrector(Phase &phase, StepLength &alpha, Solutions ¤tPt, Newton &newton, AverageComplementarity &mu, Parameter ¶m);
void display(FILE *fpout = stdout);
};
class Switch {
public:
enum SwitchType { ON, OFF };
SwitchType switchType;
Switch(SwitchType switchType = ON);
~Switch();
void initialize(SwitchType switchType = ON);
void MehrotraPredictor(Phase &phase);
void display(FILE *fpout = stdout);
};
class AverageComplementarity {
public:
mpf_class initial;
mpf_class current;
AverageComplementarity(mpf_class lambdaStar = 0.0);
~AverageComplementarity();
void initialize(mpf_class lambdaStar = 0.0);
void initialize(Solutions &initPt);
void update(Solutions ¤tPt);
void display(FILE *fpout = stdout);
};
class RatioInitResCurrentRes {
public:
mpf_class primal;
mpf_class dual;
RatioInitResCurrentRes();
RatioInitResCurrentRes(Parameter ¶m, Residuals &initRes);
~RatioInitResCurrentRes();
void initialize(Parameter ¶m, Residuals &initRes);
void update(Switch &reduction, StepLength &alpha);
void update_exact(Residuals &initRes, Residuals ¤tRes);
void display(FILE *fpout = stdout);
};
class SolveInfo {
public:
enum phaseType { noINFO, pFEAS, dFEAS, pdFEAS, pdINF, pFEAS_dINF, pINF_dFEAS, pdOPT, pUNBD, dUNBD };
mpf_class rho;
mpf_class etaPrimal;
mpf_class etaDual;
mpf_class objValPrimal;
mpf_class objValDual;
SolveInfo();
SolveInfo(InputData &inputData, Solutions ¤tPt, mpf_class mu0, mpf_class omegaStar);
~SolveInfo();
void initialize(InputData &inputData, Solutions ¤tPt, mpf_class mu0, mpf_class omegaStar);
void update(InputData &inputData, DenseLinearSpace &initPt_xMat, DenseLinearSpace &initPt_zMat, Solutions ¤tPt, Residuals ¤tRes, AverageComplementarity &mu, RatioInitResCurrentRes &theta, Parameter ¶m);
// assume initPt = lambda * I
void update(double &lambda, InputData &inputData, Solutions ¤tPt, Residuals ¤tRes, AverageComplementarity &mu, RatioInitResCurrentRes &theta, Parameter ¶m);
// check mu, gap, feasibility 2007/08/27
void check(InputData &inputData, Solutions ¤tPt, Residuals ¤tRes, AverageComplementarity &mu, RatioInitResCurrentRes &theta, Parameter ¶m);
void display(FILE *fpout = stdout);
};
class Phase {
public:
int nDim;
SolveInfo::phaseType value;
Phase();
Phase(Residuals &initRes, SolveInfo &solveInfo, Parameter ¶m, int nDim);
~Phase();
bool initialize(Residuals &initRes, SolveInfo &solveInfo, Parameter ¶m, int nDim);
bool updateCheck(Residuals ¤tRes, SolveInfo &solveInfo, Parameter ¶m);
void reverse();
void display(FILE *fpout = stdout);
};
} // namespace sdpa
#endif // __sdpa_parts_h__