gemseo.formulations.bilevel module#
A Bi-level formulation.
- class BiLevel(disciplines, objective_name, design_space, settings_model=None, **settings)[source]#
Bases:
BaseMDOFormulation
A bi-level formulation.
This formulation draws an optimization architecture that involves multiple optimization problems to be solved to obtain the solution of the MDO problem.
Here, at each iteration on the global design variables, the bi-level MDO formulation implementation performs:
a first MDA to compute the coupling variables,
several disciplinary optimizations on the local design variables in parallel,
a second MDA to update the coupling variables.
Initialize self. See help(type(self)) for accurate signature.
- Parameters:
disciplines (Sequence[Discipline]) -- The disciplines.
objective_name (str) -- The name(s) of the discipline output(s) used as objective. If multiple names are passed, the objective will be a vector.
design_space (DesignSpace) -- The design space.
settings_model (BiLevel_Settings | None) -- The settings of the formulation as a Pydantic model. If
None
, use**settings
.**settings (Any) -- The settings of the formulation. This argument is ignored when
settings_model
is notNone
.
- Settings#
alias of
BiLevel_Settings
- add_constraint(output_name, constraint_type=ConstraintType.EQ, constraint_name='', value=0, positive=False, levels=())[source]#
Add a constraint to the formulation.
- Parameters:
output_name (str) -- The name(s) of the outputs computed by \(c(x)\). If several names are given, a single discipline must provide all outputs.
constraint_type (ConstraintType) --
The type of constraint.
By default it is set to "eq".
constraint_name (str) --
The name of the constraint to be stored. If empty, the name of the constraint is generated from
output_name
,constraint_type
,value
andpositive
.By default it is set to "".
value (float) --
The value \(a\).
By default it is set to 0.
positive (bool) --
Whether the inequality constraint is positive.
By default it is set to False.
The levels at which the constraint is to be added (sublist of
LEVELS
). By default, the policy set at the initialization of the formulation is enforced.By default it is set to ().
- Raises:
ValueError -- When the constraint levels are not a sublist of BiLevel.LEVELS.
- Return type:
None
- classmethod get_default_sub_option_values(**options)[source]#
- Raises:
ValueError -- When the MDA name is not provided.
- Parameters:
options (str)
- Return type:
StrKeyMapping
- classmethod get_sub_options_grammar(**options)[source]#
Return the grammar of the selected MDA.
- Parameters:
**options (str) -- The options of the BiLevel formulation.
- Returns:
The MDA grammar.
- Raises:
ValueError -- When the MDA name is not provided.
- Return type:
- get_top_level_disciplines()[source]#
Return the disciplines which inputs are required to run the scenario.
A formulation seeks to compute the objective and constraints from the input variables. It structures the optimization problem into multiple levels of disciplines. The disciplines directly depending on these inputs are called top level disciplines.
By default, this method returns all disciplines. This method can be overloaded by subclasses.
- Returns:
The top level disciplines.
- Return type:
- DEFAULT_SCENARIO_RESULT_CLASS_NAME: ClassVar[str] = 'BiLevelScenarioResult'#
The name of the
ScenarioResult
class to be used for post-processing.
- LEVELS = ('system', 'sub-scenarios')#
- SUBSCENARIOS_LEVEL = 'sub-scenarios'#
- SYSTEM_LEVEL = 'system'#