@@ -66,6 +66,35 @@ TaskPerformConvexBounding::TaskPerformConvexBounding(EnvironmentPtr envPtr, bool
66
66
taskSelectHPPtsByObjectiveRootsearch = std::make_shared<TaskSelectHyperplanePointsObjectiveFunction>(env);
67
67
}
68
68
69
+ #ifdef HAS_CPLEX
70
+ if (env->results ->usedMIPSolver == ES_MIPSolver::Cplex)
71
+ {
72
+ MIPSolver = MIPSolverPtr (std::make_shared<MIPSolverCplex>(env));
73
+ }
74
+ #endif
75
+
76
+ #ifdef HAS_GUROBI
77
+ if (env->results ->usedMIPSolver == ES_MIPSolver::Gurobi)
78
+ {
79
+ MIPSolver = MIPSolverPtr (std::make_shared<MIPSolverGurobi>(env));
80
+ }
81
+ #endif
82
+
83
+ #ifdef HAS_CBC
84
+ if (env->results ->usedMIPSolver == ES_MIPSolver::Cbc)
85
+ {
86
+ MIPSolver = MIPSolverPtr (std::make_shared<MIPSolverCbc>(env));
87
+ }
88
+ #endif
89
+
90
+ assert (MIPSolver);
91
+
92
+ if (!MIPSolver->initializeProblem ())
93
+ throw Exception (" Cannot initialize selected MIP solver." );
94
+
95
+ taskCreateMIPProblem = std::make_shared<TaskCreateMIPProblem>(env, MIPSolver, env->reformulatedProblem );
96
+ taskCreateMIPProblem->run ();
97
+
69
98
env->timing ->stopTimer (" ConvexBounding" );
70
99
}
71
100
@@ -108,48 +137,19 @@ void TaskPerformConvexBounding::run()
108
137
else
109
138
env->output ->outputInfo (" Convex bounding started" );
110
139
111
- MIPSolverPtr MIPSolver;
112
-
113
- #ifdef HAS_CPLEX
114
- if (env->results ->usedMIPSolver == ES_MIPSolver::Cplex)
115
- {
116
- MIPSolver = MIPSolverPtr (std::make_shared<MIPSolverCplex>(env));
117
- }
118
- #endif
119
-
120
- #ifdef HAS_GUROBI
121
- if (env->results ->usedMIPSolver == ES_MIPSolver::Gurobi)
122
- {
123
- MIPSolver = MIPSolverPtr (std::make_shared<MIPSolverGurobi>(env));
124
- }
125
- #endif
126
-
127
- #ifdef HAS_CBC
128
- if (env->results ->usedMIPSolver == ES_MIPSolver::Cbc)
129
- {
130
- MIPSolver = MIPSolverPtr (std::make_shared<MIPSolverCbc>(env));
131
- }
132
- #endif
133
-
134
- assert (MIPSolver);
135
-
136
- if (!MIPSolver->initializeProblem ())
137
- throw Exception (" Cannot initialize selected MIP solver." );
138
-
139
- taskCreateMIPProblem = std::make_shared<TaskCreateMIPProblem>(env, MIPSolver, env->reformulatedProblem );
140
- taskCreateMIPProblem->run ();
141
-
142
140
int numberHyperplanesAdded = 0 ;
143
141
144
- for (auto HP : env->dualSolver ->generatedHyperplanes )
142
+ for (int i = lastAddedHyperplane; i < env->dualSolver ->generatedHyperplanes . size (); ++i )
145
143
{
146
- if (HP .isSourceConvex )
144
+ if (env-> dualSolver -> generatedHyperplanes [i] .isSourceConvex )
147
145
{
148
- if (MIPSolver->createHyperplane ((Hyperplane)HP ))
146
+ if (MIPSolver->createHyperplane ((Hyperplane)env-> dualSolver -> generatedHyperplanes [i] ))
149
147
numberHyperplanesAdded++;
150
148
}
151
149
}
152
150
151
+ int lastAddedHyperplane = env->dualSolver ->generatedHyperplanes .size ();
152
+
153
153
double currDual = env->results ->getGlobalDualBound ();
154
154
155
155
int iterationNumber = env->results ->getCurrentIteration ()->iterationNumber ;
@@ -302,15 +302,15 @@ void TaskPerformConvexBounding::run()
302
302
{
303
303
env->output ->outputInfo (fmt::format (" x Convex bounding finished with new global dual bound {}. Old bound "
304
304
" was {}. Absolute improvement: {}" ,
305
- env-> results -> getGlobalDualBound () , currDual, std::abs (currDual - env->results ->getGlobalDualBound ())));
305
+ objectiveBound , currDual, std::abs (currDual - env->results ->getGlobalDualBound ())));
306
306
307
307
env->solutionStatistics .numberOfDualImprovementsAfterConvexBounding ++;
308
308
}
309
309
else
310
310
{
311
311
env->output ->outputInfo (
312
312
fmt::format (" Convex bounding finished with dual bound {}. No improvement over old bound {}" ,
313
- currDual , env->results ->getGlobalDualBound ()));
313
+ objectiveBound , env->results ->getGlobalDualBound ()));
314
314
}
315
315
316
316
lastNumberOfHyperplanesWithConvexSource = env->solutionStatistics .numberOfHyperplanesWithConvexSource ;
0 commit comments