Class LinearSystem


  • public class LinearSystem
    extends java.lang.Object
    Represents and solves a system of linear equations.
    • Field Detail

      • USE_DEPENDENCY_ORDERING

        public static boolean USE_DEPENDENCY_ORDERING
      • USE_BASIC_SYNONYMS

        public static boolean USE_BASIC_SYNONYMS
      • SIMPLIFY_SYNONYMS

        public static boolean SIMPLIFY_SYNONYMS
      • USE_SYNONYMS

        public static boolean USE_SYNONYMS
      • SKIP_COLUMNS

        public static boolean SKIP_COLUMNS
      • OPTIMIZED_ENGINE

        public static boolean OPTIMIZED_ENGINE
      • hasSimpleDefinition

        public boolean hasSimpleDefinition
      • graphOptimizer

        public boolean graphOptimizer
      • newgraphOptimizer

        public boolean newgraphOptimizer
      • sMetrics

        public static Metrics sMetrics
      • ARRAY_ROW_CREATION

        public static long ARRAY_ROW_CREATION
      • OPTIMIZED_ARRAY_ROW_CREATION

        public static long OPTIMIZED_ARRAY_ROW_CREATION
    • Constructor Detail

      • LinearSystem

        public LinearSystem()
    • Method Detail

      • fillMetrics

        public void fillMetrics​(Metrics metrics)
      • getMetrics

        public static Metrics getMetrics()
      • reset

        public void reset()
        Reset the LinearSystem object so that it can be reused.
      • createObjectVariable

        public SolverVariable createObjectVariable​(java.lang.Object anchor)
      • createRow

        public ArrayRow createRow()
      • createErrorVariable

        public SolverVariable createErrorVariable​(int strength,
                                                  java.lang.String prefix)
      • getObjectVariableValue

        public int getObjectVariableValue​(java.lang.Object object)
      • minimize

        public void minimize()
                      throws java.lang.Exception
        Minimize the current goal of the system.
        Throws:
        java.lang.Exception
      • addConstraint

        public void addConstraint​(ArrayRow row)
        Add the equation to the system
        Parameters:
        row - the equation we want to add expressed as a system row.
      • removeRow

        public void removeRow​(ArrayRow row)
      • displayReadableRows

        public void displayReadableRows()
      • displayVariablesReadableRows

        public void displayVariablesReadableRows()
      • getMemoryUsed

        public int getMemoryUsed()
      • getNumEquations

        public int getNumEquations()
      • getNumVariables

        public int getNumVariables()
      • getCache

        public Cache getCache()
      • addGreaterThan

        public void addGreaterThan​(SolverVariable a,
                                   SolverVariable b,
                                   int margin,
                                   int strength)
        Add an equation of the form a >= b + margin
        Parameters:
        a - variable a
        b - variable b
        margin - margin
        strength - strength used
      • addGreaterBarrier

        public void addGreaterBarrier​(SolverVariable a,
                                      SolverVariable b,
                                      int margin,
                                      boolean hasMatchConstraintWidgets)
      • addLowerThan

        public void addLowerThan​(SolverVariable a,
                                 SolverVariable b,
                                 int margin,
                                 int strength)
        Add an equation of the form a <= b + margin
        Parameters:
        a - variable a
        b - variable b
        margin - margin
        strength - strength used
      • addCentering

        public void addCentering​(SolverVariable a,
                                 SolverVariable b,
                                 int m1,
                                 float bias,
                                 SolverVariable c,
                                 SolverVariable d,
                                 int m2,
                                 int strength)
        Add an equation of the form (1 - bias) * (a - b) = bias * (c - d)
        Parameters:
        a - variable a
        b - variable b
        m1 - margin 1
        bias - bias between ab - cd
        c - variable c
        d - variable d
        m2 - margin 2
        strength - strength used
      • addEquality

        public ArrayRow addEquality​(SolverVariable a,
                                    SolverVariable b,
                                    int margin,
                                    int strength)
        Add an equation of the form a = b + margin
        Parameters:
        a - variable a
        b - variable b
        margin - margin used
        strength - strength used
      • addEquality

        public void addEquality​(SolverVariable a,
                                int value)
        Add an equation of the form a = value
        Parameters:
        a - variable a
        value - the value we set
      • createRowDimensionPercent

        public static ArrayRow createRowDimensionPercent​(LinearSystem linearSystem,
                                                         SolverVariable variableA,
                                                         SolverVariable variableC,
                                                         float percent)
        Create a constraint to express A = C * percent
        Parameters:
        linearSystem - the system we create the row on
        variableA - variable a
        variableC - variable c
        percent - the percent used
        Returns:
        the created row
      • addCenterPoint

        public void addCenterPoint​(ConstraintWidget widget,
                                   ConstraintWidget target,
                                   float angle,
                                   int radius)
        Add the equations constraining a widget center to another widget center, positioned on a circle, following an angle and radius
        Parameters:
        angle - from 0 to 360
        radius - the distance between the two centers