Merge pull request #4030 from rte-france/fix/xpress-starting-basis-on-gmain
improve performance of Xpress interface and fix bug
This commit is contained in:
@@ -840,8 +840,7 @@ XpressInterface::XpressInterface(MPSolver* const solver, bool mip)
|
||||
mLp(nullptr),
|
||||
mMip(mip),
|
||||
supportIncrementalExtraction(false),
|
||||
slowUpdates(static_cast<SlowUpdates>(SlowSetObjectiveCoefficient |
|
||||
SlowClearObjective)),
|
||||
slowUpdates(SlowClearObjective),
|
||||
mapStringControls_(getMapStringControls()),
|
||||
mapDoubleControls_(getMapDoubleControls()),
|
||||
mapIntegerControls_(getMapIntControls()),
|
||||
@@ -1728,7 +1727,7 @@ void XpressInterface::SetLpAlgorithm(int value) {
|
||||
std::vector<int> XpressBasisStatusesFrom(
|
||||
const std::vector<MPSolver::BasisStatus>& statuses) {
|
||||
std::vector<int> result;
|
||||
result.reserve(statuses.size());
|
||||
result.resize(statuses.size());
|
||||
std::transform(statuses.cbegin(), statuses.cend(), result.begin(),
|
||||
MPSolverToXpressBasisStatus);
|
||||
return result;
|
||||
|
||||
@@ -329,6 +329,31 @@ TEST(XpressInterface, LpStartingBasis) {
|
||||
EXPECT_LT(iterWithBasis, 10);
|
||||
}
|
||||
|
||||
TEST(XpressInterface, LpStartingBasisNoIterationsIfBasisIsProvided) {
|
||||
UNITTEST_INIT_LP();
|
||||
buildLargeLp(solver, 1000);
|
||||
// First, we record the number of iterations without an initial basis
|
||||
solver.Solve();
|
||||
|
||||
// Then, we retrieve the final basis
|
||||
std::vector<MPSolver::BasisStatus> varStatus, constrStatus;
|
||||
for (auto* var : solver.variables()) {
|
||||
varStatus.push_back(var->basis_status());
|
||||
}
|
||||
for (auto* constr : solver.constraints()) {
|
||||
constrStatus.push_back(constr->basis_status());
|
||||
}
|
||||
|
||||
MPSolver solver_BasisProvided("XPRESS_LP", MPSolver::XPRESS_LINEAR_PROGRAMMING);
|
||||
buildLargeLp(solver_BasisProvided, 1000);
|
||||
solver_BasisProvided.SetStartingLpBasis(varStatus, constrStatus);
|
||||
solver_BasisProvided.Solve();
|
||||
const auto iterWithBasis = solver_BasisProvided.iterations();
|
||||
// ...and finally check that no iteration has been performed
|
||||
EXPECT_EQ(iterWithBasis, 0);
|
||||
}
|
||||
|
||||
|
||||
TEST(XpressInterface, NumVariables) {
|
||||
UNITTEST_INIT_MIP();
|
||||
MPVariable* x1 = solver.MakeNumVar(-1., 5.1, "x1");
|
||||
|
||||
Reference in New Issue
Block a user