Constraint
Constraint(function, value, type='eq', tolerance=1e-08)One constraint for the augmented Lagrange optimizer.
Pairs a constraint function with the value it is compared against and the comparison type. Pass a list of these as constraints to :func:optim_minimize with method="augmented_lagrange".
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| function | callable | Takes a numeric parameter vector and returns a single number – the left-hand side of the constraint. | required |
| value | float | The number function is compared against. |
required |
| type | ('eq', 'le', 'ge') | "eq" for f(x) == value, "le" for f(x) <= value, "ge" for f(x) >= value. |
"eq" |
| tolerance | float | How far from value still counts as feasible, matching the upstream Constraint class’s own default. |
1e-08 |
Examples
>>> from corehydropy import Constraint
>>> Constraint(lambda p: p[0] + p[1], value=4.0, type="eq") # x + y == 4
<Constraint f(x) == 4 (tolerance 1e-08)>