Step

class pumas.desirability.step.Step(params: Dict[str, Any] | None = None)[source]
compute_numeric(x: int | float) float[source]

Compute the centered step desirability for a numeric input.

Parameters:

x (Union[int, float]) – The numeric input value.

Returns:

The computed desirability value.

Return type:

float

Raises:
  • InvalidParameterTypeError – If the input is not a float.

  • ParameterValueNotSet – If any required parameter is not set.

compute_ufloat(x: AffineScalarFunc) AffineScalarFunc[source]

Compute the centered step desirability for an uncertain float input.

Parameters:

x (UFloat) – The uncertain float input value.

Returns:

The computed desirability value with uncertainty.

Return type:

UFloat

Raises:
  • InvalidParameterTypeError – If the input is not a UFloat.

  • ParameterValueNotSet – If any required parameter is not set.

name: ClassVar[str] = 'step'

Centered Step desirability function implementation.

This class implements a centered step desirability function.

The centered step function is defined as:

\[\begin{split}D(x) = \begin{cases} 1 & \text{if } low \leq x \leq high \\ 0 & \text{otherwise} \end{cases}\end{split}\]

If invert is True, the function becomes:

\[D_{inverted}(x) = 1 - D(x)\]

Finally, the shift is applied:

\[D_{final}(x) = D(x) \cdot (1 - shift) + shift\]
Parameters:

params (Optional[Dict[str, Any]]) – Initial parameters for the centered step function.

low

Lower bound of the step.

Type:

float

high

Upper bound of the step.

Type:

float

invert

Whether to invert the result, default False.

Type:

bool

shift

Vertical shift of the step, range [0.0, 1.0], default 0.0.

Type:

float

Usage Example
>>> from pumas.desirability import desirability_catalogue
>>> desirability_class = desirability_catalogue.get("step")
>>> params = {'low': 0.0, 'high': 1.0, "invert": False, 'shift': 0.0}
>>> desirability = desirability_class(params=params)
>>> print(desirability.get_parameters_values())
{'low': 0.0, 'high': 1.0, 'invert': False, 'shift': 0.0}
>>> result = desirability.compute_numeric(x=-1.0)
>>> print(f"{result:.2f}")
0.00
>>> result = desirability.compute_numeric(x=0.5)
>>> print(f"{result:.2f}")
1.00
>>> result = desirability(x=1.5) # Same as compute_numeric
>>> print(f"{result:.2f}")
0.00
>>> from uncertainties import ufloat
>>> result = desirability.compute_ufloat(x=ufloat(0.5, 0.1))
>>> print(result)
1.00+/-0.10

Note: The uncertainty in the last example is 1.00 because the step function is discontinuous, and the error is takne from the input.

class pumas.desirability.step.RightStep(params: Dict[str, Any] | None = None)[source]
compute_numeric(x: int | float) float[source]

Compute the right step desirability for a numeric input.

Parameters:

x (Union[int, float]) – The numeric input value.

Returns:

The computed desirability value.

Return type:

float

Raises:
  • InvalidParameterTypeError – If the input is not a float.

  • ParameterValueNotSet – If any required parameter is not set.

compute_ufloat(x: AffineScalarFunc) AffineScalarFunc[source]

Compute the right step desirability for an uncertain float input.

Parameters:

x (UFloat) – The uncertain float input value.

Returns:

The computed desirability value with uncertainty.

Return type:

UFloat

Raises:
  • InvalidParameterTypeError – If the input is not a UFloat.

  • ParameterValueNotSet – If any required parameter is not set.

name: ClassVar[str] = 'rightstep'

Right Step desirability function implementation.

This class implements a right step desirability function with adjustable parameters. It provides methods to compute the desirability for both numeric and uncertain float inputs.

The right step function is defined as:

\[\begin{split}D(x) = \begin{cases} 1 & \text{if } x \geq high \\ 0 & \text{otherwise} \end{cases}\end{split}\]

Finally, the shift is applied:

\[D_{final}(x) = D(x) \cdot (1 - shift) + shift\]
Parameters:

params (Optional[Dict[str, Any]]) – Initial parameters for the right step function.

low

Lower bound (unused in this function).

Type:

float

high

Upper bound (step threshold).

Type:

float

shift

Vertical shift of the step, range [0.0, 1.0], default 0.0.

Type:

float

Usage Example:

>>> from pumas.desirability import desirability_catalogue
>>> desirability_class = desirability_catalogue.get("rightstep")
>>> params = {'low': 0.0, 'high': 1.0, 'shift': 0.0}
>>> desirability = desirability_class(params=params)
>>> print(desirability.get_parameters_values())
{'low': 0.0, 'high': 1.0, 'shift': 0.0}
>>> result = desirability.compute_numeric(x=0.5)
>>> print(f"{result:.2f}")
0.00
>>> result = desirability(x=1.5) # Same as compute_numeric
>>> print(f"{result:.2f}")
1.00
>>> from uncertainties import ufloat
>>> result = desirability.compute_ufloat(x=ufloat(1.0, 0.1))
>>> print(result)
1.00+/-0.10
class pumas.desirability.step.LeftStep(params: Dict[str, Any] | None = None)[source]
compute_numeric(x: int | float) float[source]

Compute the left step desirability for a numeric input.

Parameters:

x (Union[int, float]) – The numeric input value.

Returns:

The computed desirability value.

Return type:

float

Raises:
  • InvalidParameterTypeError – If the input is not a float.

  • ParameterValueNotSet – If any required parameter is not set.

compute_ufloat(x: AffineScalarFunc) AffineScalarFunc[source]

Compute the left step desirability for an uncertain float input.

Parameters:

x (UFloat) – The uncertain float input value.

Returns:

The computed desirability value with uncertainty.

Return type:

UFloat

Raises:
  • InvalidParameterTypeError – If the input is not a UFloat.

  • ParameterValueNotSet – If any required parameter is not set.

name: ClassVar[str] = 'leftstep'

Left Step desirability function implementation.

This class implements a left step desirability function with adjustable parameters. It provides methods to compute the desirability for both numeric and uncertain float inputs.

The left step function is defined as:

\[\begin{split}D(x) = \begin{cases} 1 & \text{if } x \leq low \\ 0 & \text{otherwise} \end{cases}\end{split}\]

Finally, the shift is applied:

\[D_{final}(x) = D(x) \cdot (1 - shift) + shift\]
Parameters:

params (Optional[Dict[str, Any]]) – Initial parameters for the left step function.

low

Lower bound (step threshold).

Type:

float

high

Upper bound (unused in this function).

Type:

float

shift

Vertical shift of the step, range [0.0, 1.0], default 0.0.

Type:

float

Usage Example
>>> from pumas.desirability import desirability_catalogue
>>> desirability_class = desirability_catalogue.get("leftstep")
>>> params = {'low': 1.0, 'high': 2.0, 'shift': 0.0}
>>> desirability = desirability_class(params=params)
>>> print(desirability.get_parameters_values())
{'low': 1.0, 'high': 2.0, 'shift': 0.0}
>>> result = desirability.compute_numeric(x=0.5)
>>> print(f"{result:.2f}")
1.00
>>> result = desirability(x=1.5) # Same as compute_numeric
>>> print(f"{result:.2f}")
0.00
>>> from uncertainties import ufloat
>>> result = desirability.compute_ufloat(x=ufloat(1.0, 0.1))
>>> print(result)
1.00+/-0.10

Parameter Analysis (Step)

(Source code, png, hires.png, pdf)

../../_images/step-1.png

Parameter Analysis (Right Step)

(Source code, png, hires.png, pdf)

../../_images/step-2.png

Parameter Analysis (Left Step)

(Source code, png, hires.png, pdf)

../../_images/step-3.png