.. title: Water: A Multi-Objective Benchmark Problem
.. slug: 15
.. date: 2025-06-15 13:50
.. tags: documentation,english,open source, genetic algorithms, optimization
.. description:
.. wp-status: publish
.. has_math: true

.. |--|  unicode:: U+2013  .. en dash

This is a write-up that really should go into the documentation of
PGAPack_ but I was unable to include plotly_ graphics into a github
``README.rst`` file, even using the proxy-site ``raw.githack.com``
(which is a page that serves html and javascript files with the correct
content type so that it can be displayed in a web browser |--| github
choses to serve these files with content-type text/plain). Github
refuses to render an iframe inside  a github page.

The "Water Resource Planning" problem [RTS01]_ is an engineering problem
that has been used as a benchmark for multi-objective optimization in
the literature including classical papers like the original article on
NSGA_II [DPAM02]_. The problem consists of seven constraints and a
five-dimensional objective function.

I have used this for quite some time to test my NSGA-II implementation
in PGAPack_. It is in the examples/nsgaii directory and can (after
compilation) be called with test-problem index ``12``::

    examples/nsgaii/optimize 12

The output of this program can also be found in the file ::

    test/nsgaii_optimize_12.data

For testing I'm shipping a script called ``crowdingplot`` to plot
objectives in a multi-objective problem. It is in the same directory as
the code for the example.

.. TEASER_END

The "water" problem has strong correlation between objectives 0 and 2
(as also found by Singh et. al. [SIR11]_), we can see this when we plot
the two objectives using::

    crowdingplot -x=0 -y=2 test/nsgaii_optimize_12.data


.. iframe:: /content/2025/06/plotly/x_0_y_2.html
    :width: 800
    :height: 640

The call to ``crowdingplot`` above will use the matplotlib_ backend, if
you want the plotly_ backend (as in the graphics above), you can specify
the ``-S`` option.

We see in this plot that getting a better evaluation for objective 0
also gets a better evaluation of objective 2 and vice-versa, i.e. the
objectives are not contradictory. Furthermore objective 3 is redundant
[SIR11]_ with the other objectives and can be left out when plotting
objectives. So the 5-dimensional pareto front can be reduced to a
3-dimensional front and can be plotted with ``crowdingplot`` in three
dimensions showing quite similar results when scaled to the same visible
range::

 crowdingplot -3 -x=0 -y=1 -z=4 test/nsgaii_optimize_12.data
 crowdingplot -3 -x=2 -y=1 -z=4 test/nsgaii_optimize_12.data

.. iframe:: /content/2025/06/plotly/x_0_y_1_z_4.html
    :width: 800
    :height: 640

.. iframe:: /content/2025/06/plotly/x_2_y_1_z_4.html
    :width: 800
    :height: 640

On the one hand this means that this example is not really a five
dimensional problem |--| on the other hand it is nice that we can
visualize the data which is not so easy for five dimensions.


.. [DPAM02] Kalyanmoy Deb, Amrit Pratap, Sameer Agarwal, and T. Meyarivan.
       A fast and elitist multiobjective genetic algorithm: NSGA-II.
       IEEE Transactions on Evolutionary Computation, 6(2):182–197,
       April 2002.
.. [RTS01] Tapabrata Ray, Kang Tai, and Kin Chye Seow. Multiobjective design
       optimization by an evolutionary algorithm. Engineering Optimization,
       33(4):399–424, 2001.
.. [SIR11] Hemant Kumar Singh, Amitay Isaacs, and Tapabrata Ray.  A pareto
       corner search evolutionary algorithm and dimensionality reduction
       in many-objective optimization problems. IEEE Transactions on
       Evolutionary Computation, 15(4):539–556, August 2011.

.. _`PGAPack`: https://github.com/schlatterbeck/pgapack
.. _`plotly`: https://plotly.com/
.. _`matplotlib`: https://matplotlib.org/
