gemseo_box_subdivision.design_spaces#
The design space of a box-subdivided problem.
Module Attributes
The default limit on the number of boxes that |
Functions
|
Create the design space of a box-subdivided problem. |
|
Return the one-hot vectors of every box of a subdivision. |
|
Create the design space of a box-subdivided problem in normalized variables. |
- gemseo_box_subdivision.design_spaces.DEFAULT_MAX_BOXES: Final[int] = 100000#
The default limit on the number of boxes that
create_box_samples()builds.
- gemseo_box_subdivision.design_spaces.create_box_design_space(subdivision, design_space, margin=0.0001, one_hot_names=mappingproxy({}), weights=mappingproxy({}))[source]#
Create the design space of a box-subdivided problem.
The returned design space gathers the variables of both levels:
the variables of the original problem, whose bounds are widened by
BoxSubdivision.create_relaxed_design_space(), and which are solved for in the sub-problem;one categorical variable per subdivided variable, selecting a subdivision per component, which the main problem decides.
The
Bendersformulation splits the two levels apart on its own, by keeping the categorical variables in the main problem.The catalogue of a subdivided variable is the range of its subdivision indexes, and every subdivision is weighed alike, so that the distance the main problem measures is the number of components a candidate box changes. Leaving the weights at the catalogue values, which is what a catalogue design space does on its own, would not express a proximity: the constraint charges the weights the incumbent holds on the components a candidate changes and never reads what it changes them to, so leaving the first subdivision would be free and leaving the last would cost the range, however near the candidate is.
- Parameters:
subdivision (BoxSubdivision) – The Cartesian subdivision of the design space.
design_space (DesignSpace) – The design space of the original problem.
margin (float) – The relative margin applied to the bounds of the subdivided variables, so that a box lying against a bound keeps the multiplier of its face.
one_hot_names (Mapping[str, str]) – The name of the one-hot variable of each subdivided variable. If empty, suffix the design variable names with
BoxSubdivision.ONE_HOT_SUFFIX.weights (Mapping[str, ndarray]) – The weights of the subdivisions of each variable, used by the main problem to measure the distance between two boxes. If empty, weigh every subdivision alike, so that the distance is the number of components a candidate box changes.
- Returns:
The design space of the box-subdivided problem.
- Raises:
ValueError – If a subdivided variable is not in the design space.
- Return type:
CatalogueDesignSpace
- gemseo_box_subdivision.design_spaces.create_normalized_box_design_space(subdivision, design_space, one_hot_names=mappingproxy({}), normalized_names=mappingproxy({}), weights=mappingproxy({}))[source]#
Create the design space of a box-subdivided problem in normalized variables.
This is the counterpart of
create_box_design_space()for the formulation based onBoxMapping: a subdivided variable is replaced by its normalized variable, bounded by 0 and 1 whatever the box, and starting at the center of the box. A variable that is not subdivided is kept as is.Since the bounds of the sub-problem no longer depend on the box, this design space needs neither the margin of
create_box_design_space()nor a scenario adapter placing the starting point inside the box.- Parameters:
subdivision (BoxSubdivision) – The Cartesian subdivision of the design space.
design_space (DesignSpace) – The design space of the original problem.
one_hot_names (Mapping[str, str]) – The name of the one-hot variable of each subdivided variable. If empty, suffix the design variable names with
BoxSubdivision.ONE_HOT_SUFFIX.normalized_names (Mapping[str, str]) – The name of the normalized variable of each subdivided variable. If empty, suffix the design variable names with
BoxSubdivision.NORMALIZED_SUFFIX.weights (Mapping[str, ndarray]) – The weights of the subdivisions of each variable, used by the main problem to measure the distance between two boxes. If empty, weigh every subdivision alike, so that the distance is the number of components a candidate box changes.
- Returns:
The design space of the box-subdivided problem in normalized variables.
- Raises:
ValueError – If a subdivided variable is not in the design space.
- Return type:
CatalogueDesignSpace
- gemseo_box_subdivision.design_spaces.create_box_samples(subdivision, one_hot_names=mappingproxy({}), max_boxes=100000)[source]#
Return the one-hot vectors of every box of a subdivision.
Passing these samples to the
CustomDOEdriver of the main problem solves the sub-problem of every box. This is the reference against which the outer approximation has to be compared: it is exhaustive over the boxes, and it is embarrassingly parallel, so the outer approximation is only worth its complexity if it solves substantially fewer sub-problems.- Parameters:
subdivision (BoxSubdivision) – The Cartesian subdivision of the design space.
one_hot_names (Mapping[str, str]) – The name of the one-hot variable of each subdivided variable, used to order the columns as in the design space.
max_boxes (int) – The maximum number of boxes to enumerate.
- Returns:
The one-hot vectors, shaped
(n_boxes, n_binaries).- Raises:
ValueError – If the subdivision has more boxes than
max_boxes.- Return type:
ndarray