AnyLogic: Set Agents to Nodes on a GIS Map - maps

I am working within a project team and we want to create kind of a digital twin showing all the logistical streams within a city. We therefore already implemented all the stores, pharmacies, doctors, etc. as individual GIS points. In the next step we want to apply certain agents to the GIS points.
Therefore we tried to create a population of agents which we thought we could later on connect to the correct nodes representing the adress within the GIS map. Thats where our problem occured. We were only able to select one node although we set our population of agents to the amount 10. Is there a trick how to solve the problem or do we have to forget our approach and instead have to consolidate all of the adresses within an excel sheet which we can use as a database for our agents.
Thanks a lot in advance :)

on the node initial location you can use a function that retunrs a GISPoint
On this function you establish the rules you need in order to place the agents randomly accross the nodes or in a way that you want
for example if the function does this::
if(randomTrue(0.5)) return gisPoint;
else return gisPoint1;
all the agents would be placed randomly on gisPOint or gisPoint1

Related

When to use an array vs database

I'm a student and starting to relearn again the basics of programming.
The problem I stated above starts when I have read some Facebook posts that most of the programmers use arrays in their application and arrays are useful. And I started to realize that I never use arrays in my program.
I read some books but they only show the syntax of array and didn't discuss on when to apply them in creating real world applications. I tried to research this on the Internet but I cannot find any. Do you guys have circumstance when you use arrays. Can you please share it to me so I can have an idea.
Also, to clear my doubts can you please explain to me why arrays are good to store information because database can also store information. When is the right time for me to use database and arrays?
I hope to get a clear answer because I have one remaining semester before the internship and I want to clear my head on this. I do not include any specific programming language because I know most of the programming language have arrays.
I hope to get an answer that can I can easily understand.
When is the right time for me to use database and arrays?
I can see how databases and arrays may seem like competing solutions to the same problem, but you're comparing apples and oranges. Arrays are a way to represent structured data in memory. Databases are a tool to store data on disk until you need to retrieve it.
The question you pose is kind of like asking: "When is the right time to use an integer to hold a value, vs a piece of paper?" One of them is a structural representation in memory; the other is a storage tool.
Do you guys have circumstance when you use arrays
In most applications, databases and arrays work together. Applications often retrieve data from a database, and hold it in an array for easy processing. Here is a simple example:
Google allows you to receive an alert when something of interest is mentioned on the news. Let's call it the event. Many people can be interested in the event, so Google needs to keep a list of people to alert. How? Probably in a database.
When the event occurs, what does Google do? Well it needs to:
Retrieve the list of interested users from the DB and place it in an array
Loop through the array and send a notification to each user.
In this example, arrays work really well because users form a collection of similarly shaped data structures that needs to be put through a similar process. That's exactly what arrays are for!
Some other common uses of arrays
A bank wants to send invoice and payment due reminders at the end of the day. So it retrieves the users with past due payments from the DB, and loops through the users' array sending notifications.
An IT admin panel wants to check whether all critical websites in a list are still online. So it loops through the array of domains, pings each one and records the results in a log
An educational program wants to perform statistical functions on student test results. So it puts the results in an array to easily perform operations such as average, sum, standardDev...
Arrays are also awesome at keeping things in a predictable order. You can be certain that as you loop forward through an array, you encounter values in the order you put them in. If you're trying to simulate a checkout line at the store, the customers in a queue are a perfect candidate to represent in an array because:
They are similarly shaped data: each customer has a name, cart contents, wait time, and position in line
They will be put through a similar process: each customer needs methods for enter queue, request checkout, approve payment, reject payment, exit queue
Their order should be consistent: When your program executes next(), you should expect that the next customer in line will be the one at the register, not some customer from the back of the line.
Trying to store the checkout queue in a database doesn't make sense because we want to actively work with the queue while we run our simulation, so we need data in memory. The database can hold a historical record of all customers and their checkout outcomes, perhaps for another program to retrieve and use in another way (maybe build customized statistical reports)
There are two different points. Let's me try to explain the simple way:
Array: container objects to keep a fixed number of values. The array is stored in your memory. So it depends on your requirements but when you need a fixed and fast one, just use array.
Database: when you have a relational data or you would like to store it in somewhere and not really worry about the size of the objects. You can store 10, 100, 1000 records to you DB. It's also flexible and you can select/query/update the data flexible. Simple way to use is: have a relational data, large amount and would like to flexible it, use database.
Hope this help.
There are a number of ways to store data when you have multiple instances of the same type of data. (For example, say you want to keep information on all the people in your city. There would be some sort of object to hold the information on each person, and you might want to have a data structure that holds the information on every person.)
Java has two main ways to store multiple instances of data in memory: arrays and Collections.
Databases are something different. The difference between a database and an array or collection, as I see it, are:
databases are persistent, i.e. the data will stay around after your program has finished running;
databases can be shared between programs, often programs running in all different parts of the world;
databases can be extremely large, much, much larger than could fit in your computer's memory.
Arrays and collections, however, are intended only for use by one program as it runs. Your program may want to keep track of some information in order to do its calculations. But the data will be in your computer's memory, and therefore other programs on other computers won't be able to access it. And when your program is done running, the data is gone. However, since the data is in memory, it's much faster to use it than data in a database, which is stored on some sort of external device. (This is really an overgeneralization, and doesn't consider things like virtual memory and caching. But it's good enough for someone learning the basics.)
The Java run time gives you three basic kinds of collections: sets, lists, and maps. A set is an unordered collection of unique elements; you use that when the data doesn't belong in any particular order, and the main operations you want are to see if something is in the set, or return all the data in the set without caring about the order. A list is ordered, though; the data has a particular order, and provides operations like "get the Nth element" for some number N, and adding to the ends of the list or inserting in a particular place in the list. A map is unordered like a set, but it also attaches keys to the data, so that you can look for data by giving the key. (Again, this is an overgeneralization. Some sets do have order, like SortedSet. And I haven't even gotten into queues, trees, multisets, etc., some of which are in third-party libraries.)
Java provides a List type for ordered lists, but there are several ways to implement it. One is ArrayList. Like all lists, it provides the capability to get the Nth item in the list. But an ArrayList provides this capability faster; under the hood, it's able to go directly to the Nth item. Some other list implementations don't do that--they have to go through the first, second, etc., items, until they get to the Nth.
An array is similar to an ArrayList, but it has a different syntax. For an array x, you can get the Nth element by referring to x[n], while for an ArrayList you'd say x.get(n). As far as functionality goes, the biggest difference is that for an array, you have to know how big it is before you create it, while an ArrayList can grow. So you'd want to use an ArrayList if you don't know beforehand how big your list will be. If you do know, then an array is a little more efficient, I think. Although you can probably get by mostly with just ArrayList, arrays are still fundamental structures in every computer language. The implementation of ArrayList depends on arrays under the hood, for instance.
Think of an array as a book, and database as library. You can't share the book with others at the same time, but you can share a library. You can't put the entire library in one book, but you can checkout 1 book at a time.

How to store location data to speedup distance calculation?

I am working on to create an application which will fetch a list of all the hospitals within a certain radius of the user's location. So in-case we have in our database a list of all the hospitals of this planet with there GPS locations, will we need to find distance of the user with each one of them and then list the hospitals which are at less than the prescribed radius? With multiple users accessing our application concurrently, it may crash our servers. Is there a way to optimize this?
How should I store the location data of the hospitals such that the p
Although your question does not seem quite finished, I recommend taking a look at R-trees as your data structure of choice:
http://en.wikipedia.org/wiki/R-tree

Database for storing structures like Mind Map

Good day!
I need to find a base for storage and processing complex structured information.
Something like a mind map. Need to have some arbitrary values ​​in groups with connections to each other, connection must also have titles.
The biggest problem is that I need to get all the related values ​​without knowing exactly what are the connections and how many of them.
For example:
With VALUE 3 connected
VALUE 1 from the group A as NAME OF COMMUNICATION 1
and VALUE 2 from group B as NAME OF COMMUNICATION 2
and ...
Before any level of the connections (i.e., the values ​​of all properties connected to the associated properties, and for these properties and so on until a predetermined level) - but it can be implemented in the application logic.
I looked at some noSQL base, but they do not allow such requests without knowing the exact value or links. I pondered on the mysql development with a lot of logic in the application to handle all this, but perhaps there is a more suited storage for such a task?
I would be grateful for any help.
http://magika.tk/struct.png - A schematic example.
As Philipp says mind-maps are a type of graph, usually a spider diagram. A graph based NoSQL databases, such as Neo4j would be suitable. Here's a longer list. Graph databases store information about the nodes and the edges. Each node has a pointer to all its adjacent nodes so counting connections and groups should be very fast.

How to find all towns/cities within a driving distance of a particular city?

I am looking for an API to return a list of cities, given the current city (may be coordinates) and some specified driving distance. If driving distance is unfeasible, the list of cities within a radius is also acceptable. Any suggestions on what I can use to accomplish this?
I'm not quite sure why you would do something like that, but you have multiple ways to do so.
Easy way:
You need to get an area and create multiple location around your point (or your given city that you would geocode) and then you can use services that give you a multiple reverse geocoding feature like Here Platform does for example. In this way, you would get multiple cities and then you could filter the duplicated entries.
See: https://developer.here.com/rest-apis/documentation/geocoder/topics/request-first-multi-reverse-geocode.html
Complicated way but way more powerful:
Using the Here Platform, you can retrieve Drivetime area (also called isochronous) so based on a location and a duration, you can retrieve the geometry based on the selected transport mode.
See: http://developer.here.com/rest-apis/documentation/enterprise-routing/topics/resource-calculate-isoline.html#resource-calculate-isoline
Based on this geometry, you can create point as explained before or you can use your own database to query on which would contain city geometries for example.
Hope this helps, I know it's only explained and not coded (no code samples here), but it works for sure. I'll try to put more concrete cases but I'm sorry not now.

Database design for storing temporary data to be used in code

I am new to databases and so am having a little trouble thinking in terms of DB design. If this is not the correct place or way to ask this question, I will be happy to move it to the correct place if told.
I am working on a problem where I go through multiple drives on multiple user machines and store a list of directories I want to use and another list I don't want to use for each volume. These directories can be quickly ascertained/verified so these will be modified over time. This is just a starting point to the actual problem I have to solve, which is doing more stuff on the files in the "to use" list above. The code that actually acts on these directories is a different service and so needs this list to use from somewhere.
I am kind of stuck coming up with a way to store this in a DB on the backend. Since these directory lists are different for different users/volumes I do not know how long or how short this list will be. So do I store these in a DB or somewhere else?
EDIT: To make the question a little more generic, if you have a variable number of data (strings) to be shared between two services during computation how do you store them? How do you create a table to store a variable number of items? In code its easy to just store them in a array you can malloc as the need changes. Its much easier to store them to a file but it does not work across services because these services can be located anywhere.
Thanks for any pointers.

Resources