The Problem: I have database tables (imported excel) with orders and locations. The orders have a column called "destination" that is cross referenced (using "Foreign Key" to reference locations.location) to the location column locations table which is supposed to represent the actual INode. How do i specify this address say in a moveTo block?
you cannot represent AnyLogic objects like INode
as database entries. Instead, you can store characteristics about the node and create nodes programmatically at the model start.
So store things like X/Y coordinates, etc.
Below is an example for GIS points to show you the approach. You need to do something similar for INodes (check the AnyLogic help for INode API to learn how to create them).
I store the location name as a string in the dbase:
On the model startup, I programmatically create GISPoint
elements from the data (assumes I have a GIS map called map
):
List<Tuple> rows = selectFrom(routes)
.list();
for (Tuple row : rows) {
GISPoint locationFrom = map.searchFirst(row.get( routes.location_from ));
GISPoint locationTo = map.searchFirst(row.get( routes.location_to ));
map.add(locationFrom);
map.add(locationTo);
GISRoute route = map.getRoute(locationFrom.getLatitude(), locationFrom.getLongitude(),
locationTo.getLatitude(), locationTo.getLongitude());
route.setLineColor( spectrumColor(uniform_discr(1,10), 10) );
}