Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ampl/mp into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mapgccv committed Jun 17, 2024
2 parents da2ac51 + 483a2a3 commit 944a9d2
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/mp/flat/converter_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ class FlatModel

mapi.InitProblemModificationPhase(GetModelInfo());
PushVariablesTo(mapi);
PushCustomConstraintsTo(mapi);
if (!if_skip_pushing_objs())
PushObjectivesTo(mapi);
PushCustomConstraintsTo(mapi);
mapi.FinishProblemModificationPhase();
}

Expand Down
19 changes: 10 additions & 9 deletions include/mp/flat/converter_multiobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,12 @@ class MOManager {
std::function<sol::Status(void)> get_stt, std::function<Solution(void)> get_sol) {
if (++i_current_obj_ >= obj_new_.size()) {
status_ = MOManagerStatus::FINISHED;
MPD( GetEnv() ).Print(
"\n\n"
"==============================================================================\n"
"MULTI-OBJECTIVE MODE: done.\n\n");
return false; // all done
if (MPD( GetEnv() ).verbose_mode())
MPD( GetEnv() ).Print(
"\n\n"
"==============================================================================\n"
"MULTI-OBJECTIVE MODE: done.\n\n");
return false; // all done
}
if (MPD( GetEnv() ).verbose_mode())
MPD( GetEnv() ).Print(
Expand Down Expand Up @@ -216,17 +217,17 @@ class MOManager {
if (obj_last.GetQPTerms().size()) {
if (obj::MAX == obj_last.obj_sense())
MPD( AddConstraint(
QuadConGE{ { obj_last.GetLinTerms(), obj_last.GetQPTerms() }, objval_last_ } ) );
QuadConGE{ { obj_last.GetLinTerms(), obj_last.GetQPTerms() }, lim } ) );
else
MPD( AddConstraint(
QuadConLE{ { obj_last.GetLinTerms(), obj_last.GetQPTerms() }, objval_last_ } ) );
QuadConLE{ { obj_last.GetLinTerms(), obj_last.GetQPTerms() }, lim } ) );
} else {
if (obj::MAX == obj_last.obj_sense())
MPD( AddConstraint(
LinConGE{ { obj_last.GetLinTerms() }, objval_last_ } ) );
LinConGE{ { obj_last.GetLinTerms() }, lim } ) );
else
MPD( AddConstraint(
LinConLE{ { obj_last.GetLinTerms() }, objval_last_ } ) );
LinConLE{ { obj_last.GetLinTerms() }, lim } ) );
}
}

Expand Down
7 changes: 5 additions & 2 deletions solvers/gurobi/gurobibackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2102,8 +2102,11 @@ void GurobiBackend::InitCustomOptions() {
/// std feature MULTIOBJ is set.
/// Change the help text
AddToOptionDescription("obj:multi",
"The objectives must all be linear. Objective-specific "
"convergence tolerances and method values may be assigned via "
"Degradation suffixes .objabstol, .objreltol are handled "
"differently for LP, see Gurobi documentation.\n\n"
"The objectives must all be linear.\n\n"
"Objective-specific "
"tolerances and method values may be assigned via "
"keywords of the form obj_n_<name>, such as obj_1_method for the "
"first objective.");

Expand Down
30 changes: 30 additions & 0 deletions test/end2end/cases/categorized/fast/multi_obj/modellist.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,36 @@
"_sobj[4]": 32.604395604395606
}
},
{
"name" : "multiobj_abstol_MIP",
"tags" : ["linear", "integer", "multiobj"],
"options": {
"ANYSOLVER_options": "multiobj=1",
"gurobi_options": "multiobj=1 mip:gap=0"
},
"values": {
"_sobj[1]": 2.75,
"_sobj[2]": 3.5
}
},
{
"name" : "multiobj_reltol_MIP",
"tags" : ["linear", "integer", "multiobj"],
"options": {
"ANYSOLVER_options": "multiobj=1",
"gurobi_options": "multiobj=1 mip:gap=0"
},
"values": {
"_sobj[1]": 2.75,
"_sobj[2]": 3.5
}
},
{
"name" : "multiobj_abstol_manual.run",
"tags" : ["linear"],
"files": ["multiobj_abstol_manual.run"],
"objective": 3.5
},
{
"name" : "obj_suf_01 multiobj=0",
"tags" : ["linear", "continuous", "multiobj"],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

var x;
var y;
var z integer; # For Gurobi to handle AbsTol in direct way

maximize xobj: x;
minimize yobj: y;

subj to c1: y >= x;
subj to c2: y <= x + 1;

subj to c3: y <= 2*x;
subj to c4: y >= 2*x - 2;

subj to c5_keep_z: y >= z;

suffix objpriority IN;
suffix objabstol IN;

let xobj.objpriority := 10;
let yobj.objpriority := 1;

let xobj.objabstol := 0.25;

# Need mip:gap=0 due to the way tolerances are applied:
# https://www.gurobi.com/documentation/current/refman/working_with_multiple_obje.html.
# option gurobi_options "obj:multi=1 writeprob=multiobj1_MIP.lp mip:gap=0";
# option solver gurobi;

# solve;
# display x, y, z;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

var x;
var y;

maximize xobj: x;
minimize yobj: y;

subj to c1: y >= x;
subj to c2: y <= x + 1;

subj to c3: y <= 2*x;
subj to c4: y >= 2*x - 2;

option solver gurobi;
solve xobj;
# display x, y;

subj to tol: x >= x.val - 0.25;
solve yobj;
# display x, y;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

var x;
var y;
var z integer; # For Gurobi to handle AbsTol in direct way

maximize xobj: x;
minimize yobj: y;

subj to c1: y >= x;
subj to c2: y <= x + 1;

subj to c3: y <= 2*x;
subj to c4: y >= 2*x - 2;

subj to c5_keep_z: y >= z;

suffix objpriority IN;
suffix objreltol IN;

let xobj.objpriority := 10;
let yobj.objpriority := 1;

let xobj.objreltol:= 0.25/3;

# Need mip:gap=0 due to the way tolerances are applied:
# https://www.gurobi.com/documentation/current/refman/working_with_multiple_obje.html.
# option gurobi_options "obj:multi=1 writeprob=multiobj1_MIP.lp mip:gap=0";
# option solver gurobi;

# solve;
# display x, y, z;

0 comments on commit 944a9d2

Please sign in to comment.