@Test(groups="1s", timeOut=60000) public void testPropagate() { Model m = new Model(); SetVar s = m.setVar("var", new int[] {}, new int[] { 0, 1, 2, 3 }); IntVar a = m.intVar("a", 0), b = m.intVar("b", 0, 3), c = m.intVar("c", 0, 3), d = m.intVar("d", 0, 3); m.member(a, s).reifyWith(m.member(b, s).getOpposite().reify()); m.member(c, s).reifyWith(m.member(d, s).getOpposite().reify()); m.allDifferent(a, b, c, d).post(); s.setCard(c); Assert.assertTrue(m.getSolver().solve()); Assert.assertTrue(c.isInstantiatedTo(2), "" + c); }
@Override public void setCard(IntVar card) { if(!hasCard()){ cardinality=card; new Constraint(ConstraintsName.SETCARD, new PropCardinality(this, card)).post(); } else { model.arithm(cardinality, "=", card).post(); } }
SetVarImpl extends AbstractVariable implements SetVar { @Override public void setCard(IntVar card) { if(!hasCard()){ cardinality=card; new Constraint(ConstraintsName.SETCARD, new PropCardinality(this, card)).post(); } else { model.arithm(cardinality, "=", card).post(); } } }
SetVarImpl extends AbstractVariable implements SetVar { @Override public void setCard(IntVar card) { if(!hasCard()){ cardinality=card; new Constraint(ConstraintsName.SETCARD, new PropCardinality(this, card)).post(); } else { model.arithm(cardinality, "=", card).post(); } } SetVarImpl(String name, int[] ker, SetType kerType, int[] env, SetType envType, Model model);  SetVarImpl(String name, ISet lb, ISet ub, Model model);  SetVarImpl(String name, ISet value, Model model);  SetVarImpl(String name, int[] value, Model model); }
SetVarImpl extends AbstractVariable implements SetVar { @Override public void setCard(IntVar card) { if(!hasCard()){ cardinality=card; new Constraint(ConstraintsName.SETCARD, new PropCardinality(this, card)).post(); } else { model.arithm(cardinality, "=", card).post(); } } SetVarImpl(String name, int[] ker, SetType kerType, int[] env, SetType envType, Model model);  SetVarImpl(String name, ISet lb, ISet ub, Model model);  SetVarImpl(String name, ISet value, Model model);  SetVarImpl(String name, int[] value, Model model); @Override boolean isInstantiated(); @Override ISet getLB(); @Override ISet getUB(); @Override IntVar getCard(); @Override boolean hasCard(); @Override void setCard(IntVar card); @Override boolean force(int element, ICause cause); @Override boolean remove(int element, ICause cause); @Override boolean instantiateTo(int[] value, ICause cause); @Override SetDelta getDelta(); @Override int getTypeAndKind(); @Override String toString(); @Override void createDelta(); @Override SetDeltaMonitor monitorDelta(ICause propagator); }
SetVarImpl extends AbstractVariable implements SetVar { @Override public void setCard(IntVar card) { if(!hasCard()){ cardinality=card; new Constraint(ConstraintsName.SETCARD, new PropCardinality(this, card)).post(); } else { model.arithm(cardinality, "=", card).post(); } } SetVarImpl(String name, int[] ker, SetType kerType, int[] env, SetType envType, Model model);  SetVarImpl(String name, ISet lb, ISet ub, Model model);  SetVarImpl(String name, ISet value, Model model);  SetVarImpl(String name, int[] value, Model model); @Override boolean isInstantiated(); @Override ISet getLB(); @Override ISet getUB(); @Override IntVar getCard(); @Override boolean hasCard(); @Override void setCard(IntVar card); @Override boolean force(int element, ICause cause); @Override boolean remove(int element, ICause cause); @Override boolean instantiateTo(int[] value, ICause cause); @Override SetDelta getDelta(); @Override int getTypeAndKind(); @Override String toString(); @Override void createDelta(); @Override SetDeltaMonitor monitorDelta(ICause propagator);  }