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

Added in 1.1.0
public static final boolean DEBUG = false

FULL_DEBUG

Added in 1.1.0
public static final boolean FULL_DEBUG = false

Public fields

ARRAY_ROW_CREATION

Added in 1.1.0
public static long ARRAY_ROW_CREATION

OPTIMIZED_ARRAY_ROW_CREATION

Added in 1.1.0
public static long OPTIMIZED_ARRAY_ROW_CREATION

OPTIMIZED_ENGINE

Added in 1.1.0
public static boolean OPTIMIZED_ENGINE

SIMPLIFY_SYNONYMS

Added in 1.1.0
public static boolean SIMPLIFY_SYNONYMS

SKIP_COLUMNS

Added in 1.1.0
public static boolean SKIP_COLUMNS

USE_BASIC_SYNONYMS

Added in 1.1.0
public static boolean USE_BASIC_SYNONYMS

USE_DEPENDENCY_ORDERING

Added in 1.1.0
public static boolean USE_DEPENDENCY_ORDERING

USE_SYNONYMS

Added in 1.1.0
public static boolean USE_SYNONYMS

graphOptimizer

Added in 1.1.0
public boolean graphOptimizer

hasSimpleDefinition

Added in 1.1.0
public boolean hasSimpleDefinition

newgraphOptimizer

Added in 1.1.0
public boolean newgraphOptimizer

sMetrics

Added in 1.1.0
public static Metrics sMetrics

Public constructors

LinearSystem

Added in 1.1.0
public LinearSystem()

Public methods

addCenterPoint

Added in 1.1.0
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

Added in 1.1.0
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

Added in 1.1.0
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

Added in 1.1.0
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

Added in 1.1.0
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

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

addGreaterThan

Added in 1.1.0
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

Added in 1.1.0
public void addLowerBarrier(
    SolverVariable a,
    SolverVariable b,
    int margin,
    boolean hasMatchConstraintWidgets
)

addLowerThan

Added in 1.1.0
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

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

addSynonym

Added in 1.1.0
public void addSynonym(SolverVariable a, SolverVariable b, int margin)

createErrorVariable

Added in 1.1.0
public SolverVariable createErrorVariable(int strength, String prefix)

createExtraVariable

Added in 1.1.0
public SolverVariable createExtraVariable()

createObjectVariable

Added in 1.1.0
public SolverVariable createObjectVariable(Object anchor)

createRow

Added in 1.1.0
public ArrayRow createRow()

createRowDimensionPercent

Added in 1.1.0
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

Added in 1.1.0
public SolverVariable createSlackVariable()

displayReadableRows

Added in 1.1.0
public void displayReadableRows()

displayVariablesReadableRows

Added in 1.1.0
public void displayVariablesReadableRows()

fillMetrics

Added in 1.1.0
public void fillMetrics(Metrics metrics)

getCache

Added in 1.1.0
public Cache getCache()

getMemoryUsed

Added in 1.1.0
public int getMemoryUsed()

getMetrics

Added in 1.1.0
public static Metrics getMetrics()

getNumEquations

Added in 1.1.0
public int getNumEquations()

getNumVariables

Added in 1.1.0
public int getNumVariables()

getObjectVariableValue

Added in 1.1.0
public int getObjectVariableValue(Object object)

minimize

Added in 1.1.0
public void minimize()

Minimize the current goal of the system.

removeRow

Added in 1.1.0
public void removeRow(ArrayRow row)

reset

Added in 1.1.0
public void reset()

Reset the LinearSystem object so that it can be reused.