Class ClassInstanceCountSet

java.lang.Object
cruise.umple.compiler.ClassInstanceCountSet

public class ClassInstanceCountSet extends Object
Class to hold the number of class instances for a given umple model Provides methods/algorithms to calculate the number of class instances
  • Field Details

  • Constructor Details

    • ClassInstanceCountSet

      public ClassInstanceCountSet(UmpleModel aUmpleModel)
  • Method Details

    • delete

      public void delete()
    • computeInstanceDiagram

      public static InstanceDiagramResult computeInstanceDiagram(UmpleModel model, int linkingFlag, int initialClassCountFlag, int maxIterations, int maxClassCount)
    • diagramIsEmpty

      public boolean diagramIsEmpty()
      Returns true if the diagram has no class instances
    • getAllSuperclasses

      public Set<String> getAllSuperclasses(String classname)
      Wrapper for getAllSuperclassesRecursive Will return a Set instead of modifying one Will remove the current class from the superclass tree
    • getNoPossibleInheritance

      public Set<String> getNoPossibleInheritance()
      Get a set of abstract/interface/singleton/etc... classes that have no possible concrete subclasses for inheritance. These classes are not necessarily errors on their own; but they can become errors. Example: An abstract class with no possible inheritors, but with 0 required instances is valid.
    • getInstanceCounts

      public void getInstanceCounts(int maxIter, int maxClasses)
      We can represent the system as a graph problem. Each class is a node, and each association is 2 directed links between the nodes. For every link, the class count at the start multiplied by the multiplicity must be smaller/equal to the class count at the end. If you have the link A 2..4 -> 3..6 B, for every 2..4 As, there must be 3..6 Bs. Thus, we have the following tightest inequality; for every 4 or less As, there must be at at least 3 Bs There can be less As, or more Bs, but this equality must hold true. So for A = 1-4 there are >3 Bs, for A = 5-8 there are >6 Bs Algorithm: Initialize all class counts to their initial value Loop through every association End = max(End, lowerEnd*ceil(Start/UpperStart)) Repeat until no more changes appear Creates a Map of classnames and their minimum class counts
    • initializeClassCountsConstant

      public void initializeClassCountsConstant(Integer constInt)
      Set each class initially to a constant amount of instances
    • initializeClassCountsRandom

      public void initializeClassCountsRandom(Map<Integer,Double> minimumInstanceProbabilities)
      Generate the initial class counts randomly. Parameter "minimumInstanceProbabilities" is a map of initial instance counts to their probabilities
    • distributeAssociations

      public ArrayList<AssociationLinkSet> distributeAssociations(int linkingFlag)
      Using the number of instance of each class, get the associations between the instances. The linkingFlag parameter determines the number of links to create: - 0 Minimum - 1 Maximum - 2 Random Returns an arraylist of AssociationLinkSet, which is a data class
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getInstanceCountMap

      public Map<String,Integer> getInstanceCountMap()
    • getClassLoopScores

      public Map<String,Integer> getClassLoopScores()