@Test(groups = "1s", timeOut = 60000) public void testAssociates() { Model s = new Model(); BoolVar v = s.boolVar("V"); Assert.assertEquals(s.getNbVars(), 1); s.associates(v); Assert.assertEquals(s.getNbVars(), 2); s.unassociates(v); Assert.assertEquals(s.getNbVars(), 1); s.unassociates(v); Assert.assertEquals(s.getNbVars(), 0); }
public void associates(Variable variable) { if (vIdx == vars.length) { Variable[] tmp = vars; vars = new Variable[tmp.length * 2]; System.arraycopy(tmp, 0, vars, 0, vIdx); } vars[vIdx++] = variable; switch ((variable.getTypeAndKind() & Variable.KIND)) { case Variable.INT: nbIntVar++; break; case Variable.BOOL: nbBoolVar++; break; case Variable.SET: nbSetVar++; break; case Variable.REAL: nbRealVar++; break; } }
Model implements IModel { public void associates(Variable variable) { if (vIdx == vars.length) { Variable[] tmp = vars; vars = new Variable[tmp.length * 2]; System.arraycopy(tmp, 0, vars, 0, vIdx); } vars[vIdx++] = variable; switch ((variable.getTypeAndKind() & Variable.KIND)) { case Variable.INT: nbIntVar++; break; case Variable.BOOL: nbBoolVar++; break; case Variable.SET: nbSetVar++; break; case Variable.REAL: nbRealVar++; break; } } }
Model implements IModel { public void associates(Variable variable) { if (vIdx == vars.length) { Variable[] tmp = vars; vars = new Variable[tmp.length * 2]; System.arraycopy(tmp, 0, vars, 0, vIdx); } vars[vIdx++] = variable; switch ((variable.getTypeAndKind() & Variable.KIND)) { case Variable.INT: nbIntVar++; break; case Variable.BOOL: nbBoolVar++; break; case Variable.SET: nbSetVar++; break; case Variable.REAL: nbRealVar++; break; } } Model(IEnvironment environment, String name, Settings settings);  Model(IEnvironment environment, String name);  Model(String name, Settings settings);  Model(String name);  Model(Settings settings);  Model(); }
Model implements IModel { public void associates(Variable variable) { if (vIdx == vars.length) { Variable[] tmp = vars; vars = new Variable[tmp.length * 2]; System.arraycopy(tmp, 0, vars, 0, vIdx); } vars[vIdx++] = variable; switch ((variable.getTypeAndKind() & Variable.KIND)) { case Variable.INT: nbIntVar++; break; case Variable.BOOL: nbBoolVar++; break; case Variable.SET: nbSetVar++; break; case Variable.REAL: nbRealVar++; break; } } Model(IEnvironment environment, String name, Settings settings);  Model(IEnvironment environment, String name);  Model(String name, Settings settings);  Model(String name);  Model(Settings settings);  Model(); long getCreationTime(); ResolutionPolicy getResolutionPolicy(); TIntObjectHashMap<IntVar> getCachedConstants(); Constraint trueConstraint(); Constraint falseConstraint(); Solver getSolver(); Variable[] getVars(); int getNbVars(); Variable getVar(int i); int getNbIntVar(boolean includeBoolVar); IntVar[] retrieveIntVars(boolean includeBoolVar); int getNbBoolVar(); BoolVar[] retrieveBoolVars(); int getNbSetVar(); SetVar[] retrieveSetVars(); int getNbRealVar(); RealVar[] retrieveRealVars(); Constraint[] getCstrs(); int getNbCstrs(); String getName(); IEnvironment getEnvironment(); Variable getObjective(); double getPrecision(); Object getHook(String hookName); SatConstraint getMinisat(); void removeMinisat(); NogoodConstraint getNogoodStore(); void removeNogoodStore(); ClauseConstraint getClauseConstraint(); ClauseBuilder getClauseBuilder(); IbexHandler getIbexHandler(); Settings getSettings(); @SuppressWarnings("unchecked") void setObjective(boolean maximize, Variable objective); void clearObjective(); void setPrecision(double p); void setSeed(long seed); long getSeed(); void addHook(String hookName, Object hookObject); void removeHook(String hookName); void removeAllHooks(); void setName(String name); void associates(Variable variable); void unassociates(Variable variable); int nextId(); int nextNameId(); void post(Constraint... cs); void postTemp(Constraint... cs); void unpost(Constraint... constraints); @Override String toString(); @Override Model ref(); }
Model implements IModel { public void associates(Variable variable) { if (vIdx == vars.length) { Variable[] tmp = vars; vars = new Variable[tmp.length * 2]; System.arraycopy(tmp, 0, vars, 0, vIdx); } vars[vIdx++] = variable; switch ((variable.getTypeAndKind() & Variable.KIND)) { case Variable.INT: nbIntVar++; break; case Variable.BOOL: nbBoolVar++; break; case Variable.SET: nbSetVar++; break; case Variable.REAL: nbRealVar++; break; } } Model(IEnvironment environment, String name, Settings settings);  Model(IEnvironment environment, String name);  Model(String name, Settings settings);  Model(String name);  Model(Settings settings);  Model(); long getCreationTime(); ResolutionPolicy getResolutionPolicy(); TIntObjectHashMap<IntVar> getCachedConstants(); Constraint trueConstraint(); Constraint falseConstraint(); Solver getSolver(); Variable[] getVars(); int getNbVars(); Variable getVar(int i); int getNbIntVar(boolean includeBoolVar); IntVar[] retrieveIntVars(boolean includeBoolVar); int getNbBoolVar(); BoolVar[] retrieveBoolVars(); int getNbSetVar(); SetVar[] retrieveSetVars(); int getNbRealVar(); RealVar[] retrieveRealVars(); Constraint[] getCstrs(); int getNbCstrs(); String getName(); IEnvironment getEnvironment(); Variable getObjective(); double getPrecision(); Object getHook(String hookName); SatConstraint getMinisat(); void removeMinisat(); NogoodConstraint getNogoodStore(); void removeNogoodStore(); ClauseConstraint getClauseConstraint(); ClauseBuilder getClauseBuilder(); IbexHandler getIbexHandler(); Settings getSettings(); @SuppressWarnings("unchecked") void setObjective(boolean maximize, Variable objective); void clearObjective(); void setPrecision(double p); void setSeed(long seed); long getSeed(); void addHook(String hookName, Object hookObject); void removeHook(String hookName); void removeAllHooks(); void setName(String name); void associates(Variable variable); void unassociates(Variable variable); int nextId(); int nextNameId(); void post(Constraint... cs); void postTemp(Constraint... cs); void unpost(Constraint... constraints); @Override String toString(); @Override Model ref(); static boolean MAXIMIZE; static boolean MINIMIZE; static final String TASK_SET_HOOK_NAME; static final String MINISAT_HOOK_NAME; static final String NOGOODS_HOOK_NAME; static final String CLAUSES_HOOK_NAME; static final String CLAUSESBUILDER_HOOK_NAME; static final String IBEX_HOOK_NAME; }