Пример #1
0
 /**
  * Create an open right branch for HBFS
  *
  * @param decision an open decision
  * @param currentBound current lower (resp. upper) bound of the objective value for mimimization
  *     (resp. maximization)
  * @param minimization set to <tt>true</tt> for minimization
  */
 public Open(Decision<IntVar> decision, int currentBound, boolean minimization) {
   this.path = new ArrayList<>();
   while (decision != topDecision) {
     Decision d = decision.duplicate();
     while (decision.triesLeft() != d.triesLeft() - 1) {
       d.buildNext();
     }
     path.add(d);
     decision = decision.getPrevious();
   }
   this.currentBound = currentBound;
   this.minimization = (byte) (minimization ? 1 : -1);
 }
Пример #2
0
 /** Compute the initial fragment, ie set of decisions to keep. */
 private void clonePath() {
   Decision dec = mSolver.getSearchLoop().getLastDecision();
   while ((dec != RootDecision.ROOT)) {
     addToPath(dec);
     dec = dec.getPrevious();
   }
   Collections.reverse(path);
   int size = path.size();
   for (int i = 0, mid = size >> 1, j = size - 1; i < mid; i++, j--) {
     boolean bi = refuted.get(i);
     refuted.set(i, refuted.get(j));
     refuted.set(j, bi);
   }
 }
Пример #3
0
 /**
  * Copy the current decision path in _unkopen, for comparison with copen. Then, it compares each
  * decision, from the top to the bottom, to find the first difference. This is required to avoid
  * adding the same decision sub-path more than once
  *
  * @param searchLoop the search loop
  * @return the index of the decision, in _unkopen, that stops the loop
  */
 private int compareSubpath(SearchLoop searchLoop) {
   _unkopen.clear();
   Decision decision = searchLoop.decision;
   while (decision != topDecision) {
     _unkopen.add(decision);
     decision = decision.getPrevious();
   }
   Collections.reverse(_unkopen);
   //
   int i = 0;
   int I = Math.min(_unkopen.size(), copen.length);
   while (i < I && copen[i].isEquivalentTo(_unkopen.get(i))) {
     i++;
   }
   return i;
 }