40
40
namespace SHOT
41
41
{
42
42
43
- TaskPerformConvexBounding::TaskPerformConvexBounding (EnvironmentPtr envPtr) : TaskBase(envPtr) { }
43
+ TaskPerformConvexBounding::TaskPerformConvexBounding (EnvironmentPtr envPtr) : TaskBase(envPtr)
44
+ {
45
+ if (env->reformulatedProblem ->properties .numberOfNonlinearConstraints > 0 )
46
+ {
47
+ if (static_cast <ES_HyperplaneCutStrategy>(env->settings ->getSetting <int >(" CutStrategy" , " Dual" ))
48
+ == ES_HyperplaneCutStrategy::ESH)
49
+ {
50
+ tUpdateInteriorPoint = std::make_shared<TaskUpdateInteriorPoint>(env);
51
+ taskSelectHPPts = std::make_shared<TaskSelectHyperplanePointsESH>(env);
52
+ }
53
+ else
54
+ {
55
+ taskSelectHPPts = std::make_shared<TaskSelectHyperplanePointsECP>(env);
56
+ }
57
+ }
58
+
59
+ auto NLPProblemSource = static_cast <ES_PrimalNLPProblemSource>(
60
+ env->settings ->getSetting <int >(" FixedInteger.SourceProblem" , " Primal" ));
61
+
62
+ if (env->reformulatedProblem ->objectiveFunction ->properties .classification
63
+ > E_ObjectiveFunctionClassification::Quadratic)
64
+ {
65
+ taskSelectHPPtsByObjectiveRootsearch = std::make_shared<TaskSelectHyperplanePointsObjectiveFunction>(env);
66
+ }
67
+ }
44
68
45
69
TaskPerformConvexBounding::~TaskPerformConvexBounding () = default ;
46
70
@@ -80,7 +104,7 @@ void TaskPerformConvexBounding::run()
80
104
lastNumberOfHyperplanesWithConvexSource = env->solutionStatistics .numberOfHyperplanesWithConvexSource ;
81
105
lastNumberOfHyperplanesWithNonconvexSource = env->solutionStatistics .numberOfHyperplanesWithNonconvexSource ;
82
106
83
- env->output ->outputInfo (" Creating convex bounding problem " );
107
+ env->output ->outputInfo (" Convex bounding started " );
84
108
85
109
MIPSolverPtr MIPSolver;
86
110
@@ -148,15 +172,15 @@ void TaskPerformConvexBounding::run()
148
172
149
173
MIPSolver->setSolutionLimit (2100000000 );
150
174
151
- env->output ->outputInfo (fmt::format (" Convex bounding problem created. Number of hyperplanes added: {}/{}" ,
175
+ env->output ->outputInfo (fmt::format (" Problem created. Number of hyperplanes added: {}/{}" ,
152
176
numberHyperplanesAdded, env->dualSolver ->generatedHyperplanes .size ()));
153
177
auto solutionStatus = MIPSolver->solveProblem ();
154
178
155
179
auto solutionPoints = MIPSolver->getAllVariableSolutions ();
156
180
double objectiveBound = MIPSolver->getDualObjectiveValue ();
157
181
158
- env->output ->outputInfo (fmt::format (" Convex bounding problem solved with return code {} and objective "
159
- " bound {}. Number of solutions in solution pool: {}" ,
182
+ env->output ->outputInfo (fmt::format (
183
+ " Problem solved with return code {} and objective bound {}. Number of solutions in solution pool: {}" ,
160
184
(int )solutionStatus, objectiveBound, solutionPoints.size ()));
161
185
162
186
if (solutionPoints.size () > 0 )
@@ -174,6 +198,39 @@ void TaskPerformConvexBounding::run()
174
198
SOL.point .at (env->reformulatedProblem ->antiEpigraphObjectiveVariable ->index ) = objectiveValue;
175
199
}
176
200
201
+ int hyperplanesBefore = env->solutionStatistics .numberOfHyperplanesWithConvexSource
202
+ + env->solutionStatistics .numberOfHyperplanesWithNonconvexSource ;
203
+
204
+ if (env->reformulatedProblem ->properties .numberOfNonlinearConstraints > 0 )
205
+ {
206
+ if (static_cast <ES_HyperplaneCutStrategy>(env->settings ->getSetting <int >(" CutStrategy" , " Dual" ))
207
+ == ES_HyperplaneCutStrategy::ESH)
208
+ {
209
+ tUpdateInteriorPoint->run ();
210
+ static_cast <TaskSelectHyperplanePointsESH*>(taskSelectHPPts.get ())->run (solutionPoints);
211
+ }
212
+ else
213
+ {
214
+ static_cast <TaskSelectHyperplanePointsECP*>(taskSelectHPPts.get ())->run (solutionPoints);
215
+ }
216
+ }
217
+
218
+ if (env->reformulatedProblem ->objectiveFunction ->properties .classification
219
+ > E_ObjectiveFunctionClassification::Quadratic)
220
+ {
221
+ taskSelectHPPtsByObjectiveRootsearch->run (solutionPoints);
222
+ }
223
+
224
+ int hyperplanesAfter = env->solutionStatistics .numberOfHyperplanesWithConvexSource
225
+ + env->solutionStatistics .numberOfHyperplanesWithNonconvexSource ;
226
+
227
+ if (hyperplanesAfter > hyperplanesBefore)
228
+ {
229
+ env->output ->outputInfo (
230
+ fmt::format (" Added {} hyperplanes generated from convex bounding to the dual solver." ,
231
+ hyperplanesAfter - hyperplanesBefore));
232
+ }
233
+
177
234
env->primalSolver ->addPrimalSolutionCandidates (solutionPoints, E_PrimalSolutionSource::ConvexBounding);
178
235
179
236
for (auto & SOL : solutionPoints)
@@ -187,9 +244,9 @@ void TaskPerformConvexBounding::run()
187
244
}
188
245
189
246
if (currDual != env->results ->getGlobalDualBound ())
190
- env->output ->outputInfo (fmt::format (
191
- " Convex bounding returned new global dual bound {}. Old bound was {}. Absolute improvement: {}" ,
192
- env->results ->getGlobalDualBound (), currDual, std::abs (currDual - env->results ->getGlobalDualBound ())));
247
+ env->output ->outputInfo (
248
+ fmt::format ( " New global dual bound {}. Old bound was {}. Absolute improvement: {}" ,
249
+ env->results ->getGlobalDualBound (), currDual, std::abs (currDual - env->results ->getGlobalDualBound ())));
193
250
194
251
env->output ->outputInfo (" Convex bounding finished." );
195
252
}
0 commit comments