ConstraintTrees.jl
ConstraintTrees.ConstraintTrees
— ModulePackage ConstraintTrees.jl
provides a simple data structure ConstraintTree
for organizing the contents of linear and quadratic constrained optimization problems. As a main goal, it abstracts over the distinction between constraints and variables, allowing much tidier representation for many kinds of complex constraint systems.
The primary purpose of ConstraintTrees.jl
is to work with COBREXA.jl; but the package is otherwise completely independent, lightweight, dependency-free and usecase-agnostic. Generally, it is intended to be used with JuMP and the documentation uses JuMP for demonstrations, but any other solver framework will do just as well.
The package is structured as follows:
- There is no representation for variables in the model; instead, values depend on anonymous numbered variables that are mostly hidden in normal use. This assumption erases the distinction between a "simple" variable and a complex derived linear combination, allowing more freedom in model construction. If required, named values may still "implicitly" serve as representations for variables.
- Variables may be combined into
LinearValue
s andQuadraticValue
s, which are affine combinations and quadratic-affine combinations (respectively) of values of some selected variables. - Values may be bounded to an interval or exact value using a
Constraint
- A collection of named
Constraint
s is called aConstraintTree
; it behaves mostly as a specializedSymbol
-keyed dictionary. ConstraintTree
s can be very easily organized into subdirectories, combined and made independent on each other using operators^
,*
, and+
– this forms the basis of the "tidy" algebra of constraints.- A variable assignment, which is typically the "solution" for a given constraint tree, can be combined with a
ConstraintTree
to create a "value tree" viasubstitute_values
. Value trees enable browsing of the optimization results in the very same structure as the inputConstraintTree
.
You can follow the examples in documentation and the docstrings of package contents for more details.