Example #1
0
 protected boolean propagateNewUpperBound(int myub) throws ContradictionException {
   Explanation expl = this.explainVariablesUB();
   boolean anyChange = false;
   int nbVars = getNbVars();
   if (myub < 0) {
     AbstractIntSConstraint.logger.finer("ub = " + myub + " < 0 => fail");
     ((ExplainedSolver) this.getProblem()).explainedFail(expl);
   }
   int i;
   for (i = 0; i < nbPosVars; i++) {
     int newInfi = MathUtils.divCeil(-(myub), coeffs[i]) + vars[i].getSup();
     if (((ExplainedIntVar) vars[i]).updateInf(newInfi, cIndices[i], expl)) {
       AbstractIntSConstraint.logger.finer(
           "INF("
               + vars[i].toString()
               + ") >= "
               + -(myub)
               + "/"
               + coeffs[i]
               + " + "
               + vars[i].getSup()
               + " = "
               + newInfi);
       anyChange = true;
     }
   }
   for (i = nbPosVars; i < nbVars; i++) {
     int newSupi = MathUtils.divFloor(myub, -(coeffs[i])) + vars[i].getInf();
     if (((ExplainedIntVar) vars[i]).updateSup(newSupi, cIndices[i], expl)) {
       AbstractIntSConstraint.logger.finer(
           "SUP("
               + vars[i].toString()
               + ") <= "
               + myub
               + "/"
               + -(coeffs[i])
               + " + "
               + vars[i].getInf()
               + " = "
               + newSupi);
       anyChange = true;
     }
   }
   return anyChange;
 }