Aron T.
Aron T.

Reputation: 448

Multiple agents arrival based on Variable and database column

In my source block I want to be the amount of agents based on two different factors namely the amount of beds and visitors per bed. The visitors per bed is just a variable (e.g. visitors=3) and the amount of beds is loaded from the database table which is an excel file (see first image). Now I want to code this in the code block as shown in the example in image 2, but I do not know the correct code and do not know if it is even possible.

Database Sourceblock

Upvotes: 0

Views: 300

Answers (1)

Benjamin
Benjamin

Reputation: 12793

Simplest solution is just to do the pre-calcs in the input file and have in the dbase.

The more complex solution is to set the Source arrivals as: enter image description here

Now, you read your dbase code at the start of the model using SQL (i.e. the query constructor). Make the necessary computations and create a Dynamic Event for each arrival when you want it to happen, relative to the model start. Each dynamic event then calls the source.inject(1) method.

Better still is to not use Source at all but a simple Enter block. The dynamic event creates the agent with all relevant properties from your dbase and pushes it into the Enter block using enter.take(myNewAgent)

But as I said: this is not trivial

Upvotes: 1

Related Questions