RPL
This section describes changes to the RiverWare Policy Language (RPL).
RPL Editor: Highlight Equivalent Expressions
A new setting was added to the RPL Display Settings dialog to “Highlight Elements Equivalent to the Selection”. This features highlights elements in the same dialog which are equivalent to the selected expression. For example, in the screenshot in
Figure 10.5, Muddy.Outflow is selected on the first line, element 1, but the other instances are also highlighted in a paler color on subsequent rows, element rows 5 and 12.
Figure 10.5 Sample RPL Logic showing equivalent expressions highlighted
RPL Palette
The RPL Palette was improved with the following changes.
Clipboard Tab
A new Clipboard tab was added to the RPL Palette which maintains a list of the last 100 expressions copied. When you copy a RPL expression from anywhere but the clipboard itself, a copy of that expression is added to the clipboard. The clipboard updates to display that expression and you can use the Previous and Next operations to view the entire copy history. Further, you can select and copy an expression or subexpression in this history and paste it into other RPL expressions.
Thus, the clipboard tab can be used as a temporary location to hold copied expressions which you can then paste over other expressions. This is particularly useful in editing RPL expressions for readability or performance.
New Obj ^ Account . Slot Button
A new operator/button was added to the palette. The Obj^Account.Slot button,
evaluates to an account slot given an object, an account name, and a slot name. This is more efficient than the previous approach using the newly named Obj^Account&Slot button (previously named Obj^Slot). We recommend refactoring logic to use this new button whenever possible.
Figure 10.6 Screenshot of new and modified buttons in the Object/Slots area of the palette
New Account Selector Button
A new
Account Selector button was added to the palette as shown in
Figure 10.6. This button allows you to select an account from an object to replace a STRING expression. Use this
Account Selector with the new Obj^Account.Slot button described above.
Parenthesis and Comments
Usability has been improved when adding comments to an expression with parentheses or adding a parenthesis to an expression with comments.
RPL Precision
The default RPL Precision was changed from 8 digits to 2 digits. This better aligns with the default precision in unit schemes. As before, the precision can be adjusted on the RPL Set’s Adv. Properties settings. Existing sets will not be modified. This only affects the display precision. As before, full precision is always used in all computations.
Predefined Functions
This section describes new and modified predefined RPL functions.
AggregateSeriesSlot
A new RPL predefined function AggregateSeriesSlot was added. The input arguments are a slot to aggregate, the begin and end timestep, the timestep to aggregate to, and how to treat NaN values. It returns a list of datetimes (the larger timestep) and the values at those timesteps. An initialization rule can then loop over the list and set the values on the slot.
IsControllerSim
A new RPL predefined function, IsControllerSim, returns TRUE if the current controller is Simulation or Inline Simulation and Accounting.
IsControllerOpt
A new RPL predefined function, IsControllerOpt, returns TRUE if the current controller is Optimization.See
IsControllerOpt in RiverWare Policy Language (RPL) for more information.
SortPairsAscending & SortPairsDescending enhancement
The RPL predefined functions SortPairsAscending and SortPairsDescending were modified to return stable and predictable results in the case where the second item in each pair of lists is the same. Prior to the current work, the return order of values from pairs with the same second value was unspecified and unpredictable; now that order is specified and deterministic. Specifically, for pairs whose second item is the same, SortPairsAscending now returns the first items in their original order and SortPairsDescending returns the first items in the reverse of their original order. Previously, the result tended to be in these orders when the comparisons were equal. Now, the order is guaranteed. This could change model results depending on the RPL logic.
:
Example 10.1 SortPairs behavior
Given a list = {{1, "c"}, {2, "a"}, {3, "c"}, {4, "a"}}
• SortPairsAscending(list) returns {2, 4, 1, 3}
• SortPairsDescending(list) returns {3, 1, 4, 2}