@Test(groups="1s", timeOut=60000) public void testLiteral2() throws Exception { BoolVar[] b = vars[0].getModel().boolVarArray("B", 100); for(int i = 0 ; i < 100; i++){ PNG.Literal(b[i], 0, true); PNG.Literal(b[i], 0, false); } }
public int Literal(IntVar ivar, int value, boolean eq) { int vid = ivar.getId(); int var; TLongIntHashMap map; if (vid >= vv2lit.length) { TLongIntHashMap[] tmp = vv2lit; vv2lit = new TLongIntHashMap[vid + 1]; System.arraycopy(tmp, 0, vv2lit, 0, tmp.length); int[] tmpi = var2pos; var2pos = new int[vid + 1]; System.arraycopy(tmpi, 0, var2pos, 0, tmpi.length); Arrays.fill(var2pos, tmpi.length, vid + 1, NO_ENTRY); } if ((map = vv2lit[vid]) == null) { map = new TLongIntHashMap(16, .5f, NO_ENTRY, NO_ENTRY); vv2lit[vid] = map; } int pos; if ((pos = var2pos[vid]) == NO_ENTRY) { if (initialized) { addVariable(ivar); pos = vars.length - 1; } else { add_var.add(ivar); pos = add_var.size() - 1; } var2pos[vid] = pos; } long lvalue = eq ? value : leq(value); if ((var = map.get(lvalue)) == NO_ENTRY) { var = sat_.newVariable(); map.put(lvalue, var); if (var >= lit2pos.length) { int[] itmp = lit2pos; lit2pos = new int[var + 1]; System.arraycopy(itmp, 0, lit2pos, 0, itmp.length); Arrays.fill(lit2pos, itmp.length, var + 1, NO_ENTRY); long[] ltmp = lit2val; lit2val = new long[var + 1]; System.arraycopy(ltmp, 0, lit2val, 0, ltmp.length); Arrays.fill(lit2val, ltmp.length, var + 1, NO_ENTRY); } lit2pos[var] = pos; lit2val[var] = lvalue; } return makeLiteral(var, true); }
PropNogoods extends Propagator<Variable> { public int Literal(IntVar ivar, int value, boolean eq) { int vid = ivar.getId(); int var; TLongIntHashMap map; if (vid >= vv2lit.length) { TLongIntHashMap[] tmp = vv2lit; vv2lit = new TLongIntHashMap[vid + 1]; System.arraycopy(tmp, 0, vv2lit, 0, tmp.length); int[] tmpi = var2pos; var2pos = new int[vid + 1]; System.arraycopy(tmpi, 0, var2pos, 0, tmpi.length); Arrays.fill(var2pos, tmpi.length, vid + 1, NO_ENTRY); } if ((map = vv2lit[vid]) == null) { map = new TLongIntHashMap(16, .5f, NO_ENTRY, NO_ENTRY); vv2lit[vid] = map; } int pos; if ((pos = var2pos[vid]) == NO_ENTRY) { if (initialized) { addVariable(ivar); pos = vars.length - 1; } else { add_var.add(ivar); pos = add_var.size() - 1; } var2pos[vid] = pos; } long lvalue = eq ? value : leq(value); if ((var = map.get(lvalue)) == NO_ENTRY) { var = sat_.newVariable(); map.put(lvalue, var); if (var >= lit2pos.length) { int[] itmp = lit2pos; lit2pos = new int[var + 1]; System.arraycopy(itmp, 0, lit2pos, 0, itmp.length); Arrays.fill(lit2pos, itmp.length, var + 1, NO_ENTRY); long[] ltmp = lit2val; lit2val = new long[var + 1]; System.arraycopy(ltmp, 0, lit2val, 0, ltmp.length); Arrays.fill(lit2val, ltmp.length, var + 1, NO_ENTRY); } lit2pos[var] = pos; lit2val[var] = lvalue; } return makeLiteral(var, true); } }
PropNogoods extends Propagator<Variable> { public int Literal(IntVar ivar, int value, boolean eq) { int vid = ivar.getId(); int var; TLongIntHashMap map; if (vid >= vv2lit.length) { TLongIntHashMap[] tmp = vv2lit; vv2lit = new TLongIntHashMap[vid + 1]; System.arraycopy(tmp, 0, vv2lit, 0, tmp.length); int[] tmpi = var2pos; var2pos = new int[vid + 1]; System.arraycopy(tmpi, 0, var2pos, 0, tmpi.length); Arrays.fill(var2pos, tmpi.length, vid + 1, NO_ENTRY); } if ((map = vv2lit[vid]) == null) { map = new TLongIntHashMap(16, .5f, NO_ENTRY, NO_ENTRY); vv2lit[vid] = map; } int pos; if ((pos = var2pos[vid]) == NO_ENTRY) { if (initialized) { addVariable(ivar); pos = vars.length - 1; } else { add_var.add(ivar); pos = add_var.size() - 1; } var2pos[vid] = pos; } long lvalue = eq ? value : leq(value); if ((var = map.get(lvalue)) == NO_ENTRY) { var = sat_.newVariable(); map.put(lvalue, var); if (var >= lit2pos.length) { int[] itmp = lit2pos; lit2pos = new int[var + 1]; System.arraycopy(itmp, 0, lit2pos, 0, itmp.length); Arrays.fill(lit2pos, itmp.length, var + 1, NO_ENTRY); long[] ltmp = lit2val; lit2val = new long[var + 1]; System.arraycopy(ltmp, 0, lit2val, 0, ltmp.length); Arrays.fill(lit2val, ltmp.length, var + 1, NO_ENTRY); } lit2pos[var] = pos; lit2val[var] = lvalue; } return makeLiteral(var, true); } PropNogoods(Model model); }
PropNogoods extends Propagator<Variable> { public int Literal(IntVar ivar, int value, boolean eq) { int vid = ivar.getId(); int var; TLongIntHashMap map; if (vid >= vv2lit.length) { TLongIntHashMap[] tmp = vv2lit; vv2lit = new TLongIntHashMap[vid + 1]; System.arraycopy(tmp, 0, vv2lit, 0, tmp.length); int[] tmpi = var2pos; var2pos = new int[vid + 1]; System.arraycopy(tmpi, 0, var2pos, 0, tmpi.length); Arrays.fill(var2pos, tmpi.length, vid + 1, NO_ENTRY); } if ((map = vv2lit[vid]) == null) { map = new TLongIntHashMap(16, .5f, NO_ENTRY, NO_ENTRY); vv2lit[vid] = map; } int pos; if ((pos = var2pos[vid]) == NO_ENTRY) { if (initialized) { addVariable(ivar); pos = vars.length - 1; } else { add_var.add(ivar); pos = add_var.size() - 1; } var2pos[vid] = pos; } long lvalue = eq ? value : leq(value); if ((var = map.get(lvalue)) == NO_ENTRY) { var = sat_.newVariable(); map.put(lvalue, var); if (var >= lit2pos.length) { int[] itmp = lit2pos; lit2pos = new int[var + 1]; System.arraycopy(itmp, 0, lit2pos, 0, itmp.length); Arrays.fill(lit2pos, itmp.length, var + 1, NO_ENTRY); long[] ltmp = lit2val; lit2val = new long[var + 1]; System.arraycopy(ltmp, 0, lit2val, 0, ltmp.length); Arrays.fill(lit2val, ltmp.length, var + 1, NO_ENTRY); } lit2pos[var] = pos; lit2val[var] = lvalue; } return makeLiteral(var, true); } PropNogoods(Model model); @Override void propagate(int evtmask); @Override void propagate(int idxVarInProp, int mask); @Override ESat isEntailed(); void initialize(); int Literal(IntVar ivar, int value, boolean eq); int Literal(SetVar svar, int value, boolean in); @SuppressWarnings("unused") boolean addNogood(int p); @SuppressWarnings("unused") boolean addNogood(TIntList lits); void addLearnt(int... lits); }
PropNogoods extends Propagator<Variable> { public int Literal(IntVar ivar, int value, boolean eq) { int vid = ivar.getId(); int var; TLongIntHashMap map; if (vid >= vv2lit.length) { TLongIntHashMap[] tmp = vv2lit; vv2lit = new TLongIntHashMap[vid + 1]; System.arraycopy(tmp, 0, vv2lit, 0, tmp.length); int[] tmpi = var2pos; var2pos = new int[vid + 1]; System.arraycopy(tmpi, 0, var2pos, 0, tmpi.length); Arrays.fill(var2pos, tmpi.length, vid + 1, NO_ENTRY); } if ((map = vv2lit[vid]) == null) { map = new TLongIntHashMap(16, .5f, NO_ENTRY, NO_ENTRY); vv2lit[vid] = map; } int pos; if ((pos = var2pos[vid]) == NO_ENTRY) { if (initialized) { addVariable(ivar); pos = vars.length - 1; } else { add_var.add(ivar); pos = add_var.size() - 1; } var2pos[vid] = pos; } long lvalue = eq ? value : leq(value); if ((var = map.get(lvalue)) == NO_ENTRY) { var = sat_.newVariable(); map.put(lvalue, var); if (var >= lit2pos.length) { int[] itmp = lit2pos; lit2pos = new int[var + 1]; System.arraycopy(itmp, 0, lit2pos, 0, itmp.length); Arrays.fill(lit2pos, itmp.length, var + 1, NO_ENTRY); long[] ltmp = lit2val; lit2val = new long[var + 1]; System.arraycopy(ltmp, 0, lit2val, 0, ltmp.length); Arrays.fill(lit2val, ltmp.length, var + 1, NO_ENTRY); } lit2pos[var] = pos; lit2val[var] = lvalue; } return makeLiteral(var, true); } PropNogoods(Model model); @Override void propagate(int evtmask); @Override void propagate(int idxVarInProp, int mask); @Override ESat isEntailed(); void initialize(); int Literal(IntVar ivar, int value, boolean eq); int Literal(SetVar svar, int value, boolean in); @SuppressWarnings("unused") boolean addNogood(int p); @SuppressWarnings("unused") boolean addNogood(TIntList lits); void addLearnt(int... lits);  }