コード例 #1
0
 public void failurePruning(int failure_time) {
   super.failurePruning(failure_time);
   this.counterMoves = 0;
   this.g = new DelegateForest<MetaVariable, ConstraintNetwork>();
   this.resolvers.clear();
   this.metaVarsToMetaCons.clear();
 }
コード例 #2
0
 /**
  * Service method for backtracking with serialization-based saving of {@link ConstraintNetwork}s.
  * This method backs up {@link ConstraintNetwork}s before branching.
  */
 private HashMap<ConstraintSolver, byte[]> backupCNs(MultiConstraintSolver conSol) {
   // Here we want to save the CNs
   ByteArrayOutputStream bos = null;
   ObjectOutputStream oos = null;
   HashMap<ConstraintSolver, byte[]> currentLevel = new HashMap<ConstraintSolver, byte[]>();
   try {
     bos = new ByteArrayOutputStream();
     oos = new ObjectOutputStream(bos);
     for (ConstraintSolver cs : conSol.getConstraintSolvers()) {
       logger.finest("Backing up CN of " + cs.getClass().getSimpleName());
       ConstraintNetwork cn = cs.getConstraintNetwork();
       oos.writeObject(cn);
       byte[] backup = bos.toByteArray();
       currentLevel.put(cs, backup);
       if (cs instanceof MultiConstraintSolver) {
         // System.out.println("RECURSIVE on " + cs.getClass().getSimpleName());
         HashMap<ConstraintSolver, byte[]> lower = backupCNs((MultiConstraintSolver) cs);
         currentLevel.putAll(lower);
       }
     }
     return currentLevel;
   } catch (NotSerializableException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
   return null;
 }