Class MutableStreamParameterization

java.lang.Object
org.kigalisim.engine.state.MutableStreamParameterization
All Implemented Interfaces:
StreamParameterization

public class MutableStreamParameterization extends Object implements StreamParameterization
Live, mutable stream-specific parameterization for a substance.

Handles configuration of GHG intensity, initial charge, recharge rates, recovery rates, and other stream-specific values.

  • Constructor Details

    • MutableStreamParameterization

      public MutableStreamParameterization()
      Create a new stream parameterization instance.
  • Method Details

    • setGhgIntensity

      public void setGhgIntensity(EngineNumber newValue)
      Set the greenhouse gas intensity.
      Specified by:
      setGhgIntensity in interface StreamParameterization
      Parameters:
      newValue - The new GHG intensity value
    • getGhgIntensity

      public EngineNumber getGhgIntensity()
      Get the greenhouse gas intensity.
      Specified by:
      getGhgIntensity in interface StreamParameterization
      Returns:
      The current GHG intensity value
    • setEnergyIntensity

      public void setEnergyIntensity(EngineNumber newValue)
      Set the energy intensity.
      Specified by:
      setEnergyIntensity in interface StreamParameterization
      Parameters:
      newValue - The new energy intensity value
    • getEnergyIntensity

      public EngineNumber getEnergyIntensity()
      Get the energy intensity.
      Specified by:
      getEnergyIntensity in interface StreamParameterization
      Returns:
      The current energy intensity value
    • setInitialCharge

      public void setInitialCharge(String stream, EngineNumber newValue)
      Set the initial charge for a stream.
      Specified by:
      setInitialCharge in interface StreamParameterization
      Parameters:
      stream - The stream identifier ('domestic' or 'import')
      newValue - The new initial charge value
    • getInitialCharge

      public EngineNumber getInitialCharge(String stream)
      Get the initial charge for a stream.
      Specified by:
      getInitialCharge in interface StreamParameterization
      Parameters:
      stream - The stream identifier ('domestic' or 'import')
      Returns:
      The initial charge value for the stream
    • setRechargePopulation

      public void setRechargePopulation(EngineNumber newValue)
      Set the recharge population percentage.
      Specified by:
      setRechargePopulation in interface StreamParameterization
      Parameters:
      newValue - The new recharge population value
    • getRechargePopulation

      public EngineNumber getRechargePopulation()
      Get the recharge population percentage.
      Specified by:
      getRechargePopulation in interface StreamParameterization
      Returns:
      The current recharge population value
    • setRechargeIntensity

      public void setRechargeIntensity(EngineNumber newValue)
      Set the recharge intensity.
      Specified by:
      setRechargeIntensity in interface StreamParameterization
      Parameters:
      newValue - The new recharge intensity value
    • getRechargeIntensity

      public EngineNumber getRechargeIntensity()
      Get the recharge intensity.
      Specified by:
      getRechargeIntensity in interface StreamParameterization
      Returns:
      The current recharge intensity value
    • setPrechargePopulation

      public void setPrechargePopulation(EngineNumber newValue)
      Set the precharge population percentage.
      Specified by:
      setPrechargePopulation in interface StreamParameterization
      Parameters:
      newValue - The new precharge population value
    • getPrechargePopulation

      public EngineNumber getPrechargePopulation()
      Get the precharge population percentage.
      Specified by:
      getPrechargePopulation in interface StreamParameterization
      Returns:
      The current precharge population value
    • setPrechargeIntensity

      public void setPrechargeIntensity(EngineNumber newValue)
      Set the precharge intensity.
      Specified by:
      setPrechargeIntensity in interface StreamParameterization
      Parameters:
      newValue - The new precharge intensity value
    • getPrechargeIntensity

      public EngineNumber getPrechargeIntensity()
      Get the precharge intensity.
      Specified by:
      getPrechargeIntensity in interface StreamParameterization
      Returns:
      The current precharge intensity value
    • setRecoveryRate

      public void setRecoveryRate(EngineNumber newValue)
      Set the recovery rate percentage.
      Specified by:
      setRecoveryRate in interface StreamParameterization
      Parameters:
      newValue - The new recovery rate value
    • setRecoveryRate

      public void setRecoveryRate(EngineNumber newValue, RecoverOperation.RecoveryStage stage)
      Set the recovery rate percentage for a specific stage.
      Specified by:
      setRecoveryRate in interface StreamParameterization
      Parameters:
      newValue - The new recovery rate value
      stage - The recovery stage (EOL or RECHARGE)
    • getRecoveryRate

      public EngineNumber getRecoveryRate()
      Get the recovery rate percentage.
      Specified by:
      getRecoveryRate in interface StreamParameterization
      Returns:
      The current recovery rate value
    • getRecoveryRate

      public EngineNumber getRecoveryRate(RecoverOperation.RecoveryStage stage)
      Get the recovery rate percentage for a specific stage.
      Specified by:
      getRecoveryRate in interface StreamParameterization
      Parameters:
      stage - The recovery stage (EOL or RECHARGE)
      Returns:
      The current recovery rate value
    • setYieldRate

      public void setYieldRate(EngineNumber newValue)
      Set the yield rate percentage for recycling.
      Specified by:
      setYieldRate in interface StreamParameterization
      Parameters:
      newValue - The new yield rate value
    • setYieldRate

      public void setYieldRate(EngineNumber newValue, RecoverOperation.RecoveryStage stage)
      Set the yield rate percentage for recycling for a specific stage.
      Specified by:
      setYieldRate in interface StreamParameterization
      Parameters:
      newValue - The new yield rate value
      stage - The recovery stage (EOL or RECHARGE)
    • getYieldRate

      public EngineNumber getYieldRate()
      Get the yield rate percentage for recycling.
      Specified by:
      getYieldRate in interface StreamParameterization
      Returns:
      The current yield rate value
    • getYieldRate

      public EngineNumber getYieldRate(RecoverOperation.RecoveryStage stage)
      Get the yield rate percentage for recycling for a specific stage.
      Specified by:
      getYieldRate in interface StreamParameterization
      Parameters:
      stage - The recovery stage (EOL or RECHARGE)
      Returns:
      The current yield rate value
    • setInductionRate

      public void setInductionRate(EngineNumber newValue)
      Set the induction rate percentage for recycling.
      Specified by:
      setInductionRate in interface StreamParameterization
      Parameters:
      newValue - The new induction rate value
    • setInductionRate

      public void setInductionRate(EngineNumber newValue, RecoverOperation.RecoveryStage stage)
      Set the induction rate percentage for recycling for a specific stage.
      Specified by:
      setInductionRate in interface StreamParameterization
      Parameters:
      newValue - The new induction rate value
      stage - The recovery stage (EOL or RECHARGE)
    • getInductionRate

      public EngineNumber getInductionRate()
      Get the induction rate percentage for recycling.
      Specified by:
      getInductionRate in interface StreamParameterization
      Returns:
      The current induction rate value
    • getInductionRate

      public EngineNumber getInductionRate(RecoverOperation.RecoveryStage stage)
      Get the induction rate percentage for recycling for a specific stage.
      Specified by:
      getInductionRate in interface StreamParameterization
      Parameters:
      stage - The recovery stage (EOL or RECHARGE)
      Returns:
      The current induction rate value
    • setRetirementRate

      public void setRetirementRate(EngineNumber newValue)
      Set the retirement rate percentage.

      On a live (mutable) parameterization, this accumulates retirement rates across multiple retire commands in the same year to support cumulative retirement behavior. If the resulting retirement rate is negative, it is clamped to zero (no retirement).

      Specified by:
      setRetirementRate in interface StreamParameterization
      Parameters:
      newValue - The new retirement rate value to add
    • getRetirementRate

      public EngineNumber getRetirementRate()
      Get the retirement rate percentage.
      Specified by:
      getRetirementRate in interface StreamParameterization
      Returns:
      The current retirement rate value
    • getRetirementBasePopulation

      public Optional<EngineNumber> getRetirementBasePopulation()
      Get the retirement base population for cumulative calculations.
      Specified by:
      getRetirementBasePopulation in interface StreamParameterization
      Returns:
      The base population, or empty if not yet captured this step
    • setRetirementBasePopulation

      public void setRetirementBasePopulation(EngineNumber value)
      Set the retirement base population for cumulative calculations.
      Specified by:
      setRetirementBasePopulation in interface StreamParameterization
      Parameters:
      value - The base population value
    • getAppliedRetirementAmount

      public Optional<EngineNumber> getAppliedRetirementAmount()
      Get the applied retirement amount for cumulative calculations.
      Specified by:
      getAppliedRetirementAmount in interface StreamParameterization
      Returns:
      The total amount already retired this step
    • setAppliedRetirementAmount

      public void setAppliedRetirementAmount(EngineNumber value)
      Set the applied retirement amount for cumulative calculations.
      Specified by:
      setAppliedRetirementAmount in interface StreamParameterization
      Parameters:
      value - The total amount retired this step
    • getHasReplacementThisStep

      public boolean getHasReplacementThisStep()
      Get the replacement mode for this step's retire commands.
      Specified by:
      getHasReplacementThisStep in interface StreamParameterization
      Returns:
      true if with replacement, false if without replacement
    • setHasReplacementThisStep

      public void setHasReplacementThisStep(boolean value)
      Set the replacement mode for this step's retire commands.
      Specified by:
      setHasReplacementThisStep in interface StreamParameterization
      Parameters:
      value - true for with replacement, false for without replacement
    • getRetireCalculatedThisStep

      public boolean getRetireCalculatedThisStep()
      Get whether retire has been calculated this step.
      Specified by:
      getRetireCalculatedThisStep in interface StreamParameterization
      Returns:
      true if retire was calculated, false otherwise
    • setRetireCalculatedThisStep

      public void setRetireCalculatedThisStep(boolean calculated)
      Set whether retire has been calculated this step.
      Specified by:
      setRetireCalculatedThisStep in interface StreamParameterization
      Parameters:
      calculated - true if retire was calculated, false otherwise
    • getRechargeBasePopulation

      public Optional<EngineNumber> getRechargeBasePopulation()
      Get the recharge base population for cumulative calculations.
      Specified by:
      getRechargeBasePopulation in interface StreamParameterization
      Returns:
      The base population, or empty if not yet captured this step
    • setRechargeBasePopulation

      public void setRechargeBasePopulation(EngineNumber value)
      Set the recharge base population for cumulative calculations.
      Specified by:
      setRechargeBasePopulation in interface StreamParameterization
      Parameters:
      value - The base population value
    • getAppliedRechargeAmount

      public Optional<EngineNumber> getAppliedRechargeAmount()
      Get the applied recharge amount for cumulative calculations.
      Specified by:
      getAppliedRechargeAmount in interface StreamParameterization
      Returns:
      The total amount already recharged this step in kg
    • setAppliedRechargeAmount

      public void setAppliedRechargeAmount(EngineNumber value)
      Set the applied recharge amount for cumulative calculations.
      Specified by:
      setAppliedRechargeAmount in interface StreamParameterization
      Parameters:
      value - The total amount recharged this step in kg
    • getPrechargeBasePopulation

      public Optional<EngineNumber> getPrechargeBasePopulation()
      Get the precharge base population for cumulative calculations.
      Specified by:
      getPrechargeBasePopulation in interface StreamParameterization
      Returns:
      The base population, or empty if not yet captured this year
    • setPrechargeBasePopulation

      public void setPrechargeBasePopulation(EngineNumber value)
      Set the precharge base population for cumulative calculations.
      Specified by:
      setPrechargeBasePopulation in interface StreamParameterization
      Parameters:
      value - The base population value
    • getAppliedPrechargeAmount

      public Optional<EngineNumber> getAppliedPrechargeAmount()
      Get the applied precharge amount for cumulative calculations.
      Specified by:
      getAppliedPrechargeAmount in interface StreamParameterization
      Returns:
      The total amount already precharged this step in kg
    • setAppliedPrechargeAmount

      public void setAppliedPrechargeAmount(EngineNumber value)
      Set the applied precharge amount for cumulative calculations.
      Specified by:
      setAppliedPrechargeAmount in interface StreamParameterization
      Parameters:
      value - The total amount precharged this step in kg
    • isRecyclingCalculatedThisStep

      public boolean isRecyclingCalculatedThisStep()
      Get whether recycling has been calculated this step.
      Specified by:
      isRecyclingCalculatedThisStep in interface StreamParameterization
      Returns:
      true if recycling was calculated, false otherwise
    • setRecyclingCalculatedThisStep

      public void setRecyclingCalculatedThisStep(boolean calculated)
      Set whether recycling has been calculated this step.
      Specified by:
      setRecyclingCalculatedThisStep in interface StreamParameterization
      Parameters:
      calculated - true if recycling was calculated, false otherwise
    • accumulateRecharge

      public void accumulateRecharge(EngineNumber population, EngineNumber intensity)
      Accumulate recharge parameters. Sets when not previously set, accumulates otherwise.

      Multiple calls accumulate rates (addition) and intensities (weighted-average). Population rates are added, intensities are weighted-averaged using absolute values for weights to handle negative adjustments correctly.

      Weighted average formula: (|rate1| × intensity1 + |rate2| × intensity2) / (|rate1| + |rate2|)

      Specified by:
      accumulateRecharge in interface StreamParameterization
      Parameters:
      population - The recharge population rate to add
      intensity - The recharge intensity for this rate
    • accumulatePrecharge

      public void accumulatePrecharge(EngineNumber population, EngineNumber intensity)
      Accumulate precharge parameters. Sets when not previously set, accumulates otherwise.

      Multiple calls accumulate rates (addition) and intensities (weighted-average). Population rates are added, intensities are weighted-averaged using absolute values for weights to handle negative adjustments correctly.

      Weighted average formula: (|rate1| × intensity1 + |rate2| × intensity2) / (|rate1| + |rate2|)

      Specified by:
      accumulatePrecharge in interface StreamParameterization
      Parameters:
      population - The precharge population rate to add
      intensity - The precharge intensity for this rate
    • setLastSpecifiedValue

      public void setLastSpecifiedValue(String streamName, EngineNumber value)
      Set the last specified value for a stream.

      This tracks the value and units last used when setting streams to preserve user intent across carry-over years. Percentage-unit values are ignored so they do not impact last recorded values.

      Specified by:
      setLastSpecifiedValue in interface StreamParameterization
      Parameters:
      streamName - The name of the stream
      value - The last specified value with units
    • getLastSpecifiedValue

      public EngineNumber getLastSpecifiedValue(String streamName)
      Get the last specified value for a stream.
      Specified by:
      getLastSpecifiedValue in interface StreamParameterization
      Parameters:
      streamName - The name of the stream
      Returns:
      The last specified value with units, or null if not set
    • hasLastSpecifiedValue

      public boolean hasLastSpecifiedValue(String streamName)
      Check if a stream has a last specified value.
      Specified by:
      hasLastSpecifiedValue in interface StreamParameterization
      Parameters:
      streamName - The name of the stream
      Returns:
      true if the stream has a last specified value, false otherwise
    • markStreamAsEnabled

      public void markStreamAsEnabled(String streamName)
      Mark a stream as having been enabled (set to non-zero value).
      Specified by:
      markStreamAsEnabled in interface StreamParameterization
      Parameters:
      streamName - The name of the stream to mark as enabled
    • hasStreamBeenEnabled

      public boolean hasStreamBeenEnabled(String streamName)
      Check if a stream has ever been enabled (set to non-zero value).
      Specified by:
      hasStreamBeenEnabled in interface StreamParameterization
      Parameters:
      streamName - The name of the stream to check
      Returns:
      true if the stream has been enabled, false otherwise
    • isSalesIntentFreshlySet

      public boolean isSalesIntentFreshlySet()
      Check if sales intent has been freshly set in the current processing cycle.
      Specified by:
      isSalesIntentFreshlySet in interface StreamParameterization
      Returns:
      true if sales intent was freshly set, false otherwise
    • setSalesIntentFreshlySet

      public void setSalesIntentFreshlySet(boolean freshlySet)
      Set the flag indicating whether sales intent has been freshly set.
      Specified by:
      setSalesIntentFreshlySet in interface StreamParameterization
      Parameters:
      freshlySet - true if sales intent was freshly set, false otherwise
    • resetStateAtTimestep

      public void resetStateAtTimestep()
      Reset state at the beginning of a timestep.

      This resets recovery rate to 0% and induction rate to 100% between steps since recycling programs may cease and should not be expected to continue unchanged, but default induction behavior should return to induced demand (100%).

      Specified by:
      resetStateAtTimestep in interface StreamParameterization
    • clearLastSpecifiedValue

      public void clearLastSpecifiedValue(String stream)
      Clear the last specified value in this parameterization.

      The last specified value tracks the user specified target for a stream such that commands changing those values respect user directives like maintaining units-based tracking with implicit recharge. This method clears that directive so that, for example, a set command can override a prior given value. This, for example, allows the user to switch from units-based to volume-based tracking.

      This will clear the stream and those dependent upon it. Therefore, clearing sales will also clear substreams domestic and import. Similarly, clearing domestic will clear sales but not import.

      Specified by:
      clearLastSpecifiedValue in interface StreamParameterization
      Parameters:
      stream - The name of the stream like "sales" or "import" in which to clear.
    • freeze

      public StreamParameterization freeze()
      Create an immutable snapshot of this instance.

      The mutable maps and sets are copied so that additions and removals on the snapshot's original do not affect the snapshot. EngineNumber instances are immutable, so their references can be shared. The prior equipment bases are frozen recursively.

      Specified by:
      freeze in interface StreamParameterization
      Returns:
      An immutable FrozenStreamParameterization snapshot