{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Pareto front on Binh and Korn problem\n\nIn this example, we illustrate the use of the :class:`.ParetoFront` plot\non the Binh and Korn multi-objective problem.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from __future__ import unicode_literals\n\nfrom matplotlib import pyplot as plt\n\nfrom gemseo.algos.doe.doe_factory import DOEFactory"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Import\nThe first step is to import some functions from the API\nand a method to get the design space.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "from gemseo.api import configure_logger\nfrom gemseo.post.post_factory import PostFactory\nfrom gemseo.problems.analytical.binh_korn import BinhKorn\n\nconfigure_logger()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Import the optimization problem\nThen, we instantiate the BinkKorn optimization problem.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "problem = BinhKorn()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Create and execute scenario\nThen, we create a Design of Experiment factory,\nand we request the execution a a full-factorial DOE using 100 samples\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "doe_factory = DOEFactory()\ndoe_factory.execute(problem, algo_name=\"OT_OPT_LHS\", n_samples=100)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Post-process scenario\nLastly, we post-process the scenario by means of the :class:`.ParetoFront`\nplot which generates a plot or a matrix of plots if there are more than\n2 objectives, plots in blue the locally non dominated points for the current\ntwo objectives, plots in green the globally (all objectives) Pareto optimal\npoints. The plots in green denotes non-feasible points. Note that the user\ncan avoid the display of the non-feasible points.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "PostFactory().execute(\n    problem,\n    \"ParetoFront\",\n    save=False,\n    show=False,\n    show_non_feasible=False,\n    objectives=[\"compute_binhkorn\"],\n    objectives_labels=[\"f1\", \"f2\"],\n)\n\nPostFactory().execute(\n    problem,\n    \"ParetoFront\",\n    save=False,\n    show=False,\n    show_non_feasible=True,\n    objectives=[\"compute_binhkorn\"],\n    objectives_labels=[\"f1\", \"f2\"],\n)\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
}