Package org.opt4j.satdecoding
Class AbstractSATDecoder<G extends Genotype,P>
java.lang.Object
org.opt4j.satdecoding.AbstractSATDecoder<G,P>
- Type Parameters:
G- The genotype (useGenotypeif you do not override the decode method)P- The phenotype
- Direct Known Subclasses:
KnapsackSATCreatorDecoder,MinOnesDecoder,QueensSATDecoder
public abstract class AbstractSATDecoder<G extends Genotype,P>
extends Object
implements Decoder<G,P>, Creator<G>
The
AbstractSATDecoder can be used for the construction of custom SAT
Decoders.
The Creator part takes the problem dependent Constraints and
creates a SATGenotype according to the variables which is the input
for the specified Optimizer.
The Decoder takes a SATGenotype, converts it to an
Order of the variables, and solves the problem in the Order
using a SAT Solver . The resulting Model, which respects the
Constraints, must then be converted to the problem specific
phenotype.
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractSATDecoder(SATManager manager, Rand random) Constructs anAbstractSATDecoderwith the givenSATManager. -
Method Summary
Modifier and TypeMethodDescriptionabstract PconvertModel(Model model) Converts aModelinto a phenotype.create()Creates a randomGenotype.abstract Set<Constraint> Creates allConstraints.Decodes a givenGenotypeto the corresponding phenotype.Returns the constraints.getLowerBounds(Set<Object> variables) Returns the lower bounds for the variables.getUpperBounds(Set<Object> variables) Returns the upper bounds for the variables.Returns the variables.ignoreVariables(Set<Object> variables) Set the variables to be ignored (not part of the search process and genotype).voidrandomize(Collection<Object> variables, Map<Object, Double> lowerBounds, Map<Object, Double> upperBounds, Map<Object, Double> priorities, Map<Object, Boolean> phases) Creates a random initialization of the priorities and phases for the variables.
-
Constructor Details
-
AbstractSATDecoder
Constructs anAbstractSATDecoderwith the givenSATManager.- Parameters:
manager- the specified sat managerrandom- the random number generator
-
-
Method Details
-
createConstraints
Creates allConstraints.Override this method to return the problem specific
Constraints that have to be respected by the resultingModel.- Returns:
- the set of all constraints of the given problem
-
randomize
public void randomize(Collection<Object> variables, Map<Object, Double> lowerBounds, Map<Object, Double> upperBounds, Map<Object, Double> priorities, Map<Object, Boolean> phases) Creates a random initialization of the priorities and phases for the variables. Override this method for a custom initialization.- Parameters:
variables- all variableslowerBounds- the lower bounds for the priority for the variablesupperBounds- the upper bounds for the priority for the variablespriorities- the priorities of the variablesphases- the phases of the variables
-
ignoreVariables
Set the variables to be ignored (not part of the search process and genotype). Override this method if variables are ignored.- Parameters:
variables- all variables of the problem- Returns:
- the variables to be ignored
-
getLowerBounds
Returns the lower bounds for the variables.- Parameters:
variables- all variables of the problem- Returns:
- the lower bounds
-
getUpperBounds
Returns the upper bounds for the variables.- Parameters:
variables- all variables of the problem- Returns:
- the upper bounds
-
convertModel
Converts aModelinto a phenotype. Override this with your custom method.- Parameters:
model- the found model- Returns:
- the converted phenotype
-
create
Description copied from interface:CreatorCreates a randomGenotype. -
decode
Description copied from interface:DecoderDecodes a givenGenotypeto the corresponding phenotype. -
getConstraints
Returns the constraints.- Returns:
- the constraints
-
getVariables
Returns the variables.- Returns:
- the variables
-