Class MSTSolution
java.lang.Object
es.urjc.etsii.grafo.solution.Solution<MSTSolution, MSTInstance>
es.urjc.etsii.grafo.graphs.model.MSTSolution
-
Field Summary
Fields inherited from class Solution
lastModifiedTime, lastMoves -
Constructor Summary
ConstructorsConstructorDescriptionMSTSolution(MSTInstance instance) Initialize solution from instanceMSTSolution(MSTSolution solution) Clone constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToCover(int vertex) Add a vertex to the vertex cover.Clone the current solution.intNumber of vertices currently selected as part of the vertex cover.Vertices currently selected as part of the vertex cover.doublegetScore()Get the current solution score.booleanisInCover(int vertex) Is the given vertex part of the vertex cover?voidsetScore(double score) voidSet the solution score to the current vertex cover size.voidsetScoreDist(double[][] d) voidsetScoreEdges(List<Edge> mstEdges) toString()Generate a string representation of this solution.Methods inherited from class Solution
customProperties, getInstance, getLastModifiedTime, getVersion, lastExecutesMoves, lastExecutesMovesAsString, notifyUpdate, notifyUpdate
-
Constructor Details
-
MSTSolution
-
MSTSolution
-
-
Method Details
-
cloneSolution
Description copied from class:SolutionClone the current solution. Deep clone mutable data or you will regret it.- Specified by:
cloneSolutionin classSolution<MSTSolution, MSTInstance>- Returns:
- A deep clone of the current solution
-
getScore
public double getScore()Get the current solution score. The difference between this method and recalculateScore is that this result can be a property of the solution, or cached, it does not have to be calculated each time this method is called- Returns:
- current solution score as double
-
toString
Generate a string representation of this solution. Used when printing progress to console, show as minimal info as possible- Specified by:
toStringin classSolution<MSTSolution, MSTInstance>- Returns:
- Small string representing the current solution (Example: id + score)
-
setScore
public void setScore(double score) -
setScoreEdges
-
setScoreDist
public void setScoreDist(double[][] d) -
isInCover
public boolean isInCover(int vertex) Is the given vertex part of the vertex cover? Only meaningful for the MVC demo.- Parameters:
vertex- vertex id- Returns:
- true if the vertex is currently selected
-
addToCover
public void addToCover(int vertex) Add a vertex to the vertex cover. Only meaningful for the MVC demo.- Parameters:
vertex- vertex id
-
getCoverVertices
-
getCoverSize
public int getCoverSize()Number of vertices currently selected as part of the vertex cover.- Returns:
- cover size
-
setScoreCover
public void setScoreCover()Set the solution score to the current vertex cover size. Only meaningful for the MVC demo, as the MVC objective is to minimize the number of selected vertices.
-