Package hec.rss.model

Class OpController

All Implemented Interfaces:
AsciiSerializable, FieldAccessor, TSLocation, OpControllable, RssModelVariableConstants, RssReturnStatusConstants, RssTSLocation, Serializable, Cloneable, Comparable, Observer, rma.lang.Modifiable

public class OpController extends RssTSLocationObject implements OpControllable
Manages operation decision making for controllable objects. Has time series of release quantity and active rule. Also has time series of active minimum and maximum rules at the release and downstream locations
See Also:
  • Field Details

  • Constructor Details

    • OpController

      public OpController()
    • OpController

      public OpController(String name)
    • OpController

      public OpController(String name, int id)
  • Method Details

    • applyPhysicalLimits32

      public void applyPhysicalLimits32(RunTimeStep rts, boolean evalSelf)
    • loadControllerLimits

      public void loadControllerLimits(RunTimeStep rts)
    • getIncrROCLimit

      public double getIncrROCLimit(RunTimeStep rts, double[] relcap, double[] dt, double elev, List rulelist)
      Returns the approximate overall increasing rate of change constraint for this reservoir. The constraint is the total release capacity (relcap) divided by the time required to decrease from max release to zero (dt). If there is no IROC constraint the dt returned is RmaConst.UNDEFINED_DOUBLE
      Specified by:
      getIncrROCLimit in interface OpControllable
    • getDecrROCLimit

      public double getDecrROCLimit(RunTimeStep rts, double[] relcap, double[] dt, double elev, List rulelist)
      Returns the approximate overall decreasing rate of change constraint for this reservoir. The constraint is the total release capacity (relcap) divided by the time required to decrease from max release to zero (dt). If there is no DROC constraint the dt returned is RmaConst.UNDEFINED_DOUBLE
      Specified by:
      getDecrROCLimit in interface OpControllable
    • getFlowForPrevGateHeight

      public double getFlowForPrevGateHeight(RunTimeStep rts, double resElev)
      returns the estimated flow if the gate openings from the previous time step are maintained
      Specified by:
      getFlowForPrevGateHeight in interface OpControllable
    • getInstFlowCap

      public double getInstFlowCap(RunTimeStep rts, double elev, double[] cntrl, double[] unctrl)
      Description copied from interface: OpControllable
      return the instantaneous flow capacity at the given time step and elevation
      Specified by:
      getInstFlowCap in interface OpControllable
    • getCurLimitPowerFlow

      public double getCurLimitPowerFlow(RunTimeStep rts, int type)
      returns the maximum flow limit from the curMaxOpValue for each outlet that has a power plant.
      Returns:
      flow in cfs or cms
    • getWaterAccount

      public WaterAccount getWaterAccount(OpRule rule)
    • applyRuleLimits2

      public boolean applyRuleLimits2(RunTimeStep rts, OpRule rule, int iteration)
      Evaluates the given rule and incorporates its limits into the current min/max values
      Parameters:
      rule - OpRule to be considered
      Returns:
      true if method changed the limits V3.0
    • getMinReleaseVol

      public double getMinReleaseVol(RunTimeStep rts)
      return the minum volume this controller will release for the given interval. Note that for instantaneous calcs, the volume is calculated based on the actual release at the previous time step and the limit value at the current time step.
      Parameters:
      rts -
      Returns:
    • getMaxReleaseVol

      public double getMaxReleaseVol(RunTimeStep rts)
      return the maximum volume this controller will release for the given interval. Note that for instantaneous calcs, the volume is calculated based on the actual release at the previous time step and the limit value at the current time step.
      Parameters:
      rts -
      Returns:
    • isUncontrolled

      public boolean isUncontrolled()
      Returns true if this OpController is associated with an uncontrolled release element
    • hasPowerPlants

      public boolean hasPowerPlants()
    • getElementPowerPlant

      public PowerPlant getElementPowerPlant()
      Returns the power plant associated with the release element of this controller, otherwise returns null.
      Returns:
      PowerPlant or null if not exists on the element associated with this controller
    • getPowerPlantList

      public List<PowerPlant> getPowerPlantList(boolean refreshList)
      Get the list of all power plants at this controller or from all child controllers This method also saves the list in the class data member _powerPlantList
      Parameters:
      refreshList - is a boolean flag that tiggers recreation of the powerPlantList.
      Returns:
      List of PowerPlant objects
    • getRuleConnectivityRefs

      public List getRuleConnectivityRefs(boolean recurse)
      Returns a List of RuleConnectivityRef objects identifying all rule references to other objects in the network.
      Parameters:
      recurse - true means to recurse through child OpControllers
      Returns:
      ArrayList RuleConnectivityRef objects
    • 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
    • saveHotstartState

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

      public boolean restoreHotstartState(HotstartState hotstartStateParent)
    • getDownstreamRuleForParent

      public DownstreamCntrlOpRule getDownstreamRuleForParent(int dindex, int pindex)
    • getSystemHydropowerRuleForParent

      public SystemHydropowerOpRule getSystemHydropowerRuleForParent(int pindex)
    • getTandemSysOpRuleForParent

      public TandemSysOpRule getTandemSysOpRuleForParent(int pindex)
      return the TandemSysOpRule for the given Parent index
      Parameters:
      pindex -
      Returns:
      null if not found
    • setZone

      public void setZone(RunTimeStep rts, StorageZone zone)
    • initOperationStep

      public int initOperationStep(RunTimeStep rts, int iteration)
      initialization call before each operation step, or before recomputing operations with different options
      Specified by:
      initOperationStep in interface OpControllable
    • getCurrentOpValue

      public OpValue getCurrentOpValue(RunTimeStep rts)
      returns the current release value with rule type and priority
      Parameters:
      rts - requested time step
      Returns:
      the current operation value object
    • setCurrentOpValue

      public void setCurrentOpValue(double val, RunTimeStep rts)
    • setCurrentOpValue

      public void setCurrentOpValue(double val, int constraintId, RunTimeStep rts)
    • setCurrentOpValue

      public void setCurrentOpValue(double val, int ruleId, int constraintId, RunTimeStep rts)
    • setCurMaxOpValue

      public void setCurMaxOpValue(double val, int ruleId, int constraintId, RunTimeStep rts)
    • setCurMinOpValue

      public void setCurMinOpValue(double val, int ruleId, int constraintId, RunTimeStep rts)
    • getCurMinOpValue

      public OpValue getCurMinOpValue(RunTimeStep rts)
    • getCurMaxOpValue

      public OpValue getCurMaxOpValue(RunTimeStep rts)
    • getCurOpValue

      public OpValue getCurOpValue(RunTimeStep rts)
    • getDecisionValue

      public double getDecisionValue(RunTimeStep rts)
    • getEstimatedCurLimit

      public double getEstimatedCurLimit(int ruleType, RunTimeStep rts)
      return the best estimate of the release limit for the controlled element based on this controllers curMXXOpValue and the expected distribution of release from the parent controller. The result is based on the last rule set evaluated, whether committed to the physical elements or not.
      Parameters:
      ruleType - OpRule.RULETYPE_MIN or OpRule.RULETYPE_MAX
      Returns:
      estimated flow limit
    • getEstimatedCurLimitForChild

      public double getEstimatedCurLimitForChild(OpController child, int ruleType, RunTimeStep rts)
      get the estimated
      Parameters:
      child -
      Returns:
    • getCurLimitOpValue

      public double getCurLimitOpValue(int type, RunTimeStep rts)
    • recalcPhysicalLimitsInst

      public void recalcPhysicalLimitsInst(RunTimeStep rts, double elev)
      re-evaluate physical flow limits for instantaneous simulation then apply them
      Specified by:
      recalcPhysicalLimitsInst in interface OpControllable
      Parameters:
      rts - RunTimeStep
      elev - elevation at end of time step
    • recalcPhysicalLimits

      public void recalcPhysicalLimits(RunTimeStep rts, double[] xt, double[] et, int tcnt)
      re-evaluate physical flow limits then apply them
      Specified by:
      recalcPhysicalLimits in interface OpControllable
      Parameters:
      rts - RunTimeStep
    • distributePhysicalLimits

      public void distributePhysicalLimits(RunTimeStep rts)
      apply determine current physical limits
      Parameters:
      rts -
    • applyPhysicalLimits

      public void applyPhysicalLimits(RunTimeStep rts, boolean evalSelf)
      Determines and distributes physical min and max limits to all outlets. Max releases are determined at each controller level in the reservoir allowing only controlled releases at or below the current controller level to operation. Other controlled releases are assumed to be zero. All uncontrolled releases from any controller group in the reservoir are considered. Requires an iterative solution for change in elevation with release (in ReservoirOp class) so logic is added to minimize the number of evaluations.
      Parameters:
      rts -
      evalSelf - a flag that determines whether this controller evaluates its own limits.
    • getNumControlledOutlets

      public int getNumControlledOutlets()
      determines the number of controlled outlets at or below this controller level
      Returns:
      number of controlled outlets
    • applyReleaseOverrides

      public boolean applyReleaseOverrides(RunTimeStep rts)
      apply release over-rides
      Parameters:
      rts -
    • applyElevationOverrides

      public int applyElevationOverrides(RunTimeStep rts, Hashtable overrideTable)
      apply elevation over-rides
    • applyZoneOperation

      public double applyZoneOperation(RunTimeStep rts, StorageZone zone)
      apply zone operation to release to a specified zone boundary
    • commitOperation

      public int commitOperation(RunTimeStep rts, int numsteps)
      commit the operating decision for the given step to adjustable parameters
    • applyHindcastData

      public void applyHindcastData(HindcastData hd)
      applies specific hindcast data for compute
    • 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.
      Specified by:
      clone in interface OpControllable
      Overrides:
      clone in class RssTSLocationObject
    • getGmtOffset

      public int getGmtOffset()
    • getUnitSystem

      public int getUnitSystem()
    • setController

      public void setController(OpController controller)
      sets the parent controller
      Specified by:
      setController in interface OpControllable
    • resetChildOwnership

      public void resetChildOwnership()
    • getSystem

      public RssSystem getSystem()
      Description copied from class: RssTSLocationObject
      Each subclass must provide a method to return its parent RssSystem
      Specified by:
      getSystem in class RssTSLocationObject
    • getDisplayName

      public String getDisplayName()
      returns the the elements name appended to its parents full name
      Overrides:
      getDisplayName in class NamedType
    • getKeyStringForObject

      public String getKeyStringForObject(Object obj)
      Takes a object of class Element, Function, RssNode, OpController, or OpRule and returns a unique string identifying that object pass request to RssSystem This should be a TSLocation method
    • getObjectForKeyString

      public Object getObjectForKeyString(String keystr)
      Takes a key string and returns the object of class Element, Function, Node, OpController, or OpRule Pass request to RssSystem This should be a TSLocation method
    • clearTSProxyList

      public void clearTSProxyList()
      dumps all ts proxies
      Overrides:
      clearTSProxyList in class RssTSLocationObject
    • updateTSProxyList

      public void updateTSProxyList()
      Have top level controller update the TSRecordProxy set for itself and all child controllers and rules
      Specified by:
      updateTSProxyList in class RssTSLocationObject
    • getActiveTSRecordProxies

      public Vector getActiveTSRecordProxies(Vector vec, int iotype)
      add the time series record proxies associated with the active operation set to the given vector
      Overrides:
      getActiveTSRecordProxies in class RssTSLocationObject
    • getReleaseArray

      public double[] getReleaseArray()
      return the time series array containing total release data this must be called only after initializing compute
    • getReleaseTSContainer

      public doubleArrayContainer getReleaseTSContainer()
      return the time series array containing total release data this must be called only after initializing compute
    • getCurrentParameterValue

      public double getCurrentParameterValue()
      gets the total current adjustable parameter value
      Specified by:
      getCurrentParameterValue in interface OpControllable
    • getPreviousParameterValue

      public double getPreviousParameterValue(RunTimeStep rts)
      gets the total current adjustable parameter value
      Specified by:
      getPreviousParameterValue in interface OpControllable
    • computeZoneOperationStep

      public int computeZoneOperationStep(RunTimeStep rts, StorageZone zone, double release)
      Evaluates release based on getting to the given zone, only called for top most reservoir controller
    • computeGCOperationStep

      public int computeGCOperationStep(RunTimeStep rts, List rulelist)
      Evaluates release based on guide curve, only called for top most reservoir controller
    • setElementOp

      public void setElementOp(ElementOp resop)
      sets the parent reservoir/diversion Op
    • getReleaseElementId

      public int getReleaseElementId()
      index of release element this contrable is associated with
      Specified by:
      getReleaseElementId in interface OpControllable
    • setReleaseElementId

      public void setReleaseElementId(int elementId)
      index of release element this contrable is associated with
      Specified by:
      setReleaseElementId in interface OpControllable
    • getReleaseElement

      public Element getReleaseElement()
      returns the release element associated with this controller
    • setReleaseElement

      public void setReleaseElement(Element e)
      sets the associated release element and release element id
      Specified by:
      setReleaseElement in interface OpControllable
    • updateControllerTree

      public void updateControllerTree(Element elem)
      The method recursively updates the tree of OpControllable objects so that it is in sync with the current version of the reservoir
    • getElementOp

      public ElementOp getElementOp()
      returns the reservoir/diversion op that owns this controller
    • getReservoirOp

      public ReservoirOp getReservoirOp()
    • initializeCompute

      public boolean initializeCompute(RunTimeWindow rtw)
      prepares for computation for this and all child controllers
      Specified by:
      initializeCompute in interface OpControllable
    • 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.
      Specified by:
      initForPostProcessing in interface OpControllable
      Returns:
      RTN_NOPROBLEM if successful
    • getAdjustableParameter

      public AdjustableParameter getAdjustableParameter()
      returns the composite adjustable parameter associated with the controller, must be called after initializing the compute
      Specified by:
      getAdjustableParameter in interface OpControllable
    • setActiveOperations

      public void setActiveOperations(OpSet opset)
      sets the active rule set for the given OpSet for this and all child controllers
    • addControllable

      public void addControllable(Element elem)
      add the given element to the controllable vector (if it is not already in the vector)
    • newRule

      public OpRule newRule(String type, String name, int dnstrmNodeIndex)
      return a new OpRule with given name
    • getRule

      public OpRule getRule(int id)
      return the OpRule matching index, or null if it does not exist
    • getRules

      public Vector getRules(Vector rvec)
      returns a vector of rules
    • getRuleNames

      public String[] getRuleNames()
      returns a list of rule names
    • getRule

      public OpRule getRule(String name)
      return the OpRule matching name, or null if it does not exist
    • deleteRule

      public void deleteRule(String name)
      Deletes a rule for the OpControlller
      Parameters:
      name - - name of the rule to delete
    • deleteRule

      public void deleteRule(int index)
      Deletes a rule for the OpControlller
      Parameters:
      index - - index of the rule to delete
    • toString

      public String toString()
      over toString to return name - check if ok to move to namedtype
      Overrides:
      toString in class NamedType
    • getChildControllers

      public void getChildControllers(Vector vec)
      return the child controllers and their child controllers in the given vector
      Parameters:
      vec -
    • getChildControllers

      public void getChildControllers(Vector vec, boolean recurse)
      appends child controllers to the given vector
      Parameters:
      recurse - true to return recurse through the child controllers
    • getTSRecordProxy

      public TSRecordProxy getTSRecordProxy(int varId)
      finds a TSRecordProxy for the given variable id in this TSLocation
      Specified by:
      getTSRecordProxy in interface RssTSLocation
      Overrides:
      getTSRecordProxy in class RssTSLocationObject
    • getComputedTSRecordProxies

      public Vector getComputedTSRecordProxies(Vector v)
      returns a vector of computed ts record proxies assuming the downstream flow is computed
      Overrides:
      getComputedTSRecordProxies in class RssTSLocationObject
    • setParameterValue

      public double setParameterValue(double val, RunTimeStep rts)
      Description copied from interface: OpControllable
      sets the adjustable parameter value, returns the value actually applied
      Specified by:
      setParameterValue in interface OpControllable
    • 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
    • getCapacityOutageOrOveride

      public double getCapacityOutageOrOveride(double curMaxValue, RunTimeWindow rts)
    • 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 RssTSLocationObject
      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 RssTSLocationObject
      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
    • applyPowerRuleLimits

      public boolean applyPowerRuleLimits(RunTimeStep rts, OpRule rule, int iteration)
      Evaluates the given power rule and incorporates its limits into the current min/max values of all power plants that are at this controller or in its child controller hierarchy
      Parameters:
      rule - OpRule to be considered
      Returns:
      true if method changed the limits V3.0