Commit 9865aa75 authored by Marcel Campen's avatar Marcel Campen

return final gap from Gurobi

git-svn-id: http://www.openflipper.org/svnrepo/CoMISo/trunk@296 1355f012-dd97-4b2f-ae87-10fa9f823a57
parent 99396cd6
......@@ -217,6 +217,20 @@ solve(NProblemInterface* _problem,
//-----------------------------------------------------------------------------
bool
GUROBISolver::
solve_two_phase(NProblemInterface* _problem, // problem instance
std::vector<NConstraintInterface*>& _constraints, // linear constraints
std::vector<PairIndexVtype>& _discrete_constraints, // discrete constraints
const double _time_limit0, // time limit phase 1 in seconds
const double _gap0, // MIP gap phase 1
const double _time_limit1, // time limit phase 2 in seconds
const double _gap1) // MIP gap phase 2
{
double dummy;
return solve_two_phase(_problem, _constraints, _discrete_constraints, _time_limit0, _gap0, _time_limit1, _gap1, dummy);
}
bool
GUROBISolver::
......@@ -226,7 +240,8 @@ solve_two_phase(NProblemInterface* _problem, //
const double _time_limit0, // time limit phase 1 in seconds
const double _gap0, // MIP gap phase 1
const double _time_limit1, // time limit phase 2 in seconds
const double _gap1) // MIP gap phase 2
const double _gap1, // MIP gap phase 2
double& _final_gap) //return final gap
{
try
{
......@@ -352,13 +367,15 @@ solve_two_phase(NProblemInterface* _problem, //
model.getEnv().set(GRB_DoubleParam_TimeLimit, _time_limit0);
model.getEnv().set(GRB_DoubleParam_MIPGap, _gap0);
model.optimize();
_final_gap = model.get(GRB_DoubleAttr_MIPGap);
// jump into phase 2?
if(model.get(GRB_DoubleAttr_MIPGap) > _gap1)
if(model.get(GRB_DoubleAttr_MIPGap) > _gap1 && _time_limit1 > 0)
{
model.getEnv().set(GRB_DoubleParam_TimeLimit, _time_limit1);
model.getEnv().set(GRB_DoubleParam_MIPGap, _gap1);
model.optimize();
_final_gap = model.get(GRB_DoubleAttr_MIPGap);
}
}
else
......
......@@ -76,6 +76,15 @@ public:
const double _gap0 = 0.001, // MIP gap phase 1
const double _time_limit1 = 120, // time limit phase 2 in seconds
const double _gap1 = 0.2 ); // MIP gap phase 2
bool solve_two_phase(NProblemInterface* _problem, // problem instance
std::vector<NConstraintInterface*>& _constraints, // linear constraints
std::vector<PairIndexVtype>& _discrete_constraints, // discrete constraints
const double _time_limit0, // time limit phase 1 in seconds
const double _gap0 , // MIP gap phase 1
const double _time_limit1, // time limit phase 2 in seconds
const double _gap1, // MIP gap phase 2
double& _final_gap); //return final gap
// optimization with additional lazy constraints that are only added iteratively to the problem if not satisfied
......
......@@ -191,6 +191,7 @@ solve(NProblemInterface* _problem,
while(!feasible_point_found && cur_pass <(_max_passes-1))
{
++cur_pass;
//----------------------------------------------------------------------------
// 1. Create an instance of current IPOPT NLP
......@@ -237,9 +238,7 @@ solve(NProblemInterface* _problem,
if(!lazy_added[i])
{
NConstraintInterface* lc = _lazy_constraints[i];
double v = lc->eval_constraint(&(np2->solution()[0]));
bool inf = false;
bool almost_inf = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment