//Initialize.cpp #include "stdio.h" #include "iostream.h" #include "math.h" #include "string.h" #include "stdlib.h" #include "assert.h" #include "SetDef.h" #include "rankedSetDef.h" #include "subsetHolder.h" #include "Accumulated_Tallied_Variables.h" #include "Events.h" #include "JobShop.h" int Nr_Machine_Groups; int Nr_Standard_Job_Types; Machine_group * MachineGroup; Std_job_type * StdJobType; double LengthOfRun; double SimTime; void ReadInputData() { int i, j, k, n, nSteps; int mgS, StepPri, nInShop; double MTBS, PT; char c, str[500]; Std_job_type * SjtPtr; Step * StepPtr; EndProcess * EPPtr; Machine_group * MGPtr; Job * JobPtr; Sale * firstSale; //Initialize SimTime first, for use by Accumulated Variables SimTime = 0.0; //Read Length of simulation in days or fractions thereof fscanf(fp, " %[^:] %c %lf ", str, &c, &LengthOfRun); printf("INPUTS: \n\n"); printf("Length of run (days): %6.2f \n\n", LengthOfRun); //Read Machine Group Information fscanf(fp, " %[^:] %c %d ", str, &c, &Nr_Machine_Groups); printf( "Number of Machine Groups: %d \n",Nr_Machine_Groups); printf("Number of machines in each group:\n"); MachineGroup = (Machine_group *)calloc(Nr_Machine_Groups, sizeof(Machine_group)); fscanf(fp, " %[^:] %c ", str, &c); for (i=0; iMG_Nr = i; MGPtr->First_free_EndProcess_notice = NULL; fscanf(fp, " %d ", &n); MGPtr->Free_machines.Update((double)n); for (j=0; jevent_type = endProcess; EPPtr->Machine_group_used = MGPtr; //Link new EndProcess into list of free ones of MG EPPtr->Next_free_EndProcess_notice=MGPtr->First_free_EndProcess_notice; MGPtr->First_free_EndProcess_notice=EPPtr; } } for (i=0;iMean_time_between_sales = MTBS; printf("Mean time between sales for SJT %d is %f \n", i, SjtPtr->Mean_time_between_sales); fscanf(fp, " %[^:] %c ", str, &c); fscanf(fp, " %d ", &nSteps); printf("Number of Steps for SJT %d is %d \n", i , nSteps); //Cause first sale for standard type firstSale = new Sale(); firstSale->SJTPtr=SjtPtr; firstSale->event_type=sale; firstSale->time = MTBS; Timer.Cause((long)firstSale, MTBS); //Read information for EACH STEP of the type for (j=0; jMG = &MachineGroup[mgS]; StepPtr->Proc_time = PT; StepPtr->Step_priority = StepPri; //Link step StepPtr into routing of standard type SJTPtr StepPtr->Next_step = NULL; //This step will be the last so far //If step is first in set if (j==0) SjtPtr->First_step_in_routing=StepPtr; //Not first in set, then it follows old first in set else SjtPtr->Last_step_in_routing->Next_step=StepPtr; //In either case tell the standard type that this is last in set so far SjtPtr->Last_step_in_routing=StepPtr; printf("Step %d has MG = %d Proc_time = %f \n StepPri = %f nInShop = %d \n", j, (StepPtr->MG)->MG_Nr, StepPtr->Proc_time, StepPtr->Step_priority , nInShop); //Set up INITIAL JOBS AT STEP for (k=0; kPlace=StepPtr; //Like AdvanceJob, except assumes jobs being processed are half done. if((StepPtr->MG)->Free_machines.Value()>0) { assert(StepPtr->MG->First_free_EndProcess_notice!=NULL); StepPtr->MG->Free_machines.Increment(-1.0); EPPtr = StepPtr->MG->First_free_EndProcess_notice; StepPtr->MG->First_free_EndProcess_notice = EPPtr->Next_free_EndProcess_notice; EPPtr->Job_being_processed = JobPtr; EPPtr->Machine_group_used = StepPtr->MG; EPPtr->time = StepPtr->Proc_time/2.0; //assumes half processed at start Timer.Cause((long)EPPtr, EPPtr->time); } else { StepPtr->MG->Queue.fileMemberIntoSet(JobPtr->Place->Step_priority, (long)JobPtr); StepPtr->MG->Queue_size.Increment(1.0); } } } } //Reset Queue size and Idle machine statistics to reflect starting shop for (i=0; iFree_machines.Reset(); MGPtr->Queue_size.Reset(); } printf("\nSTART SIMULATION\n\n"); }