Class FLPSolution
java.lang.Object
es.urjc.etsii.grafo.solution.Solution<FLPSolution, FLPInstance>
es.urjc.etsii.grafo.flayouts.model.FLPSolution
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected doubleprotected double[]static final intprotected int[][]protected final int[]static final doubleFields inherited from class Solution
lastModifiedTime, lastMoves -
Constructor Summary
ConstructorsConstructorDescriptionFLPSolution(FLPInstance instance) Initialize solution from instanceClone constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected double[]Clone the current solution.voidint[][]getRows()doublegetScore()Get the current solution score.doubleleft(int rowIdx, int pos) Returns an array with all the coordinates of the assigned facilities The array should be used as a map, where the index / key is the facility ID, and the stored value is the coordinates of the facility as a tuple (row, pos)intintnRows()doublepartialCost(int row, int index1, int index2) doublevoidremove(int rowIndex, int i) introwSize(int rowIdx) toString()Generate a string representation of this solution.voidupdateCenters(int rowIdx) Update all facility centers in rowvoidupdateCentersFrom(int rowIdx, int start) Update all facility centers fromvoidupdateCentersFromTo(int rowIdx, int start, int end) Update all facility centers in range [start, end)Methods inherited from class Solution
customProperties, getInstance, getLastModifiedTime, getVersion, lastExecutesMoves, lastExecutesMovesAsString, notifyUpdate, notifyUpdate
-
Field Details
-
FREE_SPACE
public static final int FREE_SPACE- See Also:
-
UNKNOWN_CENTER
public static final double UNKNOWN_CENTER- See Also:
-
cachedScore
protected double cachedScore -
rows
protected int[][] rows -
center
protected double[] center -
notAssignedFacilities
-
rowSize
protected final int[] rowSize -
assignedFacilities
protected int assignedFacilities
-
-
Constructor Details
-
FLPSolution
-
FLPSolution
-
-
Method Details
-
getRows
public int[][] getRows() -
nAssigned
public int nAssigned() -
deassignAll
public void deassignAll() -
getNotAssignedFacilities
-
rowSize
public int rowSize(int rowIdx) -
left
public double left(int rowIdx, int pos) -
nRows
public int nRows() -
remove
public void remove(int rowIndex, int i) -
cloneSolution
Description copied from class:SolutionClone the current solution. Deep clone mutable data or you will regret it.- Specified by:
cloneSolutionin classSolution<FLPSolution, FLPInstance>- 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
-
recalculateScore
public double recalculateScore() -
partialCost
public double partialCost(int row, int index1, int index2) -
calculateCenters
protected double[] calculateCenters() -
toString
Generate a string representation of this solution. Used when printing progress to console, show as minimal info as possible- Specified by:
toStringin classSolution<FLPSolution, FLPInstance>- Returns:
- Small string representing the current solution (Example: id + score)
-
updateCenters
public void updateCenters(int rowIdx) Update all facility centers in row- Parameters:
rowIdx- row index
-
updateCentersFrom
public void updateCentersFrom(int rowIdx, int start) Update all facility centers from- Parameters:
rowIdx- row to updatestart- update centers from this position (included) until the end of the row
-
updateCentersFromTo
public void updateCentersFromTo(int rowIdx, int start, int end) Update all facility centers in range [start, end)- Parameters:
rowIdx- row indexstart- update centers from this position / index, includedend- update centers until this position / index, not included
-
locateAll
Returns an array with all the coordinates of the assigned facilities The array should be used as a map, where the index / key is the facility ID, and the stored value is the coordinates of the facility as a tuple (row, pos)- Returns:
- Array of facility coordinates
-