DataPDF Available

Online materials for: Determining intervention thresholds that change output behavior patterns

Authors:
Model documentation for:
Determining intervention thresholds that change output
behavior patterns
System Dynamics Review
Bob Walrave
Eindhoven University of Technology, School of Industrial Engineering
Eindhoven, The Netherlands
b.walrave@tue.nl
- 1 -
Model documentation for:
Determining intervention thresholds that change output
behavior patterns
Visual Basic for Applications (VBA) code, including comments
The boxed text in this section, if combined, would provide the full VBA code required
for the intervention thresholds analysis. A basic understanding of VBA and Excel is assumed.
The script was developed on a Microsoft Windows 7 system. Comments and clarifications are
denoted in bold. The full VBA script and the modified model can be downloaded from the
author’s website.
1) Pre-analysis setup
Define name for the VBA script, then connect to Vensim through the DDE channel:
Sub Intervention_threshold_analysis()
Dim DDE_channel As Integer
DDE_channel = Application.DDEInitiate("VENSIM", "System")
Prevent interaction during the analysis. Specifically, messages and warnings need to be
suppressed to prevent message accumulation (and potential system halt). (This limit also can
be set manually in Vensim’s settings.)
Application.DDEExecute DDE_channel, "[SPECIAL>NOINTERACTION|1]"
Application.DDEExecute DDE_channel, "[SETTING>SHOWWARNING|0]"
Declare and set constants and variables.
Dim policy_year As Long
policy_year = 1980 'First intervention year to analyze.
Dim end_year As Long
end_year = 2050 'Final intervention year to analyze.
Dim IOPCD_lower_bound As Long
IOPCD_lower_bound = 200 'Lower intervention size.
- 2 -
Dim IOPCD_higher_bound As Long
IOPCD_upper_bound = 1000 'Upper intervention size.
Dim threshold_value As Variant
cutoff_value = -0.001 'Cut-off value.
Dim result_year As Long
result_year = 2100 'Final runtime (year of observation).
Dim return_cell As Long
return_cell = 7 'First Excel row to output results.
Dim IOPCD As Variant 'Variable capturing the current IOPCD.
Dim steepest_negative_slope As Variant 'The indicator variable.
Dim returnList As Variant 'Variable capturing the results per model run.
1) Start FOR Loop 1, while intervention timing is within the intervention time
frame
'START FOR LOOP 1 (timing loop)
Do While policy_year <= end_year 'Run script until all years have been analyzed.
IOPCD = IOPCD_lower_bound 'Reset lower intervention size.
2) Start FOR Loop 2, while intervention size is within the lower and upper
bound
'START FOR LOOP 2 (size loop)
Do While IOPCD <= IOPCD_upper_bound 'Run script until an intervention threshold is
identified or all intervention sizes are analyzed.
Set the correct values for the policy year (intervention timing) and IOPCD (intervention size)
variables in Vensim:
Application.DDEExecute DDE_channel, "[Simulate>SETVAL|POLICY YEAR = " & policy_year & "]"
Application.DDEExecute DDE_channel, "[Simulate>SETVAL|industrial output per capita desired =
" & IOPCD & "]"
- 3 -
3) Run the model and save the output information
Instruct Vensim to run one simulation. Then execute a delay, required to read and save the
results. Obtain output variables. Return the policy year, IOPCD, population, indicator
variable, and Human Welfare Index variables for the final runtime.
Application.DDEExecute DDE_channel, "[MENU>RUN|O]"
Application.Wait (Now + 0.0000075) 'Depending on system speed, this value can be
set higher/lower. (Lower for faster systems.)
Sheets(1).Cells(return_cell, 1).Value = policy_year 'Return current Policy year
to Excel.
Sheets(1).Cells(return_cell, 2).Value = IOPCD 'Return current IOPCD to Excel.
varstr$ = " ""population""@" & result_year & "" 'Return population to Excel.
returnList = Application.DDERequest(DDE_channel, varstr$)
Sheets(1).Cells(return_cell, 3).Value = returnList(LBound(returnList))
varstr$ = " ""Human Welfare Index""@" & result_year & "" 'Return Human
Welfare Index to Excel.
returnList = Application.DDERequest(DDE_channel, varstr$)
Sheets(1).Cells(return_cell, 4).Value = returnList(LBound(returnList))
varstr$ = " ""Steepest negative slope""@" & result_year & "" 'Return
indicator variable to Excel.
returnList = Application.DDERequest(DDE_channel, varstr$)
Sheets(1).Cells(return_cell, 5).Value = returnList(LBound(returnList))
4) Intervention threshold assessment
Assess the indicator variable. If the cut-off value has not been reached, adjust the IOPCD by
one increment. If the cut-off value has been reached, assume an intervention threshold and
close the second loop:
- 4 -
steepest_negative_slope = returnList(LBound(returnList)) 'Save the indicator
variable.
If (steepest_negative_slope < cutoff_value) Then Exit Do 'If false: increment
intervention size. If true: increment intervention timing.
5) Adjust intervention size (IOPCD) by one increment and repeat from Step 2
IOPCD = IOPCD + 1
Loop
6) Adjust intervention timing (policy year) by one increment and repeat from
Step 1
policy_year = policy_year + 1
return_cell = return_cell + 1 'Adjust the output row in Excel (prevent overwrite).
Loop
7) Post-analysis
After the analysis finishes, terminate the DDE channel and end the VBA script.
Application.DDETerminate DDE_channel 'Stop DDE communication and end
exploration.
End Sub
- 5 -
Adjustments allowing for intervention thresholds analysis.
Constant Old value New value Units
Scenario 0 10 Dmnl
Persistent pollution technology change time 1982 Policy year Year
Persistent pollution technology change use custom 0 1 Dmnl
Resource technology change time 1982 Policy year Year
Resource technology change time use custom 0 1 Dmnl
Zero population growth time 1982 Policy year Year
Zero population growth time use custom 0 1 Dmnl
Land yield policy time 1982 Policy year Year
Land yield policy time use custom 0 1 Dmnl
Land life policy implementation time 1982 Policy year Year
Land life policy time custom 0 1 Dmnl
Fraction of industrial capital allocated to obtaining
resources switch time 1982 Policy year Year
Fraction of industrial capital allocated to obtaining
resources switch time use custom 0 1 Dmnl
Industrial equilibrium time 1982 Policy year Year
Industrial equilibrium time use custom 0 1 Dmnl
Fertility control effectiveness time 1982 Policy year Year
Fertility control effectiveness time use custom 0 1 Dmnl
Industrial output per capita desired use custom 0 1 Dmnl
Industrial output per capita desired (intervention size) 400 200-1000
$/
(Person*ye
ar)
POLICY YEAR use custom 0 1 Dmnl
Policy year (intervention timing) 1982 1980-2050 Year
d (Steepest negative slope) / dt = IF THEN ELSE (TREND (population, 1, 0) < Steepest
negative slope, TREND( population, 1, 0) – Steepest negative slope, 0)
- 6 -
ResearchGate has not been able to resolve any citations for this publication.
ResearchGate has not been able to resolve any references for this publication.