{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Post-processing\n\nIn this example, we will discover the different functions of the API\nrelated to graphical post-processing of scenarios.\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 (\n    configure_logger,\n    create_discipline,\n    create_scenario,\n    execute_post,\n    get_available_post_processings,\n    get_post_processing_options_schema,\n)\nfrom gemseo.problems.sellar.sellar_design_space import SellarDesignSpace\n\nconfigure_logger()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Get available DOE algorithms\n\nThe :meth:`~gemseo.api.get_available_post_processings` function returns the list\nof post-processing algorithms available in |g| or in external modules\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "print(get_available_post_processings())"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Get options schema\nFor a given post-processing algorithm, e.g. :code:`\"RadarChart\"`,\nwe can get the options; e.g.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "print(get_post_processing_options_schema(\"RadarChart\"))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Post-process a scenario\nThe API function :meth:`~gemseo.api.execute_post` can generate visualizations\nof the optimization or DOE results. For that, it consider the object to\npost-process :code:`to_post_proc`, the post processing :code:`post_name`\nwith its :code:`**options`. E.g.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "disciplines = create_discipline([\"Sellar1\", \"Sellar2\", \"SellarSystem\"])\ndesign_space = SellarDesignSpace()\nscenario = create_scenario(\n    disciplines, \"MDF\", \"obj\", design_space, \"SellarMDFScenario\", \"MDO\"\n)\nscenario.execute({\"algo\": \"NLOPT_SLSQP\", \"max_iter\": 100})\nexecute_post(scenario, \"OptHistoryView\", show=False, save=False)\n# Workaround for HTML rendering, instead of ``show=True``\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.8.12"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}