least_squares_penalty module

Define a variation of LeastSquares.

It is not intended to be used with phi_s fit. Approach is here to make the residuals grow when the constraints are not respected.

class LeastSquaresPenalty(*args, history_kwargs=None, **kwargs)[source]

Bases: LeastSquares

A least-squares method, with a penalty function to consider constraints.

Everything is inherited from LeastSquares.

Parameters:

history_kwargs (dict | None, default: None)

supports_constraints: bool = True
__init__(*args, history_kwargs=None, **kwargs)[source]

Set additional information.

Parameters:

history_kwargs (dict | None, default: None)

Return type:

None

_norm_wrapper_residuals(var)[source]

Give residuals with a penalty.

Parameters:

var (ndarray)

Return type:

float

_penalty(constraints_evaluations)[source]

Compute appropriate penalty.

Parameters:

constraints_evaluations (ndarray)

Return type:

float

_abc_impl = <_abc._abc_data object at 0x7318f903f840>