Ejemplo n.º 1
0
 /** This methods extracts and stores all open right branches for future exploration */
 protected void extractOpenRightBranches(SearchLoop searchLoop) {
   // update parameters for restarts
   if (nodesRecompute > 0) {
     double ratio = nodesRecompute * 1.d / searchLoop.mMeasures.getNodeCount();
     if (ratio > b && Z <= N) {
       Z *= 2;
     } else if (ratio < a && Z >= 2) {
       Z /= 2;
     }
   }
   limit += Z;
   // then start the extraction of open right branches
   int i = compareSubpath(searchLoop);
   if (i < _unkopen.size()) {
     extractOB(searchLoop, i);
   }
   // finally, get the best ORB to keep up the search
   Open next = opens.poll();
   while (next != null && !isValid(next.currentBound())) {
     next = opens.poll();
   }
   if (next != null) {
     copen = next.toArray();
     // the decision in 0 is the last taken, then the array us reversed
     ArrayUtils.reverse(copen);
     current = 0;
     nodesRecompute = searchLoop.mMeasures.getNodeCount() + copen.length;
   } else {
     // to be sure not to use the previous path
     current = copen.length;
   }
   // then do the restart
   searchLoop.restart();
 }
Ejemplo n.º 2
0
 @Override
 public boolean extend(SearchLoop searchLoop) {
   boolean extend;
   // as we observe the number of backtracks, no limit can be reached on extend()
   if (current < copen.length) {
     Decision tmp = searchLoop.decision;
     searchLoop.decision = copen[current++];
     assert searchLoop.decision != null;
     searchLoop.decision.setPrevious(tmp);
     searchLoop.mSolver.getEnvironment().worldPush();
     extend = true;
   } else /*cut will checker with propagation */ {
     extend = super.extend(searchLoop);
   }
   return extend;
 }
Ejemplo n.º 3
0
 /**
  * Extract the open right branches from the current path until it reaches the i^th decision of
  * _unkopen
  *
  * @param searchLoop the search loop
  * @param i the index of the decision, in _unkopen, that stops the loop
  */
 private void extractOB(SearchLoop searchLoop, int i) {
   Decision stopAt = _unkopen.get(i).getPrevious();
   // then, goes up in the search tree, and detect open nodes
   searchLoop.mSolver.getEnvironment().worldPop();
   Decision decision = searchLoop.decision;
   int bound;
   while (decision != stopAt) {
     bound =
         isMinimization
             ? objectiveManager.getObjective().getLB()
             : objectiveManager.getObjective().getUB();
     if (decision.hasNext() && isValid(bound)) {
       opens.add(new Open(decision, bound, isMinimization));
     }
     searchLoop.decision = searchLoop.decision.getPrevious();
     decision.free();
     decision = searchLoop.decision;
     searchLoop.mSolver.getEnvironment().worldPop();
   }
 }