Skip to content

Commit

Permalink
fixed get_rel_solution
Browse files Browse the repository at this point in the history
  • Loading branch information
hhijazi committed Sep 27, 2023
1 parent 6d5d145 commit 93c5de8
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/GurobiProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ class cuts: public GRBCallback
int soc_viol=0, soc_found=0,soc_added=0,det_viol=0, det_found=0, det_added=0;
int soc_viol_user=0, soc_found_user=0,soc_added_user=0,det_viol_user=0, det_found_user=0, det_added_user=0;


void update_rel_solution(){
size_t vid, vid_inst;
GRBVar gvar;
param_* v;
for(auto& v_p: m->_vars)
{
v = v_p.second.get();
auto idx = v->get_id();
auto dim = v->_dim[0];
for (auto i = 0; i < dim; i++) {
auto vid = idx + v->get_id_inst(i);
gvar = vars.at(vid);
v->set_double_val(i,getNodeRel(gvar));
}
}
}

void update_solution(){
size_t vid, vid_inst;
GRBVar gvar;
Expand Down Expand Up @@ -163,7 +181,7 @@ class cuts: public GRBCallback
if(nc%1==0){
add_bag_iteration=add_bag;
add_full_iteration=add_full;
update_solution();
update_rel_solution();
// m->compute_funcs();
if(add_soc){
auto res= m->cutting_planes_soc(1e-9, soc_found, soc_added);
Expand Down Expand Up @@ -584,7 +602,7 @@ bool GurobiProgram::solve(bool relax, double mipgap, double time_limit){

if(add_soc){

auto res= _model->cutting_planes_soc(1e-6, soc_found, soc_added);
auto res= _model->cutting_planes_soc(1e-9, soc_found, soc_added);
if(res.size()>=1){
add_cut=true;
for(auto i=0;i<res.size();i++){
Expand All @@ -608,7 +626,7 @@ bool GurobiProgram::solve(bool relax, double mipgap, double time_limit){
}
if(add_threed){

auto res= _model->cutting_planes_threed(1e-6, soc_found, soc_added);
auto res= _model->cutting_planes_threed(1e-9, soc_found, soc_added);
if(res.size()>=1){
add_cut=true;
for(auto i=0;i<res.size();i++){
Expand All @@ -629,7 +647,7 @@ bool GurobiProgram::solve(bool relax, double mipgap, double time_limit){

if(add_bag_iteration){

auto res=_model->cuts_eigen_bags(1e-6);
auto res=_model->cuts_eigen_bags(1e-9);
if(res.size()>=1){
add_cut=true;
for(auto i=0;i<res.size();i++){
Expand All @@ -651,7 +669,7 @@ bool GurobiProgram::solve(bool relax, double mipgap, double time_limit){
}

if(add_full_iteration){
auto res2=_model->cuts_eigen_full(1e-6);
auto res2=_model->cuts_eigen_full(1e-9);
if(res2.size()>=1){
add_cut=true;
for(auto i=0;i<res2.size();i++){
Expand Down

0 comments on commit 93c5de8

Please sign in to comment.