gemseo_box_subdivision.scenario#

A scenario solving a problem by subdividing its design space.

Composing a run by hand means chaining the mapping before the objective, building the design space from the same subdivision, naming the one-hot variables of the master, choosing the formulation and sizing the trust region. None of those is a decision: they are invariants, and every one of them is a way to get a silently wrong run.

BoxSubdivisionScenario owns them. What it leaves to the caller is what the measurements say actually matters: which variables to subdivide and how finely, and the convexity margin, which is in the units of the objective and transfers between problems no better than a length does.

Module Attributes

FORMULATIONS

The two ways of confining a sub-problem to its box.

Functions

create_box_subdivision_scenario(disciplines, ...)

Return a scenario solving a problem by subdividing its design space.

Classes

BoxSubdivisionScenario(disciplines, ...[, ...])

A scenario exploring a design space by subdividing it into boxes.

gemseo_box_subdivision.scenario.FORMULATIONS: tuple[str, ...] = ('normalized', 'constraint')#

The two ways of confining a sub-problem to its box.

class gemseo_box_subdivision.scenario.BoxSubdivisionScenario(disciplines, objective_name, design_space, n_subdivisions=10, variable_names=(), levels=1, formulation='normalized', weights=mappingproxy({}), settings=None, scenario_adapter_cls=None, name='')[source]#

Bases: MDOScenario

A scenario exploring a design space by subdividing it into boxes.

It is an ordinary GEMSEO scenario, executed the same way:

scenario = BoxSubdivisionScenario(
    [objective_discipline], "f", design_space, n_subdivisions=10
)
scenario.execute()

Executing it without arguments uses the settings it was built with, so the master of the outer approximation never has to be configured by hand. Passing settings explicitly overrides them, as for any scenario.

The algorithm of each of the two levels, and its settings, come from BoxSubdivisionSettings: the master from master_algo_name and master_algo_settings, each sub-problem from sub_problem_algo_name and sub_problem_algo_settings.

The four constructions share this one entry point:

  • a flat subdivision, the default;

  • subdividing some variables only, by passing a mapping of n_subdivisions whose keys are the variables to subdivide, or by naming them in variable_names;

  • the multi-resolution encoding, by asking for more than one level;

  • the box as a constraint of the sub-problem rather than its bounds, by asking for the "constraint" formulation.

Parameters:
  • disciplines (Sequence[Discipline])

  • objective_name (str)

  • design_space (DesignSpace)

  • n_subdivisions (int | Mapping[str, int])

  • variable_names (Iterable[str])

  • levels (int)

  • formulation (str)

  • weights (Mapping[str, ndarray])

  • settings (BaseBoxSubdivisionSettings | None)

  • scenario_adapter_cls (type[MDOScenarioAdapterBenders] | None)

  • name (str)

box_settings: BaseBoxSubdivisionSettings#

The settings of the run.

subdivision: BoxSubdivision | MultiResolution#

The subdivision of the design space the scenario explores.

class Settings(*, algo_name, algo_settings=<factory>)#

Bases: _BaseSettings

Parameters:
  • algo_name (_algo_enum)

  • algo_settings (dict[str, Any])

model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

algo_name: cls._algo_enum#
execute(algo_settings_model=None, **algo_settings)[source]#

Execute the scenario.

Without arguments, run the master named by the settings the scenario was built with, with those settings, the radius of the trust region scaled where the distance counts something other than design variables: the multi-resolution encoding has one one-hot group per level per variable, so two whole variables is twice the number of levels.

Parameters:
  • algo_settings_model (Any) – The settings of the master, overriding those of the scenario, the model naming the algorithm to execute.

  • **algo_settings (Any) – The settings of the master, as keyword arguments.

Returns:

Whatever a GEMSEO scenario returns.

Return type:

None

gemseo_box_subdivision.scenario.create_box_subdivision_scenario(disciplines, objective_name, design_space, **settings)[source]#

Return a scenario solving a problem by subdividing its design space.

The factory of BoxSubdivisionScenario, for the create_ idiom of GEMSEO. The two are interchangeable.

Parameters:
  • disciplines (Sequence[Discipline]) – The disciplines computing the objective.

  • objective_name (str) – The name of the objective output.

  • design_space (DesignSpace) – The design space of the original problem.

  • **settings (Any) – The settings of BoxSubdivisionScenario.

Returns:

The scenario, ready to execute.

Return type:

BoxSubdivisionScenario