.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_example4.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_examples_plot_example4.py: Example 4 ========= .. GENERATED FROM PYTHON SOURCE LINES 7-21 Problem statement: .. math:: \begin{aligned} & \underset{x}{\text{minimize}} & & \mathbb{E}_{\cD}(\cos(x) \sin(\Theta)) \\ & \text{subject to} & & \mathbb{P}_{\cD}(-2 - x + \Theta \leq 0) \geq 0.9 \\ & & & x - 4 \leq 0 \\ & & & \Theta \thicksim \cU(0, 2) \end{aligned} Solution: :math:`\hat{x} = \pi` .. GENERATED FROM PYTHON SOURCE LINES 23-54 .. code-block:: Python import openturns as ot import otrobopt # ot.Log.Show(ot.Log.Info) calJ = ot.SymbolicFunction(['x', 'theta'], ['cos(x) * sin(theta)']) calG = ot.SymbolicFunction(['x', 'theta'], ['-(-2 - x + theta)', '-(x - 4)']) J = ot.ParametricFunction(calJ, [1], [1.0]) g = ot.ParametricFunction(calG, [1], [1.0]) dim = J.getInputDimension() solver = ot.Cobyla() solver.setMaximumIterationNumber(1000) solver.setStartingPoint([0.0] * dim) thetaDist = ot.Uniform(0.0, 2.0) robustnessMeasure = otrobopt.MeanMeasure(J, thetaDist) reliabilityMeasure = otrobopt.JointChanceMeasure( g, thetaDist, ot.Greater(), 0.9) problem = otrobopt.RobustOptimizationProblem( robustnessMeasure, reliabilityMeasure) algo = otrobopt.SequentialMonteCarloRobustAlgorithm(problem, solver) algo.setMaximumIterationNumber(10) algo.setMaximumAbsoluteError(1e-3) algo.setInitialSamplingSize(10) algo.run() result = algo.getResult() print('x*=', result.getOptimalPoint(), 'J(x*)=', result.getOptimalValue(), 'iteration=', result.getIterationNumber()) .. rst-class:: sphx-glr-script-out .. code-block:: none x*= [3.14159] J(x*)= [-0.757706] iteration= 2 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.007 seconds) .. _sphx_glr_download_auto_examples_plot_example4.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_example4.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_example4.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_example4.zip `