ConstrainMatrix
¶
Builder for the linear constraint matrix H used in state-vector minimization.
Constructs and accumulates pairwise equality constraints between state components,
then returns a full-column-rank H matrix suitable for passing to
minimize_x or
minimize_v.
The constrained minimization is:
Parameters:
-
cost(CompositeCost or CostSegment) –Cost function whose ALSSM order determines the size of
H.
Methods:
-
constrain–Add a constraint between two state indices.
-
constrain_by_labels–Add a constraint between two state variables identified by label.
-
digest–Return a snapshot of the constraint matrix with redundant columns removed.
-
print_table–Prints the actual table of constraints to the console
Attributes:
-
TSLM_TYPES–tuple of str : Supported Two-Sided Line Model constraint type names.
Source code in lmlib/statespace/cost.py
Methods¶
constrain
¶
Add a constraint between two state indices.
Sets H[indices[0], indices[1]] = value and
H[indices[1], indices[0]] = value, creating a symmetric dependency
between the two state components.
Parameters:
-
indices(array_like of shape (2,)) –Pair of state indices to constrain.
-
value(float) –Constraint value placed at both off-diagonal positions.
Returns:
-
self(ConstrainMatrix) –Returns self to allow method chaining.
Source code in lmlib/statespace/cost.py
constrain_by_labels
¶
Add a constraint between two state variables identified by label.
Looks up the state indices for label_1 and label_2 and delegates
to constrain.
Parameters:
-
label_1(str) –Label of the first state variable.
-
label_2(str) –Label of the second state variable.
-
value(float) –Constraint value.
Returns:
-
self(ConstrainMatrix) –Returns self to allow method chaining.
Source code in lmlib/statespace/cost.py
digest
¶
Return a snapshot of the constraint matrix with redundant columns removed.
Removes columns that are zero, duplicate, or linearly dependent on other columns before returning, yielding a full-column-rank H matrix.
Returns:
-
H(ndarray of shape (N, K)) –Constraint matrix, where K <= N is the number of independent constraints remaining after redundancy removal.
Source code in lmlib/statespace/cost.py
print_table
¶
Prints the actual table of constraints to the console