@Test(groups = "1s", timeOut = 60000) public void testStampIt1() throws Exception { cos.stampIt(mvars[0]); Assert.assertEquals(cos.vars.size(), 1); Assert.assertEquals(cos.vars.get(0), mvars[0]); Assert.assertEquals(cos.prev.get(0), -1); Assert.assertEquals(cos.next.get(0), -1); Assert.assertEquals(cos.pcft, 0); cos.stampIt(mvars[1]); Assert.assertEquals(cos.vars.size(), 2); Assert.assertEquals(cos.vars.get(1), mvars[1]); Assert.assertEquals(cos.prev.get(0), -1); Assert.assertEquals(cos.next.get(0), 1); Assert.assertEquals(cos.prev.get(1), 0); Assert.assertEquals(cos.next.get(1), -1); Assert.assertEquals(cos.pcft, 1); cos.stampIt(mvars[2]); Assert.assertEquals(cos.vars.size(), 3); Assert.assertEquals(cos.vars.get(2), mvars[2]); Assert.assertEquals(cos.prev.get(0), -1); Assert.assertEquals(cos.next.get(0), 1); Assert.assertEquals(cos.prev.get(1), 0); Assert.assertEquals(cos.next.get(1), 2); Assert.assertEquals(cos.prev.get(2), 1); Assert.assertEquals(cos.next.get(2), -1); Assert.assertEquals(cos.pcft, 2); cos.stampIt(mvars[3]); Assert.assertEquals(cos.vars.size(), 4); Assert.assertEquals(cos.vars.get(3), mvars[3]); Assert.assertEquals(cos.prev.get(0), -1); Assert.assertEquals(cos.next.get(0), 1); Assert.assertEquals(cos.prev.get(1), 0); Assert.assertEquals(cos.next.get(1), 2); Assert.assertEquals(cos.prev.get(2), 1); Assert.assertEquals(cos.next.get(2), 3); Assert.assertEquals(cos.prev.get(3), 2); Assert.assertEquals(cos.next.get(3), -1); Assert.assertEquals(cos.pcft, 3); cos.stampIt(mvars[0]); Assert.assertEquals(cos.vars.size(), 4); Assert.assertEquals(cos.prev.get(1), -1); Assert.assertEquals(cos.next.get(1), 2); Assert.assertEquals(cos.prev.get(2), 1); Assert.assertEquals(cos.next.get(2), 3); Assert.assertEquals(cos.prev.get(3), 2); Assert.assertEquals(cos.next.get(3), 0); Assert.assertEquals(cos.prev.get(0), 3); Assert.assertEquals(cos.next.get(0), -1); Assert.assertEquals(cos.pcft, 0); cos.stampIt(mvars[3]); Assert.assertEquals(cos.vars.size(), 4); Assert.assertEquals(cos.prev.get(1), -1); Assert.assertEquals(cos.next.get(1), 2); Assert.assertEquals(cos.prev.get(2), 1); Assert.assertEquals(cos.next.get(2), 0); Assert.assertEquals(cos.prev.get(0), 2); Assert.assertEquals(cos.next.get(0), 3); Assert.assertEquals(cos.prev.get(3), 0); Assert.assertEquals(cos.next.get(3), -1); Assert.assertEquals(cos.pcft, 3); }
void stampIt(V cftVar) { int id = cftVar.getId(); int pos = var2pos.get(id); if (pos == -1) { pos = vars.size(); vars.add(cftVar); var2pos.put(id, pos); if (pcft > -1) { next.add(-1); next.set(pcft, pos); prev.add(pcft); } else { assert pos == 0; prev.add(-1); next.add(-1); } } else if (pos != pcft) { int p = prev.get(pos); int n = next.get(pos); if (p > -1) { next.set(p, n); } next.set(pcft, pos); next.set(pos, -1); if (n > -1) { prev.set(n, p); } prev.set(pos, pcft); } pcft = pos; }
ConflictOrderingSearch extends AbstractStrategy<V> implements IMonitorContradiction { void stampIt(V cftVar) { int id = cftVar.getId(); int pos = var2pos.get(id); if (pos == -1) { pos = vars.size(); vars.add(cftVar); var2pos.put(id, pos); if (pcft > -1) { next.add(-1); next.set(pcft, pos); prev.add(pcft); } else { assert pos == 0; prev.add(-1); next.add(-1); } } else if (pos != pcft) { int p = prev.get(pos); int n = next.get(pos); if (p > -1) { next.set(p, n); } next.set(pcft, pos); next.set(pos, -1); if (n > -1) { prev.set(n, p); } prev.set(pos, pcft); } pcft = pos; } }
ConflictOrderingSearch extends AbstractStrategy<V> implements IMonitorContradiction { void stampIt(V cftVar) { int id = cftVar.getId(); int pos = var2pos.get(id); if (pos == -1) { pos = vars.size(); vars.add(cftVar); var2pos.put(id, pos); if (pcft > -1) { next.add(-1); next.set(pcft, pos); prev.add(pcft); } else { assert pos == 0; prev.add(-1); next.add(-1); } } else if (pos != pcft) { int p = prev.get(pos); int n = next.get(pos); if (p > -1) { next.set(p, n); } next.set(pcft, pos); next.set(pos, -1); if (n > -1) { prev.set(n, p); } prev.set(pos, pcft); } pcft = pos; } ConflictOrderingSearch(Model model, AbstractStrategy<V> mainStrategy); }
ConflictOrderingSearch extends AbstractStrategy<V> implements IMonitorContradiction { void stampIt(V cftVar) { int id = cftVar.getId(); int pos = var2pos.get(id); if (pos == -1) { pos = vars.size(); vars.add(cftVar); var2pos.put(id, pos); if (pcft > -1) { next.add(-1); next.set(pcft, pos); prev.add(pcft); } else { assert pos == 0; prev.add(-1); next.add(-1); } } else if (pos != pcft) { int p = prev.get(pos); int n = next.get(pos); if (p > -1) { next.set(p, n); } next.set(pcft, pos); next.set(pos, -1); if (n > -1) { prev.set(n, p); } prev.set(pos, pcft); } pcft = pos; } ConflictOrderingSearch(Model model, AbstractStrategy<V> mainStrategy); @Override boolean init(); @Override void remove(); @SuppressWarnings("unchecked") @Override Decision<V> getDecision(); @Override void onContradiction(ContradictionException cex); }
ConflictOrderingSearch extends AbstractStrategy<V> implements IMonitorContradiction { void stampIt(V cftVar) { int id = cftVar.getId(); int pos = var2pos.get(id); if (pos == -1) { pos = vars.size(); vars.add(cftVar); var2pos.put(id, pos); if (pcft > -1) { next.add(-1); next.set(pcft, pos); prev.add(pcft); } else { assert pos == 0; prev.add(-1); next.add(-1); } } else if (pos != pcft) { int p = prev.get(pos); int n = next.get(pos); if (p > -1) { next.set(p, n); } next.set(pcft, pos); next.set(pos, -1); if (n > -1) { prev.set(n, p); } prev.set(pos, pcft); } pcft = pos; } ConflictOrderingSearch(Model model, AbstractStrategy<V> mainStrategy); @Override boolean init(); @Override void remove(); @SuppressWarnings("unchecked") @Override Decision<V> getDecision(); @Override void onContradiction(ContradictionException cex);  }