Constraints¶
Constraint classes for enforcing constraints in optimization problems.
- class ionworkspipeline.data_fits.objective_functions.regularizers.Constraint(fun: Symbol | Number, regularizer_weight: float | None = None)¶
A constraint function that takes a dictionary of inputs and returns a value.
Equality constraints are specified by a
pybamm.Symbolof the formf(x)
where
f(x)is apybamm.Symbolwhich evaluates to 0 when the constraint is satisfied.Inequality constraints are specified by a
pybamm.Symbolof the formg(x) <= h(x)
where
g(x)andh(x)arepybamm.Symbolobjects. The constraint is satisfied when the inequality holds. By convention, all inequality constraint penalties add a positive value to the cost when the constraint is violated.Parameters¶
- funpybamm.Symbol or Number
The constraint expression as a pybamm symbol or a constant number.
- regularizer_weightfloat, optional
Weight applied to the constraint term. Default is 1.0.
Extends:
ionworkspipeline.data_fits.objective_functions.regularizers.regularizers.Regularizer- property is_inequality: bool¶
bool: Whether this constraint is an inequality constraint.
- process_symbol(parameter_values: ParameterValues)¶
Process the stored symbolic expression into an evaluable function. For inequality constraints (heavisides), unwraps into max(0, lhs - rhs).
Parameters¶
- parameter_valuespybamm.ParameterValues
The parameter values used to resolve parameters in the expression.
- class ionworkspipeline.data_fits.objective_functions.regularizers.ConstraintSet(regularizers: list | tuple | ndarray, scalar_output: bool, x_to_inputs, regularizer_set_weight: float | None = None)¶
A set of constraints.
Parameters¶
- regularizerslist, tuple or ndarray
Collection of constraint terms.
- scalar_outputbool
Whether the set returns scalar or array outputs.
- x_to_inputscallable
Function converting parameter vectors to input dictionaries.
- regularizer_set_weightfloat, optional
Weight applied to the entire constraint set. Default is 1000.0.
Extends:
ionworkspipeline.data_fits.objective_functions.regularizers.regularizers.RegularizerSet- property base_regularizer_type¶
type: The base type for regularizers in this set.
Utility Functions¶
- ionworkspipeline.data_fits.objective_functions.regularizers.constraints.DEFAULT_CONSTRAINT_SET_WEIGHT()¶