Stay organized with collections Save and categorize content based on your preferences.

LinearSystem

public class LinearSystem


Represents and solves a system of linear equations.

Summary

Constants

static final boolean
DEBUG = false
static final boolean
FULL_DEBUG = false

Public fields

static long
static long
static boolean
static boolean
static boolean
static boolean
static boolean
static boolean
boolean
boolean
boolean
static Metrics

Public constructors

Public methods

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

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)

void

Add the equation to the system

void
addEquality(SolverVariable a, int value)

Add an equation of the form a = value

ArrayRow
addEquality(SolverVariable a, SolverVariable b, int margin, int strength)

Add an equation of the form a = b + margin

void
addGreaterBarrier(
    SolverVariable a,
    SolverVariable b,
    int margin,
    boolean hasMatchConstraintWidgets
)
void
addGreaterThan(
    SolverVariable a,
    SolverVariable b,
    int margin,
    int strength
)

Add an equation of the form a >= b + margin

void
addLowerBarrier(
    SolverVariable a,
    SolverVariable b,
    int margin,
    boolean hasMatchConstraintWidgets
)
void
addLowerThan(
    SolverVariable a,
    SolverVariable b,
    int margin,
    int strength
)

Add an equation of the form a <= b + margin

void
addRatio(
    SolverVariable a,
    SolverVariable b,
    SolverVariable c,
    SolverVariable d,
    float ratio,
    int strength
)
void
SolverVariable
createErrorVariable(int strength, String prefix)
SolverVariable
SolverVariable
ArrayRow
static ArrayRow
createRowDimensionPercent(
    LinearSystem linearSystem,
    SolverVariable variableA,
    SolverVariable variableC,
    float percent
)

Create a constraint to express A = C * percent

SolverVariable
void
void
void
Cache
int
static Metrics
int
int
int
void

Minimize the current goal of the system.

void
void

Reset the LinearSystem object so that it can be reused.

Constants

DEBUG

public static final boolean DEBUG = false

FULL_DEBUG

public static final boolean FULL_DEBUG = false

Public fields

ARRAY_ROW_CREATION

public static long ARRAY_ROW_CREATION

OPTIMIZED_ARRAY_ROW_CREATION

public static long OPTIMIZED_ARRAY_ROW_CREATION

OPTIMIZED_ENGINE

public static boolean OPTIMIZED_ENGINE

SIMPLIFY_SYNONYMS

public static boolean SIMPLIFY_SYNONYMS

SKIP_COLUMNS

public static boolean SKIP_COLUMNS

USE_BASIC_SYNONYMS

public static boolean USE_BASIC_SYNONYMS

USE_DEPENDENCY_ORDERING

public static boolean USE_DEPENDENCY_ORDERING

USE_SYNONYMS

public static boolean USE_SYNONYMS

graphOptimizer

public boolean graphOptimizer

hasSimpleDefinition

public boolean hasSimpleDefinition

newgraphOptimizer

public boolean newgraphOptimizer

sMetrics

public static Metrics sMetrics

Public constructors

LinearSystem

public LinearSystem()

Public methods

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
float angle

from 0 to 360

int radius

the distance between the two centers

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
SolverVariable a

variable a

SolverVariable b

variable b

int m1

margin 1

float bias

bias between ab - cd

SolverVariable c

variable c

SolverVariable d

variable d

int m2

margin 2

int strength

strength used

addConstraint

public void addConstraint(ArrayRow row)

Add the equation to the system

Parameters
ArrayRow row

the equation we want to add expressed as a system row.

addEquality

public void addEquality(SolverVariable a, int value)

Add an equation of the form a = value

Parameters
SolverVariable a

variable a

int value

the value we set

addEquality

public ArrayRow addEquality(SolverVariable a, SolverVariable b, int margin, int strength)

Add an equation of the form a = b + margin

Parameters
SolverVariable a

variable a

SolverVariable b

variable b

int margin

margin used

int strength

strength used

addGreaterBarrier

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

addGreaterThan

public void addGreaterThan(
    SolverVariable a,
    SolverVariable b,
    int margin,
    int strength
)

Add an equation of the form a >= b + margin

Parameters
SolverVariable a

variable a

SolverVariable b

variable b

int margin

margin

int strength

strength used

addLowerBarrier

public void addLowerBarrier(
    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
SolverVariable a

variable a

SolverVariable b

variable b

int margin

margin

int strength

strength used

addRatio

public void addRatio(
    SolverVariable a,
    SolverVariable b,
    SolverVariable c,
    SolverVariable d,
    float ratio,
    int strength
)

addSynonym

public void addSynonym(SolverVariable a, SolverVariable b, int margin)

createErrorVariable

public SolverVariable createErrorVariable(int strength, String prefix)

createExtraVariable

public SolverVariable createExtraVariable()

createObjectVariable

public SolverVariable createObjectVariable(Object anchor)

createRow

public ArrayRow createRow()

createRowDimensionPercent

public static ArrayRow createRowDimensionPercent(
    LinearSystem linearSystem,
    SolverVariable variableA,
    SolverVariable variableC,
    float percent
)

Create a constraint to express A = C * percent

Parameters
LinearSystem linearSystem

the system we create the row on

SolverVariable variableA

variable a

SolverVariable variableC

variable c

float percent

the percent used

Returns
ArrayRow

the created row

createSlackVariable

public SolverVariable createSlackVariable()

displayReadableRows

public void displayReadableRows()

displayVariablesReadableRows

public void displayVariablesReadableRows()

fillMetrics

public void fillMetrics(Metrics metrics)

getCache

public Cache getCache()

getMemoryUsed

public int getMemoryUsed()

getMetrics

public static Metrics getMetrics()

getNumEquations

public int getNumEquations()

getNumVariables

public int getNumVariables()

getObjectVariableValue

public int getObjectVariableValue(Object object)

minimize

public void minimize()

Minimize the current goal of the system.

Throws
java.lang.Exception java.lang.Exception

removeRow

public void removeRow(ArrayRow row)

reset

public void reset()

Reset the LinearSystem object so that it can be reused.