gemseo / problems / scalable / parametric

study module

Scalable study

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.

    By default it is set to True.

  • active_probability (float) –

    active probability

    By default it is set to 0.1.

  • feasibility_level (float) –

    level of feasibility

    By default it is set to 0.8.

  • seed (int) –

    seed for replicability.

    By default it is set to 1.

  • directory (str) –

    directory to store results

    By default it is set to results.

See also

TMScalableStudy

standard scalable study launched with different configurations in the case of parametric scalable study.

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

    By default it is set to 100.

  • post_coupling (bool) –

    store coupling plots

    By default it is set to True.

  • post_optim (bool) –

    store optimization plots

    By default it is set to True.

  • post_coeff (bool) –

    store coefficients plots

    By default it is set to True.

  • algo

    algorithm name to solve the problem

    By default it is set to NLOPT_SLSQP.

  • algo_options

    inequality and equality tolerance, xtol etc..

    By default it is set to None.

save(file_path)[source]

This method saves the results into a pickle file.

Parameters

file_path (str) – pickle file path to store the results.

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.

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’.

    By default it is set to A scalable comparison of MDO formulations.

  • save (bool) –

    save the plot. Default: False.

    By default it is set to False.

  • show (bool) –

    show the plot. Default: True.

    By default it is set to True.

  • file_path (str) –

    file path to store the figure. Default: ‘comparison.pdf’.

    By default it is set to 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.

    By default it is set to True.

  • active_probability (float) –

    active probability

    By default it is set to 0.1.

  • feasibility_level (float) –

    level of feasibility

    By default it is set to 0.8.

  • directory (str) –

    directory to store results

    By default it is set to results.

  • seed (int) –

    seed for replicability.

    By default it is set to 1.

See also

TMScalableProblem

Scalable problem managed by the scalable study and providing both disciplines and design space.

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.

    By default it is set to True.

  • save (bool) –

    if True, save plot. Default: False.

    By default it is set to 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, xdsm_pdf=False)[source]

Solve the scalable problem with a particular MDO formulation.

Parameters
  • formulation – The name of the MDO formulation.

  • max_iter

    THe maximum number of iterations.

    By default it is set to 100.

  • post_coupling

    Whether to store the coupling plots.

    By default it is set to True.

  • post_optim

    Whether to store the optimization plots.

    By default it is set to True.

  • post_coeff

    Whether to store the coefficients plots.

    By default it is set to True.

  • algo

    The name of the algorithm used to solve the problem.

    By default it is set to NLOPT_SLSQP.

  • algo_options

    The options for the algorithm.

    By default it is set to None.

  • xdsm_pdf

    Whether to export the xdsm in pdf.

    By default it is set to False.

property formulations

Names of the MDO formulations.

Returns

list of MDO formulations names

Return type

list(str)

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.

    By default it is set to 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: ‘.’.

    By default it is set to ..