Example #1
0
 protected void updateCost(int low, int up) throws ContradictionException { // consider [low, up]
   for (int i = low; i <= up; i++) {
     if (i < costVarsLength) {
       if (getCostVar(i).getSup() < sum_height - wishCapa) {
         this.fail();
       }
       if (sum_height > wishCapa) {
         int prev = getCostVar(i).getInf();
         if (prev < sum_height - wishCapa) {
           fixPoint |= getCostVar(i).updateInf(sum_height - wishCapa, this, false);
           profileMinSum.set(profileMinSum.get() + getCostVar(i).getInf() - prev);
         }
       }
     }
   }
 }
Example #2
0
 public void taskIntervals() throws ContradictionException {
   Collections.sort(Xtasks, stComp);
   Collections.sort(Ytasks, endComp);
   int maxInc = 0;
   for (int i = 0; i < nbTask; i++) {
     int D = getEnd(Ytasks.get(i)).getSup();
     int energy = 0; // int to use updateInf
     for (int j = nbTask - 1; j >= 0; j--) {
       int t = Xtasks.get(j);
       int h = getHeight(t).getInf();
       int minDur = getDuration(t).getInf();
       int e = minDur * h; // int to use updateInf
       if (getLE(t) > D) e = Math.min(e, (D - getLS(t)) * h);
       if (e > 0) {
         energy += e;
         // System.out.println(energy);
         long capaMaxDiff = capaMaxDiff(getES(t), D);
         if (capaMaxDiff < energy) {
           this.fail();
         } else {
           int inc = computeIncreasing(energy, getES(t), D);
           if (inc > maxInc) {
             maxInc = inc;
           }
         }
       }
     }
   }
   IntDomainVar obj = getObj();
   if (debug) {
     System.out.println(maxInc + ", obj = [" + obj.getInf() + ", " + obj.getSup() + "]");
   }
   if (maxInc > 0) {
     if (debug) {
       System.out.println(
           profileMinSum.get() + "-" + "obj inf = " + obj.getInf() + "- increasing = " + maxInc);
     }
     if (profileMinSum.get() + maxInc > obj.getSup()) {
       this.fail();
     } else {
       obj.updateInf(profileMinSum.get() + maxInc, this, false);
     }
   }
 }