{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n# MDF-based DOE on the Sobieski SSBJ test case\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from __future__ import division, unicode_literals\n\nfrom matplotlib import pyplot as plt\n\nfrom gemseo.api import configure_logger, create_discipline, create_scenario\nfrom gemseo.problems.sobieski.core import SobieskiProblem\n\nconfigure_logger()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Instantiate the disciplines\nFirst, we instantiate the four disciplines of the use case:\n:class:`~gemseo.problems.sobieski.wrappers.SobieskiPropulsion`,\n:class:`~gemseo.problems.sobieski.wrappers.SobieskiAerodynamics`,\n:class:`~gemseo.problems.sobieski.wrappers.SobieskiMission`\nand :class:`~gemseo.problems.sobieski.wrappers.SobieskiStructure`.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "disciplines = create_discipline(\n [\n \"SobieskiPropulsion\",\n \"SobieskiAerodynamics\",\n \"SobieskiMission\",\n \"SobieskiStructure\",\n ]\n)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Build, execute and post-process the scenario\nThen, we build the scenario which links the disciplines\nwith the formulation and the optimization algorithm. Here, we use the\n:class:`.BiLevel` formulation. We tell the scenario to minimize -y_4\ninstead of minimizing y_4 (range), which is the default option.\n\nWe need to define the design space.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "design_space = SobieskiProblem().read_design_space()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Instantiate the scenario\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "scenario = create_scenario(\n disciplines,\n formulation=\"MDF\",\n objective_name=\"y_4\",\n design_space=design_space,\n maximize_objective=True,\n scenario_type=\"DOE\",\n)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Set the design constraints\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "for constraint in [\"g_1\", \"g_2\", \"g_3\"]:\n scenario.add_constraint(constraint, \"ineq\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Execute the scenario\nUse provided analytic derivatives\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "scenario.set_differentiation_method(\"user\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Multiprocessing\nIt is possible to run a DOE in parallel using multiprocessing, in order to do\nthis, we specify the number of processes to be used for the computation of\nthe samples.\n\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
The multiprocessing option has some limitations on Windows.\n For Python versions < 3.7 and Numpy < 1.20.0, subprocesses may get hung\n randomly during execution. It is strongly recommended to update your\n environment to avoid this problem.\n The features :class:`.MemoryFullCache` and :class:`.HDF5Cache` are not\n available for multiprocessing on Windows.\n As an alternative, we recommend the method\n :meth:`.DOEScenario.set_optimization_history_backup`.
When running a parallel DOE on Windows, the execution must be\n protected to avoid recursive calls:
On Windows, the progress bar may show duplicated instances during the\n initialization of each subprocess. In some cases it may also print the\n conclusion of an iteration ahead of another one that was concluded first.\n This is a consequence of the pickling process and does not affect the\n computations of the scenario.