From: Guillaume N. <gui...@de...> - 2004-12-08 08:42:44
|
Would it be possible to add a palm binary disjunctive constraint to the library ? I've tried to do it, but my understanding of palm internals is not sufficient to have an optimized version. Following is the version i have which seems to work but does not handle whyIsTrue and whyIsFalse in addition to have a non optimal value restoration process. Additionaly, i've got a problem with palm: i'm trying to solve a problem, but the solver does not stop. It keeps looping on the same decision constraints set. Can this behavior be the result of the very ugly disjunction constraint i wrote ? Thanks, Guillaume Nodet public class PalmBinDisjunction extends BinDisjunction implements PalmConstraint, PalmIntVarListener { public PalmBinDisjunction(AbstractConstraint c1, AbstractConstraint c2) { super(c1, c2); this.hook = ((ExplainedProblem) this.getProblem()).makeConstraintPlugin(this); ((PalmConstraintPlugin) c1.getPlugIn()).addControl(this, 0); ((PalmConstraintPlugin) c2.getPlugIn()).addControl(this, 1); } public void setTargetStatus(int constIdx, boolean st) { if (st) { Constraint c0 = constIdx == 0 ? const0 : const1; Constraint c1 = constIdx == 0 ? const1 : const0; PalmExplanation expl = (PalmExplanation) ((ExplainedProblem) this.getProblem()).makeExplanation(); expl.addAll(((PalmIntVarListener) c1).whyIsFalse()); ((PalmConstraintPlugin) c0.getPlugIn()).setIndirect(expl); } } public void addListener() { super.addListener(); int idx = ((PalmConstraintPlugin) this.hook).getConstraintIdx(); ((PalmConstraintPlugin) const0.getPlugIn()).setConstraintIdx(idx); ((PalmConstraintPlugin) const1.getPlugIn()).setConstraintIdx(idx); } public void takeIntoAccountStatusChange(int index) { statusBitVector.set(0); } public void updateDataStructuresOnConstraint(int idx, int select, int newValue, int oldValue) { statusBitVector.set(0); } public void updateDataStructuresOnRestoreConstraint(int idx, int select, int newValue, int oldValue) { statusBitVector.set(0); } public void awakeOnRestoreInf(int idx) throws ContradictionException { statusBitVector.set(0); propagate(); } public void awakeOnRestoreSup(int idx) throws ContradictionException { statusBitVector.set(0); propagate(); } public void awakeOnRestoreVal(int idx, int val) throws ContradictionException { statusBitVector.set(0); propagate(); } public void awakeOnRestoreVal(int idx, IntIterator it) throws ContradictionException { statusBitVector.set(0); propagate(); } public Set whyIsTrue() { return null; } public Set whyIsFalse() { return null; } public String toString() { return const0.toString() + " v " + const1.toString(); } } |