Package net.sf.tweety.math.opt.solver
Class SimpleGeneticOptimizationSolver
- java.lang.Object
-
- net.sf.tweety.math.opt.solver.Solver
-
- net.sf.tweety.math.opt.solver.SimpleGeneticOptimizationSolver
-
public class SimpleGeneticOptimizationSolver extends Solver
This class implements a simple genetic optimization algorithm for solving optimization problems with box or equality constraints on float variables. Note that equality constraints are encoded in the target function!- Author:
- Matthias Thimm
-
-
Constructor Summary
Constructors Constructor Description SimpleGeneticOptimizationSolver(int populationSize, int populationIncreaseMutation, int populationIncreaseCrossOver, int minIterations, double precision)
Creates a new simple genetic optimization solver.
-
Method Summary
Modifier and Type Method Description static boolean
isInstalled()
java.util.Map<Variable,Term>
solve(ConstraintSatisfactionProblem problem)
Computes a solution to the given constraint satisfaction or optimization problem, i.e.java.util.Map<Variable,Term>
solve(Term t, int optimization_objective)
Returns the variable assignment that maximizes/minimizes the given term (which only contains variables with defined upper and lower bounds).-
Methods inherited from class net.sf.tweety.math.opt.solver.Solver
getDefaultGeneralSolver, getDefaultIntegerLinearSolver, getDefaultLinearSolver, hasDefaultGeneralSolver, hasDefaultIntegerLinearSolver, hasDefaultLinearSolver, setDefaultGeneralSolver, setDefaultIntegerLinearSolver, setDefaultLinearSolver
-
-
-
-
Constructor Detail
-
SimpleGeneticOptimizationSolver
public SimpleGeneticOptimizationSolver(int populationSize, int populationIncreaseMutation, int populationIncreaseCrossOver, int minIterations, double precision)
Creates a new simple genetic optimization solver.- Parameters:
populationSize
- The size of the populationpopulationIncreaseMutation
- How many new individuals are created by mutation (per individual)populationIncreaseCrossOver
- How many new individuals are created by cross-over (per pair of individuals)minIterations
- The minimal number of iterationsprecision
- If an iteration improves less than this value the algorithm ends
-
-
Method Detail
-
solve
public java.util.Map<Variable,Term> solve(ConstraintSatisfactionProblem problem) throws GeneralMathException
Description copied from class:Solver
Computes a solution to the given constraint satisfaction or optimization problem, i.e. a mapping from variables of the problem to terms.- Specified by:
solve
in classSolver
- Parameters:
problem
- the actual problem- Returns:
- a mapping from variables of the problem to terms.
- Throws:
GeneralMathException
- if something went wrong.
-
solve
public java.util.Map<Variable,Term> solve(Term t, int optimization_objective) throws GeneralMathException
Returns the variable assignment that maximizes/minimizes the given term (which only contains variables with defined upper and lower bounds).- Parameters:
t
- the term to be evaluatedoptimization_objective
- one of OptimizationProblem.MAXIMIZE, OptimizationProblem.MINIMIZE- Returns:
- the optimal variable assignment
- Throws:
GeneralMathException
- if some issue occured during computation.
-
isInstalled
public static boolean isInstalled() throws java.lang.UnsupportedOperationException
- Throws:
java.lang.UnsupportedOperationException
-
-