0
votes

I am currently working on an Agent based model in Anylogic which consists of multiple stores with a driver assigned to each store and Customers who place orders and these orders are then delivered to them from the nearest store.

I have created an agent type "Customer" with a certain order frequency event. I know that anylogic allows to assign a GIS location for the agent by placing a node on the GIS map, searching the name of the location on the map or by defining the location programmatically (setLocation(INodenode),setLocation(Point point),setLocation(Agent agent)&setLatLon (double latitude, double longitude)).

However, I want to assign a random GIS location "GIS node" to the customer each time an order is generated.I want to know If there is a certain function that I can use to do that or any other way.

Any help is highly appreciated.

2

2 Answers

1
votes

You can use this code in: Agent actions, On Startup:

Point pt = get_Main().region.randomPointInside();
setXYZ( pt.x, pt.y, pt.z );

If you get "region" cannot be resolved, you should check in the Main tree, presentation, map, if the "region" name is not there that means that you have not made it yet. You can go to the Pallet, Space Markup and use GIS Region to draw the region you want.

0
votes

I don't think you want a random location in the whole world since you don't have customers in the middle of the pacific ocean, the top of mount Everest, the white house or some point in the Antarctic.

So what you really want to do, is to define a GIS region, which is one of the elements that you can find in the same place you find a GIS point, with that you can select on the map the region in which your customers can exist and then you can just select a random point:

region.randomPointInside()

Remember though, that the route to each random point has to be calculated, so this can be quite slow if you have too many random points and deliveries to those points since the route is calculated every time...