study module¶
Scalable study¶
Classes:
|
This scalable parametric study realizes scalable studies with different scaling strategies. |
|
This class is dedicated to the post-treatment of TMParamSS results. |
|
This scalable study creates a scalable MDO problem from Tedford and Martins, 2010 and compares its resolution according to different MDO formulations. |
Functions:
|
Create a directory if not exists. |
|
Random values in a given shape. |
|
Save the graphical representation of a matrix. |
- class gemseo.problems.scalable.parametric.study.TMParamSS(n_disciplines, n_shared, n_local, n_coupling, full_coupling=True, active_probability=0.1, feasibility_level=0.8, seed=1, directory='results')[source]¶
Bases:
object
This scalable parametric study realizes scalable studies with different scaling strategies.
E.g. comparison of MDF and IDF formulations in terms of execution time for different number of coupling variables.
The TMParamSS constructor depends on:
the number of disciplines,
the number of shared design parameters,
the number of local design parameters for each discipline,
the number of coupling variables for each each discipline.
One of the three latter should be a list of integers whose components define scaling strategies.
The constructor instantiates as many TMScalableStudy as scaling strategies.
- Parameters
n_disciplines (int) – number of disciplines.
n_shared – (list of) number(s) of shared design parameters.
n_local – (list of) number(s) of local design parameters for each discipline.
n_coupling – (list of) number(s) of coupling parameters for each discipline.
full_coupling (bool) – fully couple the disciplines, ie each TMDiscipline depends on each other. Default: True.
active_probability (float) – active probability
feasibility_level (float) – level of feasibility
seed (int) – seed for replicability.
directory (str) – directory to store results
See also
TMScalableStudy
standard scalable study launched with different configurations in the case of parametric scalable study.
Methods:
run_formulation
(formulation[, max_iter, …])This method solves the scalable problems with a particular MDO formulation.
save
(file_path)This method saves the results into a pickle file.
- run_formulation(formulation, max_iter=100, post_coupling=True, post_optim=True, post_coeff=True, algo='NLOPT_SLSQP', algo_options=None)[source]¶
This method solves the scalable problems with a particular MDO formulation.
- Parameters
formulation (str) – MDO formulation name
max_iter (int) – maximum number of iterations
post_coupling (bool) – store coupling plots
post_optim (bool) – store optimization plots
post_coeff (bool) – store coefficients plots
algo – algorithm name to solve the problem
algo_options – inequality and equality tolerance, xtol etc..
- class gemseo.problems.scalable.parametric.study.TMParamSSPost(file_path)[source]¶
Bases:
object
This class is dedicated to the post-treatment of TMParamSS results.
The constructor reads data stored in a pickle file.
- Parameters
file_path (str) – file path where data are stored.
Methods:
plot
([title, save, show, file_path])Plot one line per MDO formulation where the y-axis represents the execution time and the x-axis the scaling strategies.
- plot(title='A scalable comparison of MDO formulations', save=False, show=True, file_path='comparison.pdf')[source]¶
Plot one line per MDO formulation where the y-axis represents the execution time and the x-axis the scaling strategies.
- Parameters
title (str) – title of the figure. Default: ‘A scalable comparison of MDO formulations’.
save (bool) – save the plot. Default: False.
show (bool) – show the plot. Default: True.
file_path (str) – file path to store the figure. Default: ‘comparison.pdf’.
- class gemseo.problems.scalable.parametric.study.TMScalableStudy(n_disciplines, n_shared, n_local, n_coupling, full_coupling=True, active_probability=0.1, feasibility_level=0.8, seed=1, directory='results')[source]¶
Bases:
object
This scalable study creates a scalable MDO problem from Tedford and Martins, 2010 and compares its resolution according to different MDO formulations.
The TMScalableStudy constructor depends on:
the number of disciplines,
the number of shared design parameters,
the number of local design parameters for each discipline,
the number of coupling variables for each each discipline.
- Parameters
n_disciplines (int) – number of disciplines.
n_shared (int) – number of shared design parameters.
n_local (int) – number of local design parameters for each discipline.
n_coupling (int) – number of coupling parameters for each discipline.
full_coupling (bool) – fully couple the disciplines, ie each TMDiscipline depends on each other. Default: True.
active_probability (float) – active probability
feasibility_level (float) – level of feasibility
directory (str) – directory to store results
seed (int) – seed for replicability.
See also
TMScalableProblem
Scalable problem managed by the scalable study and providing both disciplines and design space.
Attributes:
Names of the MDO formulations.
Methods:
plot_exec_time
([show, save, file_path])Barplot of the execution time of the different disciplines for the different formulations.
run_formulation
(formulation[, max_iter, …])This method solves the scalable problem with a particular MDO formulation.
- property formulations¶
Names of the MDO formulations.
- Returns
list of MDO formulations names
- Return type
list(str)
- plot_exec_time(show=True, save=False, file_path='exec_time.pdf')[source]¶
Barplot of the execution time of the different disciplines for the different formulations. When the formulation is based on a MDA, the MDO scenario is detailed in terms of MDA, MDO chain and sub-MDA.
- Parameters
show (bool) – if True, show plot. Default: False.
save (bool) – if True, save plot. Default: False.
- Parma str file_path
file path. Default: “exec_time.pdf”
- run_formulation(formulation, max_iter=100, post_coupling=True, post_optim=True, post_coeff=True, algo='NLOPT_SLSQP', algo_options=None)[source]¶
This method solves the scalable problem with a particular MDO formulation.
- Parameters
formulation (str) – MDO formulation name
max_iter (int) – maximum number of iterations
post_coupling (bool) – store coupling plots
post_optim (bool) – store optimization plots
post_coeff (bool) – store coefficients plots
algo – algorithm name to solve the problem
algo_options – inequality and equality tolerance, xtol etc..
- gemseo.problems.scalable.parametric.study.mkdir(dirname, subdirname=None)[source]¶
Create a directory if not exists.
- Parameters
dirname (str) – name of the directory.
subdirname (str) – name of the sub-directory. If None, only considers the directory. Default: None.
- gemseo.problems.scalable.parametric.study.rand(d0, d1, ..., dn)¶
Random values in a given shape.
Note
This is a convenience function for users porting code from Matlab, and wraps random_sample. That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones.
Create an array of the given shape and populate it with random samples from a uniform distribution over
[0, 1)
.- Parameters
d0 (int, optional) – The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
d1 (int, optional) – The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
... (int, optional) – The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
dn (int, optional) – The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
- Returns
out – Random values.
- Return type
ndarray, shape
(d0, d1, ..., dn)
See also
random
Examples
>>> np.random.rand(3,2) array([[ 0.14022471, 0.96360618], #random [ 0.37601032, 0.25528411], #random [ 0.49313049, 0.94909878]]) #random
- gemseo.problems.scalable.parametric.study.save_matrix_plot(matrix, disc, name, directory='.')[source]¶
Save the graphical representation of a matrix.
- Parameters
matrix (ndarray) – matrix.
disc (str) – discipline name.
name (str) – name of the matrix.
directory (str) – name of the directory to write the file. Default: ‘.’.