1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | ///////////////////////////////////////////////////////////////////// // DESP-C++ (Discrete-Event Simulation Package) // Version 1.1, February 1998 // Jerome Darmont // LIMOS, Blaise Pascal University (Clermont-Ferrand II), France ///////////////////////////////////////////////////////////////////// // simulc.h: Simulation engine classes definition // Invariable ///////////////////////////////////////////////////////////////////// class Simulation; class Scheduler; class SchedulerCell; class Resource; class QueueCell; class SetUp; class EventManager; // Defined in the eventc.hh variable module class Client; // Defined in the eventc.hh variable module ///////////////////////////////////////////////////////////////////// // Constants ///////////////////////////////////////////////////////////////////// #define STRS 25 // Resources' names size #define DEFAULT_SEED 127 // Default random seed #define GivenResCap 5 // number of resources must be set up capacity #define RegulaTime 12 // regular working hour ///////////////////////////////////////////////////////////////////// // CLASS Simulation ///////////////////////////////////////////////////////////////////// // Simulation control ///////////////////////////////////////////////////////////////////// class Simulation { public: // Methods //Simulation(double start, int CusIn, long int seed, int *, int NumDoc); // Constructor Simulation(double, int, long int, int *, int, int); ~Simulation(); // Destructor void Run(int nreplic); // Simulation execution Scheduler *Sched(); // Returns scheduler address double Tnow(); // Returns tnow //double Tmax(); // Returns tmax void Reset(double start, int CusIn, long int seed); // Reinitialization Client *NewClient(double att1, int att2, int att3, double att4, bool att5); // Creates a client in clientlist void KillClient(Client *client); // Deletes a client in clientlist void PurgeClientList(); // Deletes all clients int NCusIn(); // Return number of customer into system void GetCusSche(double *, int *, int *, double *, bool*); // Read customer schedule from txt file double AveTotalTime(); // return average total time double AveOverTime(); // return average overtime time double AveReplicAveLOS(); private: // Private attributes double tstart; // Simulation starting time //double tmax; // Simulation ending time double tnow; // Current date long int rseed; // Random generator seed Client *clientlist; // Clients list Scheduler *scheduler; // Pointer toward scheduler EventManager *eventmanager; // Pointer toward event manager int NumCustomerIn; // number of customer into system double ave_totaltime; // average total time double ave_overtime; // average overtime double ave_ReplicAveLOS; // summation all replication SumLOS }; ///////////////////////////////////////////////////////////////////// // CLASS Scheduler ///////////////////////////////////////////////////////////////////// // Scheduler (sorted event list) ///////////////////////////////////////////////////////////////////// class Scheduler { public: // Methods Scheduler(); // Constructor ~Scheduler(); // Destructor int IsEmpty(); // Returns scheduler state void Schedule(int eventcode, double eventdate, Client *client); // Insert int GetEventCode(); // Returns next event code double GetEventDate(); // Returns next event date Client *GetClient(); // Returns client to "serve" void DestroyEvent(); // Deletes next event void Purge(); // Deteles all events private: // Private attributes SchedulerCell *top; // Pointer toward 1st (next) event SchedulerCell *bottom; // Pointer toward last event }; ///////////////////////////////////////////////////////////////////// // CLASS SchedulerCell ///////////////////////////////////////////////////////////////////// // Scheduler cell ///////////////////////////////////////////////////////////////////// class SchedulerCell { public: // Methods SchedulerCell(int code, double date, Client *cli); // Constructor int Code(); // Returns event code double Date(); // Returns event date Client *Cli(); // Returns client served SchedulerCell *Next(); // Returns next cell SchedulerCell *Previous(); // Returns previous cell void SetNext(SchedulerCell *newnext); // New next cell void SetPrevious(SchedulerCell *newprev); // New previous cell private: // Private attributes int eventcode; // Event code double eventdate; // Event date Client *client; // Client served SchedulerCell *next; // Next cell SchedulerCell *previous; // Previous cell }; ///////////////////////////////////////////////////////////////////// // CLASS Resource ///////////////////////////////////////////////////////////////////// // Passive resource (active resources are subclasses) ///////////////////////////////////////////////////////////////////// class Resource { public: // Public methods Resource(char n[STRS], int cap, Simulation *sim); // Constructor ~Resource(); // Destructor void PurgeQueue(); // Empties queue void P(int event, Client *client, int prior); // Reserves resource void V(); // Frees ressource Simulation *Sim(); // Returns simulation object address void ResetCounters(); // Counters reinitialization void ResetStats(); // Global stats reinitialization void Stats(); // Stats computation void DisplayStats(); // Stats display double Mean(short i); // Returns stats (mean value) double Dev(short i); // Returns stats (std dev) int GetNumberOut(); // return number of customers out of process int NumPatient; // number of patients are creatived double SumLOS; // summation of LOS for each replication private: // Internal methods void EnQueue(int eventcode, Client *client, int priority); // Insert int GetEventCode(); // Returns 1st event in queue Client *GetClient(); // Returns 1st client in queue void DestroyTop(); // Deletes 1st element in queue int QueueEmpty(); // Queue status // Private attributes char name[STRS]; // Resource name QueueCell *top; // Queue top QueueCell *bottom; // Queue bottom int capacity; // Resource capacity int ccapacity; // Current capacity Simulation *simul; // Pointer toward simulation object double response; // Response time (1 replication) double wait; // Waiting time (1 replication) int nbserv; // Number of clients served double stats[5],stats2[5]; // Stats (accumulated) int n; // Stats (number of experiences) double mean[5], dev[5], cint[5]; // Mean values - Standard deviations - Confidence intervals // 0 : Response time // 1 : Waiting time // 2 : Number of clients served // 3 : Current number of clients // 4 : Number of waiting clients }; ///////////////////////////////////////////////////////////////////// // CLASS QueueCell ///////////////////////////////////////////////////////////////////// // Resource queue cell ///////////////////////////////////////////////////////////////////// class QueueCell { public: // Methods QueueCell(int code, Client *cli, int prior); // Constructor int Code(); // Returns event code Client *Cli(); // Returns client int Priority(); // Returns priority QueueCell *Next(); // Returns next cell QueueCell *Previous(); // Returns previous cell void SetNext(QueueCell *newnext); // New next cell void SetPrevious(QueueCell *newprev); // New previous cell private: // Private attributes int eventcode; // Event code Client *client; // Client int priority; // Priority QueueCell *next; // Next cell QueueCell *previous; // Previous cell }; //======================================= // class set up resource capacity //======================================= class SetUp { public: SetUp(); ~SetUp(); int *MaxResCap, *MinResCap; }; |
Direct link: https://paste.plurk.com/show/213011