Package gaphas :: Module solver

Module solver

source code

Constraint solver allows to define constraint between two or more different variables and keep this constraint always true when one or more of the constrained variables change. For example, one may want to keep two variables always equal.

Variables change and at some point of time we want to make all constraints valid again. This process is called solving constraints.

Gaphas' solver allows to define constraints between Variable instances. Constraint classes are defined in gaphas.constraint module.

How It Works

Every constraint contains list of variables and has to be registered in solver object. Variables change (Variable.dirty(), Solver.request_resolve() methods) and their constraints are marked by solver as dirty. To solve constraints, solver loops through dirty constraints and asks constraint for a variable (called weakest variable), which

(weakest variable invariants defined above)

Having weakest variable (constraint.Constraint.weakest() method) every constraint is being asked to solve itself (constraint.Constraint.solve_for() method) changing appropriate variables to make the constraint valid again.


Version: $Revision: 2093 $

Classes
  Variable
Representation of a variable in the constraint solver.
  Projection
Projections are used to convert values from one space to another, e.g.
  Solver
Solve constraints.
  solvable
Easy-to-use drop Variable descriptor.
  JuggleError
Variable juggling exception.
Variables
  EPSILON = 1e-010
  VERY_WEAK = 0
  WEAK = 10
  NORMAL = 20
  STRONG = 30
  VERY_STRONG = 40
  REQUIRED = 100
  __test__ = {'Solver.add_constraint': <unbound method Solver.ad...
Variables Details

__test__

Value:
{'Solver.add_constraint': <unbound method Solver.add_constraint>,
 'Solver.remove_constraint': <unbound method Solver.remove_constraint>\
}