Module es.upm.fi.cig.multictbnc
Class BNTabuSearch
java.lang.Object
es.upm.fi.cig.multictbnc.learning.structure.optimisation.hillclimbing.implementation.BNHillClimbing
es.upm.fi.cig.multictbnc.learning.structure.optimisation.tabusearch.BNTabuSearch
- All Implemented Interfaces:
HillClimbingImplementation
Implements the tabu search algorithm for Bayesian networks.
-
Constructor Summary
ConstructorDescriptionBNTabuSearch
(BNScoreFunction scoreFunction, int tabuListSize, int maxNumNotImprovements) Initialises the tabu search algorithm by proving a score function and a tabu list size. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
findBestNeighbor
(BN<? extends Node> bn, HillClimbingSolution bestSolution, double[] scores, boolean[][][] adjacencyMatrices, String operation) Finds the best neighbour of the adjacency matrix "bestStructure" given an operation to perform (addition, deletion or reversal of arcs).findStructure
(PGM<? extends Node> pgm) Finds a structure for a given PGM.Returns a unique identifier for the hill climbing-based algorithm.Returns the parameters that are used by the hill climbing implementation.protected boolean
isScoreImproved
(HillClimbingSolution solution, boolean[][][] adjacencyMatrices, int idxBestOperation, double iterationBestScore) Checks if a solution given by the hill climbing algorithm in a certain iteration is better than the current solution.Methods inherited from class es.upm.fi.cig.multictbnc.learning.structure.optimisation.hillclimbing.implementation.BNHillClimbing
computeScore, findStructure, findStructure, getInfoScoreFunction, getNumEdgesTested, increaseNumEdgesTested, resetNumEdgesTested
-
Constructor Details
-
BNTabuSearch
Initialises the tabu search algorithm by proving a score function and a tabu list size.- Parameters:
scoreFunction
- score functiontabuListSize
- tabu list sizemaxNumNotImprovements
- maximum number of iterations to continue without improvements in the score before stopping the search
-
-
Method Details
-
getIdentifier
Description copied from interface:HillClimbingImplementation
Returns a unique identifier for the hill climbing-based algorithm.- Specified by:
getIdentifier
in interfaceHillClimbingImplementation
- Overrides:
getIdentifier
in classBNHillClimbing
- Returns:
- unique identifier for the hill climbing-based algorithm
-
getParametersAlgorithm
Description copied from interface:HillClimbingImplementation
Returns the parameters that are used by the hill climbing implementation.- Specified by:
getParametersAlgorithm
in interfaceHillClimbingImplementation
- Overrides:
getParametersAlgorithm
in classBNHillClimbing
- Returns:
- a
Map
with the parameters used by the algorithm
-
findStructure
Description copied from interface:HillClimbingImplementation
Finds a structure for a given PGM.- Specified by:
findStructure
in interfaceHillClimbingImplementation
- Overrides:
findStructure
in classBNHillClimbing
- Parameters:
pgm
- a probabilistic graphical model- Returns:
- solution given by the hill climbing algorithm
-
findBestNeighbor
protected void findBestNeighbor(BN<? extends Node> bn, HillClimbingSolution bestSolution, double[] scores, boolean[][][] adjacencyMatrices, String operation) Description copied from class:BNHillClimbing
Finds the best neighbour of the adjacency matrix "bestStructure" given an operation to perform (addition, deletion or reversal of arcs).- Overrides:
findBestNeighbor
in classBNHillClimbing
- Parameters:
bn
- Bayesian network whose structure is being learntbestSolution
- best structure so farscores
- two-dimensionaldouble
array containing the structure scores after applying each of the possible operations over the adjacency matrixadjacencyMatrices
- three-dimensionalboolean
array containing the resulting adjacency matrices after applying each of the possible operations over the original matrixoperation
- operation to perform over the adjacency matrix
-
isScoreImproved
protected boolean isScoreImproved(HillClimbingSolution solution, boolean[][][] adjacencyMatrices, int idxBestOperation, double iterationBestScore) Description copied from class:BNHillClimbing
Checks if a solution given by the hill climbing algorithm in a certain iteration is better than the current solution.- Overrides:
isScoreImproved
in classBNHillClimbing
- Parameters:
solution
- current solutionadjacencyMatrices
- best adjacency matrices given by each possible operationidxBestOperation
- index of the best operationiterationBestScore
- score of the iteration solution- Returns:
true
if the solution of the iteration is better than the current solution,false
otherwise
-