@Test(groups="1s", timeOut=60000) public void testSetVarInstantiated() { Model m = new Model(); Assert.assertTrue(m.setVar("var", new int[] { -1, -2, 3, 18 }).getCard().isInstantiatedTo(4)); Assert.assertTrue(m.setVar("var", new int[] { -1, -1, -1, 0 }).getCard().isInstantiatedTo(2)); Assert.assertTrue(m.setVar("var").getCard().isInstantiatedTo(0)); }
@Override public IntVar getCard() { if(!hasCard()){ int ubc = ub.size(), lbc = lb.size(); if(ubc==lbc) cardinality = model.intVar(ubc); else{ cardinality = model.intVar(name+".card", lbc, ubc); new Constraint(ConstraintsName.SETCARD, new PropCardinality(this, cardinality)).post(); } } return cardinality; }
SetVarImpl extends AbstractVariable implements SetVar { @Override public IntVar getCard() { if(!hasCard()){ int ubc = ub.size(), lbc = lb.size(); if(ubc==lbc) cardinality = model.intVar(ubc); else{ cardinality = model.intVar(name+".card", lbc, ubc); new Constraint(ConstraintsName.SETCARD, new PropCardinality(this, cardinality)).post(); } } return cardinality; } }
SetVarImpl extends AbstractVariable implements SetVar { @Override public IntVar getCard() { if(!hasCard()){ int ubc = ub.size(), lbc = lb.size(); if(ubc==lbc) cardinality = model.intVar(ubc); else{ cardinality = model.intVar(name+".card", lbc, ubc); new Constraint(ConstraintsName.SETCARD, new PropCardinality(this, cardinality)).post(); } } return cardinality; } 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 IntVar getCard() { if(!hasCard()){ int ubc = ub.size(), lbc = lb.size(); if(ubc==lbc) cardinality = model.intVar(ubc); else{ cardinality = model.intVar(name+".card", lbc, ubc); new Constraint(ConstraintsName.SETCARD, new PropCardinality(this, cardinality)).post(); } } return cardinality; } 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 IntVar getCard() { if(!hasCard()){ int ubc = ub.size(), lbc = lb.size(); if(ubc==lbc) cardinality = model.intVar(ubc); else{ cardinality = model.intVar(name+".card", lbc, ubc); new Constraint(ConstraintsName.SETCARD, new PropCardinality(this, cardinality)).post(); } } return cardinality; } 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);  }