pymoto.Scaling
- class pymoto.Scaling(scaling: float = 100.0, minval: float = None, maxval: float = None, minmax_smooth: float = 1.0)
Scales (scalar) input for different response functions in optimization (objective / constraints). This is useful, for instance, for MMA where the objective must be scaled in a certain way for good convergence.
Objective scaling using absolute value or vector norm (minval and maxval are both undefined): \(y^{(i)} = s \frac{x^{(i)}}{||x^{(0)}||}\)
For the constraints, the negative null-form convention is used, which means the constraint is \(y(x) \leq 0\).
Upper limit constraint \(x\leq x_\text{max}\) (maxval is specified): \(y = s \left( \frac{x - x_\text{max}}{|x_\text{max}|} \right)\)
Lower limit constraint \(x\geq x_\text{min}\) (minval is specified): \(y = s \left( \frac{x_\text{min} - x}{|x_\text{min}|} \right)\)
Note: If the supplied minimum or maximum value is equal to zero, the normalization will be skipped.
- Input Signal:
x: Unscaled variable \(x\)
- Output Signal:
y: Scaled variable \(y\)
- __init__(scaling: float = 100.0, minval: float = None, maxval: float = None, minmax_smooth: float = 1.0)
Initialize the scaling module
- Parameters:
scaling (float, optional) – Value \(s\) to scale with. Defaults to 100.0.
minval (float, optional) – Minimum value \(x_ ext{min}\) for negative-null-form constraint
maxval (float, optional) – Maximum value \(x_ ext{max}\) for negative-null-form constraint
minmax_smooth (float, optional) – Smoothing parameter for double-sided constraints. Defaults to 1.0.
Methods
__init__([scaling, minval, maxval, ...])Initialize the scaling module
connect(sig_in[, sig_out])Connect without automatic adding to a function network
get_input_sensitivities([as_list])get_input_states([as_list])get_output_sensitivities([as_list])get_output_states([as_list])reset()Reset the state of the sensitivities (they are set to zero or to None)
response()Calculate the response from sig_in and output this to sig_out
Calculate sensitivities using backpropagation
Attributes
Get the number of input signals
Get the number of output signals
- reset_scaling()
- connect(sig_in: Signal | Iterable[Signal], sig_out: Signal | Iterable[Signal] = None)
Connect without automatic adding to a function network
- get_input_sensitivities(as_list=False)
- get_input_states(as_list=False)
- get_output_sensitivities(as_list=False)
- get_output_states(as_list=False)
- property n_in: int
Get the number of input signals
- property n_out: int
Get the number of output signals
Note: Cannot be used in the initial __call__()
- reset()
Reset the state of the sensitivities (they are set to zero or to None)
- response()
Calculate the response from sig_in and output this to sig_out
- sensitivity()
Calculate sensitivities using backpropagation
Based on the sensitivity we get from sig_out, reverse the process and output the new sensitivities to sig_in
- sig_in: List = None
- sig_out: List = None