- All Implemented Interfaces:
- OptimizationProblem<BitVector>,- Problem<BitVector>
TwoMax problem, but in the TwoMax
 problem, more of the search space is within the attraction basin of the global optima than within
 that of the local optima.
 The Trap problem is to maximize the following fitness function, f(x), where x is a vector of n bits. Let z = floor((3/4)n). If CountOfOneBits(x) ≤ z, then f(x) = (8n/z)(z-c). Otherwise, f(x) = (10n/(n-z))(c-z).
The global optimal solution is when x is all ones, which has a maximal value of 10*n. This search landscape also has a local optima when x is all zeros, which has a value of 8*n. Only bit vectors with at least 3/4 of the bits equal to a one are within the attraction basin of the global optima.
The value method implements the original maximization version of the Trap
 problem, as described above. The algorithms of the Chips-n-Salsa library are defined for
 minimization, requiring a cost function. The cost method implements the equivalent
 as the following minimization problem: minimize cost(x) = 10*n - f(x), where f(x) is the Trap
 function as defined above. The global optima is still all 1-bits, which has a cost equal to 0.
 The local optima is still all 0-bits, which has a cost equal to 2*n.
 
The Trap problem was introduced by David Ackley in the following paper:
 David H. Ackley. An empirical study of bit vector function optimization. Genetic Algorithms and
 Simulated Annealing, pages 170-204, 1987.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptiondoubleComputes the cost of a candidate solution to the problem instance.booleanisMinCost(double cost) Checks if a given cost value is equal to the minimum theoretical cost across all possible solutions to the problem instance, where lower cost implies better solution.doubleminCost()A lower bound on the minimum theoretical cost across all possible solutions to the problem instance, where lower cost implies better solution.doubleComputes the value of the candidate solution within the usual constraints and interpretation of the problem.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cicirello.search.problems.OptimizationProblemcostAsDouble, getSolutionCostPair
- 
Constructor Details- 
Trappublic Trap()Constructs an instance of Ackley's Trap function.
 
- 
- 
Method Details- 
costDescription copied from interface:OptimizationProblemComputes the cost of a candidate solution to the problem instance. The lower the cost, the more optimal the candidate solution.- Specified by:
- costin interface- OptimizationProblem<BitVector>
- Parameters:
- candidate- The candidate solution to evaluate.
- Returns:
- The cost of the candidate solution. Lower cost means better solution.
 
- 
minCostpublic double minCost()Description copied from interface:OptimizationProblemA lower bound on the minimum theoretical cost across all possible solutions to the problem instance, where lower cost implies better solution. The default implementation returns Double.NEGATIVE_INFINITY.- Specified by:
- minCostin interface- OptimizationProblem<BitVector>
- Returns:
- A lower bound on the minimum theoretical cost of the problem instance.
 
- 
valueDescription copied from interface:OptimizationProblemComputes the value of the candidate solution within the usual constraints and interpretation of the problem.- Specified by:
- valuein interface- OptimizationProblem<BitVector>
- Parameters:
- candidate- The candidate solution to evaluate.
- Returns:
- The actual optimization value of the candidate solution.
 
- 
isMinCostpublic boolean isMinCost(double cost) Description copied from interface:OptimizationProblemChecks if a given cost value is equal to the minimum theoretical cost across all possible solutions to the problem instance, where lower cost implies better solution.- Specified by:
- isMinCostin interface- OptimizationProblem<BitVector>
- Parameters:
- cost- The cost to check.
- Returns:
- true if cost is equal to the minimum theoretical cost,
 
 
-