예제 #1
0
int createConstraintKnapsack(const Problem<double>& P, IloEnv& env, 
			     IloModel& model, IloNumVarMatrix& x, IloNumVarMatrix& y){
  for (int e=0;e<2*P.nbTask-1;++e){
    IloExpr expr(env);
    for (int i=0;i<P.nbTask;++i){   
      if (P.bmin(i)!=0)  {
	IloExpr expr2(env);
	for (int f=0;f<=e;f++){
	  expr2+=x[i][f];
	  expr2-=y[i][f];
	}
	expr+=expr2*P.bmin(i);
      }
    }
    model.add(expr<=P.B);
    expr.end();
  }
  return 0;
}
예제 #2
0
int createConstraintBmin(const Problem<double>&P, IloModel& model, IloEnv& env, 
			 IloNumVarArray& t, IloNumVarMatrix& x,IloNumVarMatrix& y, IloNumVarMatrix& b, 
			 const std::vector<std::vector<double>> &M_evt){
  for (int i=0;i<P.nbTask;i++){
    for (int e=0;e<2*P.nbTask-1;e++){
      IloExpr expr(env);
      for (int f=0;f<=e;f++){
	expr-= x[i][f];
	expr+= y[i][f];
      }
      expr+=1;
      expr*=-M_evt[e][0]*P.bmin(i);
      expr+=(t[e+1]-t[e])*P.A[i].bmin;
      model.add(expr <= b[i][e]);
      expr.end();
    }
  }
  return 0;
}
예제 #3
0
int createConstraintBmin(const Problem<double>&P, IloModel& model, IloEnv& env, IloNumVarArray& t, IloNumVarMatrix& x, IloNumVarMatrix& y,IloNumVarMatrix& b, const int& bigM){
  for (int i=0;i<P.nbTask;i++){
    for (int e=0;e<2*P.nbTask-1;e++){
      IloExpr expr(env);
    for (int f=0;f<=e;f++){
      expr-= x[i][f];
      expr+= y[i][f];
    }
    expr+=1;
    if (bigM)
      expr*=-M;
    else 
      expr*= - P.bmin(i)*(P.d(i)-P.r(i));
    expr+=(t[e+1]-t[e])*P.A[i].bmin;
    model.add(expr <= b[i][e]);
    expr.end();
    }
  }
  
  return 0;
}