Class FrozenSimulationState
- All Implemented Interfaces:
SimulationState
SimulationState.
Holds only final fields populated at construction (each substance's
StreamParameterization already frozen, and priorState captured by
reference since the prior chain is already frozen) and throws
UnsupportedOperationException from every mutator, so a snapshot captured
for a prior-year lookup can never be silently corrupted.
-
Field Summary
Fields inherited from interface org.kigalisim.engine.state.SimulationState
ZERO_VOLUME -
Constructor Summary
ConstructorsConstructorDescriptionFrozenSimulationState(Map<String, StreamParameterization> substances, Map<String, EngineNumber> streams, Optional<SimulationState> priorState, OverridingConverterStateGetter stateGetter, UnitConverter unitConverter, int currentYear) Create a new immutable snapshot with the specified field values. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccumulatePrecharge(UseKey useKey, EngineNumber population, EngineNumber intensity) Accumulate precharge parameters.voidaccumulateRecharge(UseKey useKey, EngineNumber population, EngineNumber intensity) Accumulate recharge parameters.voidclearLastSpecifiedValue(UseKey useKey, String stream) Clear the last specified value in this parameterization.voidensureSubstance(UseKey useKey) Ensure a substance exists for a key, creating it if needed.freeze()Get an immutable snapshot of this instance.getAppliedPrechargeAmount(UseKey useKey) Get the applied precharge amount for cumulative calculations.getAppliedRechargeAmount(UseKey useKey) Get the applied recharge amount for cumulative calculations.getAppliedRetirementAmount(UseKey useKey) Get the applied retirement amount for cumulative calculations.getAtPrior(int years) Get the simulation state from N years ago.intGet the current year for this simulation state.getDistribution(UseKey useKey) Get a sales stream distribution for the given substance/application.getDistribution(UseKey useKey, boolean includeExports) Get a sales stream distribution for the given substance/application.getEnergyIntensity(UseKey useKey) Get the energy intensity for a key.getGhgIntensity(UseKey useKey) Get the greenhouse gas intensity for a key.booleangetHasReplacementThisStep(UseKey useKey) Get the replacement mode for retire commands this step.getInductionRate(UseKey useKey) Get the induction rate percentage for recycling for a key.getInductionRate(UseKey useKey, RecoverOperation.RecoveryStage stage) Get the induction rate percentage for recycling for a key with a specific stage.getInductionStream(UseKey useKey, RecoverOperation.RecoveryStage stage) Get the induction stream value for a specific recovery stage.getInductionStream(UseKey useKey, RecoverOperation.RecoveryStage stage, boolean priorYear) Get the induction stream value for a specific recovery stage.getInitialCharge(UseKey useKey, String substream) Get the initial charge for a key.getLastSpecifiedValue(UseKey useKey, String streamName) Get the last specified value for a stream.getPrechargeBasePopulation(UseKey useKey) Get the precharge base population for cumulative calculations.getPrechargeIntensity(UseKey useKey) Get the precharge intensity for a key.getPrechargePopulation(UseKey useKey) Get the precharge population percentage for a key.getRechargeBasePopulation(UseKey useKey) Get the recharge base population for cumulative calculations.getRechargeIntensity(UseKey useKey) Get the recharge intensity for a key.getRechargePopulation(UseKey useKey) Get the recharge population percentage for a key.getRecoveryRate(UseKey useKey) Get the recovery rate percentage for a key.getRecoveryRate(UseKey useKey, RecoverOperation.RecoveryStage stage) Get the recovery rate percentage for a key with a specific stage.Get all registered substance-application pairs.booleangetRetireCalculatedThisStep(UseKey useKey) Get whether retire has been calculated this step.getRetirementBasePopulation(UseKey useKey) Get the retirement base population for cumulative calculations.getRetirementRate(UseKey useKey) Get the retirement rate percentage for a key.Get the value of a specific stream using key.Get the value of a specific stream using key from this or prior year.getTotalInductionStream(UseKey useKey) Get total induction across all stages.getTotalInductionStream(UseKey useKey, boolean priorYear) Get total induction across all stages.getYieldRate(UseKey useKey) Get the yield rate percentage for recycling for a key.getYieldRate(UseKey useKey, RecoverOperation.RecoveryStage stage) Get the yield rate percentage for recycling for a key with a specific stage.booleanhasLastSpecifiedValue(UseKey useKey, String streamName) Check if a stream has a last specified value.booleanhasStreamBeenEnabled(UseKey useKey, String streamName) Check if a stream has ever been enabled (set to non-zero value).booleanhasStreamsEnabled(UseKey useKey) Check if any sales streams have been enabled for the given substance/application.booleanhasSubstance(UseKey useKey) Check if a substance exists for a key.voidIncrement the year, updating populations and resetting internal params.booleanisKnownStream(UseKey useKey, String name) Check if a stream exists for a key.booleanisRecyclingCalculatedThisStep(UseKey useKey) Get whether recycling has been calculated this step.booleanisSalesIntentFreshlySet(UseKey useKey) Check if sales intent has been freshly set for the given scope.voidmarkStreamAsEnabled(UseKey useKey, String streamName) Mark a stream as having been enabled (set to non-zero value).voidresetSalesIntentFlag(UseKey useKey) Reset the sales intent flag for the given scope.voidsetAppliedPrechargeAmount(UseKey useKey, EngineNumber value) Set the applied precharge amount for cumulative calculations.voidsetAppliedRechargeAmount(UseKey useKey, EngineNumber value) Set the applied recharge amount for cumulative calculations.voidsetAppliedRetirementAmount(UseKey useKey, EngineNumber value) Set the applied retirement amount for cumulative calculations.voidsetCurrentYear(int year) Set the current year for this simulation state.voidsetEnergyIntensity(UseKey useKey, EngineNumber newValue) Set the energy intensity for a key.voidsetGhgIntensity(UseKey useKey, EngineNumber newValue) Set the greenhouse gas intensity for a key.voidsetHasReplacementThisStep(UseKey useKey, boolean value) Set the replacement mode for retire commands this step.voidsetInductionRate(UseKey useKey, EngineNumber newValue) Set the induction rate percentage for recycling for a key.voidsetInductionRate(UseKey useKey, EngineNumber newValue, RecoverOperation.RecoveryStage stage) Set the induction rate percentage for recycling for a key with a specific stage.voidsetInitialCharge(UseKey useKey, String substream, EngineNumber newValue) Set the initial charge for a key's stream.voidsetLastSpecifiedValue(UseKey useKey, String streamName, EngineNumber value) Tracks the last specified value for sales-related streams.voidsetPrechargeBasePopulation(UseKey useKey, EngineNumber value) Set the precharge base population for cumulative calculations.voidsetPrechargeIntensity(UseKey useKey, EngineNumber newValue) Set the precharge intensity for a key.voidsetPrechargePopulation(UseKey useKey, EngineNumber newValue) Set the precharge population percentage for a key.voidsetRechargeBasePopulation(UseKey useKey, EngineNumber value) Set the recharge base population for cumulative calculations.voidsetRechargeIntensity(UseKey useKey, EngineNumber newValue) Set the recharge intensity for a key.voidsetRechargePopulation(UseKey useKey, EngineNumber newValue) Set the recharge population percentage for a key.voidsetRecoveryRate(UseKey useKey, EngineNumber newValue) Set the recovery rate percentage for a key.voidsetRecoveryRate(UseKey useKey, EngineNumber newValue, RecoverOperation.RecoveryStage stage) Set the recovery rate percentage for a key with a specific stage.voidsetRecyclingCalculatedThisStep(UseKey useKey, boolean calculated) Set whether recycling has been calculated this step.voidsetRetireCalculatedThisStep(UseKey useKey, boolean calculated) Set whether retire has been calculated this step.voidsetRetirementBasePopulation(UseKey useKey, EngineNumber value) Set the retirement base population for cumulative calculations.voidsetRetirementRate(UseKey useKey, EngineNumber newValue) Set the retirement rate percentage for a key.voidsetYieldRate(UseKey useKey, EngineNumber newValue) Set the yield rate percentage for recycling for a key.voidsetYieldRate(UseKey useKey, EngineNumber newValue, RecoverOperation.RecoveryStage stage) Set the yield rate percentage for recycling for a key with a specific stage.voidupdate(SimulationStateUpdate stateUpdate) Set a stream using pre-computed stream data.
-
Constructor Details
-
FrozenSimulationState
public FrozenSimulationState(Map<String, StreamParameterization> substances, Map<String, EngineNumber> streams, Optional<SimulationState> priorState, OverridingConverterStateGetter stateGetter, UnitConverter unitConverter, int currentYear) Create a new immutable snapshot with the specified field values.- Parameters:
substances- The frozen per-substance parameterizations, keyed by application/substancestreams- The stream values at the time of the snapshotpriorState- The (already frozen) prior year's state, if anystateGetter- Structure to retrieve state information, shared with the live stateunitConverter- Converter for handling unit transformations, shared with the live statecurrentYear- The year this snapshot was captured at
-
-
Method Details
-
getRegisteredSubstances
Get all registered substance-application pairs.- Specified by:
getRegisteredSubstancesin interfaceSimulationState- Returns:
- Array of substance identifiers
-
hasSubstance
Check if a substance exists for a key.- Specified by:
hasSubstancein interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- true if the substance exists for the key
-
ensureSubstance
Ensure a substance exists for a key, creating it if needed.- Specified by:
ensureSubstancein interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
update
Set a stream using pre-computed stream data.This method replaces setStream, setOutcomeStream, and setSalesStream with a unified interface that accepts pre-computed stream values. The SimulationStateUpdate object encapsulates all necessary parameters including distribution logic and recycling behavior.
This method provides clear architectural separation between calculation instructions (StreamUpdate) and pre-computed results (SimulationStateUpdate).
- Specified by:
updatein interfaceSimulationState- Parameters:
stateUpdate- Pre-computed stream data with all parameters- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getStream
Get the value of a specific stream using key. Uses current year.- Specified by:
getStreamin interfaceSimulationState- Parameters:
useKey- The key containing application and substancename- The stream name- Returns:
- The stream value
-
getStream
Get the value of a specific stream using key from this or prior year.- Specified by:
getStreamin interfaceSimulationState- Parameters:
useKey- The key containing application and substancename- The stream namepriorYear- If true, returns prior year value if available, returns current year if no prior year exists.- Returns:
- The stream value
-
isKnownStream
Check if a stream exists for a key.- Specified by:
isKnownStreamin interfaceSimulationState- Parameters:
useKey- The key containing application and substancename- The stream name- Returns:
- true if the stream exists
-
getInductionStream
Get the induction stream value for a specific recovery stage. Uses current year.- Specified by:
getInductionStreamin interfaceSimulationState- Parameters:
useKey- The key containing application and substancestage- The recovery stage (EOL or RECHARGE)- Returns:
- The induction stream value in kg
-
getInductionStream
public EngineNumber getInductionStream(UseKey useKey, RecoverOperation.RecoveryStage stage, boolean priorYear) Get the induction stream value for a specific recovery stage.- Specified by:
getInductionStreamin interfaceSimulationState- Parameters:
useKey- The key containing application and substancestage- The recovery stage (EOL or RECHARGE)priorYear- If true, returns prior year value if available, returns current year if no prior year exists.- Returns:
- The induction stream value in kg
-
getTotalInductionStream
Get total induction across all stages. Uses current year.- Specified by:
getTotalInductionStreamin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- Total induction in kg
-
getTotalInductionStream
Get total induction across all stages.- Specified by:
getTotalInductionStreamin interfaceSimulationState- Parameters:
useKey- The key containing application and substancepriorYear- If true, returns prior year value if available, returns current year if no prior year exists.- Returns:
- Total induction in kg
-
getDistribution
Get a sales stream distribution for the given substance/application.This method centralizes the logic for creating sales distributions by getting the current domestic and import values, determining their enabled status, and building an appropriate distribution using the builder pattern. Exports are excluded for backward compatibility.
- Specified by:
getDistributionin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- A SalesStreamDistribution with appropriate percentages
-
getDistribution
Get a sales stream distribution for the given substance/application.This method centralizes the logic for creating sales distributions by getting the current domestic, import, and optionally export values, determining their enabled status, and building an appropriate distribution using the builder pattern.
- Specified by:
getDistributionin interfaceSimulationState- Parameters:
useKey- The key containing application and substanceincludeExports- Whether to include exports in the distribution calculation- Returns:
- A SalesStreamDistribution with appropriate percentages
-
hasStreamsEnabled
Check if any sales streams have been enabled for the given substance/application.- Specified by:
hasStreamsEnabledin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- True if any of domestic, import, or export streams are enabled
-
getCurrentYear
public int getCurrentYear()Get the current year for this simulation state.- Specified by:
getCurrentYearin interfaceSimulationState- Returns:
- The current year
-
setCurrentYear
public void setCurrentYear(int year) Set the current year for this simulation state.- Specified by:
setCurrentYearin interfaceSimulationState- Parameters:
year- The current year- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getAtPrior
Get the simulation state from N years ago.Returns Optional.empty() if years is negative. Returns Optional.of(this) if years is 0. Otherwise traverses the linked list of prior states: getAtPrior(1) returns the state from the previous year, getAtPrior(2) returns the state from two years ago, and so on. If the linked list is exhausted before reaching the requested year, returns Optional.empty().
- Specified by:
getAtPriorin interfaceSimulationState- Parameters:
years- The number of years to look back- Returns:
- Optional.of(this) if years is 0, Optional.of(priorState) if years is 1, traversing the linked list for larger values, or Optional.empty() if not available
-
incrementYear
public void incrementYear()Increment the year, updating populations and resetting internal params.Freezes the current state before modifications to build the linked list of prior states, enabling lookback N years via getAtPrior().
- Specified by:
incrementYearin interfaceSimulationState- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
setGhgIntensity
Set the greenhouse gas intensity for a key.- Specified by:
setGhgIntensityin interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new GHG intensity value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
setEnergyIntensity
Set the energy intensity for a key.- Specified by:
setEnergyIntensityin interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new energy intensity value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getGhgIntensity
Get the greenhouse gas intensity for a key.- Specified by:
getGhgIntensityin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The GHG intensity value
-
getEnergyIntensity
Get the energy intensity for a key.- Specified by:
getEnergyIntensityin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The energy intensity value
-
setInitialCharge
Set the initial charge for a key's stream.- Specified by:
setInitialChargein interfaceSimulationState- Parameters:
useKey- The key containing application and substancesubstream- The stream identifier ('domestic' or 'import')newValue- The new initial charge value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getInitialCharge
Get the initial charge for a key.- Specified by:
getInitialChargein interfaceSimulationState- Parameters:
useKey- The key containing application and substancesubstream- The substream name- Returns:
- The initial charge value
-
setRechargePopulation
Set the recharge population percentage for a key.- Specified by:
setRechargePopulationin interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new recharge population value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getRechargePopulation
Get the recharge population percentage for a key.- Specified by:
getRechargePopulationin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The current recharge population value
-
setRechargeIntensity
Set the recharge intensity for a key.- Specified by:
setRechargeIntensityin interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new recharge intensity value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getRechargeIntensity
Get the recharge intensity for a key.- Specified by:
getRechargeIntensityin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The current recharge intensity value
-
accumulateRecharge
Accumulate recharge parameters. Sets when not previously set, accumulates otherwise.Multiple calls accumulate rates (addition) and intensities (weighted-average). Rates add linearly and intensities use weighted-average with absolute value weights to handle negative adjustments correctly.
- Specified by:
accumulateRechargein interfaceSimulationState- Parameters:
useKey- The key containing application and substancepopulation- The recharge population rate to addintensity- The recharge intensity for this rate- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getRechargeBasePopulation
Get the recharge base population for cumulative calculations.- Specified by:
getRechargeBasePopulationin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The base population, or null if not yet captured this year
-
setRechargeBasePopulation
Set the recharge base population for cumulative calculations.- Specified by:
setRechargeBasePopulationin interfaceSimulationState- Parameters:
useKey- The key containing application and substancevalue- The base population value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getAppliedRechargeAmount
Get the applied recharge amount for cumulative calculations.- Specified by:
getAppliedRechargeAmountin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The total amount already recharged this year in kg
-
setAppliedRechargeAmount
Set the applied recharge amount for cumulative calculations.- Specified by:
setAppliedRechargeAmountin interfaceSimulationState- Parameters:
useKey- The key containing application and substancevalue- The total amount recharged this year in kg- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
setPrechargePopulation
Set the precharge population percentage for a key.- Specified by:
setPrechargePopulationin interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new precharge population value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getPrechargePopulation
Get the precharge population percentage for a key.- Specified by:
getPrechargePopulationin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The current precharge population value
-
setPrechargeIntensity
Set the precharge intensity for a key.- Specified by:
setPrechargeIntensityin interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new precharge intensity value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getPrechargeIntensity
Get the precharge intensity for a key.- Specified by:
getPrechargeIntensityin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The current precharge intensity value
-
accumulatePrecharge
Accumulate precharge parameters. Sets when not previously set, accumulates otherwise.- Specified by:
accumulatePrechargein interfaceSimulationState- Parameters:
useKey- The key containing application and substancepopulation- The precharge population rate to addintensity- The precharge intensity for this rate- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getPrechargeBasePopulation
Get the precharge base population for cumulative calculations.- Specified by:
getPrechargeBasePopulationin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The base population, or null if not yet captured this year
-
setPrechargeBasePopulation
Set the precharge base population for cumulative calculations.- Specified by:
setPrechargeBasePopulationin interfaceSimulationState- Parameters:
useKey- The key containing application and substancevalue- The base population value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getAppliedPrechargeAmount
Get the applied precharge amount for cumulative calculations.- Specified by:
getAppliedPrechargeAmountin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The total amount already precharged this year in kg
-
setAppliedPrechargeAmount
Set the applied precharge amount for cumulative calculations.- Specified by:
setAppliedPrechargeAmountin interfaceSimulationState- Parameters:
useKey- The key containing application and substancevalue- The total amount precharged this year in kg- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
isRecyclingCalculatedThisStep
Get whether recycling has been calculated this step.- Specified by:
isRecyclingCalculatedThisStepin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- true if recycling was calculated, false otherwise
-
setRecyclingCalculatedThisStep
Set whether recycling has been calculated this step.- Specified by:
setRecyclingCalculatedThisStepin interfaceSimulationState- Parameters:
useKey- The key containing application and substancecalculated- true if recycling was calculated, false otherwise- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
setRecoveryRate
Set the recovery rate percentage for a key.If a recovery rate is already set, this method implements additive recycling:- Recovery rates are added together.
- Both rates are converted to percentage units before addition.
- The combined rate is stored as a percentage.
- Specified by:
setRecoveryRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new recovery rate value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
setRecoveryRate
public void setRecoveryRate(UseKey useKey, EngineNumber newValue, RecoverOperation.RecoveryStage stage) Set the recovery rate percentage for a key with a specific stage.Implements additive behavior for multiple recovery commands on the same stage:- When a recovery rate is already set for this stage, the new rate is added to the existing one.
- The first recovery rate for a timestep is set directly without addition.
- Specified by:
setRecoveryRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new recovery rate valuestage- The recovery stage (EOL or RECHARGE)- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getRecoveryRate
Get the recovery rate percentage for a key.- Specified by:
getRecoveryRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The current recovery rate value
-
getRecoveryRate
Get the recovery rate percentage for a key with a specific stage.- Specified by:
getRecoveryRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substancestage- The recovery stage (EOL or RECHARGE)- Returns:
- The current recovery rate value
-
setYieldRate
Set the yield rate percentage for recycling for a key.Convenience method that sets the yield rate for the RECHARGE recovery stage. Delegates to
SimulationState.setYieldRate(UseKey, EngineNumber, RecoveryStage)with RecoveryStage.RECHARGE.- Specified by:
setYieldRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new yield rate value- Throws:
UnsupportedOperationException- always, since this instance is frozen- See Also:
-
setYieldRate
public void setYieldRate(UseKey useKey, EngineNumber newValue, RecoverOperation.RecoveryStage stage) Set the yield rate percentage for recycling for a key with a specific stage.When an existing yield rate is set for this stage, combines them using a weighted average approach that uses equal weighting, which is a reasonable approximation for efficiency rates.
- Specified by:
setYieldRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new yield rate valuestage- The recovery stage (EOL or RECHARGE)- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getYieldRate
Get the yield rate percentage for recycling for a key.- Specified by:
getYieldRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The current yield rate value
-
getYieldRate
Get the yield rate percentage for recycling for a key with a specific stage.- Specified by:
getYieldRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substancestage- The recovery stage (EOL or RECHARGE)- Returns:
- The current yield rate value
-
setInductionRate
Set the induction rate percentage for recycling for a key.- Specified by:
setInductionRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new induction rate value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
setInductionRate
public void setInductionRate(UseKey useKey, EngineNumber newValue, RecoverOperation.RecoveryStage stage) Set the induction rate percentage for recycling for a key with a specific stage.- Specified by:
setInductionRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new induction rate valuestage- The recovery stage (EOL or RECHARGE)- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getInductionRate
Get the induction rate percentage for recycling for a key.- Specified by:
getInductionRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The current induction rate value
-
getInductionRate
Get the induction rate percentage for recycling for a key with a specific stage.- Specified by:
getInductionRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substancestage- The recovery stage (EOL or RECHARGE)- Returns:
- The current induction rate value
-
setRetirementRate
Set the retirement rate percentage for a key.- Specified by:
setRetirementRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substancenewValue- The new retirement rate value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getRetirementRate
Get the retirement rate percentage for a key.- Specified by:
getRetirementRatein interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The current retirement rate value
-
getRetirementBasePopulation
Get the retirement base population for cumulative calculations.- Specified by:
getRetirementBasePopulationin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The base population, or null if not yet captured
-
setRetirementBasePopulation
Set the retirement base population for cumulative calculations.- Specified by:
setRetirementBasePopulationin interfaceSimulationState- Parameters:
useKey- The key containing application and substancevalue- The base population value- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getAppliedRetirementAmount
Get the applied retirement amount for cumulative calculations.- Specified by:
getAppliedRetirementAmountin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- The total amount already retired this year
-
setAppliedRetirementAmount
Set the applied retirement amount for cumulative calculations.- Specified by:
setAppliedRetirementAmountin interfaceSimulationState- Parameters:
useKey- The key containing application and substancevalue- The total amount retired this year- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getHasReplacementThisStep
Get the replacement mode for retire commands this step.- Specified by:
getHasReplacementThisStepin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- null if no retire yet, true if with replacement, false if without replacement
-
setHasReplacementThisStep
Set the replacement mode for retire commands this step.- Specified by:
setHasReplacementThisStepin interfaceSimulationState- Parameters:
useKey- The key containing application and substancevalue- true for with replacement, false for without replacement- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getRetireCalculatedThisStep
Get whether retire has been calculated this step.- Specified by:
getRetireCalculatedThisStepin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- true if retire was calculated, false otherwise
-
setRetireCalculatedThisStep
Set whether retire has been calculated this step.- Specified by:
setRetireCalculatedThisStepin interfaceSimulationState- Parameters:
useKey- The key containing application and substancecalculated- true if retire was calculated, false otherwise- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
setLastSpecifiedValue
Tracks the last specified value for sales-related streams.This method preserves user intent across carry-over years by storing the units and values that were explicitly specified by the user. This is essential for maintaining correct behavior when sales values carry over to subsequent years, particularly for unit-based specifications where recharge calculations need to be applied consistently.
- Specified by:
setLastSpecifiedValuein interfaceSimulationState- Parameters:
useKey- The key containing application and substancestreamName- The name of the stream (e.g., "sales", "domestic", "import")value- The value being specified with its units- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
getLastSpecifiedValue
Get the last specified value for a stream.- Specified by:
getLastSpecifiedValuein interfaceSimulationState- Parameters:
useKey- The key containing application and substancestreamName- The name of the stream- Returns:
- The last specified value with units, or null if not set
-
hasLastSpecifiedValue
Check if a stream has a last specified value.- Specified by:
hasLastSpecifiedValuein interfaceSimulationState- Parameters:
useKey- The key containing application and substancestreamName- The name of the stream- Returns:
- true if the stream has a last specified value, false otherwise
-
isSalesIntentFreshlySet
Check if sales intent has been freshly set for the given scope.- Specified by:
isSalesIntentFreshlySetin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Returns:
- true if sales intent was freshly set, false otherwise
-
resetSalesIntentFlag
Reset the sales intent flag for the given scope.- Specified by:
resetSalesIntentFlagin interfaceSimulationState- Parameters:
useKey- The key containing application and substance- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
hasStreamBeenEnabled
Check if a stream has ever been enabled (set to non-zero value).- Specified by:
hasStreamBeenEnabledin interfaceSimulationState- Parameters:
useKey- The key containing application and substancestreamName- The name of the stream to check- Returns:
- true if the stream has been enabled, false otherwise
-
markStreamAsEnabled
Mark a stream as having been enabled (set to non-zero value).- Specified by:
markStreamAsEnabledin interfaceSimulationState- Parameters:
useKey- The key containing application and substancestreamName- The name of the stream to mark as enabled- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
clearLastSpecifiedValue
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.
- Specified by:
clearLastSpecifiedValuein interfaceSimulationState- Parameters:
useKey- The substance / application pair in which to clear last specified value.stream- The name of the stream like "sales" or "import" in which to clear.- Throws:
UnsupportedOperationException- always, since this instance is frozen
-
freeze
Get an immutable snapshot of this instance.Container fields (maps) are copied so the mutable original can keep mutating its own containers independently. Immutable values (
EngineNumber) are shared by reference. Each substance'sStreamParameterizationis frozen recursively, andpriorStateis captured by reference (the prior chain is already frozen, so sharing is safe and O(1) per year).- Specified by:
freezein interfaceSimulationState- Returns:
- this same instance, since it is already frozen
-