.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_reliability_sensitivity/design_of_experiments/plot_optimal_lhs.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_reliability_sensitivity_design_of_experiments_plot_optimal_lhs.py: Optimize an LHS design of experiments ===================================== .. GENERATED FROM PYTHON SOURCE LINES 6-7 This examples show how to generate optimized LHS experiments according to the different criteria. .. GENERATED FROM PYTHON SOURCE LINES 9-15 .. code-block:: Python import openturns as ot import openturns.viewer as viewer from matplotlib import pylab as plt ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 16-17 **LHS and space filling** .. GENERATED FROM PYTHON SOURCE LINES 19-39 .. code-block:: Python N = 100 # Considering independent Uniform distributions of dimension 3 # Bounds are (-1,1), (0,2) and (0, 0.5) distribution = ot.ComposedDistribution( [ot.Uniform(-1.0, 1.0), ot.Uniform(0.0, 2.0), ot.Uniform(0.0, 0.5)] ) # Random LHS lhs = ot.LHSExperiment(distribution, N) lhs.setAlwaysShuffle(True) # randomized design = lhs.generate() # C2 c2 = ot.SpaceFillingC2().evaluate(design) # PhiP with default p phip = ot.SpaceFillingPhiP().evaluate(design) # mindist mindist = ot.SpaceFillingMinDist().evaluate(design) # For p->infinity phip_inf = ot.SpaceFillingPhiP(100).evaluate(design) print(phip, mindist, phip_inf) .. rst-class:: sphx-glr-script-out .. code-block:: none 17.054824704132752 0.0469316649638053 17.054817010338425 .. GENERATED FROM PYTHON SOURCE LINES 40-41 **Optimized LHS using Monte Carlo** .. GENERATED FROM PYTHON SOURCE LINES 43-58 As with Monte Carlo, user decides of a fixed number of iterations, but this time this number is part of the temperature profile. Two profiles are currently provided: - Linear profile: :math:`T_i = T_0 (1-\frac{1}{n_{iter}})` - Geometric profile: :math:`T_i = T_O c^i, 0 draw criterion graph = result.drawHistoryCriterion() view = viewer.View(graph) .. image-sg:: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_optimal_lhs_001.png :alt: C2 criterion history of optimal design :srcset: /auto_reliability_sensitivity/design_of_experiments/images/sphx_glr_plot_optimal_lhs_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 146-148 Convergence needs to be performed New algo starting from this design .. GENERATED FROM PYTHON SOURCE LINES 148-151 .. code-block:: Python algo = ot.SimulatedAnnealingLHS(design, distribution, space_filling, temperatureProfile) design = algo.generate() plt.show() .. _sphx_glr_download_auto_reliability_sensitivity_design_of_experiments_plot_optimal_lhs.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_optimal_lhs.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_optimal_lhs.py `