disciplines_generator module¶
Dummy linear discipline generator¶
A utility that generates dummy disciplines from a specification. The inputs and output names are specified by the user. A linear random dependency between the inputs and outputs is created. The size of the inputs and outputs can be parametrized by the user. The MDA of the generated disciplines will always converge because all the outputs are in [0, 1] if the inputs are in [0, 1]. The analytic Jacobian is provided.
Functions:
|
Generate :class:`.LinearDiscipline`s according to a specification. |
|
Generate :class:`.LinearDiscipline`s according to a specification. |
|
Modify a sequence in-place by shuffling its contents. |
- gemseo.problems.scalable.linear.disciplines_generator.create_disciplines_from_desc(disc_descriptions, inputs_size=1, outputs_size=1, grammar_type='JSON')[source]¶
Generate :class:`.LinearDiscipline`s according to a specification.
The specification is as follows:
[ ("Disc_name1", ["in1"], ["out1", "out2"]), ("Disc_name2", ["in2", "out1"], ["out3", "out2"]), ]
- This will generate two disciplines:
One named “Disc_name1” with the inputs [“in1”] and the outputs [“out1”, “out2”].
Another named “Disc_name2” with the inputs [“in2”, “out1”] and the outputs [“out3”, “out2”].
- Parameters
disc_descriptions – The specification of the disciplines, each item is (name, inputs_names, outputs_names), disciplines names may be non unique.
inputs_size (int) – The size of the input vectors, each input data is of shape (inputs_size,).
outputs_size (int) – The size of the output vectors, each output data is of shape (outputs_size,).
grammar_type (str) – The type of grammars used by the disciplines.
- Returns
The :class:`.LinearDiscipline`s.
- Return type
List[gemseo.problems.scalable.linear.linear_discipline.LinearDiscipline]
- gemseo.problems.scalable.linear.disciplines_generator.create_disciplines_from_sizes(nb_of_disc, nb_of_total_disc_io, nb_of_disc_inputs=1, nb_of_disc_outputs=1, inputs_size=1, outputs_size=1, grammar_type='JSON')[source]¶
Generate :class:`.LinearDiscipline`s according to a specification.
The names of the disciplines are generated from capital letters words. The names of the inputs and outputs are generated from string representations of integers.
- Parameters
nb_of_disc (int) – The total number of disciplines.
nb_of_total_disc_io (int) – The total number of input and output data names in the overall process.
nb_of_disc_inputs (int) – The number of disciplines inputs, same for all disciplines.
nb_of_disc_outputs (int) – The number of disciplines outputs, same for all disciplines.
inputs_size (int) – The size of the input vectors, each input data is of shape (inputs_size,).
outputs_size (int) – The size of the output vectors, each output data is of shape (outputs_size,).
grammar_type (str) – The type of grammars used by the discipline.
- Returns
The :class:`.LinearDiscipline`s.
- Raises
ValueError – If the number of disciplines is inconsistent with the total number of inputs or outputs.
- Return type
List[gemseo.problems.scalable.linear.linear_discipline.LinearDiscipline]
- gemseo.problems.scalable.linear.disciplines_generator.shuffle(x)¶
Modify a sequence in-place by shuffling its contents.
This function only shuffles the array along the first axis of a multi-dimensional array. The order of sub-arrays is changed but their contents remains the same.
Note
New code should use the
shuffle
method of adefault_rng()
instance instead; please see the random-quick-start.- Parameters
x (ndarray or MutableSequence) – The array, list or mutable sequence to be shuffled.
- Returns
- Return type
None
See also
Generator.shuffle
which should be used for new code.
Examples
>>> arr = np.arange(10) >>> np.random.shuffle(arr) >>> arr [1 7 5 2 9 4 3 6 0 8] # random
Multi-dimensional arrays are only shuffled along the first axis:
>>> arr = np.arange(9).reshape((3, 3)) >>> np.random.shuffle(arr) >>> arr array([[3, 4, 5], # random [6, 7, 8], [0, 1, 2]])