RiverWare SCT support for TVA Preschedule Editor Functionality
New Expression Slots and Expression Slot Update Trigger
Tim Magee, Phil Weinstein, Patrick Lynn, CADSWES, 7-01-2014 (b)
The preschedule SCT will rely on some underlying enhancements in RiverWare’s underlying functionality. Several pieces of data in the existing Excel prescheduler are recalculated as a result of manual schedule changes. These include the total system hydropower generation and the marginal cost of new generation. Currently, RiverWare calculates these values at the end of simulation using the Avoided Cost thermal object. The need for these values to dynamically update in an SCT implementation of the preschedule will require changes in RiverWare. First, these calculations must be reimplemented as expression slots. Second, changes in the SCT will have to trigger reevaluation of these expression slots to update their values. There are two potential options: to automatically update the expressions as the SCT changes or a manual selection to update. If the calculations are too slow users may prefer to use a manual update. One compromise solution would be to update only for certain changes, for example when a user changes to a different reservoir. While this task is motivated by the preschedule SCT, large parts of it are independent from the SCT changes. This task could be completed before, after, or during the SCT changes.
We propose supporting automatic recomputations of expression series slots shown within the SCT at the timesteps where user edits are made to other series slots within that SCT. The recomputation would occur as the user presses the "Enter" key when editing a single cell or multiple cells, and also as a result of operating value transformation functions within the SCT (e.g. interpolation between selected ranges of values). We're concerned mostly with the run-time performance in the course of entering data in a sequence of cells, but it seems unlikely that there would be a problem since such edits involve just a single timestep for each cell edit.
RiverWare's RPL Expression Slot Manager supports an iterative algorithm on a set of expression series slots -- optionally at a single timestep -- to insure that dependencies between those slots are handled correctly. (This algorithm assumes that such dependencies are not cyclical). Some careful code refactoring will be required to support use of that mechanism for a set of expression slots at an externally specified timestep.
The SCT has a pure model/view implementation with regard to display of, and changes to series slot values: value edits are applied directly to the actual series slots, and change notifications from those series slots to the SCT cause updates to the SCT display. For the most part, SCT display update processing makes no distinction between value changes initiated from the SCT and changes initiated elsewhere within RiverWare.
There are two "opportunities" to initiate the additional processing associated with series value changes made by the user within an SCT:
The second option depends on the fact value change notifications are not de-coupled from the initiation of the value changed operations. That is, while performing a value-change operation, the SCT can set a flag indicating that such an operation is in progress -- and that flag is guaranteed to be set when the resulting change notifications are received. While this is a possible point from which to initiate expression slot recomputations, I recommend instead choosing the former option -- at the point of the initiation of value-setting operations. This is because the SCT's processing of value-changed notifications has a good amount of complexity in order to reduce the overall amount of processing. At certain times (e.g. during a model run), multiple value-changed notifications are efficiently condensed into a single update operation. This is sometimes done without taking time to examine the value-changed notification's timestep value, as a full SCT display refresh will ultimately be done later on.
With one minor exception*, all relevant value-setting operations operate on the current slot/timestep cell selection. Note that some display cells correspond to a set of contiguous timesteps on a single slot. It is latter type of "cells" which are significant here. (This cell selection is represented with the SctSlotTstepSet class which has efficient representations of "all timesteps" of a slot, and also "all slots" at a given timestep). At the point of initiation of value-change operations, the current slot/timestep cell selection can be examined to determine at which timesteps the expression series slots in the SCT need to be recomputed. If that cell selection contains an "all timesteps" indication (for any particular series slot, excluding expression series slots), then the SCT will initiate a full recomputation of the relevant expression slots (across all timesteps) instead of using the new algorithm to recompute expression slots only at specific timesteps.
Recomputation of the SCT's expression series slots will be initiated from the following methods:
*The SctView::clipboardImportDlg_Paste() method can optionally set values at timesteps beyond the current cell selection.
As these are high level "hooks" for user-initiated operations, it will not be necessary to defer the actual expression series slot recomputation (i.e. using a QTimer, to condense multiple "trigger" events into a single recomputation event). This recomputation will be implemented with the following new method:
This automatic expression series slot recomputation will occur only if this new general configuration option in the SCT is checked:
[x] Auto update expression slots on edit.
As mentioned above, RPL Expression Slot Manager initiates the recomputation of expression slots in the model. This is currently done using this method:
where EvalTime is one of the following values:
The "now" EvalTime is reconciled with each expression slot's EvalTime to determine if the slot should be evaluated. If "now" is ON_DEMAND, then the evaluation occurs regardless of the slot's EvalTime (with the exception of slots having the NEVER EvalTime). The RplExprSlotMgr::evaluateSlots() method iteratively reevaluates all expression slots needing to be evaluated (depending on the "now" parameter value) until all mutual dependencies have been satisfied.
Without significantly impacting on the run-time performance of this method -- and with care to insure that its behavior in its current uses are not changed -- we need a way of providing the set of expression slots to be evaluated.
The RplExprSlotMgr::evaluateSlots() method calls this SeriesSlot method to evaluate an expression series slot:
This method recomputes values at timesteps based on the following criteria. If active within a "timestep controller" run, evaluation occurs only at the run controller's current timestep. Otherwise, evaluation occurs at the expression slot's full configured time range.
Again, without significantly impacting on the run-time performance of this method -- and with care to insure that its behavior in its current uses are not changed -- we need ways of specifying the following:
*It would be unusual (and likely, problematic) for the user to apply edits to series data in an SCT during a run, but that is not actually prevented.
Task | Est. (hours) |
Description |
1 | 4.0 | SCT: Add configuration option: [x] Auto update expression slots on edit. (a) Sct configuration data model and flex/bison persistence, (b) Checkbox in the "General" SCT Configuration tab. |
2 | 4.0 | SCT: Implement recomputeRplExpressionSeriesSlots() method to evaluate the SCT's expression series slots at the appropriate timesteps. |
3 | 4.0 | SCT: Call that method from the six identified high-level value edit methods. In one special case, this involves constructing a SctSlotTstepSet instance to represent the time range of the modified series slot timesteps. |
4 | 8.0 | RplExprSlotMgr::evaluateSlots() modifications: devise an efficient way of optionally specifying: (a) a set of expression slots to be evaluated, and (b) a timestep range at which those slots should be evaluated. |
5 | 6.0 | SeriesSlot::evaluateExpr() modifications: devise an efficient way of optionally specifying a range at which the slot should be evaluated. |
26.0 | Total Estimate [hours] |
--- (end) ---