gemseo.core.mdo_functions.mdo_linear_function module#
A linear function defined from coefficients and offset matrices.
- class MDOLinearFunction(coefficients, name, f_type=FunctionType.NONE, input_names=(), value_at_zero=0.0, output_names=(), 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}\]- Parameters:
coefficients (SparseOrDenseRealArray) -- The coefficient matrix \(A\) of the linear function.
value_at_zero (OutputType) --
The value \(b\) of the linear function output at zero.
By default it is set to 0.0.
expr (str | None) -- The expression of the function, if any. If
None
, create an expression from the coefficients and the value at zero.name (str)
f_type (MDOFunction.FunctionType) --
By default it is set to "".
input_names (Sequence[str]) --
By default it is set to ().
output_names (Sequence[str]) --
By default it is set to ().
- normalize(input_space)[source]#
Create a linear function using a scaled input vector.
- Parameters:
input_space (DesignSpace) -- The input space.
- Returns:
The scaled linear function.
- Return type:
- 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:
- property coefficients: NumberArray#
The coefficient matrix of the linear function.
This is the matrix \(A\) in the expression \(y=Ax+b\).
- 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.