SkyBlue
Created on 2020-08-31T01:03:00+00:00
2022-10-12T03:53:00+00:00 Revisit
- Variable: some value which is observed or managed by the system.
- Constraint: a function which consumes variables and assigns new values to other variables.
- Unenforced constraint: a function which is not used in a solution
- Enforced constraint: a function which is used in a solution
Constraints map input values to an executable function and one or more output values. There is also a strength level assigned to constraints.
All constraints are added to a set. The set is walked and constraints are enforced so long as a constraint of equal or higher strength does not conflict with the same output values.
Higher strengths are allowed to bump lower strengths out of a solution.
If there is a conflict the weaker constraint is bumped and re-added to the set of unenforced constraints.
Repeat picking a constraint from the unenforced set and trying to enforce it until there are no elements remaining.
Constraints might be unenforcable if there is no alternative that does not try to claim a higher ranking constraint. In that case the constraint has to be left as failed.
Cycles are allowed but they are basically cut out of the graph and isolated. Those isolated islands are replaced with a single constraint with multiple inputs and outputs and solving the cycles are undefined. Another solver like Cassowary is needed to run inside those blocks.
Stay constraints just assign a variable to some fixed value.
Changing values involves provisionally setting a new value, running all constraints outward from the variable that changed, and either failing if a constraint fails or committing the new value of each variable on success.
2020-08-31T01:03:00+00:00
A constraint solver. Although does not solve constraints so much as selects methods which claim to solve the constraint in such a way that none of the methods conflict.
- Enforced: A node on the graph with a chosen method is "enforced."
- Unenforced: A node on the graph with no method is "unenfoced."
- Creates a "method graph," containing the list of constraints and the selected method for solving those constraints.
- Any number of constraint strengths can be chosen.
- Tries to select a method to solve the "root" constraint.
- Start from root; enforce using its first "method."
- Walk the vine. If a conflict occurs and the victim constraint is weaker than root, unenforce it.
- If a constraint is stronger or equal in strength to root, enforce it with a different method.
- If the newly chosen method conflicts with other previously enforced constraints, backtrack and try to solve a previous constraint with a new method.
- If no system can be found where all constraints stronger or equal to root can be found, where there are no conflicts, then constraint resolution fails.
Walk bounds
- Have to recompute a "walk bounds" every time the method graph is updated used to deal with cyclical constraints