void BNC::configureCPLEX(){ op1=op2=0; //disable output //cplex->setOut(env->getNullStream()); //define a time limit execution cplex->setParam( IloCplex::TiLim, time_limit ); //disable presolve cplex->setParam( IloCplex::PreInd, false ); //assure linear mappings between the presolved and original models cplex->setParam( IloCplex::PreLinear, 0 ); //Turn on traditional search for use with control callback cplex->setParam( IloCplex::MIPSearch, IloCplex::Traditional); //Decides how often to apply the periodic heuristic. Setting the value to -1 turns off the periodic heuristic cplex->setParam( IloCplex::HeurFreq, 0 ); //CPX_PARAM_MIPCBREDLP equivalent is not availible in c++ api //cpx_ret = CPXsetintparam (env, CPX_PARAM_MIPCBREDLP, CPX_OFF); /* impressao para conferencia */ if (primal_heuristic) { //cout << "*** Primal Heuristic is going to be used." << endl; cplex->use(Rounddown(*env, *variables, graph, adj)); } cplex->setParam( IloCplex::FracCuts, -1 ); //disable cplex cutting separation cplex->setParam( IloCplex::CutsFactor, 1.0);//conferir valor //Decides whether or not Gomory fractional cuts should be generated for the problem: -1 disables cuts cplex->setParam( IloCplex::FracCuts, -1 ); //Controls whether CPLEX applies a local branching heuristic to try to improve new incumbents found during a MIP search cplex->setParam( IloCplex::LBHeur, false ); //Set the upper limit on the number of cutting plane passes CPLEX performs when solving the root node of a MIP model printf("N cortes %d\n", n_cortes); printf("MaxDeep %d\n", max_deep); //status = CPXsetintparam (env, CPX_PARAM_DATACHECK, CPX_ON); //actives the node callback MySelect cplex->use( MySelect( *env, ¤t_deep ) ); }
int main (int argc, char **argv) { IloEnv env; try { IloModel model(env); IloCplex cplex(env); if ( argc != 2 ) { usage (argv[0]); throw(-1); } IloObjective obj; IloNumVarArray var(env); IloRangeArray rng(env); cplex.importModel(model, argv[1], obj, var, rng); cplex.use(Rounddown(env, var)); cplex.extract(model); // Check model is all binary except for objective constant variable if ( cplex.getNbinVars() < cplex.getNcols() - 1 ) { cerr << "Problem contains non-binary variables, exiting." << endl; throw (-1); } cplex.setParam(IloCplex::Param::MIP::Strategy::Search, IloCplex::Traditional); cplex.solve(); IloNumArray vals(env); cplex.getValues(vals, var); env.out() << "Solution status = " << cplex.getStatus() << endl; env.out() << "Solution value = " << cplex.getObjValue() << endl; env.out() << "Values = " << vals << endl; } catch (IloException& e) { cerr << "Concert exception caught: " << e << endl; } catch (...) { cerr << "Unknown exception caught" << endl; } env.end(); return 0; } // END main