0
votes

I have a database table (id, arrivalTime, flightNumber) and I have created a population of agents from this table. I would like a pedestrian to show up at each arrivalTime from a target line in the model. I (incorrectly) assumed this would be a breeze using a schedule but I have had no luck. Any suggestions on how perform this in anylogic?

2

2 Answers

0
votes

There are other ways but you can use this one since all your agents are already generated:

Let's assume your model time units are minutes... make a function called getDateDifference returning a double:

long diff = date.getTime() - date().getTime();
double diffMinutes=(int) (diff / (60 * 1000));
return diffMinutes;

Then in each one of your agents create an event with the following code:

pedSource.inject();

that event will be triggered by a timeout equal to getDateDifference() minutes.... but then you will have only 1 pedestrian arriving per arrival in your database... But maybe that database is associated with pedestrian arrivals. Or planes? I don't know...

0
votes

First let me thank Felipe for answering so quickly. I did work on this a bit in the morning and was able to determine a partial solution.

My Data was set as such: (note my arrival times are in decimal 24-hours)

db_table id[int] arrival_time[double] flight_number[int] 1 .1701 XYZ 2 .1714 XYZ ...

I was getting confused with the 'Repeat every:' portion of the schedule. This essentially set the granularity of injections so if you wish to inject a pedestrian created from a data table in a seconds time frame:

  1. Set 'Repeat every' to 86400 seconded (one day in seconds)
  2. Ensure that your data is in seconds... so to create a new pedestrian at 1 minutes the arrival_time should equal 60 and of course for 5 minutes arrival time should equal 300.

Below are images of my sample data table in my database and the properties of the schedule added to main. Running this will add one pedestrian when the run-time is equal to the arrival_time.

enter image description here

enter image description here

I still do not believe this create 'MyAgents' which are a population of agents created from the database table??? Need to work this.

Regards,