Package org.jacop.satwrapper.translation
Class SimpleCpVarDomain
java.lang.Object
org.jacop.satwrapper.translation.SatCPBridge
org.jacop.satwrapper.translation.SimpleCpVarDomain
- All Implemented Interfaces:
WrapperComponent
A simple representation for small domains, not lazy. It allocates boolean
variables to stand for propositions '[x=v]' and '[x<=v]' for each value v of
the domain of x (even '[x<=max]', which is a tautology, for simplicity)
- Version:
- 4.10
-
Field Summary
FieldsFields inherited from class org.jacop.satwrapper.translation.SatCPBridge
hasSetDomain, initialDomain, max, min, variable, wrapper -
Constructor Summary
ConstructorsConstructorDescriptionSimpleCpVarDomain(SatWrapper wrapper, IntVar variable) SimpleCpVarDomain(SatWrapper wrapper, IntVar variable, boolean translate) -
Method Summary
Modifier and TypeMethodDescriptionfinal intboolVarToCpValue(int literal) return the value corresponding to given literal (variable)final intcpValueToBoolVar(int value, boolean isEquality) return the literal that represents the assertion 'var = value'.voidinitialize(SatWrapper wrapper) connect the component to the wrapperfinal booleanisEqualityBoolVar(int literal) checks if the literal stands for a 'x=d' proposition, or a 'x<=d' propositionbooleanpredicate for whether this variable should be handled by the DomainClausesDatabase or notvoidpropagate(int literal) given some literal has a value, what other literals should be asserted ?voidsetDomain(int minValue, int maxValue) set the domain to be between minValue and maxValue.Methods inherited from class org.jacop.satwrapper.translation.SatCPBridge
getLeftLimit, getRightLimit, isInThisRange, toString
-
Field Details
-
firstVar
private int firstVar -
width
private int width -
clauseDatabase
-
isTranslated
public boolean isTranslated
-
-
Constructor Details
-
SimpleCpVarDomain
-
SimpleCpVarDomain
-
-
Method Details
-
cpValueToBoolVar
public final int cpValueToBoolVar(int value, boolean isEquality) Description copied from class:SatCPBridgereturn the literal that represents the assertion 'var = value'. For the proposition 'var<= value', set the isEquality flag to false- Specified by:
cpValueToBoolVarin classSatCPBridge- 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 final int boolVarToCpValue(int literal) Description copied from class:SatCPBridgereturn the value corresponding to given literal (variable)- Specified by:
boolVarToCpValuein classSatCPBridge- Parameters:
literal- the literal standing for 'var = value'- Returns:
- the value such that 'var = value' (or 'var<= value')
-
isEqualityBoolVar
public final boolean isEqualityBoolVar(int literal) Description copied from class:SatCPBridgechecks if the literal stands for a 'x=d' proposition, or a 'x<=d' proposition- Specified by:
isEqualityBoolVarin classSatCPBridge- Parameters:
literal- the literal (among literals from this range)- Returns:
- true if the literal stands for 'x=d', false otherwise
-
setDomain
public void setDomain(int minValue, int maxValue) Description copied from class:SatCPBridgeset the domain to be between minValue and maxValue. It only does something on the first call.- Overrides:
setDomainin classSatCPBridge- Parameters:
minValue- minimum value of the rangemaxValue- maximum value of the range
-
propagate
public void propagate(int literal) given some literal has a value, what other literals should be asserted ?- Specified by:
propagatein classSatCPBridge- Parameters:
literal- the literal that has been asserted
-
isTranslated
public boolean isTranslated()Description copied from class:SatCPBridgepredicate for whether this variable should be handled by the DomainClausesDatabase or not- Specified by:
isTranslatedin classSatCPBridge- Returns:
- true if the variable should be handled by the DomainClausesDatabase
-
initialize
Description copied from interface:WrapperComponentconnect the component to the wrapper- Specified by:
initializein interfaceWrapperComponent- Specified by:
initializein classSatCPBridge- Parameters:
wrapper- the wrapper
-