Beispiel #1
0
 /**
  * Posts a constraints in the problem. If it has ever been posted (but deactivated), it is only
  * reactivated and repropagated.
  *
  * @param constraint The constraint to post.
  */
 public void post(SConstraint constraint) {
   if (constraint instanceof PalmSConstraint) {
     PalmSConstraint pconstraint = (PalmSConstraint) constraint;
     PalmConstraintPlugin pi = (PalmConstraintPlugin) pconstraint.getPlugIn();
     if (!(pi.isEverConnected())) {
       int idx;
       constraints.staticAdd((Propagator) constraint);
       idx = this.constraints.size() - 1;
       pi.setConstraintIdx(idx);
       pconstraint.addListener(false);
       ConstraintEvent event = (ConstraintEvent) pconstraint.getEvent();
       propagationEngine.registerEvent(event);
       propagationEngine.postConstAwake(pconstraint, true);
     } else {
       logger.fine("The constraint " + constraint + " is reactivated.");
       this.propagationEngine.postConstAwake(pconstraint, true);
       pconstraint.setActive();
     }
     if (pi.isDepending()) pi.setDependance();
   } else {
     throw new Error("Impossible to post non-Palm constraints to a Palm problem");
   }
 }
Beispiel #2
0
 /**
  * Posts an indirect constraint with an explain.
  *
  * @param constraint The constraint to post.
  * @param expl The set of constraint this posted constraint depends on.
  */
 public void post(SConstraint constraint, PalmExplanation expl) {
   ((PalmConstraintPlugin) ((PalmSConstraint) constraint).getPlugIn()).setIndirect(expl);
   this.post(constraint);
 }
Beispiel #3
0
 /**
  * Posts a constraint with the specified weight.
  *
  * @param constraint The constraint to post.
  * @param w The weight associated to the constraint.
  */
 public void post(SConstraint constraint, int w) {
   this.post(constraint);
   ((PalmConstraintPlugin) ((PalmSConstraint) constraint).getPlugIn()).setWeight(w);
 }