public class MinWatchCard extends Object implements Propagatable, Constr, Undoable, Serializable
Modifier and Type | Field and Description |
---|---|
static boolean |
ATLEAST |
static boolean |
ATMOST |
protected int |
degree
degree of the cardinality constraint
|
protected int |
watchCumul
contains the sum of the coefficients of the watched literals
|
Modifier | Constructor and Description |
---|---|
|
MinWatchCard(ILits voc,
IVecInt ps,
boolean moreThan,
int degree)
Constructs and normalizes a cardinality constraint. used by
minWatchCardNew in the non-normalized case.
|
protected |
MinWatchCard(ILits voc,
IVecInt ps,
int degree)
Constructs and normalizes a cardinality constraint. used by
MinWatchCardPB.normalizedMinWatchCardNew() in the normalized case.
|
Modifier and Type | Method and Description |
---|---|
void |
assertConstraint(UnitPropagationListener s)
Method called when the constraint is to be asserted.
|
void |
assertConstraintIfNeeded(UnitPropagationListener s)
Method called when the constraint is added to the solver "on the fly".
|
void |
calcReason(int p,
IVecInt outReason)
computes the reason for a literal
|
void |
calcReasonOnTheFly(int p,
IVecInt trail,
IVecInt outReason)
Compute the reason for a given assignment in a the constraint created on
the fly in the solver.
|
boolean |
canBePropagatedMultipleTimes()
Partition constraints into the ones that can only be found once on the
trail (e.g. clauses) and the ones that can be found several times (e.g.
|
protected MinWatchCard |
computePropagation(UnitPropagationListener s) |
protected void |
computeWatches() |
boolean |
equals(Object card) |
void |
forwardActivity(double claInc) |
int |
get(int i)
returns the ith literal in the constraint
|
double |
getActivity()
Returns the activity of the constraint
|
int[] |
getLits() |
ILits |
getVocabulary() |
int |
hashCode() |
void |
incActivity(double claInc)
Increments activity of the constraint
|
boolean |
learnt()
Returns wether the constraint is learnt or not.
|
protected static int |
linearisation(ILits voc,
IVecInt ps)
Simplifies the constraint w.r.t. the assignments of the literals
|
boolean |
locked()
Returns if the constraint is the reason for a unit propagation.
|
static Constr |
minWatchCardNew(UnitPropagationListener s,
ILits voc,
IVecInt ps,
boolean moreThan,
int degree)
Constructs a cardinality constraint with a minimal set of watched
literals Permet la cr?
|
void |
normalize()
normalize the constraint (cf.
|
boolean |
propagate(UnitPropagationListener s,
int p)
propagates the value of a falsified literal
|
void |
register()
Register the constraint to the solver.
|
void |
remove(UnitPropagationListener upl)
Removes a constraint from the solver
|
void |
rescaleBy(double d)
Rescales the activity value of the constraint
|
void |
setActivity(double d)
Set the activity at a specific value
|
void |
setLearnt()
Mark a constraint as learnt.
|
boolean |
simplify()
simplifies the constraint
|
int |
size() |
Constr |
toConstraint()
Allow to access a constraint view of the propagatable to avoid casting.
|
String |
toString()
Returns a string representation of the constraint.
|
void |
undo(int p)
Updates information on the constraint in case of a backtrack
|
public static final boolean ATLEAST
public static final boolean ATMOST
protected int degree
protected int watchCumul
public MinWatchCard(ILits voc, IVecInt ps, boolean moreThan, int degree)
voc
- vocabulary used by the constraintps
- literals involved in the constraintmoreThan
- should be ATLEAST or ATMOST;degree
- degree of the constraintprotected MinWatchCard(ILits voc, IVecInt ps, int degree)
voc
- vocabulary used by the constraintps
- literals involved in the constraintdegree
- degree of the constraintpublic void calcReason(int p, IVecInt outReason)
calcReason
in interface Constr
p
- falsified literal (or Lit.UNDEFINED)outReason
- the reason to be computed. Vector of literals.Constr.calcReason(int p, IVecInt outReason)
public double getActivity()
getActivity
in interface IConstr
IConstr.getActivity()
public void incActivity(double claInc)
incActivity
in interface Constr
claInc
- value to be added to the activity of the constraintConstr.incActivity(double claInc)
public void setActivity(double d)
Constr
setActivity
in interface Constr
d
- the new activitypublic boolean learnt()
learnt
in interface IConstr
IConstr.learnt()
protected static int linearisation(ILits voc, IVecInt ps)
voc
- vocabulary usedps
- literals involvedpublic boolean locked()
locked
in interface Constr
Constr.locked()
public static Constr minWatchCardNew(UnitPropagationListener s, ILits voc, IVecInt ps, boolean moreThan, int degree) throws ContradictionException
s
- tool for propagationvoc
- vocalulary used by the constraintps
- literals involved in the constraintmoreThan
- sign of the constraint. Should be ATLEAST or ATMOST.degree
- degree of the constraintContradictionException
public final void normalize()
public boolean propagate(UnitPropagationListener s, int p)
propagate
in interface Propagatable
s
- tool for literal propagationp
- falsified literalpublic void remove(UnitPropagationListener upl)
public void rescaleBy(double d)
public boolean simplify()
public String toString()
public void undo(int p)
public void setLearnt()
Constr
public void register()
Constr
public int size()
public int get(int i)
IConstr
public void assertConstraint(UnitPropagationListener s)
Constr
assertConstraint
in interface Constr
s
- a UnitPropagationListener to use for unit propagation.public void assertConstraintIfNeeded(UnitPropagationListener s)
Constr
Constr.assertConstraint(UnitPropagationListener)
method.assertConstraintIfNeeded
in interface Constr
s
- a UnitPropagationListener to use for unit propagation.protected void computeWatches()
protected MinWatchCard computePropagation(UnitPropagationListener s) throws ContradictionException
ContradictionException
public int[] getLits()
public ILits getVocabulary()
public void forwardActivity(double claInc)
forwardActivity
in interface Constr
public boolean canBePropagatedMultipleTimes()
IConstr
canBePropagatedMultipleTimes
in interface IConstr
public Constr toConstraint()
Propagatable
toConstraint
in interface Propagatable
public void calcReasonOnTheFly(int p, IVecInt trail, IVecInt outReason)
Constr
Constr.calcReason(int, IVecInt)
, the falsification may not have been
detected as soon as possible. As such, it is necessary to take into
account the order of the literals in the trail.calcReasonOnTheFly
in interface Constr
p
- a satisfied literal (or Lit.UNDEFINED)trail
- all the literals satisfied in the solvers, should not be
modified.outReason
- a list of falsified literals whose negation is the reason of
the assignment of p to true.Copyright © 2013 Centre de Recherche en Informatique de Lens (CRIL). All Rights Reserved.