diff --git a/examples/Optimization/MINLP/LABS/LABS.cpp b/examples/Optimization/MINLP/LABS/LABS.cpp index 1f426003..ba2818df 100644 --- a/examples/Optimization/MINLP/LABS/LABS.cpp +++ b/examples/Optimization/MINLP/LABS/LABS.cpp @@ -39,7 +39,7 @@ int main(int argc, char * argv[]){ if(new_algorithm){ vector> models; - for (int i = 0; i M("LABS_"+to_string(n)+"_"+to_string(i)); models.push_back(M); @@ -64,9 +64,9 @@ int main(int argc, char * argv[]){ M_obj.add(s.in(s_ids)); M_obj.add(c.in(c_ids)); indices pairs("pairs"), quad_terms("quad_terms"), multi_terms("multi_terms"), multi_quad_terms("multi_quad_terms"); - func obj; + func<> obj; for (int k = 1; k<=n-1; k++) { - func cterm; + func<> cterm; for (int i = 0; i z_def("z_def"); - z_def = z - (2*y.from(z_ids) - 1)*(2*y.to(z_ids) - 1); - M.add(z_def.in(z_ids) == 0); +// Constraint<> z_def("z_def"); +// z_def = z - (2*y.from(z_ids) - 1)*(2*y.to(z_ids) - 1); +// M.add(z_def.in(z_ids) == 0); indices z_sum("z_sum"); + indices y_sum_fr("y_sum_fr"), y_sum_to("y_sum_to"); + param<> rhs("rhs"); + rhs.in(c_ids); for (int k = 1; k<=n-1; k++) { for (int i = 0; i c_def("c_def"); - c_def = c - z.in(z_sum); +// c_def = c - z.in(z_sum); + c_def = c - (2*y.in(y_sum_fr) - 1)*(2*y.in(y_sum_to) - 1) - rhs; M.add(c_def.in(c_ids) == 0); + Constraint<> c_fix("c_fix"); + c_fix = c[1]; + M.add(c_fix == 1); + // Constraint<> cs_def("cs_def"); // cs_def = cs - c*c; // m.add(cs_def.in(c_ids) >= 0); @@ -179,15 +192,16 @@ int main(int argc, char * argv[]){ ones.in(c_ids); ones = 1; M.min(ones.tr()*c*c); - + M.print(); solver<> mip_solver(M,gurobi); // solver<> nlp_solver(M,ipopt); - mip_solver.run(); + mip_solver.run(1e-6, 120); // nlp_solver.run(); // M.print_solution(); // M.round_solution(); + opt_obj = round(M.get_obj_val()); M.print_solution(); - opt_obj = M.get_obj_val(); + } double total_time_end = get_wall_time(); auto total_time = total_time_end - total_time_start; diff --git a/include/gravity/solver.h b/include/gravity/solver.h index 9ab3efd1..bf396843 100755 --- a/include/gravity/solver.h +++ b/include/gravity/solver.h @@ -211,7 +211,7 @@ class solver { } int run(type tol , double time_limit){ - return run(5, tol, 10000, 1e-6, true, {false,""}, time_limit); + return run(5, tol, 10000, 1e-6, false, {false,""}, time_limit); } //OPF.run(tol,time_limit,"ma97"); diff --git a/src/GurobiProgram.cpp b/src/GurobiProgram.cpp index a1e2cf83..2e1ca0bf 100755 --- a/src/GurobiProgram.cpp +++ b/src/GurobiProgram.cpp @@ -502,8 +502,8 @@ bool GurobiProgram::solve(bool relax, double mipgap, double time_limit){ // grb_mod->getEnv().set(GRB_IntParam_Method, 1); // grb_mod->getEnv().set(GRB_IntParam_NodeMethod, 1); grb_mod->getEnv().set(GRB_IntParam_LazyConstraints, 1); -// grb_mod->set(GRB_IntParam_Threads, 8); - grb_mod->set(GRB_IntParam_NonConvex,2); + grb_mod->set(GRB_IntParam_Threads, 8); +// grb_mod->set(GRB_IntParam_NonConvex,2); // grb_mod->set(GRB_DoubleParam_IntFeasTol, 1e-9); // grb_mod->set(GRB_IntParam_NumericFocus,3); // grb_mod->set(GRB_IntParam_PreCrush,0);