public class GeneticGrid extends HyperHeuristicGrid
setGridCells
method. The solutions themselves can be evaluated independently of this,
but the grid can suggest what the better ones are, or what ones to combine or evolve.
The solve
method then optimises the solution based on the entered
parameter values. This is closely linked with the genetic algorithms
, as the grid result
will suggest solutions to evolve further.
For example, the hyperMatch
variable can be used to choose between solving using
a hill-climbing approach (false) that simply maximises
the sum of any two solutions, to
matching
similar scores in the new hyper-heuristic process (true). These values
are passed in using the TestSpec
specification.
Modifier and Type | Field and Description |
---|---|
protected boolean |
hyperMatch
True if try the hyper-heuristic matching approach.
|
protected int |
maxSolutions
Maximum number of solutions or rows, for the matching or the hill-climbing version
|
protected double |
similarityRange
Range for which values are considered to be the same
|
protected boolean |
similarityRangeAsPercentage
True if the similarity range is measured as a percentage of the largest score.
|
errorFeedback, gridName, gridSolution, gridType, lib
Constructor and Description |
---|
GeneticGrid(TestSpec testSpec)
Create a new instance of GeneticGrid.
|
GeneticGrid(TestSpec testSpec,
boolean thisLib)
Create a new instance of GeneticGrid.
|
Modifier and Type | Method and Description |
---|---|
double[][] |
getGridCells()
Get the array of grid cell values.
|
Result |
getGridSolution()
Get the list of solutions that are part of a best match.
|
void |
insertColumn(int col,
double[] insertCol)
Insert the specified column into the grid at the specified position.
|
void |
insertRow(int row,
double[] insertRow)
Insert the specified row into the grid at the specified position.
|
double[] |
removeColumn(int col)
Remove the specified column from the grid and return.
|
double[] |
removeRow(int row)
Remove the specified row from the grid and return.
|
void |
setGridCells(double[][] theGridCells)
Set the array of grid of cell values to process.
|
void |
solve()
Solve the currently saved grid.
|
getErrorFeedback, getGridName, getGridType, setGridName
protected boolean hyperMatch
protected int maxSolutions
protected boolean similarityRangeAsPercentage
protected double similarityRange
public GeneticGrid(TestSpec testSpec)
testSpec
- the test specification. Can be null for default values.public GeneticGrid(TestSpec testSpec, boolean thisLib)
testSpec
- the test specification. Can be null for default values.thisLib
- true if larger value is better, false if smaller value is better.public void solve() throws java.lang.Exception
solve
in class HyperHeuristicGrid
java.lang.Exception
- any error.public double[] removeRow(int row)
row
- the row to remove.public void insertRow(int row, double[] insertRow)
row
- the position to insert the row at.insertRow
- the row totalValue to insert.public double[] removeColumn(int col)
col
- the column to remove.public void insertColumn(int col, double[] insertCol)
col
- the position to insert the column at.insertCol
- the column totalValue to insert.public void setGridCells(double[][] theGridCells)
theGridCells
- the array of cell values.public double[][] getGridCells()
public Result getGridSolution()
getGridSolution
in class HyperHeuristicGrid