From 787be6c3efb50cd1d9916e9a4cc3571db727b9e9 Mon Sep 17 00:00:00 2001 From: Gleb Belov Date: Tue, 27 Aug 2024 10:51:39 +1000 Subject: [PATCH] NL multiobj #237 #239 Only for NL solvers with linear obj (SCIP). For proper expressions in obj, need more work in the emulator --- include/mp/flat/constr_2_expr.h | 4 ++-- include/mp/flat/converter.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mp/flat/constr_2_expr.h b/include/mp/flat/constr_2_expr.h index bcccd2479..25ab7c982 100644 --- a/include/mp/flat/constr_2_expr.h +++ b/include/mp/flat/constr_2_expr.h @@ -353,11 +353,11 @@ class Constraints2Expr { pre::AutoLinkScope auto_link_scope{ *(Impl*)this, obj_src }; if (qobj.GetQPTerms().empty()) exprResVar = MPD( AssignResultVar2Args( - LinearFunctionalConstraint{ {lt_in_expr, 1.0} } ) ); + LinearFunctionalConstraint{ {lt_in_expr, 0.0} } ) ); else // Move QP terms into the expr exprResVar = MPD( AssignResultVar2Args( QuadraticFunctionalConstraint - { {{lt_in_expr, std::move(qobj.GetQPTerms())}, 1.0} } ) ); + { {{lt_in_expr, std::move(qobj.GetQPTerms())}, 0.0} } ) ); MPD( AddInitExprContext(exprResVar, // Context is compulsory obj::MAX==qobj.obj_sense_true() // no need to propagate ? Context::CTX_POS : Context::CTX_NEG) ); diff --git a/include/mp/flat/converter.h b/include/mp/flat/converter.h index a25f551f6..369af7aa9 100644 --- a/include/mp/flat/converter.h +++ b/include/mp/flat/converter.h @@ -273,13 +273,13 @@ class FlatConverter : constr_depth_ = 1; // Workaround. TODO have maps as special constraints MP_DISPATCH( ConvertMaps() ); MP_DISPATCH( PreprocessFlatFinal() ); // final flat model prepro - MP_DISPATCH( ConsiderEmulatingMultiobj() ); if constexpr (IfAcceptingNLOutput()) { if (IfWantNLOutput()) { MPD( Convert2NL() ); MPD( PreprocessNLFinal() ); } } + MP_DISPATCH( ConsiderEmulatingMultiobj() ); // After NL conversion } catch (const ConstraintConversionFailure& cff) { MP_RAISE(cff.message()); }