Reputation: 1
I'm simulating the operation of a railroad. I have a table with train departure time, departure location, and arrival location data. Locations are given using longitude and latitude coordinates. I created my rail yards on the GIS map using their coordinates. I can make the trains depart following the schedules in the table and the correct departure location. But I can't get them to go to the right destination. When trying to use the moveTo block you can only indicate a single destination. In my simulator, each train will go to a different yard.
How can I perform this movement using a data table and geographic coordinates?
Some pertinent remarks: I'm not using the rail library. I'm working in the GIS space with routes determined by Anylogic itself. I didn't design or import railroads.
For this reason, I'm using the "source" and "moveTo" blocks from the process modeling library.
In the "moveTo" block I didn't find options that allow me to use the longitude and latitude data of the destination and which are stored in the data table (as I do in the "source" block). Whenever I try to insert some code that does this, Anylogic returns saying the error: "Exception during discrete event execution: root: Non-unique value in the database!"
Upvotes: 0
Views: 358
Reputation: 3975
It is better to rather use an agent-based approach for this kind of movement instead of doing it using move to blocks. It is hard to explain here but do some more tutorial examples and you will understand. You want the agents to move at a specific time and in a process flow modelling approach unless you use delay or hold blocks agents will flow from one block to the next as soon as there is space.
Here is an example of how to do it using the agent-based approach using your setup.
I have an agent called Trem with a dynamic event to move it to a specific location.
Now we populate the dynamic events with data from the database at the start of the model using the code below.
List<Tuple> rows = selectFrom(db_table)
.list();
for (Tuple row : rows) {
//What is the start time of the movement
double timeToTripBegin = dateToTime(row.get( db_table.trip_begin_time ));
//Lets create a new movement event to trigger the movement in the future
create_MoveToLocation(timeToTripBegin,
row.get( db_table.latitude_chegada ),
row.get( db_table.longitude_chegada ));
}
These events will then trigger the required movement for us when the event executes.
Upvotes: 0