Subject: Multiple runs of model with variable variations Posted: 3/4/2011 Viewed: 25053 times
Hi all, I have been using WEAP for almost a year now, and we are performing uncertainty analysis in different models, one of them WEAP, for a high elevation Andean watershed. I know there is a scripting possibility with the new version of WEAP, has anybody already experimented with automatic iterations for one model and automatic variations of a certain variable ?
For example, I would like to have the model output for +-5% variations of soil conductivity, any heads up on a script that has already done that ?
Subject: Re: Multiple runs of model with variable variations Posted: 3/4/2011 Viewed: 25052 times
Here's a very simple script that demonstrates running a model with varying values of a data variable. Save these lines to a file with a .VBS extension, e.g., Simple.vbs, and double click the file to run it.
' Run WEAP as a COM Automation Server
' Do a sensitivity analysis on the Supply Measures scenario to the population growth rate of South City
' Vary the population growth for South City from 0 to 5%, saving groundwater storage results for each run in c:\GWn.csv
Set WEAP = CreateObject("WEAP.WEAPApplication")
WEAP.Verbose = 1 ' 0 = no dialogs, 1 = errors only, 2 = questions & errors, 3 = warnings, questions & errors, 4 = all dialogs
WEAP.Logfile = WEAP.Directory + "WeapErrors.txt" ' log all errors and warnings to this text file
WEAP.ActiveArea = "Weaping River Basin"
WEAP.ActiveScenario = "Supply Measures"
CALL WEAP.LoadFavorite("Groundwater Storage") ' This will calculate first
IF WEAP.Status = FALSE THEN ' If the user cancels the calculations, exit the FOR loop
CALL WEAP.ExportResults("c:\GW" + FormatNumber(GrowthRate, 0) + ".csv", FALSE, TRUE) ' save these results to a CSV file
' WEAP will close automatically when the script is done, and the changes will NOT be saved to the area
Subject: Re: Multiple runs of model with variable variations Posted: 3/4/2011 Viewed: 25039 times
Thanks! I have tried to perform the sensitivity analysis using key assumptions, but I keep getting errors such as "Object doesn´t support..."
The error is displaye for this line and its modifications
Is there a special way to modify key assumptions using scripting ?
Subject: Re: Multiple runs of model with variable variations Posted: 3/4/2011 Viewed: 25038 times
You cannot put an expression on the branch \Key Assumption itself. Instead, right click on the Key Assumption branch and create new branches, then put the expressions there. You can also create folders of branches (like in the Weaping River Basin example) under Key Assumptions--just right click on a new branch to create a branch underneath it.
Subject: Re: Multiple runs of model with variable variations Posted: 10/2/2013 Viewed: 16610 times
Until recently, I've successfully used a VBScript, based on the one posted above. However, I recently received a new computer that has the 64-bit version of Windows 7 Professional installed, and the VBScript no longer works. I'm receiving the following dialog:
Searching online suggests there may be a problem with registering dlls. I've tried this, but still haven't been able to get the VBScript to run, so any suggestions would be appreciated.
Subject: Re: Multiple runs of model with variable variations Posted: 10/3/2013 Viewed: 16609 times
Here is how you can manually "register" WEAP. Make sure WEAP is not running. Right click on the Windows "Command Prompt" program and choose "Run as admin". In the command window, go to WEAP folder (e.g., cd C:\Program Files (x86)\WEAP ) and run:
Nothing visible will happen when you do this (you will not see WEAP start), but it should add the correct entries to the Windows Registry to allow you to run WEAP from a script.
Subject: Re: Multiple runs of model with variable variations Posted: 10/3/2013 Viewed: 16602 times
Thank you, Jack. After registering WEAP, the VBScript is running again.
Topic "Multiple runs of model with variable variations"