Welcome to WEAP's Website WEAP
WEAP is an initiative of the Stockholm Environment Institute.

About WEAP

What's New?
Sample Screens
History and Credits

Using WEAP
User Guide
Videos (YouTube)

User Forum
Members List
Edit Profile

Additional Support
University Courses

About Us
SEI-US Water Resources Program
Please Contact Us

Interested in Energy?
Read about LEAP: SEI's software for energy planning.

Link WEAP and LEAP for combined Water-Energy planning.
Watch a video demo!

User Forum

All Topics | Topic "WEAPs' optimization principle"
Log in to post new messages or reply to existing messages.
Author Message

Subject: WEAPs' optimization principle   
Posted: 12/2/2015 Viewed: 21304 times
Dear members,

I had a doubt about WEAPs' optimization principle. The results of my simulation looks like the model would optimize the water alocation locally. In other words, it is like WEAP would calculate step by step the water alocation without changing the reservoir operation if some demand site isn't attended in one of the timesteps. To explane me better: I have a demand with highest priority that isn't attended at timestep 20, but if the reservoir would save more water in the timesteps before, he would attend the demand afterwords.
Does the WEAP calculate the hole operation again and again until he attends the demandas or does he calculate the best calculation for the 1. timestep, then for the 2. timestep, etc... till the end of the simulation period?
Ms. Stephanie Galaitsi

Subject: Re: WEAPs' optimization principle   
Posted: 12/7/2015 Viewed: 21254 times
Dear Micol,

WEAP divides between demand priorities on each time step, so if your demand is met, the reservoir will retain water, but if it is not, the reservoir will release water. If you want to implement more sophisticated reservoir operations (for example, when the reservoir level is a below a certain threshold ("buffer zone"), it releases only a fraction of the water demanded, you can use the "operations" tab to program that in. You can also use the monthly time series wizard to change the threshold values or release fractions by month, if you prefer.

WEAP cannot hold water for the future unless you program it, because WEAP assumes the future is unknown. But you can make it do this in many different ways.
Mr. Jack Sieber

Subject: Re: WEAPs' optimization principle   
Posted: 12/7/2015 Viewed: 21247 times
WEAP is a simulation model, not an optimization model. When making allocations in a timestep, WEAP does NOT attempt to look ahead to future timesteps, or even to lower-priority demands in the same timesetep. As Stephanie pointed out, you can use the reservoir rule curves (Top of Conservation, Top of Buffer -- which can varying over time or scenario) to release or hold water in anticipation of future needs.

WEAP does have a Safe Yield Wizard, which can help you determine the maximum yield for a system. See http://www.weap21.org/WebHelp/index.html#Yield_Wizard.htm for more information.

Subject: Re: WEAPs' optimization principle   
Posted: 1/12/2016 Viewed: 21070 times
Dear Forum,
With the aim of restrict the system to attend the flow requirement during all the time steps (streamflow always same or bigger than flow requirement), I want to make an external programmation/script in C language. Therefore, I would like to know if the correct way is to make a call in the expression builder option. How do I pass the input variables form the model to the script? These variables are the stream flows, the time steps and the flow requirements. I also would like to know, how to return the results from the external script to the model. The variables to return are the reservoir volumes and the demand priorities. Could somebody send me an example of a C script that was insert in the WEAP model?

Mr. Jack Sieber

Subject: Re: WEAPs' optimization principle   
Posted: 1/12/2016 Viewed: 21067 times
You can use the WEAP function "Call" to call a script (Visual Basic Script, Javascript, Python, Perl, Ruby) or a compiled DLL and get a result value. If you want to call a C program, you will need to compile it into a DLL. See the help for Call for more information, including an example of a C program and details on how to call the program and get the result value: http://www.weap21.org/WebHelp/Call.htm


Subject: Re: WEAPs' optimization principle   
Posted: 1/12/2016 Viewed: 21063 times
Thanks Jack,

I still don't understand how to include WEAP's variables and functions into my script. for example if I need the Flow requirement how do I name it in the script?
It seams that all the examples work with aleatory parameters and I want to use results of WEAP's simulation.

Subject: Re: WEAPs' optimization principle   
Posted: 1/13/2016 Viewed: 21022 times
I am trying to insert the example of WEAP's user guide for a DLL file in c language into the model. I inserted exactly the same code (ex. Call( C:\Users\GRH\Desktop\test.dll ! Sum, 1, 2, 3, 4, 5) ;) but the model can't recognize the parameters. Some idea why it is not working. Or maybe somebody have another example that works, so that I can compare them.

Mr. Jack Sieber

Subject: Re: WEAPs' optimization principle   
Posted: 1/13/2016 Viewed: 21018 times
What error message do you get? Perhaps there was a problem when you built the DLL? Did you export the Sum function?

Perhaps your computer is not allowing you to call a dll that is located on the desktop? You could try putting it into the WEAP program directory (C:\Program Files (x86)\WEAP) and calling it from there:

Call( C:\Program Files (x86)\WEAP\test.dll ! Sum, 1, 2, 3, 4, 5)


Subject: Re: WEAPs' optimization principle   
Posted: 1/21/2016 Viewed: 20911 times
Dear forum,

I couldn't call the .dll file so I started programing in vbscript.
I am trying to increase the reservoir priority in the time step before the minimum requirement can't be attended.

The algorithm is the following

Function calculeVazao( Vd, Vm)
If Vd >= Vm Then
calculeVazao = 3
If Vd < Vm Then
calculeVazao = 2
End If
End If
End Function

with this call:

Priority =
Call(calculeVazao, PrevTSValue(Supply and Resources\River\RIO SAO FRANCISCO\Reaches\Below vazao defl SOB:Streamflow[m^3]), PrevTSValue(Supply and Resources\River\RIO SAO FRANCISCO\Flow Requirements\vazao defl SOB:Instream Flow Requirement[m^3]))

Obviously the model changes the reservoire priority the time step after the not attendance of the minimum requirement.
I also tried with the prevTSCalcTS but the model doesn't permit to inser results with this operation.

Some body knows how to use results from the "future" to change the priorities in the past?

Mr. Jack Sieber

Subject: Re: WEAPs' optimization principle   
Posted: 1/21/2016 Viewed: 20906 times

It is not possible to reference the current or future value of streamflow in an expression for reservoir priority, because this could be circular -- each dependent on the other.

By the way, you could replace your vbscript with an If WEAP expression, e.g., If(Vd >= Vm, 3, 2). In this case, it would be

If(PrevTSValue(Supply and Resources\River\RIO SAO FRANCISCO\Reaches\Below vazao defl SOB:Streamflow[m^3]) >= PrevTSValue(Supply and Resources\River\RIO SAO FRANCISCO\Flow Requirements\vazao defl SOB:Instream Flow Requirement[m^3], 3, 2)


Subject: Re: WEAPs' optimization principle   
Posted: 1/21/2016 Viewed: 20903 times
So, there is no way to attend the minimum requirement 100%?

I allready used the If WEAP expression.

Topic "WEAPs' optimization principle"