- java.lang.Object
-
- org.logicng.solvers.datastructures.MSClause
-
public final class MSClause extends Object
A clause of the SAT solver for MiniSAT-style solvers.- Since:
- 1.0
- Version:
- 2.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<MSClause>glucoseComparatorA comparator for clauses based on LBD and activity (used for the Glucose solver).static Comparator<MSClause>minisatComparatorA comparator for clauses based on activity (used for the MiniSAT solver).
-
Constructor Summary
Constructors Constructor Description MSClause(LNGIntVector ps, boolean learnt)Constructs a new clauseMSClause(LNGIntVector ps, boolean learnt, boolean isAtMost)Constructs a new clause
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleactivity()Returns the activity of this clause.intatMostWatchers()Returns the number of watchers if this is an at-most clause.booleancanBeDel()Returnstrueif this clause can be deleted,falseotherwise.intcardinality()Returns the right-hand k side of an at-most k constraint.booleanequals(Object o)intget(int i)Returns the literal at indexi.inthashCode()voidincrementActivity(double inc)Increments this clause's activity by a given valuebooleanisAtMost()Returnstrueif this is an at-most clause,falseotherwise.longlbd()Returns the LBD of this clause.booleanlearnt()Returnstrueif this clause is learnt,falseotherwise.booleanoneWatched()Returnstrueif this clause is a one literal watched clause,falseotherwisevoidpop()Pops (removes) the last literal of this clause.voidrescaleActivity()Rescales this clause's activitybooleanseen()Returnstrueif this clause is marked 'seen',falseotherwise.voidset(int i, int lit)Sets the literal at indexi.voidsetAtMostWatchers(int atMostWatchers)Sets the number of watchers for this at-most clause.voidsetCanBeDel(boolean canBeDel)Sets whether this clause can be deleted or not.voidsetLBD(long lbd)Sets the LBD of this clause.voidsetOneWatched(boolean oneWatched)Sets whether this clause is a one literal watched clause or not.voidsetSeen(boolean seen)Marks this clause with the given 'seen' flag.voidsetSizeWithoutSelectors(int szWithoutSelectors)Sets the size of this clause without selector variables.intsize()Returns the size (number of literals) of this clause.intsizeWithoutSelectors()Returns the size of this clause without selector variables.StringtoString()
-
-
-
Field Detail
-
glucoseComparator
public static final Comparator<MSClause> glucoseComparator
A comparator for clauses based on LBD and activity (used for the Glucose solver).
-
minisatComparator
public static final Comparator<MSClause> minisatComparator
A comparator for clauses based on activity (used for the MiniSAT solver).
-
-
Constructor Detail
-
MSClause
public MSClause(LNGIntVector ps, boolean learnt)
Constructs a new clause- Parameters:
ps- the vector of literalslearnt-trueif it is a learnt clause,falseotherwise
-
MSClause
public MSClause(LNGIntVector ps, boolean learnt, boolean isAtMost)
Constructs a new clause- Parameters:
ps- the vector of literalslearnt-trueif it is a learnt clause,falseotherwiseisAtMost-trueif it is an at-most clause,falseotherwise
-
-
Method Detail
-
size
public int size()
Returns the size (number of literals) of this clause.- Returns:
- the size
-
get
public int get(int i)
Returns the literal at indexi.- Parameters:
i- the index- Returns:
- the literal at index
i
-
set
public void set(int i, int lit)Sets the literal at indexi.- Parameters:
i- the indexlit- the literal
-
activity
public double activity()
Returns the activity of this clause.- Returns:
- the activity of this clause
-
incrementActivity
public void incrementActivity(double inc)
Increments this clause's activity by a given value- Parameters:
inc- the increment value
-
rescaleActivity
public void rescaleActivity()
Rescales this clause's activity
-
learnt
public boolean learnt()
Returnstrueif this clause is learnt,falseotherwise.- Returns:
trueif this clause is learnt
-
sizeWithoutSelectors
public int sizeWithoutSelectors()
Returns the size of this clause without selector variables.- Returns:
- the size of this clause without selector variables
-
setSizeWithoutSelectors
public void setSizeWithoutSelectors(int szWithoutSelectors)
Sets the size of this clause without selector variables.- Parameters:
szWithoutSelectors- the size of this clause without selector variables
-
seen
public boolean seen()
Returnstrueif this clause is marked 'seen',falseotherwise.- Returns:
trueif this clause is marked 'seen'
-
setSeen
public void setSeen(boolean seen)
Marks this clause with the given 'seen' flag.- Parameters:
seen- the 'seen' flag
-
lbd
public long lbd()
Returns the LBD of this clause.- Returns:
- the LBD of this clause
-
setLBD
public void setLBD(long lbd)
Sets the LBD of this clause.- Parameters:
lbd- the LBD of this clause
-
canBeDel
public boolean canBeDel()
Returnstrueif this clause can be deleted,falseotherwise.- Returns:
trueif this clause can be deleted
-
setCanBeDel
public void setCanBeDel(boolean canBeDel)
Sets whether this clause can be deleted or not.- Parameters:
canBeDel-trueif it can be deleted,falseotherwise
-
oneWatched
public boolean oneWatched()
Returnstrueif this clause is a one literal watched clause,falseotherwise- Returns:
trueif this clause is a one literal watched clause
-
setOneWatched
public void setOneWatched(boolean oneWatched)
Sets whether this clause is a one literal watched clause or not.- Parameters:
oneWatched-trueif it is a one literal watched clause,falseotherwise
-
isAtMost
public boolean isAtMost()
Returnstrueif this is an at-most clause,falseotherwise.- Returns:
trueif this is an at-most clause
-
atMostWatchers
public int atMostWatchers()
Returns the number of watchers if this is an at-most clause.- Returns:
- the number of watchers
-
setAtMostWatchers
public void setAtMostWatchers(int atMostWatchers)
Sets the number of watchers for this at-most clause.- Parameters:
atMostWatchers- the number of watchers
-
pop
public void pop()
Pops (removes) the last literal of this clause.
-
cardinality
public int cardinality()
Returns the right-hand k side of an at-most k constraint.- Returns:
- the right-hand side
-
-