Class BMSSCSolution

java.lang.Object
es.urjc.etsii.grafo.solution.Solution<BMSSCSolution,BMSSCInstance>
es.urjc.etsii.grafo.bmssc.model.sol.BMSSCSolution

public class BMSSCSolution extends Solution<BMSSCSolution,BMSSCInstance>
  • Constructor Details

  • Method Details

    • score

      public static double score(BMSSCInstance instance, Set<Integer>[] solution)
      Calculate the score of a set of points without using a solution, and without side effects, used for validation purposes
      Parameters:
      instance - current instance
      solution - Solution data
      Returns:
      Score calculated from scratch.
    • costPerCluster

      public static double[] costPerCluster(BMSSCInstance instance, Set<Integer>[] solution)
    • relaxClusterSizeConstraint

      public void relaxClusterSizeConstraint(float margin)
      Relax cluster size constraint, by the given margin. New cluster sizes will be clusterSize * (1 + margin) Subsequent calls to this method do NOT further relax the constraint.
      Parameters:
      margin - margin, must be greater or equal to zero.
    • restoreClusterSizeConstraint

      public void restoreClusterSizeConstraint()
      Restore cluster size constraint to the feasible value provided by the instance
    • cloneSolution

      public BMSSCSolution 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<BMSSCSolution,BMSSCInstance>
      Returns:
      A deep clone of the current solution
    • getScore

      public double getScore()
    • recalculateScore

      public double recalculateScore()
    • toString

      public String toString()
      Description copied from class: Solution
      Resume this solution Generate a toString method using your IDE
      Specified by:
      toString in class Solution<BMSSCSolution,BMSSCInstance>
      Returns:
      string representation of the current solution
    • getClusterSize

      public int getClusterSize(int i)
    • getClusterSizes

      public int[] getClusterSizes()
    • feasibleClusterSizes

      public boolean feasibleClusterSizes()
    • getCluster

      public Set<Integer> getCluster(int i)
    • getNotAssignedPoints

      public Set<Integer> getNotAssignedPoints()
    • generateCachedScore

      public void generateCachedScore()
    • isFullCluster

      public boolean isFullCluster(int cluster)
      Checks if a cluster is full. Checks if the cluster size restriction is relaxed, and takes it into account
      Parameters:
      cluster - cluster to check
      Returns:
      true if the current cluster size is equals to its assigned size, false otherwise
    • clusterOf

      public int clusterOf(int a)
      Get the set a point is inside of
      Parameters:
      a - Point to get which cluster is assigned to
      Returns:
      the cluster ID, or -1 if the point is not assigned yet
    • cachedAssignCost

      public double cachedAssignCost(int a, int k)
    • calculateAssignCost

      public double calculateAssignCost(int a, int k)
    • isAssigned

      public boolean isAssigned(int a)
      Checks if a point is asigned to a cluster
      Parameters:
      a - Point to check
      Returns:
      true if assigned to a cluster, false otherwise