Skip to content

Commit

Permalink
Fix true obj sense init #239 #240
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbelov committed Aug 26, 2024
1 parent 98e97c0 commit 0a6b776
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions include/mp/flat/constr_2_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/mp/flat/obj_std.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class LinearObjective {
class VarVec=std::initializer_list<int> >
LinearObjective(obj::Type s, CoefVec&& c, VarVec&& v,
std::string nm = {}) noexcept :
sense_(s),
sense_(s), sense_true_(s),
lt_(std::forward<CoefVec>(c), std::forward<VarVec>(v)),
name_(std::move(nm)){ }
/// Get original sense
Expand Down
2 changes: 1 addition & 1 deletion solvers/scipmp/scipmpmodelapi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit 0a6b776

Please sign in to comment.