
FirstIdleConnection rule) or
to select one randomly among all idle blocks (RandomConnection rule), among others.
TSelector class.
TSelector constructor contains one mandatory item — the first one — Capacity, which specifies the maximum number of outputs.
FirstIdleConnection by default).

CreateDefault constructor can be used for the TQueue class instance.
Initial Values parameter for the TSelector class should be specified as RandomConnection.
However, because the method of selecting an idle server does not affect the results, the default FirstIdleConnection value can be used instead.
Therefore, this parameter can be omitted.
Connect method of the TServer class has a version that sequentially connects any block class instance to a connection point,
but in this case an array of TServer instances would need to be created to represent the servers.
TSelector Connect method has an implementation that can automatically create the required number of the
specified block class instances and assign them to the specified range of Connection Points.
Connect ( Lower bound, Upper bound, Block class, Initial values )
TSelector.
Connect (1, 2, TServer, [ ExpTime, 1.3 ] )
InitialValues for the TServer class will be specified as parameters for the TSelector block.
TServer instances.
TotalEntities — the total number of entities to be simulated during the model run.NumberOfServers — the number of servers in the system.InterarrivalTime — the mean time between entity arrivals.ServiceTime — the mean service time.ExpTime — a pointer to a function that returns exponentially distributed random values.Gen, Que, and Sel for the instances of the TGenerator,
TQueue, and TSelector classes, respectively.
Gen := TGenerator.Create([TotalEntities, ExpTime, InterarrivalTime]); // Creating Generator. Que := TQueue.CreateDefault; // Creating Queue with default initial values. Sel := TSelector.Create([NumberOfServers]); // Creating Selector with default rule. Gen.Connect(Que); // Connecting Generator to Queue. Que.Connect(Sel); // Connecting Queue to Selector. Sel.Connect(1, NumberOfServers, TServer, [ExpTime, ServiceTime]); // Connecting Selector to Servers. // The specified number (NumberOfServers) of TServer instances are automatically created, // initialized with [ExpTime, ServiceTime], and connected to the Selector's outputs 1..NumberOfServers.
program MMC;
{$AppType GUI}
{$S-}
uses
SimBase,
SimBlocks,
SimStdGUI;
type
TMyModel = class(TModel) // Model declaration.
procedure Body; override;
end;
var // Model parameters.
TotalEntities,
NumberOfServers: Integer;
InterarrivalTime,
ServiceTime: Double;
procedure TMyModel.Body; // Model behavior.
var
Gen: TGenerator; // Blocks declaration.
Que: TQueue;
Sel: TSelector;
begin
Gen := TGenerator.Create([TotalEntities, ExpTime, InterarrivalTime]);
Que := TQueue.CreateDefault;
Sel := TSelector.Create([NumberOfServers]);
Gen.Connect(Que);
Que.Connect(Sel);
Sel.Connect(1, NumberOfServers, TServer, [ExpTime, ServiceTime]);
Run(Gen); // Launching start block.
// Results.
Que.ShowStats; // Probability of waiting,
// mean waiting time, mean queue length
end;
begin
TotalEntities := 3000; // Initial values of model.
InterarrivalTime := 1;
ServiceTime := 1.3;
NumberOfServers := 2;
Simulate(TMyModel); // Starting model.
end.