@Test(groups = "1s") public void testPropagateOneLiteral() throws Exception { int ap = SatSolver.makeLiteral(a, true); int an = SatSolver.makeLiteral(a, false); int bp = SatSolver.makeLiteral(b, true); int bn = SatSolver.makeLiteral(b, false); int cp = SatSolver.makeLiteral(c, true); int cn = SatSolver.makeLiteral(c, false); int dp = SatSolver.makeLiteral(d, true); int dn = SatSolver.makeLiteral(d, false); sat.addClause(an, bp); sat.addClause(cn, dp); sat.addClause(cp, dp); Assert.assertTrue(sat.propagateOneLiteral(ap)); Assert.assertEquals(sat.valueVar(a), SatSolver.Boolean.kFalse); Assert.assertEquals(sat.valueVar(b), SatSolver.Boolean.kFalse); Assert.assertEquals(sat.valueVar(c), SatSolver.Boolean.kUndefined); Assert.assertEquals(sat.valueVar(d), SatSolver.Boolean.kUndefined); Assert.assertEquals(sat.qhead_, 2); Assert.assertEquals(sat.trail_.size(), 2); Assert.assertEquals(sat.trail_.get(0), 1); Assert.assertEquals(sat.trail_.get(1), 3); Assert.assertEquals(sat.trail_markers_.size(), 1); Assert.assertEquals(sat.trailMarker(), 1); Assert.assertEquals(sat.trail_markers_.get(0), 0); Assert.assertFalse(sat.propagateOneLiteral(an)); Assert.assertTrue(sat.propagateOneLiteral(bp)); Assert.assertEquals(sat.valueVar(a), SatSolver.Boolean.kFalse); Assert.assertEquals(sat.valueVar(b), SatSolver.Boolean.kFalse); Assert.assertEquals(sat.valueVar(c), SatSolver.Boolean.kUndefined); Assert.assertEquals(sat.valueVar(d), SatSolver.Boolean.kUndefined); Assert.assertEquals(sat.qhead_, 2); Assert.assertEquals(sat.trail_.size(), 2); Assert.assertEquals(sat.trail_.get(0), 1); Assert.assertEquals(sat.trail_.get(1), 3); Assert.assertEquals(sat.trail_markers_.size(), 2); Assert.assertEquals(sat.trailMarker(), 2); Assert.assertEquals(sat.trail_markers_.get(0), 0); Assert.assertEquals(sat.trail_markers_.get(1), 2); Assert.assertFalse(sat.propagateOneLiteral(bn)); sat.uncheckedEnqueue(dn); Assert.assertFalse(sat.propagateOneLiteral(cn)); }
public boolean propagateOneLiteral(int lit) { assert ok_; touched_variables_.resetQuick(); if (!propagate()) { return false; } if (valueLit(lit) == Boolean.kTrue) { pushTrailMarker(); return true; } else if (valueLit(lit) == Boolean.kFalse) { return false; } pushTrailMarker(); assert valueLit(lit) == Boolean.kUndefined; assignment_.put(var(lit), makeBoolean(!sign(lit))); trail_.add(lit); return propagate(); }
SatSolver implements SatFactory { public boolean propagateOneLiteral(int lit) { assert ok_; touched_variables_.resetQuick(); if (!propagate()) { return false; } if (valueLit(lit) == Boolean.kTrue) { pushTrailMarker(); return true; } else if (valueLit(lit) == Boolean.kFalse) { return false; } pushTrailMarker(); assert valueLit(lit) == Boolean.kUndefined; assignment_.put(var(lit), makeBoolean(!sign(lit))); trail_.add(lit); return propagate(); } }
SatSolver implements SatFactory { public boolean propagateOneLiteral(int lit) { assert ok_; touched_variables_.resetQuick(); if (!propagate()) { return false; } if (valueLit(lit) == Boolean.kTrue) { pushTrailMarker(); return true; } else if (valueLit(lit) == Boolean.kFalse) { return false; } pushTrailMarker(); assert valueLit(lit) == Boolean.kUndefined; assignment_.put(var(lit), makeBoolean(!sign(lit))); trail_.add(lit); return propagate(); } SatSolver(); }
SatSolver implements SatFactory { public boolean propagateOneLiteral(int lit) { assert ok_; touched_variables_.resetQuick(); if (!propagate()) { return false; } if (valueLit(lit) == Boolean.kTrue) { pushTrailMarker(); return true; } else if (valueLit(lit) == Boolean.kFalse) { return false; } pushTrailMarker(); assert valueLit(lit) == Boolean.kUndefined; assignment_.put(var(lit), makeBoolean(!sign(lit))); trail_.add(lit); return propagate(); } SatSolver(); @Override SatSolver _me(); int newVariable(); boolean addClause(TIntList ps); boolean learnClause(int... ps); boolean addClause(int l); void cancelUntil(int level); int trailMarker(); int nLearnt(); boolean propagateOneLiteral(int lit); void detachLearnt(int ci); static int makeLiteral(int var, boolean sign); static int negated(int l); static boolean sign(int l); static int var(int l); void copyFrom(SatSolver o); long nbclauses(); long numvars(); }
SatSolver implements SatFactory { public boolean propagateOneLiteral(int lit) { assert ok_; touched_variables_.resetQuick(); if (!propagate()) { return false; } if (valueLit(lit) == Boolean.kTrue) { pushTrailMarker(); return true; } else if (valueLit(lit) == Boolean.kFalse) { return false; } pushTrailMarker(); assert valueLit(lit) == Boolean.kUndefined; assignment_.put(var(lit), makeBoolean(!sign(lit))); trail_.add(lit); return propagate(); } SatSolver(); @Override SatSolver _me(); int newVariable(); boolean addClause(TIntList ps); boolean learnClause(int... ps); boolean addClause(int l); void cancelUntil(int level); int trailMarker(); int nLearnt(); boolean propagateOneLiteral(int lit); void detachLearnt(int ci); static int makeLiteral(int var, boolean sign); static int negated(int l); static boolean sign(int l); static int var(int l); void copyFrom(SatSolver o); long nbclauses(); long numvars(); public boolean ok_; public ArrayList<Clause> clauses; public ArrayList<Clause> learnts; public TIntObjectHashMap<TIntArrayList> implies_; public TIntArrayList touched_variables_; }