Skip to content

Commit 7defae3

Browse files
Add cuts generated for solutions to the bounding problem
1 parent 9527d88 commit 7defae3

File tree

3 files changed

+75
-16
lines changed

3 files changed

+75
-16
lines changed

src/DualSolver.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,7 @@ void DualSolver::checkDualSolutionCandidates()
115115
break;
116116
}
117117

118-
if(C.sourceType == E_DualSolutionSource::ConvexBounding)
119-
{
120-
env->output->outputInfo(fmt::format(" New dual bound {}, source: {}", C.objValue, sourceDesc));
121-
}
122-
else
123-
{
124-
env->output->outputDebug(fmt::format(" New dual bound {}, source: {}", C.objValue, sourceDesc));
125-
}
118+
env->output->outputDebug(fmt::format(" New dual bound {}, source: {}", C.objValue, sourceDesc));
126119
}
127120
}
128121

src/Tasks/TaskPerformConvexBounding.cpp

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,31 @@
4040
namespace SHOT
4141
{
4242

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+
}
4468

4569
TaskPerformConvexBounding::~TaskPerformConvexBounding() = default;
4670

@@ -80,7 +104,7 @@ void TaskPerformConvexBounding::run()
80104
lastNumberOfHyperplanesWithConvexSource = env->solutionStatistics.numberOfHyperplanesWithConvexSource;
81105
lastNumberOfHyperplanesWithNonconvexSource = env->solutionStatistics.numberOfHyperplanesWithNonconvexSource;
82106

83-
env->output->outputInfo(" Creating convex bounding problem");
107+
env->output->outputInfo(" Convex bounding started");
84108

85109
MIPSolverPtr MIPSolver;
86110

@@ -148,15 +172,15 @@ void TaskPerformConvexBounding::run()
148172

149173
MIPSolver->setSolutionLimit(2100000000);
150174

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: {}/{}",
152176
numberHyperplanesAdded, env->dualSolver->generatedHyperplanes.size()));
153177
auto solutionStatus = MIPSolver->solveProblem();
154178

155179
auto solutionPoints = MIPSolver->getAllVariableSolutions();
156180
double objectiveBound = MIPSolver->getDualObjectiveValue();
157181

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: {}",
160184
(int)solutionStatus, objectiveBound, solutionPoints.size()));
161185

162186
if(solutionPoints.size() > 0)
@@ -174,6 +198,39 @@ void TaskPerformConvexBounding::run()
174198
SOL.point.at(env->reformulatedProblem->antiEpigraphObjectiveVariable->index) = objectiveValue;
175199
}
176200

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+
177234
env->primalSolver->addPrimalSolutionCandidates(solutionPoints, E_PrimalSolutionSource::ConvexBounding);
178235

179236
for(auto& SOL : solutionPoints)
@@ -187,9 +244,9 @@ void TaskPerformConvexBounding::run()
187244
}
188245

189246
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())));
193250

194251
env->output->outputInfo(" Convex bounding finished.");
195252
}

src/Tasks/TaskPerformConvexBounding.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
#include "TaskCreateMIPProblem.h"
1818

19+
#include "TaskSelectHyperplanePointsObjectiveFunction.h"
20+
#include "TaskSelectHyperplanePointsESH.h"
21+
#include "TaskSelectHyperplanePointsECP.h"
22+
#include "TaskUpdateInteriorPoint.h"
23+
1924
namespace SHOT
2025
{
2126

@@ -33,5 +38,9 @@ class TaskPerformConvexBounding : public TaskBase
3338
int lastNumberOfHyperplanesWithConvexSource = 0;
3439
int lastNumberOfHyperplanesWithNonconvexSource = 0;
3540
int idleIterations = 0;
41+
42+
std::shared_ptr<TaskBase> taskSelectHPPts;
43+
std::shared_ptr<TaskSelectHyperplanePointsObjectiveFunction> taskSelectHPPtsByObjectiveRootsearch;
44+
std::shared_ptr<TaskUpdateInteriorPoint> tUpdateInteriorPoint;
3645
};
3746
} // namespace SHOT

0 commit comments

Comments
 (0)