コード例 #1
0
void displayResults(IloCplex& cplex,
                    IloNumVarArray inside,
                    IloNumVarArray outside) {
   cout << "cost: " << cplex.getObjValue() << endl;
   for(IloInt p = 0; p < nbProds; p++) {
      cout << "P" << p << endl;
      cout << "inside:  " << cplex.getValue(inside[p]) << endl;
      cout << "outside: " << cplex.getValue(outside[p]) << endl;
   }
}
コード例 #2
0
ファイル: Functions.cpp プロジェクト: trungda/BioScheduling
void PrintStorageBindingResult(BoolVar3DMatrix R, map<int, string> start_time_rev, IloCplex cplex){
  double R_[n_m][E][T_MAX];
  for(int p = 0; p < n_m; p++){
    for(int e = 0; e < E; e++){
      for(int t = 0; t < T_MAX; t++){
        R_[p][e][t] = cplex.getValue(R[p][e][t]);
      }
    }
  }

  cout << "STORAGE BINDING RESULTS" << endl;
  for(int p = 0; p < n_m; p++){
    cout << "Module-" << p << " ";
    for(int e = 0; e < E; e++){
      for(int t = 0; t < T_MAX; t++){
        if(R_[p][e][t] == 1){
          cout << "(" <<start_time_rev[edges.at(e).first] << "-" << start_time_rev[edges.at(e).second] <<  ")" <<":" << t << " ";
        }
      }
    }
    cout << endl;
  }
  cout << endl;
  return;
}
コード例 #3
0
ファイル: kMST_ILP.cpp プロジェクト: schuay/algorithmics
static void print_values(IloCplex &cplex, const IloIntVarArray *xs)
{
	for (u_int i = 0; i < xs->getSize(); i++) {
		const int v = cplex.getValue((*xs)[i]);
		if (v == 0) {
			continue;
		}
		cout << (*xs)[i] << " = " << v << endl;
	}
}
コード例 #4
0
ファイル: Functions.cpp プロジェクト: trungda/BioScheduling
void PrintSchedulingResult(IloNumVarArray s, map<int, string> start_time_rev, IloCplex cplex){
  vector<double> s_;
  for(int i = 0; i <= n; i++){
    s_.push_back(cplex.getValue(s[i]));
  }

  cout << "\nSCHEDULING RESULTS" << endl;
  map<string, int>::iterator it;
  for(it = start_time.begin(); it != start_time.end(); it++){
    cout << it->first << setw(4) << s_.at(it->second) << endl;
  }
  cout << endl;
  return;
}
コード例 #5
0
ファイル: cplex_utils.cpp プロジェクト: Razzis/projet_ECMA
DataNumMatrix DataVarBoolMatrix::ExtractSol(IloEnv env, IloCplex cplex, Solution& sol){
	DataNumMatrix x_ij(env,sol.get_inst().get_n(),sol.get_inst().get_m());
	double Ca_x = 0;
	double Cp_x = 0;

	double CaHa_x = 0;
	double CpHp_x = 0;

	//int Cost = 0;


	for(int i = 1; i <= sol.get_inst().get_n(); i++){
		for(int j = 1; j <= sol.get_inst().get_m(); j++){
			Coordinate coord(i,j);
			//if(cplex.getValue(this->Matrix[i-1][j-1]) == 1)
			//	Cost++;
			Ca_x += sol.get_inst().get_grille(coord).get_Ca()*cplex.getValue(this->Matrix[i-1][j-1]);
			Cp_x += sol.get_inst().get_grille(coord).get_Cp()*cplex.getValue(this->Matrix[i-1][j-1]);

			CaHa_x += sol.get_inst().get_grille(coord).get_Ha()*sol.get_inst().get_grille(coord).get_Ca()*cplex.getValue(this->Matrix[i-1][j-1]);
			CpHp_x += sol.get_inst().get_grille(coord).get_Hp()*sol.get_inst().get_grille(coord).get_Cp()*cplex.getValue(this->Matrix[i-1][j-1]);

			sol.set_Choix_maille(coord) = cplex.getValue(this->Matrix[i-1][j-1]);
			x_ij[coord] = cplex.getValue(this->Matrix[i-1][j-1]);
		}
	}

	//sol.set_cost() = Cost;

	sol.set_Ha() = CaHa_x/Ca_x;
	sol.set_Hp() = CpHp_x/Cp_x;



	return x_ij;
}
コード例 #6
0
ファイル: cplex_utils.cpp プロジェクト: Razzis/projet_ECMA
bool DataVarBoolTriMatrix::ExtractSol(IloEnv env, IloCplex cplex){
	for(int l = 0; l < this->k; l++){
		cout << "S : " << l << endl;
		cout << "----------------------" << endl;
 		for(int j = 1; j <= this->m; j++){
			for(int i = 1; i <= this->n; i++){

					cout << int(cplex.getValue(this->Matrix[i-1][j-1][l])) ;
			}
			cout << endl;
		}
 		cout << "----------------------" << endl;
	}
	return true;
}
コード例 #7
0
ファイル: cplex_utils.cpp プロジェクト: Razzis/projet_ECMA
DataNumMatrix DataVarBoolTriMatrix::ExtractSumK(IloEnv env, IloCplex cplex){
	DataNumMatrix res(env,this->n, this->m);

	for(int j = 1; j <= this->m; j++){
		for(int i = 1; i <= this->n; i++){
			Coordinate coord(i,j);
			res[coord] = 0;
			for(int l = 0; l < this->k; l++){
				res[coord] += cplex.getValue(this->get(i,j,l));

			}
		}
	}
	return res;
}
コード例 #8
0
ファイル: util.cpp プロジェクト: jeffersonmoises/pdpLU
// Set components[i] to the representative of the 
// component that contains the vertex i.
void getComponents (IloCplex &cplex,
					const IloArray <IloBoolVarArray>& solution,
					vector <int>& components) {
	// The size of the graph.
	int n = solution.getSize();

	// Each vertex is a component itself.
	for (int i = 0; i < n; i++)
		components[i] = i;
	
	// For each 1 in the incidence matrix,
	// join the components of these vertex.
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			if (cplex.getValue (solution[i][j]) == 1)
				join (components, i, j);
}
コード例 #9
0
ファイル: startEndModel.cpp プロジェクト: sims2B/Expe_these
int modelToSol(const Problem<double> &P,
	       Solution<double,double> &s,IloCplex& cplex,
	       IloNumVarArray& t,IloNumVarMatrix& x,
	       IloNumVarMatrix& y,IloNumVarMatrix& b){
  const int E=2*P.nbTask;
  for (int i=0;i<P.nbTask;++i){
    for (int e=0;e<E-1;++e){
      if (isEqual(cplex.getValue(x[i][e]),1.0)) s.st[i]=cplex.getValue(t[e]);
      if (isEqual(cplex.getValue(y[i][e]),1.0)) s.ft[i]=cplex.getValue(t[e]);
      if (!isEqual(cplex.getValue(t[e+1]-t[e]),0.0))
	s.b[i][e]=cplex.getValue(b[i][e])/(cplex.getValue(t[e+1]-t[e]));
      else
	s.b[i][e]=0.0;
    }
    if (isEqual(cplex.getValue(y[i][E-1]),1.0)) s.ft[i]=cplex.getValue(t[E-1]);
  }
  for (int e=0;e<E;++e)
    s.event.push_back(cplex.getValue(t[e]));
  return 0;
}
コード例 #10
0
ファイル: Functions.cpp プロジェクト: trungda/BioScheduling
void PrintMixingBindingResult(BoolVarMatrix M, map<int, string> start_time_rev, IloCplex cplex){
  double M_[n_m][E];
  for(int i = 0; i < n_m; i++){
    for(int j = 0; j < n; j++)
      M_[i][j] = cplex.getValue(M[i][j]);
  }

  cout << "MIXING BINDING RESULTS" << endl;
  for(int i = 0; i < n_m; i++){
    cout << "Module-" << i << " ";
    for(int j = 0; j < n; j++){
      if(M_[i][j] == 1){
        cout << start_time_rev[j] << " ";
      }
    }
    cout << endl;
  }
  cout << endl;
  return;
}
コード例 #11
0
ファイル: util.cpp プロジェクト: jeffersonmoises/pdpLU
// Finds the total path if there's no irregularity or an sub-path that 
// contains I and not I - n (Infeasible for family (5))
void getPath (const IloCplex& cplex,
			  const IloArray <IloBoolVarArray>& solution,
			  vector <int>& P,
			  vector<int>& VP,
			  int src,
			  const vector< Client > &precedences,
			  bool reverse) {
	// The depot always belongs to P
	P.push_back(src);

	// Mark the vertex alread visited on the path
	vector< bool > visited ( solution.getSize(), false );
	visited [src] = true;

	// Each iteration finds the next vertex on the path
	while ( P.size() < (size_t) solution.getSize() ) {

		// Finds the next vertex on the path (after src on the route)
		int v;
		for (v = ((reverse && (P.size() == 1)) ? 1 : 0); 
			 v < solution [src].getSize();
			 v++) { 
			if ((cplex.getValue (solution [src][v])) && 
				(visited [v] == false) )
				break;
		}
		// There must be such a vertex v (This solution is TSP feasible)
		//assert (v < solution.getSize());
		
		// Testing infeasibility (Searching in the precedence rules)
		for (size_t i = 0; i < precedences.size(); i++) {

			// If v is a location in this pair (rule)
			if (precedences[i].delivery == v || 
				precedences[i].pickup == v)  {

				// Adding v to the path and starting over with src == v;
				P.push_back(v); src = v; visited [v] = true;

				// Checking infeasibility 
				if (!reverse) {
					// If v is a delivery vertex and its pickup wasn't visited yet
					if ((precedences[i].delivery == v) && 
						(visited [ precedences[i].pickup ] == false)) {
						getCutComplement (visited, VP);
							return;
					}
				}
				else {
					// If v is a pickup vertex and its delivery wasn't visited yet
					if ((precedences[i].pickup == v) && 
						(visited [ precedences[i].delivery ] == false)) {
						getCutComplement (visited, VP);
						return;
					}
				}
				
				// v is feasible
				break;
			}
		}
		// Test other vertex at the while
	}
}
コード例 #12
0
IloNum columnGeneration (IloCplex2 subSolver, IloCplex rmpSolver, 
	IloNumVarArray3 x, IloNumVarArray2 z, IloNumVarArray2 lambda,
	IloObjective2 reducedCost, IloObjective rmpObj,
	IloRangeArray2 maintConEng, IloRangeArray2 removeMod, IloRangeArray2 convex,
	IloNumArray2 addXCol, IloNumArray addZCol,
	IloNumArray2 priceRemoveMod, IloNumArray2 priceMaintConEng, IloNumArray priceConvex, 
	const IloNumArray2 compCosts, const IloNumArray convexityCoef,
	IloBool weightedDW_in, IloBool allowCustomTermination,
	IloInt relChangeSpan, IloNum relChange) {

	// extract optimization enviroment
	IloEnv env = rmpSolver.getEnv();
	
	
	// ANALYSIS: write to file
	const char*	output = "results/colGen_analysis.dat";
	
	// variable declarations..	
	
	// loop counters
	IloInt i, m, t, testCounter;

	testCounter = 0;

	// declare two clock_t objects for start and end time.		
	clock_t start, end;

	// declare an array of size NR_OF_MODULES to temporarily hold the
	// reduced costs from the NR_OF_MODULES different subproblems.
	IloNumArray redCosts(env, NR_OF_MODULES);

	IloBool weightedDW = weightedDW_in;

	// declare an array to hold the RMP objective values: e.g. add
	// one value to array for each iteration.
//	IloNumArray objValues(env);

	// declare an array to hold the lower bounds for the full MP, given
	//  	z(RMP)* + sum_[m in subproblems] redCost(m)^* <= z(full MP)^* <= z(RMP)^*
//	IloNumArray lowerBounds(env);

	// declare two temp IloNum objects for temporarily hold rmp objective value
	// and full MP lower bound. (full: MP with _all_ columns availible).
	IloNum tempRmpObj, tempLowerBound, bestLowerBound;
	bestLowerBound = -IloInfinity;

	// also use a num-array to hold the REL_CHANGE_SPAN most
	// recent RMP objective values. Used to the relative change
	// break criteria (if improvement by col-gen becomes to
	// "slow"/"flat").
	IloNumArray recentObjValues(env, REL_CHANGE_SPAN);

	// declare and initiate col-gen iteration counter
	IloInt itNum = 0;

	// ---- weighted DW decomp - for less trailing in colgen.
	//IloBool weightedDW = IloTrue;

	// declare two IloNum-array to hold all 2x (NR_OF_MODULES x TIME_SPAN)
	// dual vars - or specific, best dual vars (giving highest lower bound)
	IloNumArray2 dualsModBest(env);
	IloNumArray2 dualsEngBest(env);

	// temp..
	//IloBoolArray continueSub(env, NR_OF_MODULES);
	
	// allocate memory for sub-arrays
	for (m = 0; m < NR_OF_MODULES; m++) {

		dualsModBest.add(IloNumArray(env,TIME_SPAN));	
		dualsEngBest.add(IloNumArray(env,TIME_SPAN));

		//continueSub[m] = IloTrue;

		// and maybe: initially set all dual vars to 0?
		for (t = 0; t < TIME_SPAN; t++) {
			dualsModBest[m][t] = 0.0;
			dualsEngBest[m][t] = 0.0;
		}
	}

	// also, a weight for weighted DW:
	IloNum weight = 2.0;

	// counter number of improvements of "best duals"
	IloInt nrOfImprov = 0;

	// const used in weigt
	IloNum weightConst = DW_WEIGHT;

	// initiate numarray for recent objective values
	// UPDATE: this is not really needed now as we check the
	// relative change break criteria only when we know this
	// vector has been filled by REL_CHANGE_SPAN "proper" values...
	recentObjValues[0] = 0.0;
	for (i = 1; i < REL_CHANGE_SPAN; i++) {
		recentObjValues[i] = 0.0;
	}						

	// model before generation start:
	//rmpSolver.exportModel("rmpModel.lp");

	//write results to file
/*	ofstream outFile(output);

	outFile << "Writing out results from initial column generation, T=" << TIME_SPAN << endl
		<< "Form: [(itNum) (dual solution value) (upper bound = tempRmpObj)]" << endl << endl;*/


	//cout << endl << "WE GOT OURSELVES A SEGMENTATION FAULT!" << endl;

	// start timer
	start = clock();

	// also use an alternative time counter..
	time_t start2, end2;
	start2 = time(NULL);

	// loop until break...
	for (;;) {

		// increase iteration counter
		itNum++;

		// solve master
		if ( !rmpSolver.solve() ) {
       			env.error() << "Failed to optimize RMP." << endl;
			throw(-1);
		}
		
		// get the rmp objective value
		tempRmpObj = rmpSolver.getValue(rmpObj);

		// add to objective value array (size: iterations)
	//	objValues.add(tempRmpObj);

		// update recentObjValues:
		recentObjValues.remove(0);
			// remove oldest:
		recentObjValues.add(tempRmpObj);
			// save newest		

		// report something (... report1() )
		// UPDATE: colgen is to quick for anything to see anything reported... so skip this

		// update weight: weight = min{ 2,
		if (itNum>1) { 
			weight = (IloNum(itNum - 1) + IloNum(nrOfImprov))/2;
		}
		if ( weight > weightConst) {
			weight = weightConst;
		}	


		// update duals
		// -> updates obj. functions for subproblems (w.r.t. duals)
		for (m = 0; m < NR_OF_MODULES; m++) {

			//cout << "weight = " << weight << endl;
			//cin.get();

			for (t = 0; t < TIME_SPAN; t++) {

				// if we try weightedWD decomp:
				// for first iteration: just extract duals which will become best duals
				if (itNum > 1 && weightedDW) {

					// price associated with const. removeMod
					priceRemoveMod[m][t] = (rmpSolver.getDual(removeMod[m][t]))/weight + (weight-1)*(dualsModBest[m][t])/weight;

					// price associated with const. maintConEng
					priceMaintConEng[m][t] = (rmpSolver.getDual(maintConEng[m][t]))/weight + (weight-1)*(dualsEngBest[m][t])/weight;	

				}
				// normally:
				else {

					// price associated with const. removeMod
					priceRemoveMod[m][t] = rmpSolver.getDual(removeMod[m][t]);

					// price associated with const. maintConEng
					priceMaintConEng[m][t] = rmpSolver.getDual(maintConEng[m][t]);
				}

				//cout << "priceRemoveMod[m][t] = " << priceRemoveMod[m][t] << endl;

				// update subproblem obj. function coefficients for z[m][t] vars:
				reducedCost[m].setLinearCoef(z[m][t],-(priceRemoveMod[m][t] + priceMaintConEng[m][t]));
			} 

			//cin.get();

			// rmpSolver.getDuals(priceRemoveMod[m], removeMod[m]);
			// rmpSolver.getDuals(priceMaintConEng[m], maintConEng[m]);
			// priceConvex[m] = -rmpSolver.getDual(convex[m][0]);
				
			// if we try weightedWD decomp:
			// for first iteration: just extract duals which will become best duals
	/*		if (itNum > 1 && weightedDW) {

				// price associated with convexity constraint
				priceConvex[m] = -abs(rmpSolver.getDual(convex[m][0]))/weight - (weight-1)*(dualsConvBest[m])/weight;
			} */
		
			// price associated with convexity constraint
			priceConvex[m] = -abs(rmpSolver.getDual(convex[m][0]));

			// update subproblem obj. function's constant term
			reducedCost[m].setConstant(priceConvex[m]);
			
		} // END of updating duals

		// solve subproblems
		for (m = 0; m < NR_OF_MODULES; m++) {

			//if (continueSub[m]) {

				// solve subproblem m
				cout << endl << "Solving subproblem #" << (m+1) << "." << endl;
				if ( !subSolver[m].solve() ) {
       					env.error() << "Failed to optimize subproblem #" << (m+1) << "." << endl;
       					throw(-1);
				}
		
				// extract reduced cost: subSolver[m].getValue(reducedCost[m])
				// into a IloNumArray(env, NR_OF_MODULES) at position m.				
				redCosts[m] = subSolver[m].getValue(reducedCost[m]);

				//env.out() << endl << "Reduced cost for problem #" << (m+1) << ":" << redCosts[m] << endl;

				// if reduced cost is negative, att optimal solution to
				// column pool Q(m)
				if (!(redCosts[m] > -RC_EPS)) {
					
					// add column		
					addColumn(subSolver[m], x[m], z[m], lambda[m], rmpObj, maintConEng[m], removeMod[m],
						convex[m], addXCol, addZCol, compCosts[m], convexityCoef);

					//env.out() << endl << "Added a column to pool Q(" << (m+1) 
					//	<< "). Lambda[" << (m+1) << "].size = " << lambda[m].getSize() << endl; 

					testCounter++;
				}	
				//else {
				//	continueSub[m] = IloFalse;
				//}
			//}
			//else {
			//	redCosts[m] = 0;
			//}	


		} // END of solving subproblems (for this iteration)

		// calculate lower bound on full MP
		tempLowerBound = tempRmpObj + sumArray(redCosts);

		// update best lower bound
		if (tempLowerBound > bestLowerBound) {
			bestLowerBound = tempLowerBound;
		
			// increase counter for number of improved "best duals".
			nrOfImprov++;

			//cout << endl << "WHATEVAAAH" << endl;
			//cin.get();

			// save best duals
			for (m = 0; m < NR_OF_MODULES; m++) {
				for (t = 0; t < TIME_SPAN; t++) {			
					dualsModBest[m][t] = priceRemoveMod[m][t];
					dualsEngBest[m][t] = priceMaintConEng[m][t];
				}
			}
		}						

		// update lower bounds vector
		//lowerBounds.add(bestLowerBound);
		
		// ANALYSIS: print out to file:
		// [(itNum) (dual solution value) (upper bound = tempRmpObj)]
		//outFile << itNum << " " << tempLowerBound << " " << tempRmpObj << endl;

		// if the smallest reduced cost in the updated red-cost vector 
		// with NR_OF_MODULES entries is greater than -RC_EPS: break
		// otherwise, repeat.
		if (minMemberValue(redCosts) > -RC_EPS) {
			env.out() << endl << "All reduced costs non-negative: breaking." << endl;
			bestLowerBound = tempRmpObj;
			break;
		}

		// if relative change in objective value over the last REL_CHANGE_SPAN iterations is
		// less than REL_CHANGE, break.
		//if (allowCustomTermination && (itNum >= REL_CHANGE_SPAN) && (relativeImprovement(recentObjValues) < REL_CHANGE)) {
		if (allowCustomTermination && (itNum >= relChangeSpan) && (relativeImprovement(recentObjValues) < relChange)) {
			env.out() << endl << "Relative change smaller than pre-set acceptance: breaking." << endl;
			break;
		}													

		// if the gap currentUpperBound - currentLowerBound is small enough, break
		if ((tempRmpObj - bestLowerBound) < RC_EPS) {
			env.out() << endl << "Lower<>Upper bound gap less than pre-set acceptance: breaking." << endl;
			cout << endl << "(tempRmpObj - bestLowerBound) = " << (tempRmpObj - bestLowerBound) << endl;
			bestLowerBound = tempRmpObj;
			break;
		}


	} // END of column generation.
		
	// alternative: print the REL_CHANGE_SPAN most recent RMP objective values		
	env.out() << endl;
	/*for (i = 0; i < recentObjValues.getSize(); i++) {
		env.out() << "Recent #" << (i+1) << ": " << recentObjValues[i] << endl;
	}*/

	// solve master using final column setup
      	if ( !rmpSolver.solve() ) {
        	env.error() << "Failed to optimize RMP." << endl;
        	throw(-1);
      	}

	// also add final objective value to objective value array (size: iterations)
//	objValues.add(rmpSolver.getValue(rmpObj));

	// create IloNum object and extract the final RMP objective value.
	IloNum finalObj;
	finalObj = rmpSolver.getValue(rmpObj);

	// end program time counter(s)
	end = clock();
	end2 = time(NULL);

	// print result to file
	//outFile << endl << endl << "Final objective value: " << finalObj << endl
	//	<< "Time required for execution: " << (double)(end-start)/CLOCKS_PER_SEC << " seconds." << endl;

	// outfile.close()	
	//outFile.close(); 
	itNum = 0;
		// re- use iteration counter to count total number of columns generated

	// nr of columns generated from each subproblem		
	for (m = 0; m < NR_OF_MODULES; m++) {
		// ### outFile << "Number of columns generated from subproblem (m = " << m << "): " << (lambda[m].getSize() - 1) << endl;
		cout << "Number of columns generated from subproblem (m = " << m << "): " << (lambda[m].getSize() - 1) << endl;
		//outFile << "Pool (m = " << m << "): " << (lambda[m].getSize() - 1) << endl;
		
		itNum += lambda[m].getSize();
	}
 
	// ###
/*	outFile << endl << "Total number of columns generated: " << itNum << endl;
	outFile << "Time required for column generation: " << (double)(end-start)/CLOCKS_PER_SEC << " seconds." << endl;
	outFile << "ALTERNATIVE: Time required for colgen: " << end2-start2 << " seconds." << endl;
	outFile << "RMP objective function cost: " << finalObj << endl << endl;
	//outFile << "Objective function values for each iteration: " << endl;		
	//outFile << objValues;
	//outFile << endl << endl << "Lower bounds for each iteration: " << endl; 
	//outFile << lowerBounds;
	outFile.close(); */

	//cout << "Initial column generation complete, press enter to continue..." << endl;
	//cin.get();


	// print some results..
	/*env.out() << endl << "RMP objective function cost: " << finalObj << endl;
	env.out() << endl << "Size of objective value vector: " << objValues.getSize() << endl;
	env.out() << endl << "Nr of iterations: " << itNum << endl;	

	cout << endl << "Number of new columns generated: " << testCounter << endl;*/		

	// Note: to explicit output (void function), ass columns are added implicitely via 
	// income argument pointers.		
					
	// clear memory assigned to temporary IloNumArrays:
	redCosts.end();
	//objValues.end();	
	//lowerBounds.end();	
	recentObjValues.end();

	// save best duals
	for (m = 0; m < NR_OF_MODULES; m++) {
		dualsModBest[m].end();
		dualsEngBest[m].end();
	}
	dualsModBest.end();
	dualsEngBest.end();
	//continueSub.end();	

	//cout << endl << "NR OF IMPROVEMENTS: " << nrOfImprov << endl;
	//cin.get();

	// return lower bound
	return bestLowerBound;	

} // END of columnGeneration()
コード例 #13
0
bool FrontalSolverWithoutConnexity::solve(int borne_max, bool warmstart) {
  LOG(INFO) << name_ << " :: " << description_;

  //Extracting data
  VLOG(2) << "Extracting data";
  int n = data_.n;
  int m = data_.m;
  double Ba = data_.Ba;
  double Bp = data_.Bp;
  const vector<vector<double> >& Ha = data_.Ha;
  const vector<vector<double> >& Ca = data_.Ca;
  const vector<vector<double> >& Hp = data_.Hp;
  const vector<vector<double> >& Cp = data_.Cp;
  
  //Environement
  VLOG(2) << "Creating environment";
  IloEnv env;
  IloModel model = IloModel (env);
  IloCplex cplex = IloCplex(model);

  //Variables
  VLOG(2) << "Creating variables";
  BoolVarMatrix x(env); 
  NumVarMatrix y(env);
  NumVarMatrix z(env);

  VLOG(2) << "Creating variables";
   for (int i = 0; i < m ; ++i) {
     x.add(IloBoolVarArray(env,n));
     y.add(IloNumVarArray(env,n,0,Bp));
     z.add(IloNumVarArray(env,n,0,Ba));
   }


  IloNumVar ha_var(env);
  model.add(ha_var);
  IloNumVar hp_var(env);
  model.add(hp_var);

  //Objective function
  VLOG(2) << "Processing objective function";
  IloExpr objective(env,0);

  for (int i = 0; i < m ; ++i) {
    for (int j = 0; j < n ; ++j) {
      objective += x[i][j];
    }
  }
  model.add(IloMaximize(env, objective ));

  VLOG(2) << "Creating constraint expressions";
  IloExpr sum_Cy(env,0);
  IloExpr sum_HCPx(env,0);
  IloExpr sum_Cz(env,0);
  IloExpr sum_HCAx(env,0);

  VLOG(2) << "Computing constraint expressions";
  for (int i = 0; i < m ; ++i) {
    for (int j = 0; j < n ; ++j) {

      VLOG(5) << i << " " << j << " " << Cp[i][j] << endl;
      sum_Cy += y[i][j]*Cp[i][j];
      sum_Cz += z[i][j]*Ca[i][j];
      sum_HCPx += x[i][j]*Hp[i][j]*Cp[i][j];
      sum_HCAx += x[i][j]*Ha[i][j]*Ca[i][j];

    }
  }

  VLOG(2) << "Adding constraints";
  //Selection of an admissible area
  model.add(sum_Cy == sum_HCPx);
  model.add(sum_Cz == sum_HCAx);
  model.add(ha_var + hp_var >= 2);

  for (int i = 0; i < m ; ++i) {
    for (int j = 0; j < n ; ++j) {

      //Defining y
      model.add(y[i][j] <= Bp*x[i][j]);
      model.add(y[i][j] <= hp_var);
      model.add(y[i][j] >= hp_var - Bp*(1-x[i][j]));
      model.add(y[i][j] >= 0);

      //Defining z
      model.add(z[i][j] <= Ba*x[i][j]);
      model.add(z[i][j] <= ha_var);
      model.add(z[i][j] >= ha_var - Ba*(1-x[i][j]));
      model.add(z[i][j] >= 0);

      //Constraint on x
      if (Cp[i][j] == 0) 
        model.add(x[i][j]==0);

    }
  }

  // Warmstart
  if (warmstart) {
    // Setting Warmstart from solution
    VLOG(2) << "Setting informations for warmstart";
    IloNumVarArray startVar(env);
    IloNumArray startVal(env);
    for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j) {
      startVar.add(x[i][j]);
      startVal.add(sol_.x_[i][j]);

      if (sol_.x_[i][j] == 0){
        startVar.add(y[i][j]);
        startVal.add(sol_.x_[i][j]);

        startVar.add(z[i][j]);
        startVal.add(sol_.x_[i][j]);
      }
    }
    cplex.addMIPStart(startVar, startVal);
    startVal.end();
    startVar.end();
  }




  //Solve
  VLOG(2) << "Resolution...";
  cplex.solve();

  //Output
  VLOG(2) << "Solution status = " << cplex.getStatus() << endl;
  VLOG(2) << "Solution value  = " << cplex.getObjValue() << endl;

  for (int i = 0; i < data_.m; ++i) {
    for (int j = 0; j < data_.n; ++j) {   
      sol_.x_[i][j] = cplex.getValue(x[i][j]);
    }
  } 
  env.end();

  return false;
}