How to get agents to follow GIS Route created on-the-fly - anylogic

I'm currently working on a model where agents move to random points in the ocean on a GIS map. I have managed to write code (with constraints mentioned in my previous post) that often create non-straight GIS Routes between the agent's location and the random point on the GIS map, by building an array of GISMarkupSegments, and calling the new GISRoute(this.map, segments) constructor. However, even after constructing this route, the agents do not follow the route. I have read all the relevant documentation and I'm still quite confused on how to get the agents to follow this programmatically constructed GIS route:
At first, I thought I would only need to create the GIS route, and the agent could automatically use it if it's on top of the starting point of the route, but it doesn't seem to find this route, as it throws an error when I turn on "show error dialog" in the map routing settings, meaning it cannot find this route I just created.
Then, I thought I would have to add all the routes to a GIS network and have the agents move along this network, but this doesn't seem to work since the network will need to constantly be added to over time, and once a network is initialized, I can't add any more GIS routes to it.
I think my question boils down to how AnyLogic implements the "create straight route" option under the Routing setting if route is not found for a GIS map, so I can recreate that for my own custom GIS route for agents to take on the fly. i.e. how do I make it so that my agents actually take the GIS route I just created?

Related

Is it possible to convert a (Leaflet) route into a polyline?

I'm currently making a map with roads that I have driven in the past. Right now, for one route I enter a few waypoints, and the route is calculated through these waypoints using OSRM.
It works fine, but the problem is that on every pageload this route will be recalculated (which makes sense, cause that's how routing works). Let's say I have 50 routes, that'll be a lot of requests. However, I want to be able to calculate the route once, and save the line that is generated as a polyline, which essentially caches the route forever.
Since the routes all stay the same, and no recalculation is necessary, this would be the best way, because then I don't need to setup my own OSRM server or pay for a routing service. (I might need to recalculate routes every once in a while, but that's alright).
Is this way of converting/cachine routes possible? It would be great if I could get this project working live without any routing attached to it.
Thanks for your help in advance!

Fetching potentially needed data from repository - DDD

We have (roughly) following architecture:
Application service does the infrastructure job - fetches data from repositories which are hidden behind interfaces.
Object graph is created and passed to appropriate domain service.
Domain service does it thing and raises appropriate events.
Events are handled in different application services which perform some persistent operations (altering repositories, sending e-mails etc).
However. Domain service (3) has become so complex that it requires data from different external APIs only if particular conditions are satisfied. For example - if Product X is of type Car, we need to know price of that car model from some external CatalogService (example invented) hidden behind ICatalogService. This operation is potentially expensive one (REST call).
How do we go about this?
A. Do we pre-fetch all data in Application Service listed as (1) even we might not need it? Do we inject interface ICatalogService into given Domain Service and fetch data only when needed? The latter solution might create performance issues if, some other client of Domain Service, calls this Domain Service repeatedly without knowing there is a REST call hidden inside it.
Or did we simply get the domain model wrong?
This question is related to Domain Driven Design.
How do we go about this?
There are two common patterns.
One is to pass the capability to make the query into the domain model, allowing the model to fetch the information itself when it is needed. What this will usually look like is defining an interface / a contract that will be consumed by the domain model, but implemented in the application/infrastructure layers.
The other is to extend the protocol between the domain model and the application, so that we can signal to the application layer what information is needed, and then the application code can decide how to provide it. You end up with something like a state machine for the processes, with the application code coordinating the exchange of information between the external api and the domain model.
If you use a bit of imagination, you've already got a state machine something like this; as your application code is already coordinating the movement of inputs to the repository and the domain model. The difference, of course, is that the existing "state machine" is simple and linear enough that it may not be obvious that there is a state machine present at all.
how exactly would you signal application layer?
Simple queries; which is to say, the application code pulls the information it needs out of the domain model and uses that information to compute the next action. When the action is completed, the application code pushes information to the domain model.
There isn't enough information to give you targeted good advice. I suspect you need to refactor your domains into further subdomains. It sounds like your domain service has way more than 1 responsibility. Keep the service simple.
In addition, If you have a long running task like a service call that takes a long time, then you need to architect it away. The most supple design will not keep the consumer waiting. It'll return immediately with some sort of result to the user even if it's simply a periodic status update.

Route Costing in Anylogic

I am trying to simulate a manufacturing system that uses Automated Guided Vehicles (AGVs) to carrying loads around the network to be processed. While the AGVs are travelling, it is ideal for them to pick the fastest route to the destination (not necessarily the shortest).
Here is my model
I am kind of stuck at trying to implement a route costing algorithm, because I am not too familiar with the intricacies of this program yet. Can anyone kindly give me some rough idea on how it can be implemented in pseudo code with the following scenario:
The load needs to move from A to B and there are three possible paths. However, there is congestion in the red highlighted areas that will cause the load to take a longer time to reach point B.
How can I read the network to check for congestion and also calculate the various times needed to go to point B?

Routing using OSRM for multiple profiles - does profile in the URL actually do anything?

With ORSM there are 3 profiles for different modes of transport, cycle, foot and car. These come with OSRM.
According to the following post which was made 1 year ago, OSRM does not support multiple profiles:
OSM routing (OSRM): do I need to duplicate all data for different profiles?
Yet in the official documentation there is a profile argument as part of the URL called for retrieving a route from a running OSRM instance:
http://project-osrm.org/docs/v5.6.4/api/#general-options
The path would look something like this:
http://router.project-osrm.org/route/v1/driving/
Without driving, foot or cycle in the URL a route won't be retrieved so one of them is required for the API, yet if I compile a route for car on the server, but then use /foot/ in the URL to retrieve a route, it will still retrieve a car based route, completely ignoring 'foot'.
Could anybody from OSRM explain why something as useful as multiple profile support has been withdrawn, and what the point of driving is in the above URL seeing as it is ignored anyway and just appears to use the profile attached to the running instance of OSRM?
The solution to the problem of multiple profiles appears to be to host parallel copies of the routing machine for each profile and address different IP's, so again, what is the point of 'profile' in the URL?
Could anybody from OSRM explain why something as useful as multiple profile support has been withdrawn
The support has never been there. You will need to run separate osrm instances for each profile.
The URL option is merely there to make it easier to stick a nginx in front of your OSRM instances and distribute to the correct instance based on profile string.
We might implement multiple profiles in the same OSRM instance in the future, but this is still far out.

where does common/global data go in mvvm?

I'm trying to get my head around mvvm and came up with a test application that I think will give me a good foundation. Suppose my application has a service that goes out every minute and gets the latest flight arrival and departure information at an airport. Now suppose I have 3 different views: InboundView, OutboundView and GateView. The Inbound and Outbound views would simply display the various flight details for inbound and outbound flights that I'm sure we've all seen on the flight boards in the airport. The GateView would display similar flight information but might be sorted by gate # instead of flight #.
So the model for the Flight object would contain the flight data details as well as an instance of a Gate object that would be updated appropriately once a flight arrives.
So all 3 views are using the same flight data service and I know I can pass an instance of that service to each VM but then I'd need to hook up the appropriate INPC events at each view model and that seems less than ideal as the number of views/vms increases.
Right now, each VM uses a ListCollectionView wrapped around the passed in collection of flight data and I just sort/filter based on inbound/outbound, etc.. but I was hoping to incorporate the service results into a sort of parent view model that would then pass a reference to itself along to the sub-views and then I could just handle all the INPC, etc.. events at the parent view model level and those will automatically trickle down to each of the subviews if data on a particular flight changes (such as its gate) instead of having to handle that separately in each of the VMs.
I've looked into the Messenger framework for MVVM Light but it still seems like each of the sub-VMs would have to register for the message and respond to it individually.
Does that make sense? Am I on the right track here?
So all 3 views are using the same flight data service and I know I can pass an instance of that service to each VM but then I'd need to hook up the appropriate INPC events at each view model and that seems less than ideal as the number of views/vms increases.
You don't necessarily have to do this, if the "service" implements INotifyPropertyChanged. Remember, you can bind to a property within a property, ie: {Binding Path=FlightService.Gate} or whatever, which may work. (It's difficult to know your requirements here, though.)
I've looked into the Messenger framework for MVVM Light but it still seems like each of the sub-VMs would have to register for the message and respond to it individually.
Yes, if you wanted to use a messaging framework, you would need this to be handled in each of the ViewModels. Alternatively, you could use some form of service location or constructor injection to "pull in" the flight service. The latter is my personal preference here.
The advantage of handling this in each VM is that each VM will likely want to handle things somewhat differently (otherwise, why is there more than 1?). By pulling a reference to the service in via IoC, you can handle this anyway you need to.