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 |
|
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¶
Description | Illustration |
---|---|
Add a general indicator script that calculates the average of a time series. This script will be used for defining: |
Prepare Indicators¶
Description | Illustration |
---|---|
Enable indicators or the model setup | |
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 |
|
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. |
Add Optimizer¶
Description | Illustration |
---|---|
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¶
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. |
|
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¶
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. |
|
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¶
Description | Illustration |
---|---|
Two objectives will be set up in optimizer 1. |
|
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. |
|
Select the objective function in the “Objective functions” table Click “Add objective function detail”. 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 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” 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. (2) Choose an indicator from the drop-down menu at the “Indicator Name” property |
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. |
|
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¶
Description | Illustration |
---|---|
Click the save button above the tables |
Run the Optimization¶
Run the optimization scenario¶
Description | Illustration |
---|---|
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¶
Description | Illustration |
---|---|
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 |
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 |
|
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 (\<right-click>\<edit>) |
|
In the optimization setup, the water demand time series was defined as decision. The values of the optimization parameters have automatically been copied to the water demand time series when the scenario was created. |
Plot Objective Functions¶
Description | Illustration |
---|---|
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¶
Description | Illustration |
---|---|
Save the spreadsheet (including chart and other changes) 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. |