I am busy modeling a truck yard where trucks arrive in bays and are offloaded and then loaded again by the same worker.
I have built the model in detail using transfer stations etc. but now I want to set-up the essence of the model so that it will be easier to run experiments on it. The variables that will be changed in the experiment manager are number of workers and number of bays.
The easiest will be if it possible to use a ParallelProc but then the importer request a new worker for every truck that enters (Workerpool setting as workers can work remotely, then workspace amounts do not matter).
Is this possible?
Solved! Go to Solution.
There are some points connected with the ParallelProc you should take into account:
- you don't have a place(bay-) based statistics (usually you need the ulilization for each bay)
- the ParallelProc requests the services en bloc, not depending on the number of occupied bays
So it may be better to prepare the (maximum number of) bays and connect them dynamically with the entrance based on the number in the experiment in a init-method.
One more question regarding this; is there a simpler approach to dynamically change the number of workers in the workerpool?
I currently have the following in the INIT method with "number_of_workers" as a root variable:
is workers: table[object,integer]; do --set number of workers in the workerpool workers.create; workerpool.getCreationTable(workers); workers[2,1] := number_of_workers; workerpool.setcreationTable(workers); end;
If anyone is interested, the coding to connect the bays is as follow:
INIT Method: I inserted a variable "Number_Of_Bays" which sets the amount of connections to make (Max: 10)
--Connect the number of bays selected for local i:=1 to Number_Of_Bays loop /*This command connects the Truck Queue to Bay1, Bay2 etc.. "Bay" and the i value of the loop are combined as strings, and then converted to an object so that the command works*/ .materialflow.connector.connect(Truck_Queue,str_to_obj("Bay"+to_str(i))); next;
RESET method: In order for the experiment manager to start connecting the bays from new in every run I wrote the following:
--Delete all the connectors at the end of the simulation --unless they are already deleted if Truck_Queue.succ /= VOID then for local i:=1 to Number_Of_Bays loop Truck_Queue.succconnector.deleteobject; next; end;
"is there a simpler approach to dynamically change the number of workers in the workerpool?"
I don't think so. The direct access to the worker table is not possible.
It seems that the ".setcreationtable" command has a glitch. If I change the number of workers using the Experiment Manager, it updates the workerpool's creation table but not the amount of actual workers in the model:
See example below:
In the report (looking at the workerchart) Exp1 had 5 workers, Exp2 had 2 workers, Exp3 had 10 workers, Exp4 had 1 worker and Exp5 had 10 workers
It uses the workers from the previous experiment:
the workerpool creates the worker before the init-method is processed (V.11).
Try instead an observer for value in the global variable of the worker-number. It seems to work.
open your variable number_of_workers. In the dialog --> Tools - Edit Observers --> New - Observed value: Value --> Executed method e.g. F4 , insert into the method the setting of the workerpool. This method is called directly after changing the value of the variable (before init).
Ok, I understand now:
So the observer of the value is:
(attribute: string; oldValue: any) is workers: table[object,integer]; do --set number of workers in the workerpool whenever number_of_workers changes workers.create; workerpool.getCreationTable(workers); workers[2,1] := number_of_workers; workerpool.setcreationTable(workers); end;
yes, this is correct.
You can set a debug; into the init-method to check the number of workers in the pool at the beginning of the experiment.