int chooseVar6(const Problem<type,type2>& P,type epsilon){ type2 max=std::numeric_limits<type2>::min(); int j=-1; int i=0; while (i<P.nbTask){ if (P.A[i].Fi(P.bmax(i))*(P.d(i)-P.r(i))-P.W(i)>=max && P.smax(i) - P.r(i)>epsilon) { j=i; max=P.A[i].Fi(P.bmax(i))*(P.d(i)-P.r(i))-P.W(i); } if (P.A[i].Fi(P.bmax(i))*(P.d(i)-P.r(i))-P.W(i)>max && P.d(i)-P.emin(i)>epsilon){ j=i+P.nbTask; max=P.A[i].Fi(P.bmax(i))*(P.d(i)-P.r(i))-P.W(i); } ++i; } return j; }
int createConstraintBmax(const Problem<double>&P, IloModel& model, IloNumVarArray& t, IloNumVarMatrix& b){ for (int i=0;i<P.nbTask;i++){ for (int e=0;e<2*P.nbTask-1;e++) model.add((t[e+1]-t[e])*P.bmax(i) >= b[i][e]); } return 0; }
int createVars(const Problem<double>& P, IloEnv& env, IloNumVarMatrix& x, IloNumVarMatrix& y, IloNumVarMatrix& b, IloNumVarMatrix& w){ try{ int i; const int nbTask=P.nbTask; const int E= 2*nbTask; for (i=0;i<nbTask;i++){ x[i]=IloNumVarArray(env, E, 0, 1, ILOINT); y[i]=IloNumVarArray(env, E, 0, 1, ILOINT); b[i]=IloNumVarArray(env, E-1, 0, ((P.d(i)-P.r(i))*P.bmax(i)), ILOFLOAT); w[i]=IloNumVarArray(env, E-1, 0, (P.d(i)-P.r(i))*P.A[i].Fi(P.bmax(i)), ILOFLOAT); } return 0; } catch (IloException &e){ std::cout << "iloexception in create vars" <<e <<std::endl; e.end(); return 1; } }
int createConstraintNonConsump(const Problem<double>& P, IloModel& model, IloEnv& env, IloNumVarMatrix& x, IloNumVarMatrix& y , IloNumVarMatrix& b, 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]; } if (!bigM) expr*=P.bmax(i)*(P.d(i)-P.r(i)); else expr*=M; model.add(expr >=b[i][e]); expr.end(); } } return 0; }
int createConstraintMinDur(const Problem<double>& P, IloModel& model, IloNumVarArray& t, IloNumVarMatrix& x, IloNumVarMatrix& y){ const int E=2*P.nbTask; for (int i=0;i<P.nbTask;i++){ for (int e=1;e<E-1;e++) { for (int f=e;f<E;f++) model.add(t[f] >= t[e] + x[i][e] * (P.A[i].emin-P.A[i].ri) - (1-y[i][f])*(P.W(i)/P.A[i].Fi(P.bmax(i)))); } } return 0; }