Package jline.lang

Class Environment

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Env

public class Environment extends Ensemble
An environment model defined by a collection of network sub-models coupled with an environment transition rule that selects the active sub-model.
See Also:
  • Field Details

  • Constructor Details

    • Environment

      public Environment(String name)
    • Environment

      public Environment(String name, int numStages)
  • Method Details

    • addStage

      public void addStage(int stageIdx, String name, String type, Network model)
      Adds a network model to a specific stage of the environment. All stages must have networks with the same number of stateful nodes.
      Parameters:
      stageIdx - the index of the stage (0-based)
      name - the name of this stage
      type - the type classification for this stage
      model - the network model to associate with this stage
      Throws:
      RuntimeException - if the model has a different number of stateful nodes than other stages
    • addTransition

      public void addTransition(int fromStageIdx, int toStageIdx, Markovian distrib)
      Adds a transition between two stages with default reset function (identity).
      Parameters:
      fromStageIdx - the source stage index
      toStageIdx - the destination stage index
      distrib - the Markovian distribution governing this transition
    • addTransition

      public void addTransition(int fromStageIdx, int toStageIdx, Markovian distrib, Environment.ResetQueueLengthsFunction resetFun)
      Adds a transition between two stages with a custom reset function.
      Parameters:
      fromStageIdx - the source stage index
      toStageIdx - the destination stage index
      distrib - the Markovian distribution governing this transition
      resetFun - function to apply when transitioning to reset queue lengths
    • addTransition

      public void addTransition(int fromStageIdx, int toStageIdx, Markovian distrib, Environment.ResetQueueLengthsFunction resetFun, Environment.ResetEnvRatesFunction resetEnvRatesFun)
      Adds a transition between two stages with custom reset functions for both queue lengths and environment rates.
      Parameters:
      fromStageIdx - the source stage index
      toStageIdx - the destination stage index
      distrib - the Markovian distribution governing this transition
      resetFun - function to apply when transitioning to reset queue lengths
      resetEnvRatesFun - function to apply when transitioning to reset environment rates
    • init

      public void init()
    • printStageTable

      public void printStageTable()
      Prints a formatted table showing all stages, their properties, and transitions. Displays stage names, types, associated networks, and transition rates.
    • findStageByName

      public int findStageByName(String stageName)
      Finds the stage index by name.
      Parameters:
      stageName - the name of the stage to find
      Returns:
      the index of the stage, or -1 if not found
    • getStageName

      public String getStageName(int stageIdx)
      Gets the name of the stage at the given index.
      Parameters:
      stageIdx - the index of the stage (0-based)
      Returns:
      the name of the stage
      Throws:
      ArrayIndexOutOfBoundsException - if stageIdx is out of range
    • getNumberOfStages

      public int getNumberOfStages()
      Gets the number of stages in this environment.
      Returns:
      the number of stages
    • addNodeBreakdown

      public void addNodeBreakdown(Network baseModel, String nodeName, Markovian breakdownDist, Markovian downServiceDist)
      Adds a breakdown stage for a specific node in the network. This creates an UP stage (if not already present) and a DOWN stage where the specified node has a reduced service rate. A transition from UP to DOWN is added with the given breakdown distribution.
      Parameters:
      baseModel - the base network model with normal (UP) service rates
      nodeName - the name of the node that can break down
      breakdownDist - the distribution for time until breakdown (UP->DOWN transition)
      downServiceDist - the service distribution when the node is down
      Throws:
      RuntimeException - if the node is not found in the base model
    • addNodeBreakdown

      public void addNodeBreakdown(Network baseModel, Node node, Markovian breakdownDist, Markovian downServiceDist)
      Adds a breakdown stage for a specific node in the network. Overload that accepts a Node object instead of a node name.
      Parameters:
      baseModel - the base network model with normal (UP) service rates
      node - the node that can break down
      breakdownDist - the distribution for time until breakdown (UP->DOWN transition)
      downServiceDist - the service distribution when the node is down
    • addNodeBreakdown

      public void addNodeBreakdown(Network baseModel, String nodeName, Markovian breakdownDist, Markovian downServiceDist, Environment.ResetQueueLengthsFunction resetFun)
      Adds a breakdown stage for a specific node with a custom reset policy.
      Parameters:
      baseModel - the base network model with normal (UP) service rates
      nodeName - the name of the node that can break down
      breakdownDist - the distribution for time until breakdown
      downServiceDist - the service distribution when the node is down
      resetFun - function to reset queue lengths on breakdown
    • addNodeBreakdown

      public void addNodeBreakdown(Network baseModel, Node node, Markovian breakdownDist, Markovian downServiceDist, Environment.ResetQueueLengthsFunction resetFun)
      Adds a breakdown stage for a specific node with a custom reset policy. Overload that accepts a Node object instead of a node name.
      Parameters:
      baseModel - the base network model with normal (UP) service rates
      node - the node that can break down
      breakdownDist - the distribution for time until breakdown
      downServiceDist - the service distribution when the node is down
      resetFun - function to reset queue lengths on breakdown
    • addNodeRepair

      public void addNodeRepair(String nodeName, Markovian repairDist)
      Adds a repair transition from DOWN to UP stage for a previously added breakdown.
      Parameters:
      nodeName - the name of the node that can be repaired
      repairDist - the distribution for repair time (DOWN->UP transition)
      Throws:
      RuntimeException - if the DOWN stage for this node is not found
    • addNodeRepair

      public void addNodeRepair(Node node, Markovian repairDist)
      Adds a repair transition from DOWN to UP stage for a previously added breakdown. Overload that accepts a Node object instead of a node name.
      Parameters:
      node - the node that can be repaired
      repairDist - the distribution for repair time (DOWN->UP transition)
    • addNodeRepair

      public void addNodeRepair(String nodeName, Markovian repairDist, Environment.ResetQueueLengthsFunction resetFun)
      Adds a repair transition with a custom reset policy.
      Parameters:
      nodeName - the name of the node that can be repaired
      repairDist - the distribution for repair time
      resetFun - function to reset queue lengths on repair
    • addNodeRepair

      public void addNodeRepair(Node node, Markovian repairDist, Environment.ResetQueueLengthsFunction resetFun)
      Adds a repair transition with a custom reset policy. Overload that accepts a Node object instead of a node name.
      Parameters:
      node - the node that can be repaired
      repairDist - the distribution for repair time
      resetFun - function to reset queue lengths on repair
    • addNodeFailureRepair

      public void addNodeFailureRepair(Network baseModel, String nodeName, Markovian breakdownDist, Markovian repairDist, Markovian downServiceDist)
      Convenience method to add both breakdown and repair for a node. This is the most common use case where a node can fail and be repaired.
      Parameters:
      baseModel - the base network model with normal (UP) service rates
      nodeName - the name of the node that can break down and repair
      breakdownDist - the distribution for time until breakdown
      repairDist - the distribution for repair time
      downServiceDist - the service distribution when the node is down
    • addNodeFailureRepair

      public void addNodeFailureRepair(Network baseModel, Node node, Markovian breakdownDist, Markovian repairDist, Markovian downServiceDist)
      Convenience method to add both breakdown and repair for a node. Overload that accepts a Node object instead of a node name.
      Parameters:
      baseModel - the base network model with normal (UP) service rates
      node - the node that can break down and repair
      breakdownDist - the distribution for time until breakdown
      repairDist - the distribution for repair time
      downServiceDist - the service distribution when the node is down
    • addNodeFailureRepair

      public void addNodeFailureRepair(Network baseModel, String nodeName, Markovian breakdownDist, Markovian repairDist, Markovian downServiceDist, Environment.ResetQueueLengthsFunction resetBreakdown, Environment.ResetQueueLengthsFunction resetRepair)
      Adds both breakdown and repair for a node with custom reset policies.
      Parameters:
      baseModel - the base network model with normal (UP) service rates
      nodeName - the name of the node that can break down and repair
      breakdownDist - the distribution for time until breakdown
      repairDist - the distribution for repair time
      downServiceDist - the service distribution when the node is down
      resetBreakdown - reset function for breakdown transition
      resetRepair - reset function for repair transition
    • addNodeFailureRepair

      public void addNodeFailureRepair(Network baseModel, Node node, Markovian breakdownDist, Markovian repairDist, Markovian downServiceDist, Environment.ResetQueueLengthsFunction resetBreakdown, Environment.ResetQueueLengthsFunction resetRepair)
      Adds both breakdown and repair for a node with custom reset policies. Overload that accepts a Node object instead of a node name.
      Parameters:
      baseModel - the base network model with normal (UP) service rates
      node - the node that can break down and repair
      breakdownDist - the distribution for time until breakdown
      repairDist - the distribution for repair time
      downServiceDist - the service distribution when the node is down
      resetBreakdown - reset function for breakdown transition
      resetRepair - reset function for repair transition
    • setBreakdownResetPolicy

      public void setBreakdownResetPolicy(String nodeName, Environment.ResetQueueLengthsFunction resetFun)
      Sets the reset policy for queue lengths when a node breaks down.
      Parameters:
      nodeName - the name of the node
      resetFun - function to reset queue lengths: resetFun(q) -> q_new Common policies: - input -> input (keep all jobs, default) - input -> input.mult(0, null) (clear all queues)
      Throws:
      RuntimeException - if the breakdown transition is not found
    • setBreakdownResetPolicy

      public void setBreakdownResetPolicy(Node node, Environment.ResetQueueLengthsFunction resetFun)
      Sets the reset policy for queue lengths when a node breaks down. Overload that accepts a Node object instead of a node name.
      Parameters:
      node - the node
      resetFun - function to reset queue lengths: resetFun(q) -> q_new
    • setRepairResetPolicy

      public void setRepairResetPolicy(String nodeName, Environment.ResetQueueLengthsFunction resetFun)
      Sets the reset policy for queue lengths when a node is repaired.
      Parameters:
      nodeName - the name of the node
      resetFun - function to reset queue lengths: resetFun(q) -> q_new
      Throws:
      RuntimeException - if the repair transition is not found
    • setRepairResetPolicy

      public void setRepairResetPolicy(Node node, Environment.ResetQueueLengthsFunction resetFun)
      Sets the reset policy for queue lengths when a node is repaired. Overload that accepts a Node object instead of a node name.
      Parameters:
      node - the node
      resetFun - function to reset queue lengths: resetFun(q) -> q_new
    • getReliabilityTable

      public Map<String,Double> getReliabilityTable()
      Computes system-wide reliability metrics (MTTF, MTTR, MTBF, Availability). This method analyzes the breakdown/repair transitions configured using addNodeBreakdown() and addNodeRepair() to compute reliability metrics.
      Returns:
      a Map containing reliability metrics with keys: "MTTF" - Mean Time To Failure (time from UP to DOWN) "MTTR" - Mean Time To Repair (time from DOWN to UP) "MTBF" - Mean Time Between Failures (MTTF + MTTR) "Availability" - Steady-state probability of being in UP state
      Throws:
      RuntimeException - if the environment has not been initialized or if no breakdown/repair transitions are configured
    • relT

      public Map<String,Double> relT()
      Short alias for getReliabilityTable.
      Returns:
      a Map containing reliability metrics (MTTF, MTTR, MTBF, Availability)
      See Also:
    • getRelT

      public Map<String,Double> getRelT()
      Short alias for getReliabilityTable.
      Returns:
      a Map containing reliability metrics (MTTF, MTTR, MTBF, Availability)
      See Also:
    • relTable

      public Map<String,Double> relTable()
      Short alias for getReliabilityTable.
      Returns:
      a Map containing reliability metrics (MTTF, MTTR, MTBF, Availability)
      See Also:
    • getRelTable

      public Map<String,Double> getRelTable()
      Short alias for getReliabilityTable.
      Returns:
      a Map containing reliability metrics (MTTF, MTTR, MTBF, Availability)
      See Also:
    • getStageTable

      public String getStageTable()
      Returns a table of stage information for this environment. Matches MATLAB Environment.getStageTable() which returns a Table with columns: Stage, Name, Type, Prob, HoldT, Model.
      Returns:
      a formatted string table of stage information
    • getStageT

      public String getStageT()
      Short alias for getStageTable.
      Returns:
      a formatted string table of stage information
      See Also: