Skip to content

Optimization

Optimization Overview

Optimization of a scenario is configured in the Scenario Manager

Setup optimization

Start by making the goal of the optimization clear to yourself...Identify the objectives and which input that should be used as decisions.

In this example a simple MIKE Basin model with on reservoir and one water user is treated.

The goal of the optimization is to find the water demand that minimizes the demand deficit while at the same time maximizing the amount of used water.

Prepare Scenario

Add Water Demand input time series to scenario from Model data view.

The optimizer is going to use Water Demand as decision variable.

Add Water Demand deficit and Used Water output time series to scenario from Model data view.

The optimizer is going to use Water Demand deficit and Used Water for defining objective functions.

Prepare Indicator Scripts

Add a general indicator script that calculates the average of a time series.

This script will be used for defining

  • An indicator that measures the average Water Demand Deficit.
  • An indicator that measures the average Used Water.

Prepare Indicators

Enable indicators or the model setup.

Add a model indicator that measures the demand deficit, e.g. by calculating the average over the simulation period.

  1. Make a New indicator
  2. Change the name to Average water deficit.
  3. Specify the script for the indicator (drag it from script manager).
  4. Define the time series as a model reference.
  5. Drag the model setup output time series from the model setup data view.
  6. Save the indicator.

Add a model indicator that measures the used water, e.g. by calculating the average over the simulation period.

  1. Make a New indicator.
  2. Change the name to Average used water.
  3. Specify the script for the indicator (drag it from script manager).
  4. Define the time series as a model reference.
  5. Drag the model setup output time series from the model setup data view.
  6. Save the indicator.

Check that the defined indicators work by running an ordinary simulation.

  1. In scenario explorer: right-click Scenario of MB and choose Run simulation.
  2. When the simulation has completed: double-click Indicator Values node.
  3. Check that each of the indicators has returned a number (and not an error message).

Add optimizer

Right-click the scenario and select Add optimizer.

The optimizer is added as a sub-node to the active scenario.

When created the name of the optimizer is editable allowing the default name to be changed.

Add decision variables

Double-click on the optimizer node. The configuration pages for the optimizer are shown in the data view.

Select the Decision variables tab (default when optimizer configuration is opened).

The list of decision variables is empty.

Open the data view of the parent scenario by double-clicking on the scenario node.

Browse to the Water demand and right-click. Choose Add variable to optimizer Optimizer 1 in the context menu.

Alternatively, the Water demand can be added as decision variable by dragging it onto the optimizer node.

Go back to the optimizer configuration. The Water Demand is now shown in the Decision variables list.

Select the row with Water Demand in Decision variables list. Each time set of the time series is displayed in the Decision variable details list below.

Configure decision variables

The next steps set up a quarterly variation of the water demand.

Select the row named D1_1(January) in the decision variable details table

  • In column Type choose Variable from drop-down menu.
  • In column UseInitialValue set a check-mark.
  • In column UpperBound enter 100.

Repeat this setup for D1_4 (April), D1_7 (July), D_10 (October).

These are the four variables that the optimizer will vary between 0 and 100.

Now February and March values are defined to equal the January value:

Select the row named D1_2 (February) in the Decision variable details table.

  • In column Type choose Dependent from drop-down-menu.
  • In column Equation write D1_1.

Repeat for the row named D1_3 (March) in the same way.

  • Define the May and June values to equal April the value
  • Define the August and September values to equal the July value
  • Define the November and December values to equal the October value).

Configure objective functions

Two objectives will be set up in Optimizer 1.

  1. Minimize Water deficit
  2. Maximize Used water

Set up the Minimize water deficit objective:

Go to the tab optimizer configuration

  1. Click Add objective function
    The properties of the objective function is shown in the table Objective functions.
  2. Select the objective function in the table. Its properties can now be configured in the property grid.
    • At the name property enter W5 Water deficit –average
    • At the ObjectiveType choose Minimize (default).
    • At the Weight property keep the default value (1)
    • At the Aggregation of objective function details property keep the default value (SumValues)

Note: The properties are described in the bottom of the property grid

Select the objective function in the Objective functions table.

  1. Click Add objective function detail.
    A row is added to the Objective functions detail table
  2. Select the added row. It can now be configured in the property grid.

Choose an indicator from the drop-down menu at the Indicator Name property (the drop-down arrow appears when the field is clicked)

Set up the Maximize used water objective. As the inherent nature of the optimization algorithms is to minimize, a target is set up for the objective. The optimizer will minimize the distance to the target. Go to the tab optimizer configuration

  1. Click Add objective function
    The properties of the objective function are shown in the table Objective functions.
  2. Select the objective function in the table. Its properties can now be configured in the property grid. At the name property enter W5 used Water –average
    • At the Weight property keep the default value (1)
    • At the ObjectiveType choose Target.
    • At the Target property set the value to 100
    • At the Aggregation property keep the default value (SumValues)

Note: The properties are described in the bottom of the property grid

Select the objective function in the Objective functions table. 1. Click Add objective function detail.

A row is added to the Objective functions detail table Select the added row. It can now be configured in the property grid.

  1. Choose an indicator from the drop-down menu at the Indicator Name property.

Configure optimization algorithm

Go to the tab optimizer configuration. (The same tab where the objective functions were configured)

In the Optimization Algorithm table choose Monte Carlo from the drop-down menu.

The configuration parameters for the Monte Carlo method are shown in the property grid. Only available parameter is Seed (for the random number generator), which generally not need to be altered.

Below the Algorithm parameters, the Stop criteria parameters are shown.

Expand the list by clicking the three-dot next to List of Stop Criteria (Collection). This will expand the list of stop criteria.

The Monte Carlo method only has one stop criterion, Maximum number of model realizations.

Select the criterion to the left and configure its properties to the right. In this case: leave the default value (*200").

Save the optimization configuration

Click the save button above the tables.

Run the optimization

Run the optimization scenario

Right-click the Optimizer node and choose Run Optimization.

A progress indicator shows the iterations.

An information dialog indicates success.

Refresh the scenario explorer. A new scenario named Optimized Scenario of MB has been added.

View the results

Find results

Expanding the Optimizer 1 node will display the Results node.

Double-click Results to open a spreadsheet that contains the results.

The All model runs tab holds details for all model evaluations in the order the simulations were carried out.

Details include:

  • parameter values (i.e. the value choice for the variable decision variables in the optimization setup).
  • Objective function values.

Create a new scenario from a parameter record

Any simulation can be promoted to a scenario:

  1. Select the range containing the parameters.
  2. Click the Create Scenario button.

Confirm (click Yes) in the dialog box.

Refresh the scenario explorer to display the created scenario Optimized Scenario of MB(2).

Double-click Optimized Scenario of MB(2).

Browse to the Water demand

Open the table view of the water demand series ()

In the optimization setup, the water demand time series was defined as decision.

  • Jan, Apr, Jul and Oct values were defined as variable.
  • The months in the following quarter were defined to equal Jan, Apr, Jul and Oct values respectively.

The values of the optimization parameters have automatically been copied to the water demand time series when the scenario was created.

Plot objective functions

Make a scatter plot of objective function 1 and objective function 2.

The scatter plot shows the trade-offs between objective function 1 (minimize water deficit) and objective2.

Objective 2 is a target objective, thus the plot shows the discrepancy between Average Used Water and the target (100).

Save results

Save the spreadsheet (including chart and other changes).

  1. Click the Save button.
  2. Specify a location in the Spreadsheet manager. No default location is proposed.

The saved spreadsheet can be opened from the Spreadsheet Manager.

Double-clicking the results node will open a spreadsheet with the as-simulated results. i.e. the original optimization results are NOT overwritten when saving the spreadsheet.