.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_numerical_methods/optimization/plot_minmax_optimization.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_numerical_methods_optimization_plot_minmax_optimization.py: Mix/max search using optimization ================================= .. GENERATED FROM PYTHON SOURCE LINES 6-7 In this example we are going to evaluate the min and max values of the output variable of interest in a domain using an optimization algorithm. .. GENERATED FROM PYTHON SOURCE LINES 10-14 .. code-block:: Python import openturns as ot ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 15-16 Create the marginal distributions of the parameters .. GENERATED FROM PYTHON SOURCE LINES 16-23 .. code-block:: Python dist_E = ot.Beta(0.93, 2.27, 2.8e7, 4.8e7) dist_F = ot.LogNormalMuSigma(30000, 9000, 15000).getDistribution() dist_L = ot.Uniform(250, 260) dist_I = ot.Beta(2.5, 1.5, 3.1e2, 4.5e2) marginals = [dist_E, dist_F, dist_L, dist_I] distribution = ot.ComposedDistribution(marginals) .. GENERATED FROM PYTHON SOURCE LINES 24-25 Define bounds .. GENERATED FROM PYTHON SOURCE LINES 25-29 .. code-block:: Python lowerBound = [marginal.computeQuantile(0.1)[0] for marginal in marginals] upperBound = [marginal.computeQuantile(0.9)[0] for marginal in marginals] bounds = ot.Interval(lowerBound, upperBound) .. GENERATED FROM PYTHON SOURCE LINES 30-31 Create the model .. GENERATED FROM PYTHON SOURCE LINES 31-33 .. code-block:: Python model = ot.SymbolicFunction(["E", "F", "L", "I"], ["F*L^3/(3*E*I)"]) .. GENERATED FROM PYTHON SOURCE LINES 34-35 Define the problems .. GENERATED FROM PYTHON SOURCE LINES 35-42 .. code-block:: Python minProblem = ot.OptimizationProblem(model) minProblem.setBounds(bounds) maxProblem = ot.OptimizationProblem(model) maxProblem.setBounds(bounds) maxProblem.setMinimization(False) .. GENERATED FROM PYTHON SOURCE LINES 43-44 Create a solver .. GENERATED FROM PYTHON SOURCE LINES 44-47 .. code-block:: Python solver = ot.TNC() solver.setStartingPoint(distribution.getMean()) .. GENERATED FROM PYTHON SOURCE LINES 48-49 Solve the problems .. GENERATED FROM PYTHON SOURCE LINES 49-58 .. code-block:: Python solver.setProblem(minProblem) solver.run() minResult = solver.getResult() print("min: y=", minResult.getOptimalValue(), "with x=", minResult.getOptimalPoint()) solver.setProblem(maxProblem) solver.run() maxResult = solver.getResult() print("max: y=", maxResult.getOptimalValue(), "with x=", maxResult.getOptimalPoint()) .. rst-class:: sphx-glr-script-out .. code-block:: none min: y= [6.37642] with x= [4.04419e+07,21319.7,251,435.785] max: y= [23.4246] with x= [2.87477e+07,41178.7,259,354.141] .. _sphx_glr_download_auto_numerical_methods_optimization_plot_minmax_optimization.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_minmax_optimization.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_minmax_optimization.py `