Class RetireExactOperation

java.lang.Object
org.kigalisim.lang.operation.RetireExactOperation
All Implemented Interfaces:
Operation

public class RetireExactOperation extends Object implements Operation
Operation backing the retire N year old exact shortcut.

Delegates the actual retirement to the existing units-based retirement path once the age-N cohort's size is computed by amountOperation, optionally replacing retired equipment to maintain population the same way RetireWithReplacementOperation and RetireWeibullOperation do. Kept as its own operation type rather than reusing RetireOperation / RetireWithReplacementOperation directly so that ProgramValidator can flag it when combined with a directly-set priorEquipment, whose age this shortcut's sales-history lookup cannot see, unless assumingNew is set.

  • Constructor Details

    • RetireExactOperation

      public RetireExactOperation(Operation amountOperation, int ageYears, boolean assumingNew, boolean withReplacement)
      Create a new RetireExactOperation that applies to all years.
      Parameters:
      amountOperation - The operation that calculates the age-N cohort size to retire.
      ageYears - The exact age in years at which the cohort retires.
      assumingNew - Whether prior equipment should be treated as a pseudo-cohort assumed to have entered service when the simulation began (the assuming new modifier).
      withReplacement - Whether retired equipment should be replaced to maintain population.
    • RetireExactOperation

      public RetireExactOperation(Operation amountOperation, int ageYears, boolean assumingNew, boolean withReplacement, ParsedDuring during)
      Create a new RetireExactOperation that applies to a specific time period.
      Parameters:
      amountOperation - The operation that calculates the age-N cohort size to retire.
      ageYears - The exact age in years at which the cohort retires.
      assumingNew - Whether prior equipment should be treated as a pseudo-cohort assumed to have entered service when the simulation began (the assuming new modifier).
      withReplacement - Whether retired equipment should be replaced to maintain population.
      during - The time period during which this operation applies.
  • Method Details

    • execute

      public void execute(PushDownMachine machine)
      Execute the exact retire operation on the given push-down machine.

      Evaluates the amount operation to get the size of the age-N cohort, builds a year matcher from the optional during clause, and checks if this operation should execute in the current year. If the year is in range, validates that retire commands are not mixed with and without replacement in the same step. With assuming new, any priorEquipment not explained by tracked sales cohorts is added to the retirement amount in the one year the simulation reaches the given age (as if that stock had entered service when the simulation began). The cohort is then retired, replacing it to maintain population when withReplacement is set.

      Specified by:
      execute in interface Operation
      Parameters:
      machine - The push-down machine context for evaluating operations.
    • getStaticSemantics

      public OperationStaticSemantics getStaticSemantics()
      Get a record describing this operation's semantics.

      Get a record describing this operation's semantics that are inferrable from its static expression in code. In other words, properties and effects which do not require inspection at time of executing the operation.

      Specified by:
      getStaticSemantics in interface Operation
      Returns:
      Inference of common static properties found for this operation.