From 0a6b7767d1e3b7d43a8e7453417f63984b43b3d2 Mon Sep 17 00:00:00 2001 From: Gleb Belov Date: Mon, 26 Aug 2024 13:29:44 +1000 Subject: [PATCH] Fix true obj sense init #239 #240 --- include/mp/flat/constr_2_expr.h | 7 ++++--- include/mp/flat/obj_std.h | 2 +- solvers/scipmp/scipmpmodelapi.cc | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/mp/flat/constr_2_expr.h b/include/mp/flat/constr_2_expr.h index ed0b2cb80..81bc5f500 100644 --- a/include/mp/flat/constr_2_expr.h +++ b/include/mp/flat/constr_2_expr.h @@ -114,8 +114,10 @@ class Constraints2Expr { int i, ConstraintAcceptanceLevel , ExpressionAcceptanceLevel eal) { assert(stage_cvt2expr_>0 && stage_cvt2expr_<=2); - if (ExpressionAcceptanceLevel::NotAccepted != eal) { // going into an expr - if (1==stage_cvt2expr_) { // otherwise it's a flat con + // See if the item is going into an expr. + // Otherwise it's a flat con. + if (ExpressionAcceptanceLevel::NotAccepted != eal) { + if (1==stage_cvt2expr_) { if (!con.GetConstraint().GetBody().is_variable()) { // already a variable ConvertConditionalConLHS(con, i); return true; @@ -343,7 +345,6 @@ class Constraints2Expr { int exprResVar = -1; if (lt_in_expr.is_variable() && qobj.GetQPTerms().empty()) { exprResVar = lt_in_expr.get_representing_variable(); - // assert( !MPCD( IsProperVar(exprResVar) ) ); // is an expr } else { // We need a new expression // Set up AutoLink auto obj_src = // source value node for this obj diff --git a/include/mp/flat/obj_std.h b/include/mp/flat/obj_std.h index 2754896b8..58cf12bbb 100644 --- a/include/mp/flat/obj_std.h +++ b/include/mp/flat/obj_std.h @@ -21,7 +21,7 @@ class LinearObjective { class VarVec=std::initializer_list > LinearObjective(obj::Type s, CoefVec&& c, VarVec&& v, std::string nm = {}) noexcept : - sense_(s), + sense_(s), sense_true_(s), lt_(std::forward(c), std::forward(v)), name_(std::move(nm)){ } /// Get original sense diff --git a/solvers/scipmp/scipmpmodelapi.cc b/solvers/scipmp/scipmpmodelapi.cc index a3f6a75da..f81d20f91 100644 --- a/solvers/scipmp/scipmpmodelapi.cc +++ b/solvers/scipmp/scipmpmodelapi.cc @@ -44,7 +44,7 @@ void ScipModelAPI::AddVariables(const VarArrayDef& v) { void ScipModelAPI::SetLinearObjective( int iobj, const LinearObjective& lo ) { if (iobj<1) { - SCIP_CCALL( SCIPsetObjsense(getSCIP(), + SCIP_CCALL( SCIPsetObjsense(getSCIP(), obj::Type::MAX==lo.obj_sense() ? SCIP_OBJSENSE_MAXIMIZE : SCIP_OBJSENSE_MINIMIZE) ); SCIP_VAR** vars = getPROBDATA()->vars; for (int i = 0; i < getPROBDATA()->nvars; i++) {