예제 #1
0
int chooseVar4(const Problem<type,type2>& P, type epsilon){  
  type max=std::numeric_limits<type>::min();
  int j=-1;
  int i=0;
  while (i<P.nbTask){
    if (P.smax(i) - P.r(i) >= max && P.smax(i) - P.r(i)>epsilon){ 
      j=i;
      max=P.smax(i) - P.r(i);
    }
    if (P.d(i) - P.emin(i) >= max && P.d(i) - P.emin(i)>epsilon)	{  
      j=i+P.nbTask;
      max=P.d(i) - P.emin(i);
    }
    ++i;
  }
  return j;
}
예제 #2
0
int chooseVar1(const Problem<type,type2>& P, type epsilon){
  int i=0;
  while (i<P.nbTask){
    if (P.smax(i) - P.r(i) > epsilon) return i;
    if (P.d(i) - P.emin(i) > epsilon) return i+P.nbTask;
    ++i;
  }
  return -1;
}
예제 #3
0
int chooseVar2(const Problem<type,type2>& P,type epsilon){
  const uint n = P.nbTask;
  int real_size = 0;
  uint i;
  int s, j = -1;
  for (i = 0 ; i < n ; ++i) {
    if (P.smax(i) - P.r(i) > epsilon) ++real_size;
    if (P.d(i) - P.emin(i) > epsilon) ++real_size;
  }
  if (!real_size) return -1;
  if (real_size == 1) s = 1;
  else s = rand() % real_size;
  for (i = 0 ; i < n && j < 0 ; ++i) {
    if (P.smax(i) - P.r(i) > epsilon) --s;
    if (!s) j = i;
    else {
      if (P.d(i) - P.emin(i)> epsilon) --s;
      if (!s) j = i +n;
    }
  }
  return j;
}
예제 #4
0
int createConstraintTimeW(const Problem<double>& P, IloModel& model,
			  IloNumVarArray& t, IloNumVarMatrix& x,  IloNumVarMatrix& y, const std::vector<double>& M_te){
  const int E=2*P.nbTask;  
  for (int i=0;i<P.nbTask;i++) {
    for (int e=0;e<E;++e){
      model.add(x[i][e]*P.r(i) <= t[e]);
      model.add(t[e] <= x[i][e]*P.smax(i) + 
		(1-x[i][e])*M_te[e]);
      model.add(P.d(i)*y[i][e] + (1-y[i][e])*M_te[e]>= t[e]);
      model.add(t[e] >= y[i][e]*P.emin(i));
    }
  }
  return 0;
}
예제 #5
0
void createBranch(Problem<type,type2>& P,int x,std::stack<Problem<type,type2>>& explore, double param){
  Problem<type,type2> Q(P);
  if (x < P.nbTask){
    P.A[x].smax-=(P.smax(x)-P.r(x))*(1.0-param);
    explore.push(P);
    Q.A[x].ri+=(Q.smax(x)-Q.r(x))*param;
    Q.A[x].updateEMin();
    explore.push(Q);
  }
  else  { 
    P.A[x-P.nbTask].emin+=(P.d(x-P.nbTask)-P.emin(x-P.nbTask))*(1.0-param);
    explore.push(P);
    Q.A[x-Q.nbTask].di-=(Q.d(x-Q.nbTask)-Q.emin(x-Q.nbTask))*param;
    Q.A[x-Q.nbTask].updateSMax();
    explore.push(Q);
  }
}
예제 #6
0
int chooseVar5(const Problem<type,type2>& P,type epsilon){
  type2 min=std::numeric_limits<type2>::max();
  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)<=min && P.smax(i) - P.r(i)>epsilon) {
      j=i;
      min=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)<min && P.d(i)-P.emin(i)>epsilon){ 
      j=i+P.nbTask;
      min=P.A[i].Fi(P.bmax(i))*(P.d(i)-P.r(i))-P.W(i);
    }
    ++i;
  }
  return j;
}