Run this example in your browser

This page was generated from nimbus-river-pollution.ipynb.
Interactive online version: Binder badge (without output) Binder badge (with output)

Solving the river pollution problem using NIMBUS

First, some boilerplate imports. We import optimisation methods from desdeo, the RiverPollution problem from example (FIXME), and visualisation and preference selection tools and widgets from desdeo_vis. Finally, we import and initialise altair.

In [1]:
from desdeo.method.NIMBUS import NIMBUS
from desdeo.optimization import SciPyDE

from desdeo.problem.toy import RiverPollution

from desdeo_vis.plot import parplot
from desdeo_vis.widget import NimbusPrefWidget

import altair.vega.v3 as vg
vg.renderers.enable('notebook');

Initial iteration and preference selection

In this notebook, we explore solutions to the RiverPollution problem with NIMBUS. First we initialise the RiverPollution problem and the NIMBUS solution method. Then we get an initial result. We can plot solutions at any time using parplot.

In [2]:
problem = RiverPollution()
method = NIMBUS(problem, SciPyDE)
results = method.init_iteration()

parplot(results.objective_vars, problem)

_images/nimbus-river-pollution_3_3.png

Next, we will give our first preference based on NIMBUS. We construct a NimbusPrefWidget and save it to a variable

In [3]:
pref = NimbusPrefWidget(results.objective_vars, problem)
pref

Solutions based on preference

We can now generate a new set of results based on this preference. Note that this will raise an InvalidNimbusPreferencesException if you run it while the above preferences are invalid.

In [4]:
results2_all = method.next_iteration(preference=pref.nimbus_clf(method))

parplot(results2_all.objective_vars, problem)

_images/nimbus-river-pollution_7_3.png

We might choose to generate less extra solutions…

In [5]:
results2_less = method.next_iteration(preference=pref.nimbus_clf(method), num_scalars=2)

parplot(results2_less.objective_vars, problem)

_images/nimbus-river-pollution_9_3.png

We can also choose a subset of scalarization functions from NIM, ACH, GUESS, STOM. These are the NIMBUS scalarization function and the NIMBUS version of the achievement, guess and satisficing trade-off functions respectively.

In [6]:
results2_spec = method.next_iteration(preference=pref.nimbus_clf(method), scalars=['NIM', 'GUESS', 'STOM'])

parplot(results2_spec.objective_vars, problem)

_images/nimbus-river-pollution_11_3.png

Generating intermediate solutions

If none of these solutions exactly satisfy us, we can generate and view solutions between two solutions we’ve generated so far. Here we generate 4 solutions between the solutions generated by the NIMBUS and GUESS scalarisation functions.

In [7]:
results3 = method.between(results2_spec.objective_vars[0], results2_spec.objective_vars[1], 4)

parplot(results3.objective_vars, problem)

_images/nimbus-river-pollution_13_3.png