Example #1
0
//implementation of the solver by CLQ model + b&c
void BNC::solveCLQBC(){
	
	buildModelCF();
	
	cplex->use( CtCallback(*env, *variables, graph, n_cortes, max_deep ) );
	try{
		if( !cplex->solve() ){
			env->error() << "Failed to optimize LP" << endl;
			throw(-1);
		}
		}catch (IloException &e){
			env->error() << e.getMessage();
		}
	printResult();
}
Example #2
0
int
main(int argc, char** argv)
{
   IloEnv env;
   try {
      IloModel m(env);
      IloCplex cplex(env);
    
      IloObjective   obj;
      IloNumVarArray var(env);
      IloRangeArray  con(env);

      const char* datadir = (argc >= 2) ? argv[1] : "../../../examples/data";
      char *fname = new char[strlen(datadir) + 1 + strlen("noswot.mps") + 1];
      sprintf(fname, "%s/noswot.mps", datadir);
      env.out() << "reading " << fname << endl;
      cplex.importModel(m, fname, obj, var, con);
      delete[] fname;
    
      env.out() << "constructing cut callback ..." << endl;
      
      IloExprArray lhs(env);
      IloNumArray  rhs(env);
      makeCuts(var, lhs, rhs);
      cplex.use(CtCallback(env, lhs, rhs, cplex.getParam(
         IloCplex::Param::Simplex::Tolerances::Feasibility)));
    
      env.out() << "extracting model ..." << endl;
      cplex.extract(m);
    
      cplex.setParam(IloCplex::Param::MIP::Interval, 1000);
      cplex.setParam(IloCplex::Param::MIP::Strategy::Search,
                     IloCplex::Traditional);
      env.out() << "solving model ...\n";
      cplex.solve();
      env.out() << "solution status is " << cplex.getStatus() << endl;
      env.out() << "solution value  is " << cplex.getObjValue() << endl;
   }
   catch (IloException& ex) {
      cerr << "Error: " << ex << endl;
   }
   env.end();
   return 0;
}