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
ConstructorsConstructorDescriptionBNTabuSearch(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 voidfindBestNeighbor(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 booleanisScoreImproved(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:HillClimbingImplementationReturns a unique identifier for the hill climbing-based algorithm.- Specified by:
getIdentifierin interfaceHillClimbingImplementation- Overrides:
getIdentifierin classBNHillClimbing- Returns:
- unique identifier for the hill climbing-based algorithm
-
getParametersAlgorithm
Description copied from interface:HillClimbingImplementationReturns the parameters that are used by the hill climbing implementation.- Specified by:
getParametersAlgorithmin interfaceHillClimbingImplementation- Overrides:
getParametersAlgorithmin classBNHillClimbing- Returns:
- a
Mapwith the parameters used by the algorithm
-
findStructure
Description copied from interface:HillClimbingImplementationFinds a structure for a given PGM.- Specified by:
findStructurein interfaceHillClimbingImplementation- Overrides:
findStructurein 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:BNHillClimbingFinds the best neighbour of the adjacency matrix "bestStructure" given an operation to perform (addition, deletion or reversal of arcs).- Overrides:
findBestNeighborin classBNHillClimbing- Parameters:
bn- Bayesian network whose structure is being learntbestSolution- best structure so farscores- two-dimensionaldoublearray containing the structure scores after applying each of the possible operations over the adjacency matrixadjacencyMatrices- three-dimensionalbooleanarray 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:BNHillClimbingChecks if a solution given by the hill climbing algorithm in a certain iteration is better than the current solution.- Overrides:
isScoreImprovedin classBNHillClimbing- Parameters:
solution- current solutionadjacencyMatrices- best adjacency matrices given by each possible operationidxBestOperation- index of the best operationiterationBestScore- score of the iteration solution- Returns:
trueif the solution of the iteration is better than the current solution,falseotherwise
-