From d9d7e7d6e75cabfcdd861060c859f34a114acc52 Mon Sep 17 00:00:00 2001
From: dansl <dansl@LAPTOP-SIKRVJU7.ern.nps.edu>
Date: Wed, 7 Jun 2023 16:02:22 -0700
Subject: [PATCH] Revert "Commit final version of Computer Assignment 8"

This reverts commit de41879f5c46cbedd0b257c4399791226a4ad26b.
---
 .../src/mv3302/StoppedPartArrivalProcess.java | 30 ++++++------
 .../mv3302/run/RunSteadyStateAnalysis.java    | 46 +++++++++----------
 .../src/mv3302/run/RunTransientAnalysis.java  | 37 +++++++--------
 3 files changed, 52 insertions(+), 61 deletions(-)

diff --git a/MV3302ClassCode/src/mv3302/StoppedPartArrivalProcess.java b/MV3302ClassCode/src/mv3302/StoppedPartArrivalProcess.java
index 5daa5d407c..78767c0917 100644
--- a/MV3302ClassCode/src/mv3302/StoppedPartArrivalProcess.java
+++ b/MV3302ClassCode/src/mv3302/StoppedPartArrivalProcess.java
@@ -1,18 +1,21 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Beans/Bean.java to edit this template
+ */
 package mv3302;
 
+import simkit.random.RandomVariate;
+
+
 /**
- * The StoppedPartArrivalProcess class extends the PartArrivalProcess class and
- * represents a process that stops the arrival of parts for a specified
- * duration. It overrides the doRun() method to wait for a specified stop time
- * before resuming the arrival of parts. It also provides methods to schedule
- * the next arrival and get/set the stop time.
  *
  * @author dansl
  */
 public final class StoppedPartArrivalProcess extends PartArrivalProcess {
 
-    private int stopTime;
-
+    //private RandomVariate interarrivalTimeGenerator;
+public int stopTime;
+    //int stopTime = 480;
     /**
      * Zero-argument constructor
      */
@@ -21,27 +24,22 @@ public final class StoppedPartArrivalProcess extends PartArrivalProcess {
     }
 
     /**
-     * Constructs a StoppedPartArrivalProcess object with the given stop time.
+     * Instantiate with the given parameters
      *
-     * @param stopTime The duration for which the arrival of parts should be
-     * stopped.
+     * @param interarrivalTimes Given inter arrival times
      */
     public StoppedPartArrivalProcess(int stopTime) {
         this.stopTime = stopTime;
     }
 
-    /**
-     * Overrides the doRun() method from the parent class. Pauses the arrival of
-     * parts for the specified stop time.
-     */
     @Override
     public void doRun() {
         waitDelay("StopArrivals", getStopTime());
     }
 
     /**
-     * Schedule the next arrival after stopping. This method schedules the
-     * Arrival(index) process.
+     * Schedule next Arrival<br>
+     * Schedule Arrival(index)
      */
     public void doStopArrivals() {
         interrupt("Arrival");
diff --git a/MV3302ClassCode/src/mv3302/run/RunSteadyStateAnalysis.java b/MV3302ClassCode/src/mv3302/run/RunSteadyStateAnalysis.java
index 51a6b72b76..ab7af7fd32 100644
--- a/MV3302ClassCode/src/mv3302/run/RunSteadyStateAnalysis.java
+++ b/MV3302ClassCode/src/mv3302/run/RunSteadyStateAnalysis.java
@@ -1,5 +1,7 @@
+
 package mv3302.run;
 
+
 import static java.lang.Math.sqrt;
 import mv3302.PartArrivalProcess;
 import mv3302.TransferLineComponent;
@@ -11,63 +13,58 @@ import simkit.stat.StudentT;
 import simkit.stat.TruncatingSimpleStatsTally;
 
 /**
- * The main class for running steady state analysis.
  *
  * @author dansl
  */
 public class RunSteadyStateAnalysis {
 
     /**
-     * The main method for executing the steady state analysis.
-     *
      * @param args the command line arguments
      */
     public static void main(String args[]) {
-        // Create a random variate generator for interarrival times with an exponential distribution and mean of 2.5
         RandomVariate interarrivalTimeGenerator = RandomVariateFactory.getInstance(
                 "Exponential", 2.5);
-        // Create a part arrival process with the interarrival time generator
         PartArrivalProcess arrivalProcess = new PartArrivalProcess(interarrivalTimeGenerator);
-        // Create an array of random variate generators for processing times
-        RandomVariate[] processingTimeGenerator
-                = {RandomVariateFactory.getInstance("Exponential", 2.4),
-                    RandomVariateFactory.getInstance("Gamma", 3.2, 3.3),
-                    RandomVariateFactory.getInstance("Uniform", 4.5, 6.7),
-                    RandomVariateFactory.getInstance("Exponential", 3.0)};
-        // Create an array of total number of workstations
+
+        RandomVariate[] processingTimeGenerator = 
+        {RandomVariateFactory.getInstance("Exponential", 2.4), RandomVariateFactory.getInstance("Gamma", 3.2, 3.3), RandomVariateFactory.getInstance("Uniform", 4.5, 6.7), RandomVariateFactory.getInstance("Exponential", 3.0)};
+
         int[] totalNumberWorkstations = new int[4];
         totalNumberWorkstations[0] = 1;
         totalNumberWorkstations[1] = 5;
         totalNumberWorkstations[2] = 4;
         totalNumberWorkstations[3] = 2;
-        // Create a transfer line component with the processing time generators and total number of workstations
+        
         TransferLineComponent transferLineComponent = new TransferLineComponent(processingTimeGenerator, totalNumberWorkstations);
-        // Add the transfer line component as a listener to the arrival process
+
         arrivalProcess.addSimEventListener(transferLineComponent);
+
         int warmup = 1000;
         int observations = 10000;
-        // Create a statistical tally for tracking delay in queue
+        
         SimpleStatsTally delayInQueueStat = new TruncatingSimpleStatsTally("delayInQueue", 2000);
-        // Add the delay in queue stat as a property change listener to the transfer line component
+
         transferLineComponent.addPropertyChangeListener(delayInQueueStat);
+
         System.out.println(arrivalProcess);
         System.out.println(transferLineComponent);
-        // Create a statistical tally for tracking delay in queue in the outer loop
+        
         SimpleStatsTally outerDelayInQueueStat = new SimpleStatsTally("outerDelayInQueue");
-        // Stop the simulation after warmup + observations arrivals
+
         Schedule.stopOnEvent(warmup + observations, "Arrival");
-        int numberReplications = 50;
+        
+        int numberReplications = 15;
         double alpha = 0.05;
-        // Outer loop for multiple replications
+        
         System.out.println("Avg Delay In Queue");
         for (int replication = 1; replication <= numberReplications; ++replication) {
-            // Reset the simulation schedule and delay in queue stat for each replication
+
             Schedule.reset();
             delayInQueueStat.reset();
+
             Schedule.startSimulation();
-            // Record the mean delay in queue for the replication in the outer tally
             outerDelayInQueueStat.newObservation(delayInQueueStat.getMean());
-            // Print the replication number, average delay, and confidence interval
+
             System.out.printf("%d %.3f ± %.3f%n",
                     replication,
                     outerDelayInQueueStat.getMean(),
@@ -75,5 +72,6 @@ public class RunSteadyStateAnalysis {
                     * StudentT.getQuantile(1.0 - 0.5 * alpha, outerDelayInQueueStat.getCount() - 1) / sqrt(outerDelayInQueueStat.getCount())
             );
         }
+
     }
-}
+}
\ No newline at end of file
diff --git a/MV3302ClassCode/src/mv3302/run/RunTransientAnalysis.java b/MV3302ClassCode/src/mv3302/run/RunTransientAnalysis.java
index 156fce31bf..9c566be25b 100644
--- a/MV3302ClassCode/src/mv3302/run/RunTransientAnalysis.java
+++ b/MV3302ClassCode/src/mv3302/run/RunTransientAnalysis.java
@@ -4,6 +4,7 @@ import static java.lang.Math.sqrt;
 import mv3302.PartArrivalProcess;
 import mv3302.StoppedPartArrivalProcess;
 import mv3302.TransferLineComponent;
+import mv3302.TransientStats;
 import simkit.Schedule;
 import simkit.random.RandomVariate;
 import simkit.random.RandomVariateFactory;
@@ -20,57 +21,50 @@ public class RunTransientAnalysis {
      * @param args the command line arguments
      */
     public static void main(String args[]) {
-        // Create an exponential random variate generator with a mean of 2.5
         RandomVariate interarrivalTimeGenerator = RandomVariateFactory.getInstance(
                 "Exponential", 2.5);
-        // Define the stop time for the simulation (in minutes)
         int stopTime = 480;
-        // Create a part arrival process using the interarrival time generator
         PartArrivalProcess partArrivalProcess = new PartArrivalProcess(interarrivalTimeGenerator);
-        // Create a stopped part arrival process with the given stop time
         StoppedPartArrivalProcess stoppedArrivalProcess = new StoppedPartArrivalProcess(stopTime);
-        // Create an array of random variate generators for processing times
+
         RandomVariate[] processingTimeGenerator
-                = {RandomVariateFactory.getInstance("Exponential", 2.4), 
-                    RandomVariateFactory.getInstance("Gamma", 3.2, 3.3), 
-                    RandomVariateFactory.getInstance("Uniform", 4.5, 6.7), 
-                    RandomVariateFactory.getInstance("Exponential", 3.0)};
-        // Define the total number of workstations for each type of processing time
+                = {RandomVariateFactory.getInstance("Exponential", 2.4), RandomVariateFactory.getInstance("Gamma", 3.2, 3.3), RandomVariateFactory.getInstance("Uniform", 4.5, 6.7), RandomVariateFactory.getInstance("Exponential", 3.0)};
+
         int[] totalNumberWorkstations = new int[4];
         totalNumberWorkstations[0] = 1;
         totalNumberWorkstations[1] = 5;
         totalNumberWorkstations[2] = 4;
         totalNumberWorkstations[3] = 2;
-        // Create a transfer line component with the processing time generators and workstation numbers
+
         TransferLineComponent transferLineComponent = new TransferLineComponent(processingTimeGenerator, totalNumberWorkstations);
-        // Add the transfer line component as a listener to the part arrival processes
+
         partArrivalProcess.addSimEventListener(transferLineComponent);
         stoppedArrivalProcess.addSimEventListener(transferLineComponent);
-        // Create a statistics tally for total time in the system
+
+//        SimpleStatsTally delayInQueueTransient = new SimpleStatsTally("delayInQueue");
+//        
         SimpleStatsTally totalTimeInSystemStat = new SimpleStatsTally("totalTimeInSystem");
-        // Add the statistics tally as a property change listener to the transfer line component
+        
         transferLineComponent.addPropertyChangeListener(totalTimeInSystemStat);
 
         System.out.println(partArrivalProcess);
         System.out.println(stoppedArrivalProcess);
         System.out.println(transferLineComponent);
-        // Create a statistics tally for outer time in the system
+
         SimpleStatsTally outerTimeInSystemStat = new SimpleStatsTally("outerTimeInSystem");
-        // Define the confidence level (alpha)
+        
+        int numberReplications = 200;
         double alpha = 0.05;
-        // Stop the simulation after 10,000 events with the name "Arrival"
         Schedule.stopOnEvent(10000, "Arrival");
 
         System.out.println("Avg Delay In Queue");
-        // Run the replications
         for (int replication = 1; replication <= stopTime; ++replication) {
             Schedule.reset();
-            // Reset the statistics tally for total time in the system
             totalTimeInSystemStat.reset();
             Schedule.startSimulation();
-            // Record the outer time in the system using the mean of the total time in the system
+
             outerTimeInSystemStat.newObservation(totalTimeInSystemStat.getMean());
-            // Print the replication number, mean, and confidence interval
+
             System.out.printf("%d %.3f ± %.3f%n",
                     replication,
                     outerTimeInSystemStat.getMean(),
@@ -78,5 +72,6 @@ public class RunTransientAnalysis {
                     * StudentT.getQuantile(1.0 - 0.5 * alpha, outerTimeInSystemStat.getCount() - 1) / sqrt(outerTimeInSystemStat.getCount())
             );
         }
+
     }
 }
-- 
GitLab