gemseo / core / mdofunctions

Show inherited members

mdo_linear_function module

A linear function defined from coefficients and offset matrices.

class gemseo.core.mdofunctions.mdo_linear_function.MDOLinearFunction(coefficients, name, f_type=None, input_names=None, value_at_zero=0.0, output_names=None, expr=None)[source]

Bases: MDOFunction

Linear multivariate function defined by.

  • a matrix \(A\) of first-order coefficients \((a_{ij})_{\substack{i = 1, \dots m \\ j = 1, \dots n}}\)

  • and a vector \(b\) of zero-order coefficients \((b_i)_{i = 1, \dots m}\)

\[\begin{split}F(x) = Ax + b = \begin{bmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{m1} & \cdots & a_{mn} \end{bmatrix} \begin{bmatrix} x_1 \\ \vdots \\ x_n \end{bmatrix} + \begin{bmatrix} b_1 \\ \vdots \\ b_m \end{bmatrix}.\end{split}\]

Initialize self. See help(type(self)) for accurate signature.

Parameters:
  • coefficients (NumberArray) – The coefficients \(A\) of the linear function.

  • name (str) – The name of the linear function.

  • f_type (str | None) – The type of the linear function among MDOFunction.FunctionType. If None, the linear function will have no type.

  • input_names (Sequence[str] | None) – The names of the inputs of the linear function. If None, the inputs of the linear function will have no names.

  • value_at_zero (OutputType) –

    The value \(b\) of the linear function output at zero.

    By default it is set to 0.0.

  • output_names (Sequence[str] | None) – The names of the outputs of the function. If None, the outputs of the function will have no names.

  • expr (str | None) – The expression of the linear function.

offset(value)[source]

Add an offset value to the function.

Parameters:

value (ndarray[Any, dtype[number]] | Number) – The offset value.

Returns:

The offset function.

Return type:

MDOLinearFunction

restrict(frozen_indexes, frozen_values)[source]

Build a restriction of the linear function.

Parameters:
  • frozen_indexes (ndarray[int]) – The indexes of the inputs that will be frozen.

  • frozen_values (NumberArray) – The values of the inputs that will be frozen.

Returns:

The restriction of the linear function.

Raises:

ValueError – If the frozen indexes and values have different shapes.

Return type:

MDOLinearFunction

property coefficients: NumberArray

The coefficients of the linear function.

This is the matrix \(A\) in the expression \(y=Ax+b\).

Raises:

ValueError – If the coefficients are not passed as a 1-dimensional or 2-dimensional ndarray.

force_real: bool

Whether to cast the results to real value.

has_default_name: bool

Whether the name has been set with a default value.

last_eval: OutputType | None

The value of the function output at the last evaluation.

None if it has not yet been evaluated.

special_repr: str

The string representation of the function overloading its default string ones.

property value_at_zero: NumberArray

The value of the function at zero.

This is the vector \(b\) in the expression \(y=Ax+b\).

Raises:

ValueError – If the value at zero is neither a ndarray nor a number.