Skip to content

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

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

The optimizer is going to use Water Demand as decision variable
./Optimization/image2.png
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.
./Optimization/image3.png

Prepare Indicator Scripts

Description Illustration
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
  • ./Optimization/image4.png

    Prepare Indicators

    Description Illustration
    Enable indicators or the model setup ./Optimization/image5.png
    Description Illustration
    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
    ./Optimization/image7.png
    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
    ./Optimization/image8.png
    Check that the defined indicators work by running an ordinary simulation.
  • In scenario explorer: right-click \ and choose \
  • When the simulation has completed: double-click “Indicator Values” node
  • Check that each of the indicators has returned a number (and not an error message)
  • ./Optimization/image9.png

    Add Optimizer

    Description Illustration
    Right-click the scenario and select \<Add optimizer> ./Optimization/image10.png
    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.
    ./Optimization/image11.png

    Add Decision Variables

    Description Illustration
    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.
    ./Optimization/image12.png
    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
    ./Optimization/image13.png
    Alternatively the Water demand can be added as decision variable by dragging it onto the optimizer node. ./Optimization/image14.png
    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.
    ./Optimization/image15.png

    Configure Decision Variables

    Description Illustration
    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.
    ./Optimization/image16.png
    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).
    ./Optimization/image17.png

    Configure Objective Functions

    Description Illustration
    Two objectives will be set up in optimizer 1.
  • Minimize Water deficit
  • Maximize Used water
  • Set up the “Minimize water deficit” objective:
    Go to the tab “optimizer configuration”
    Click “Add objective function”
    The properties of the objective function is shown in the table “Objective functions”.
    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
  • ./Optimization/image18.png
    Select the objective function in the “Objective functions” table
    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.
    Choose an indicator from the drop-down menu at the “Indicator Name” property (the drop-down arrow appears when the field is clicked)
  • ./Optimization/image19.png
    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 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 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
  • ./Optimization/image20.png
    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.
    (2) Choose an indicator from the drop-down menu at the “Indicator Name” property
    ./Optimization/image21.png

    Configure Optimization Algorithm

    Description Illustration
    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.
    ./Optimization/image22.png
    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").
    ./Optimization/image23.png

    Save the Optimization Configuration

    Description Illustration
    Click the save button above the tables ./Optimization/image24.png

    Run the Optimization

    Run the optimization scenario

    Description Illustration
    Right-click the Optimizer node and choose Run Optimization ./Optimization/image25.png
    A progress indicator shows the iterations ./Optimization/image26.png
    An information dialog indicates success ./Optimization/image27.png
    Refresh the scenario explorer. A new scenario named “Optimized Scenario of MB” has been added ./Optimization/image28.png

    View the Results

    Find Results

    Description Illustration
    Expanding the “Optimizer 1” node will display the “Results” node. ./Optimization/image29.png
    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
  • ./Optimization/image30.png

    Create a New Scenario from a Parameter Record

    Description Illustration
    Any simulation can be promoted to a scenario:
    (1) Select the range containing the parameters(2) Click the “Create Scenario” button
    ./Optimization/image31.png
    Confirm (click “Yes”) in the dialog box. ./Optimization/image32.png
    Refresh the scenario explorer to display the created scenario “Optimized Scenario of MB(2)”. ./Optimization/image33.png
    Double-click “Optimized Scenario of MB(2)”.
    Browse to the “Water demand”
    Open the table view of the water demand series (\<right-click>\<edit>)
    ./Optimization/image34.png
    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.
  • ./Optimization/image35.png

    Plot Objective Functions

    Description Illustration
    Make a scatter plot of “objective function 1” and “objective function 2” ./Optimization/image36.png
    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).
    ./Optimization/image37.png

    Save Results

    Description Illustration
    Save the spreadsheet (including chart and other changes)
  • Click the “Save” button
  • 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.
  • ./Optimization/image38.png