Package org.jacop.satwrapper.translation
Class SatCPBridge
- java.lang.Object
-
- org.jacop.satwrapper.translation.SatCPBridge
-
- All Implemented Interfaces:
WrapperComponent
- Direct Known Subclasses:
LazyCpVarDomain
,SimpleCpVarDomain
public abstract class SatCPBridge extends java.lang.Object implements WrapperComponent
interface representing the domain of a CP variable as a range. It is used to provide literals to represent assertions like 'X = v' or 'X<= v' where X is the CP variable and v a value from its domain- Version:
- 4.8
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
hasSetDomain
IntDomain
initialDomain
int
max
int
min
IntVar
variable
protected SatWrapper
wrapper
-
Constructor Summary
Constructors Constructor Description SatCPBridge(IntVar variable)
simple constructor with a variable
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract int
boolVarToCpValue(int literal)
return the value corresponding to given literal (variable)abstract int
cpValueToBoolVar(int value, boolean isEquality)
return the literal that represents the assertion 'var = value'.int
getLeftLimit()
the left limit of the rangeint
getRightLimit()
the right limit of the rangeabstract void
initialize(SatWrapper wrapper)
connect the component to the wrapperabstract boolean
isEqualityBoolVar(int literal)
checks if the literal stands for a 'x=d' proposition, or a 'x<=d' propositionboolean
isInThisRange(int literal)
checks if the literal represents a proposition about the variable this object managesabstract boolean
isTranslated()
predicate for whether this variable should be handled by the DomainClausesDatabase or notabstract void
propagate(int literal)
does all propagation required, in a way specific to this range.void
setDomain(int minValue, int maxValue)
set the domain to be between minValue and maxValue.java.lang.String
toString()
-
-
-
Field Detail
-
wrapper
protected SatWrapper wrapper
-
variable
public final IntVar variable
-
initialDomain
public final IntDomain initialDomain
-
min
public int min
-
max
public int max
-
hasSetDomain
protected boolean hasSetDomain
-
-
Constructor Detail
-
SatCPBridge
public SatCPBridge(IntVar variable)
simple constructor with a variable- Parameters:
variable
- the variable of which this is the range
-
-
Method Detail
-
getLeftLimit
public final int getLeftLimit()
the left limit of the range- Returns:
- the *value* of the current left limit of the range
-
getRightLimit
public final int getRightLimit()
the right limit of the range- Returns:
- the *value* of the current right limit of the range
-
setDomain
public void setDomain(int minValue, int maxValue)
set the domain to be between minValue and maxValue. It only does something on the first call.- Parameters:
minValue
- minimum value of the rangemaxValue
- maximum value of the range
-
cpValueToBoolVar
public abstract int cpValueToBoolVar(int value, boolean isEquality)
return the literal that represents the assertion 'var = value'. For the proposition 'var<= value', set the isEquality flag to false- Parameters:
value
- the value for the variable this range representsisEquality
- true if we want the literal for 'x=d
' kind of propositions, false for 'x<=d
'- Returns:
- the literal corresponding to 'var = this value'. If the value is out of the domain of the variable, returns 0.
-
boolVarToCpValue
public abstract int boolVarToCpValue(int literal)
return the value corresponding to given literal (variable)- Parameters:
literal
- the literal standing for 'var = value'- Returns:
- the value such that 'var = value' (or 'var<= value')
-
isEqualityBoolVar
public abstract boolean isEqualityBoolVar(int literal)
checks if the literal stands for a 'x=d' proposition, or a 'x<=d' proposition- Parameters:
literal
- the literal (among literals from this range)- Returns:
- true if the literal stands for 'x=d', false otherwise
-
isInThisRange
public final boolean isInThisRange(int literal)
checks if the literal represents a proposition about the variable this object manages- Parameters:
literal
- a literal- Returns:
- true if there is a 'd' such that literal stands for 'x=d' or 'x<=d'
-
propagate
public abstract void propagate(int literal)
does all propagation required, in a way specific to this range. This part may not be used, if the variable is not bound to a DomainClausesDatabase. This will be called only ifthis.isTranslated()
is false.- Parameters:
literal
- the literal that has been asserted
-
isTranslated
public abstract boolean isTranslated()
predicate for whether this variable should be handled by the DomainClausesDatabase or not- Returns:
- true if the variable should be handled by the DomainClausesDatabase
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
initialize
public abstract void initialize(SatWrapper wrapper)
Description copied from interface:WrapperComponent
connect the component to the wrapper- Specified by:
initialize
in interfaceWrapperComponent
- Parameters:
wrapper
- the wrapper
-
-