Class FLPSolution

java.lang.Object
es.urjc.etsii.grafo.solution.Solution<FLPSolution, FLPInstance>
es.urjc.etsii.grafo.flayouts.model.FLPSolution

public class FLPSolution extends Solution<FLPSolution, FLPInstance>
  • 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

      protected final HashSet<Integer> notAssignedFacilities
    • rowSize

      protected final int[] rowSize
    • assignedFacilities

      protected int assignedFacilities
  • Constructor Details

    • FLPSolution

      public FLPSolution(FLPInstance instance)
      Initialize solution from instance
      Parameters:
      instance -
    • FLPSolution

      public FLPSolution(FLPSolution s)
      Clone constructor
      Parameters:
      s - Solution to clone
  • Method Details

    • getRows

      public int[][] getRows()
    • nAssigned

      public int nAssigned()
    • deassignAll

      public void deassignAll()
    • getNotAssignedFacilities

      public Set<Integer> 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

      public FLPSolution cloneSolution()
      Description copied from class: Solution
      Clone the current solution. Deep clone mutable data or you will regret it.
      Specified by:
      cloneSolution in class Solution<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

      public String toString()
      Generate a string representation of this solution. Used when printing progress to console, show as minimal info as possible
      Specified by:
      toString in class Solution<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 update
      start - 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 index
      start - update centers from this position / index, included
      end - update centers until this position / index, not included
    • locateAll

      public FLPSolution.Coords[] 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