SIMLIB/C++
3.09
Toggle main menu visibility
Loading...
Searching...
No Matches
examples/model2.cc
Queuing system
////////////////////////////////////////////////////////////////////////////
// Model MODEL2 SIMLIB/C++
//
// Simple model of queueing system (M/D/1)
//
#include "
simlib.h
"
// Global objects
Facility Box(
"Server"
);
Histogram Table(
"Table of time spent in system"
,0,25,20);
class
Customer :
public
Process {
// Customer description
double
ArrivalTime;
// Attribute for each customer
void
Behavior() {
// - Customer behavior description
ArrivalTime = Time;
// Mark arrival time
Seize(Box);
// Try to enter Box or queue
Wait(10);
// In service
Release(Box);
// Leave Box
Table(Time-ArrivalTime);
// Record time spent in system
}
};
class
Generator :
public
Event {
// Generator of customers
void
Behavior() {
// - Generator behavior description
(
new
Customer)->
Activate
();
// Create new customer, activate at Time
Activate
(Time+
Exponential
(1e3/150));
// Arrival time interval
}
};
int
main
() {
// Experiment description
//DebugON();
SetOutput
(
"model2.out"
);
// Write results to file
Print
(
" MODEL2 \n"
);
Init
(0,1000);
// Init simulator for time 0..1000
(
new
Generator)->
Activate
();
// Create generator, activate at 0
Run
();
// - Simulation run
Box.Output();
// Print results
Table.Output();
SIMLIB_statistics
.
Output
();
// Print simulator internal statistics
}
main
int main()
Definition
_test_.cc:44
simlib3::Activate
void Activate(Entity *e)
activate entity e
Definition
simlib.h:436
simlib3::SetOutput
void SetOutput(const char *name)
Definition
print.cc:50
simlib3::Run
void Run()
run simulation experiment
Definition
run.cc:228
simlib3::Print
int Print(const char *fmt,...)
for Output methods, can be redirected
Definition
print.cc:92
simlib3::Exponential
double Exponential(double mv)
Exponential distribution generator.
Definition
random2.cc:152
simlib3::Init
void Init(double t0, double t1=SIMLIB_MAXTIME)
Definition
simlib.h:186
simlib3::SIMLIB_statistics
const SIMLIB_statistics_t & SIMLIB_statistics
interface to internal run-time statistics structure
Definition
run.cc:78
simlib.h
Main SIMLIB/C++ interface.
simlib3::SIMLIB_statistics_t::Output
void Output() const
print run-time statistics to output
Definition
output1.cc:63
Generated on
for SIMLIB/C++ by
1.18.0