Package hec.rss.model

Class ReservoirOp

All Implemented Interfaces:
hec.event.AbstractDataListener, hec.event.DataChangeListener, hec.event.LockListener, AsciiSerializable, FieldAccessor, DataObject, DataStruct, ElementOp, RssReturnStatusConstants, Serializable, Cloneable, Comparable, EventListener, Observer, rma.lang.Modifiable

public class ReservoirOp extends AbstractReservoirOp implements RssReturnStatusConstants, Cloneable, ElementOp
Contains operating rules for RSS reservoirs
See Also:
  • Field Details

  • Constructor Details

    • ReservoirOp

      public ReservoirOp()
  • Method Details

    • loadControllerLimits

      public void loadControllerLimits(RunTimeStep rts)
    • testOperationStep

      public int testOperationStep(RunTimeStep rts, int iteration, int flags, OpRule excludeRule)
      logic only need for 3.x compute
    • testOperationStep

      public int testOperationStep(RunTimeStep rts, int iteration, int flags, OpRule excludeRule, double elev)
      logic only need for 3.x compute
    • commitOperation

      public void commitOperation(RunTimeStep rts)
    • initOperationStep

      public void initOperationStep(RunTimeStep rts, int iteration)
    • applyPhysicalLimits32

      public void applyPhysicalLimits32(RunTimeStep rts)
    • applyReleaseOverrides

      public void applyReleaseOverrides(RunTimeStep rts)
    • applyElevationOverrides

      public void applyElevationOverrides(RunTimeStep rts)
    • applyRuleLimits2

      public void applyRuleLimits2(RunTimeStep rts, OpRule rule, int iteration)
    • applyGCOperation

      public void applyGCOperation(RunTimeStep rts, List ruleList)
    • getControllerRuleNameByID

      public String getControllerRuleNameByID(int ruleid)
      given the combined controller-rule id that is saved to the OpController decision array, return the appropriate rule name.
      Specified by:
      getControllerRuleNameByID in interface ElementOp
      Parameters:
      ruleid -
      Returns:
    • getControllerConstraintNameByID

      public String getControllerConstraintNameByID(int cnstrntid)
      given the combined controller-constraint id that is saved to the OpController constraint array, return the appropriate constraint name.
      Specified by:
      getControllerConstraintNameByID in interface ElementOp
      Parameters:
      cnstrntid -
      Returns:
    • evaluateRuleLimits

      public void evaluateRuleLimits(RunTimeStep timestep, int k)
    • updateDecisions

      public void updateDecisions(RunTimeStep rts, int iteration)
      process decision making for the given time step
      Parameters:
      rts -
      iteration -
    • initPumpbackStep

      public int initPumpbackStep(RunTimeStep rts)
    • computePumpbackStep

      public int computePumpbackStep(RunTimeStep rts)
      after regular computations are complete for a time step, pumpback operation moves a volume of water from the source reservoir to this reservoir
      Parameters:
      rts -
      Returns:
    • deleteConditionalBlock

      public ConditionalBlock deleteConditionalBlock(ConditionalBlock cb)
    • deleteConditionalBlock

      public ConditionalBlock deleteConditionalBlock(int cbIndex)
      Parameters:
      cbIndex -
      Returns:
    • createNewConditionalBlock

      public ConditionalBlock createNewConditionalBlock(String name)
    • getConditionalBlock

      public ConditionalBlock getConditionalBlock(int index)
      Specified by:
      getConditionalBlock in interface ElementOp
      Parameters:
      index -
      Returns:
    • getConditionalBlock

      public ConditionalBlock getConditionalBlock(String name)
      Returns a Conditional Block with the specified name. If now conditional block exists then a null value is returned. Names are not case sensitive. A null value is acceptable as input, but a null value is returned.
      Parameters:
      name - the name of the conditional block to retrieve
      Returns:
      the conditional block or null if none exists.
    • getConditionalBlocks

      public List<ConditionalBlock> getConditionalBlocks()
    • getRequiredTSRecordProxies

      public Vector getRequiredTSRecordProxies(Vector v)
      returns the flow TSRecordProxies from upstream nodes on this element and any TSRecordProxies required by active operating rules
    • getGuideCurveStorage

      public double getGuideCurveStorage(RunTimeStep rts)
    • getInactiveStorage

      public double getInactiveStorage(RunTimeStep rts)
    • saveHotstartState

      public void saveHotstartState(HotstartState parent, int stateId)
    • restoreHotstartState

      public boolean restoreHotstartState(HotstartState parent)
    • saveFunctionState

      public void saveFunctionState(int stateid)
      save the current state of the rule with the given identifier - default behavior is to do nothing
      Parameters:
      stateid - identifier for the state
    • restoreFunctionState

      public void restoreFunctionState(int stateid)
      restore the state of the rule matching the given identifier - default behavior is to do nothing
      Parameters:
      stateid - identifier for the state
    • deletDownstreamRulesForParent

      public void deletDownstreamRulesForParent(int dindex, int pindex)
    • deleteSystemHydropowerRulesForParent

      public void deleteSystemHydropowerRulesForParent(int pindex)
    • deleteTandemSysOpRulesForParent

      public void deleteTandemSysOpRulesForParent(int pindex)
      delete all TandemSysOpRules related to the given parent TandemOpParent index
      Parameters:
      pindex -
    • loadSystemDownstreamRules

      public void loadSystemDownstreamRules()
      Copies the current data for all DownstreamCntrlOpRules from the master rules held by the RssSystem
    • loadSystemSystemHydropowerRules

      public void loadSystemSystemHydropowerRules()
      Copies the current data for all SystemHydropowerRules from the master rules held by the RssSystem
    • storeSystemHydropowerRules

      public void storeSystemHydropowerRules()
    • storeTandemSysOpRules

      public void storeTandemSysOpRules()
    • storeSystemDownstreamRules

      public void storeSystemDownstreamRules()
      Saves the current data for all DownstreamCntrlOpRules to the master rules held by the RssSystem, adding new rules and deleting rules no longer used.
    • getNumDecisionSteps

      public int getNumDecisionSteps()
      returns the number of decision steps in the current decision calculation should be called only during a compute
      Returns:
      number of decision steps for the current decision
    • isRuleActive

      public boolean isRuleActive(OpRule rule, RunTimeStep rts)
      returns true if the given rule is active (included in the zone rules of the current OpSet for this ReservoirOp).
      Specified by:
      isRuleActive in interface ElementOp
      Parameters:
      rule -
      rts -
      Returns:
    • getWQControlDeviceFlow

      public double getWQControlDeviceFlow(RunTimeStep rts, OpRule rule, boolean usePrevStepAsEstimate)
      Returns the current controller min op value for the outlet element that the rule is applied to. If usePrevStepAsEstimate is true, then the op value is estimated from the previous time step. This is called from scripted rules for operating a water quality control device. The rule must be applied to a release element that has a water quality control device.
      Parameters:
      rts - the run time step
      rule - the op rule (scripted rule for WQ operation)
      usePrevStepAsEstimate - whether to use the previous time step as an estimate
      Returns:
      the rule's controller min op value
    • setWQControlDeviceFlowRatios

      public boolean setWQControlDeviceFlowRatios(double[] wqcdFlows, OpRule rule, double wqcdTotalFlow)
      Sets the flow ratios through the outlets of the water quality control device. The length of the array wqcdFlows must be equal to the number of outlets of the water quality control device. The flow ratios are used because the actual flow through the outlet may not be known at the time this method is called in the scripted rule. This is called from scripted rules for operating a water quality control device. The rule must be applied to a release element that has a water quality control device.
      Parameters:
      wqcdFlows - array of flows through individual outlets of the water quality control device
      rule - the op rule (scripted rule for WQ operation)
      wqcdTotalFlow - total sum of flow through the water quality control device
      Returns:
      true if flows successfully set
    • clone

      public Object clone()
      Creates a new object of the same class as this object.
      It then initializes each of the new object's fields by assigning it the same value as the corresponding field in this object. No
      constructor is called.
      Overrides:
      clone in class AbstractReservoirOp
    • clearTSProxyList

      public void clearTSProxyList()
      dumps all ts proxies
    • updateTSProxyList

      public void updateTSProxyList()
      Have top level controller update the TSRecordProxy set for itself and all child controllers and rules
    • getActiveTSRecordProxies

      public void getActiveTSRecordProxies(Vector vec, int iotype)
      add the time series record proxies associated with the active operation set to the given vector
    • addDuplicateOpSet

      public OpSet addDuplicateOpSet(int oid, String name)
      Duplicates an operation set identified by the id and gives it the name identified by name.
    • printErrorMessage

      public void printErrorMessage(String str)
      forward printErrorMessage to parent RssSystem if available
      Specified by:
      printErrorMessage in interface ElementOp
    • printMessage

      public void printMessage(String str)
      forward printMessage to parent RssSystem if available
      Specified by:
      printMessage in interface ElementOp
    • computeHindcastStep

      public int computeHindcastStep(RunTimeStep rts)
    • testOperationStepOld

      public int testOperationStepOld(RunTimeStep rts, int iteration, int flags, OpRule excludeRule)
      perform operation decision making without committing to the result. Used get operation limits without selected rules
    • testOperationStepOld

      public int testOperationStepOld(RunTimeStep rts, int iteration, int flags, OpRule excludeRule, double elev)
      perform operation decision making without committing to the result. Used get operation limits without selected rules
    • determinePhysicalLimits

      public void determinePhysicalLimits(OpController controller, RunTimeStep rts)
      Specified by:
      determinePhysicalLimits in interface ElementOp
      Parameters:
      controller -
      rts -
    • initializeCompute

      public boolean initializeCompute(RunTimeWindow rtw)
      prepare for computations - to be called after setting the active operations set
    • initForPostProcessing

      public boolean initForPostProcessing(RunTimeWindow rtw)
      Prepares this run for post processing in the ResSim Simulation Module. This routing sets up all data model connectivity, but does not load time series arrays.
      Returns:
      RTN_NOPROBLEM if successful
    • setActiveOpSet

      public void setActiveOpSet(int id)
      sets the active operations set for the current compute
    • getActiveOpSet

      public OpSet getActiveOpSet()
      returns the active operations set for the current compute
      Specified by:
      getActiveOpSet in interface ElementOp
      Returns:
    • getActiveRules

      public List getActiveRules(RunTimeStep rts, List list)
    • getActiveRules

      public List getActiveRules(RunTimeStep rts, double elev, List list)
      returns the list of rules active for the given time step and elevation
      Parameters:
      rts -
      elev -
      list - List to store rules in, may be null
      Returns:
      the list of active rules
    • getActiveRules

      public List getActiveRules(RunTimeStep rts, double elev, StorageZone szForZBOp, List list)
      Gets active rules for the reservoir given a time step and elevation If szForZBOp != null, the reservoir will operate to a zone boundary by inserting a rule at the top of the stack
      Parameters:
      rts -
      elev -
      szForZBOp -
      list -
      Returns:
    • setReservoirElement

      public void setReservoirElement(ReservoirElement res)
      sets the parent reservoir element
    • deleteControllerReferences

      public void deleteControllerReferences(int ctrlId)
      loops over OpSets, removing all references to a deleted controller
      Specified by:
      deleteControllerReferences in interface ElementOp
      Parameters:
      ctrlId -
    • deleteOpRule

      public void deleteOpRule(OpRule rule)
      Specified by:
      deleteOpRule in interface ElementOp
      Parameters:
      rule -
    • getReservoirElement

      public ReservoirElement getReservoirElement()
      returns the parent reservoir element
    • getDownstreamRuleNodes

      public void getDownstreamRuleNodes(int opid, Hashtable nodetable)
      adds all downstream nodes used as downstream control points to the given hashtable
    • getStorageZones

      public void getStorageZones(int opid, List<StorageZone> zoneList)
      adds all storage zones from the given opid to the given list
    • getRules

      public Vector getRules()
      Returns a vector all rules in this ReservoirOp controllers
      Specified by:
      getRules in interface ElementOp
      Returns:
    • getRules

      public void getRules(int opid, List<OpRule> ruleVec)
      adds all rules to the given vector
    • getDownstreamRules

      public void getDownstreamRules(int opid, List ruleVec)
      adds all downstream rules to the given vector
    • getSystemHydropowerOpRules

      public void getSystemHydropowerOpRules(int opid, ArrayList ruleList)
      adds all SystemHydropowerOpRules rules to the given ArrayList
    • hasDownstreamGoals

      public boolean hasDownstreamGoals(int opid)
      returns true if any rules referenced in the given opset have downstream operating goals
    • doesOpSetExist

      public boolean doesOpSetExist(String opSetName)
      Tests to see if a given operation set exists. Returns true if it does, otherwise false.
      Parameters:
      opSetName - - name of the operation set to search for
    • addNewOpSet

      public OpSet addNewOpSet(String name)
      instatiates a new OpSet with the given name and adds it to the table.
    • removeOpSet

      public void removeOpSet(int id)
    • removeOpSet

      public void removeOpSet(OpSet opset)
    • loadData

      public boolean loadData()
      Description copied from class: AbstractDataObject
      this method should be called from the concrete class's loadData method to ensure that the object references get loaded correctly.
      Specified by:
      loadData in interface DataObject
      Overrides:
      loadData in class AbstractDataObject
    • copyInto

      public void copyInto(ReservoirOp rop)
      Performs a deep copy that clones data of the given reservoirOp. This method is used by the reservoir editor.
    • getController

      public OpController getController()
      Returns the primary controller for the reservoir
      Specified by:
      getController in interface ElementOp
      Returns:
    • getControllers

      public Vector<OpController> getControllers()
      Returns a vector of controllers
      Specified by:
      getControllers in interface ElementOp
    • getController

      public OpController getController(int id)
      Returns a controller by index
      Specified by:
      getController in interface ElementOp
      Parameters:
      id -
      Returns:
    • getController

      public OpController getController(Element relElem)
      Returns a controller by release element
      Specified by:
      getController in interface ElementOp
      Parameters:
      relElem -
      Returns:
    • getControllerForElement

      public OpController getControllerForElement(Element elem)
      returns the OpController associated with the given element, or null
      Parameters:
      elem -
      Returns:
      OpController associated with the given element, or null
    • getControllerNames

      public String[] getControllerNames()
      Returns a list of controller names
    • getOperationSets

      public Vector<OpSet> getOperationSets()
      Returns a Vector of reservoir operation sets
      Specified by:
      getOperationSets in interface ElementOp
      Returns:
    • getOpSetTable

      public Hashtable<intContainer,OpSet> getOpSetTable()
      Specified by:
      getOpSetTable in interface ElementOp
      Returns:
    • getOperationSetNames

      public String[] getOperationSetNames()
      Returns a list of reservoir operation set names
    • getOperationSet

      public OpSet getOperationSet(String name)
      Returns an operation set by name
      Specified by:
      getOperationSet in interface ElementOp
      Parameters:
      name -
      Returns:
    • getOperationSet

      public OpSet getOperationSet(int id)
      Returns an operation set by ID
      Specified by:
      getOperationSet in interface ElementOp
      Parameters:
      id -
      Returns:
    • newController

      public OpController newController()
      make all new controllers for from here to manage indexing
      Specified by:
      newController in interface ElementOp
      Returns:
    • resetId

      public void resetId()
      reset this Objects id to undefined so that when a ReservoirOp is cloned and saved to the DataList, it won't overwrite the original object
    • useRecursiveModifiedTest

      public boolean useRecursiveModifiedTest()
      Indicates whether object uses recursive modified testing. Should be overrided by subclasses that use recursive testing to return true
      Overrides:
      useRecursiveModifiedTest in class NamedType
    • getGmtOffset

      public int getGmtOffset()
      Specified by:
      getGmtOffset in interface ElementOp
      Overrides:
      getGmtOffset in class AbstractDataObject
    • getUnitSystem

      public int getUnitSystem()
      Specified by:
      getUnitSystem in interface ElementOp
      Overrides:
      getUnitSystem in class AbstractDataObject
      Returns:
    • getFieldObject

      public Object getFieldObject(Field fld)
      Description copied from interface: FieldAccessor
      This method allows access to java.lang.reflect.Field objects within the implementing class.
      Specified by:
      getFieldObject in interface FieldAccessor
      Overrides:
      getFieldObject in class AbstractDataObject
      Parameters:
      fld - The field to get.
      Returns:
      The data object that is stored in the given field
    • setFieldObject

      public boolean setFieldObject(Field fld, Object fobj)
      Description copied from interface: FieldAccessor
      This allows access to fields withing the implementing object to set there data.
      Specified by:
      setFieldObject in interface FieldAccessor
      Overrides:
      setFieldObject in class AbstractDataObject
      Parameters:
      fld - The java field object representing the member field to be set
      fobj - The data to set in that field
      Returns:
      returns true if successful
    • getOperationsElement

      public OperationsElement getOperationsElement()
      Specified by:
      getOperationsElement in interface ElementOp
      Returns: