Class AbstractSATDecoder<G extends Genotype,P>

java.lang.Object
org.opt4j.satdecoding.AbstractSATDecoder<G,P>
Type Parameters:
G - The genotype (use Genotype if you do not override the decode method)
P - The phenotype
All Implemented Interfaces:
Creator<G>, Decoder<G,P>
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 Details

  • Method Details

    • createConstraints

      public abstract Set<Constraint> createConstraints()
      Creates all Constraints.

      Override this method to return the problem specific Constraints that have to be respected by the resulting Model.

      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 variables
      lowerBounds - the lower bounds for the priority for the variables
      upperBounds - the upper bounds for the priority for the variables
      priorities - the priorities of the variables
      phases - the phases of the variables
    • ignoreVariables

      public Set<Object> ignoreVariables(Set<Object> variables)
      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

      public Map<Object,Double> getLowerBounds(Set<Object> variables)
      Returns the lower bounds for the variables.
      Parameters:
      variables - all variables of the problem
      Returns:
      the lower bounds
    • getUpperBounds

      public Map<Object,Double> getUpperBounds(Set<Object> variables)
      Returns the upper bounds for the variables.
      Parameters:
      variables - all variables of the problem
      Returns:
      the upper bounds
    • convertModel

      public abstract P convertModel(Model model)
      Converts a Model into a phenotype. Override this with your custom method.
      Parameters:
      model - the found model
      Returns:
      the converted phenotype
    • create

      public G create()
      Description copied from interface: Creator
      Creates a random Genotype.
      Specified by:
      create in interface Creator<G extends Genotype>
      Returns:
      the created genotype
    • decode

      public P decode(G genotype)
      Description copied from interface: Decoder
      Decodes a given Genotype to the corresponding phenotype.
      Specified by:
      decode in interface Decoder<G extends Genotype,P>
      Parameters:
      genotype - the genotype to decode
      Returns:
      the decoded phenotype
    • getConstraints

      Returns the constraints.
      Returns:
      the constraints
    • getVariables

      Returns the variables.
      Returns:
      the variables