Constraints

class ionworkspipeline.constraints.EqualityConstraint(fun, regularizer_weight=None)

An equality constraint that must evaluate to 0.

Parameters

funcallable

The constraint function that takes a dictionary of inputs and returns a value.

regularizer_weightfloat, optional

Weight applied to the constraint term. Default is 1.0.

Extends: ionworkspipeline.data_fits.regularizers.constraints.Constraint

class ionworkspipeline.constraints.EqualityConstraintSet(regularizers: list | tuple | ndarray, scalar_output: bool, x_to_inputs: callable, regularizer_set_weight: float | None = None)

A set of equality constraints.

Parameters

regularizerslist, tuple or ndarray

Collection of equality 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.regularizers.regularizers.RegularizerSet

property base_regularizer_type

type: The base type for regularizers in this set.

class ionworkspipeline.constraints.InequalityConstraint(fun, regularizer_weight=None, sign_convention=None)

An inequality constraint that must evaluate to less than or equal to 0.

By convention, the constraint is active when f(x) > 0 for a positive sign convention and f(x) < 0 for a negative sign convention.

Parameters

funcallable

The constraint function that takes a dictionary of inputs and returns a value.

regularizer_weightfloat, optional

Weight applied to the constraint term. Default is 1.0.

sign_convention{‘positive’, ‘negative’}, optional

The sign convention for the constraint. Default is ‘positive’.

Extends: ionworkspipeline.data_fits.regularizers.constraints.Constraint

evaluate_to_scalar(inputs)

Evaluate the regularizer function with dictionary inputs, returning a scalar.

Parameters

inputsdict

Dictionary of input values.

Returns

float

Scalar regularizer value.

set_sign_convention(sign_convention)

Set the sign convention for this constraint.

Parameters

sign_convention{‘positive’, ‘negative’}

The sign convention to use.

property sign_convention

str: The sign convention (‘positive’ or ‘negative’) for this constraint.

transform(out)

Apply the sign convention transform to the constraint output.

Parameters

outfloat or ndarray

The raw constraint output.

Returns

float or ndarray

The transformed constraint output.

class ionworkspipeline.constraints.InequalityConstraintSet(regularizers: list | tuple | ndarray, scalar_output: bool, x_to_inputs: callable, regularizer_set_weight: float | None = None)

A set of inequality constraints.

Parameters

regularizerslist, tuple or ndarray

Collection of inequality 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.regularizers.regularizers.RegularizerSet

property base_regularizer_type

type: The base type for regularizers in this set.

set_sign_convention(sign_convention)

Set the sign convention for all constraints in this set.

Parameters

sign_convention{‘positive’, ‘negative’}

The sign convention to use.

ionworkspipeline.constraints.DEFAULT_CONSTRAINT_SET_WEIGHT()