I have an Anylogic model in which vehicles move from point to point on a GIS map. The destination points are loaded from a database (see figure). By using a source block, the order details are mapped into a population of agents (Type Order). This set of orders is used to guide a vehicle over the GISmap. Now, I would like to know the distance that the vehicles traversed. However, I run into some troubles.
The locations from the database can only be mapped to a parameter type string. This is annoying because this means that I can't use the "distanceTo" function for example. Is it possible to map the strings from the database to an agent of type location (which is a GISPoint)?
DB snapshot
What you need is an object that maps the location name (String) to an actual Agent (your location). You can use a LinkedHashMap for this
And then in the On startup: code of your location agent, you simply add it to the map.
Now you can access the actual agent using the location name so you can do
getDistanceTo(mapOfNameAndAgents.get("Boxtel"))
Related
I have two populations of agents (only one of which I want to control) and I want to program one agent's actions based on the distance to the agents in the other population. I can get the location of each agent in their own population by using getX() and getY(). However, once these values are stored in a variable, they are not able to be communicated to a different population. Also, using distanceTo (agent other) does not seem to work for agents in a different population. Another issue I am having is how to call up location information for a specific agent (i.e., agent 1 in a population of X agents). When I print the agent names during a model simulation run, I see the agents listed as root.agent[0], etc., however, this syntax does not seem to work for calling up that specific agent when trying to code specific actions based on that agent (i.e., when this agent is so close, do something).
I tried storing locations using getX() and getY() into separate variables. Then using those variables to perform distance calculations. However, these variables, when stored in agent1 agent type, they cannot be communicated to agent2 agent type for variable use. I tried this for distanceTo() as well and got similar errors. I also try calling root.agents[0], root.agent[0] and agent[0] to use for distance calculations (both in and out of that agent's agent type) and get errors for "variable root not recognized" and "variable agent not recognized."
I understand this may be a beginning level programming question, but I cannot find literature on how to solve this problem in AnyLogic help sites online, nor have I been able to find a specific tutorial that works with this type of issue. Thank you for the help.
During the creation of a generalized warehouse model, I ran into a problem when trying to create an order event that can be used by order pickers to retrieve the products from the storages racks. Currently, I am using a source block which creates "orders" of a single type of pallet (1 to 5). The pickers each travel to pick up a pallet from the rack and transports them to the next location.
Question: How can I create an order consisting out of several pallets consisting of different types.
Question: How can I use a single picker (resource) to pick multiple pallets in a single run through the warehouse before transporting all the pallets to the next location (process).
Kind regards,
Stefan
Question 1
normally i would create a class for the higher level order (say Pickwave class).
And when instantiating it you need to save a list of actual picking orders(pallets) into it (say collection of type ArrayList<Order>).
And to process your pickwave you can use a loop which will steer your resource/transporter/picker to the next Order location until all orders are picked. If everything is picked you exit your loop and move to your next location
Question 2
you don't really pick the orders as you would normally pick them using RackPick block in 1-to-1 scenario. But as you have a refence to all your orders inside you pickwave object you can still control their location/animation programmatically.
I would like to store my pallets into my pallet racks if the set conditions of my function are true. So now I have to connect the function to the determine ids (typeIDs) in my database that the function could loop through all entries in my dbase table and assign the pallet types to the pallet racks. After that the typeID should be resolved and when it comes to the store block the parameter typeID in my function should be connected to the dbase and the different ids get assigned to my deposit pallet racks PRD6,PRD7 and PRD8.
Could someone exactly say me how I could solve that?
I attached the dbase, the store block and the function.
Thank you for your help.
You are using a wrong approach, I think.
Your dbase table should create custom agents that you name "Pallet" (or similar). In there, you have a parameter typeID(integer).
You create those "Pallet" agents at the arrival time from the dbase and map the id column value to the agent's parameter typeID (see AnyLogic help and example models on parameter mapping).
Now, each Pallet knows its pallet-rack ID.
When the pallet needs to be stored into a pallet rack, that is when you use your function getMyPalletRack function (which must sit in your "Pallet" agent type).
cheers
how is it possible that the sourceof a process model only creates the agents out of a population and in best case at once? In my model the source is creating more agents than the size of the population.
thx in advance
Using a Source it is not possible to output already existing Agents of a population from it, as the source is always creating them at the time of output.
You have two possibilities:
Instead of a Source, use the Process Modelling element Enter at
the start of your process flow. Using the function
enter.take(myPopulation.get(index)) you can input your already
existing population members. This way you can also input them "at once".
In the Source properties under Advanced - Population select your
custom population. Whenever the source creates a new Agent, it will
get added to this population. Note: The Agent type of the population
must be the same as the Agent type defined in the Source.
I built a custom CHAID tree in SPSS modeler. I would like to assign the particular terminal nodes to all of the records in the dataset. How would I go about doing this from within the software?
Assuming that you used the regular node called CHAID, if you select inside the diamond icon (created chaid model) in the tab configurations the rule identifyer, the output will add another variable called $RI-XXX that will classify all the records within the terminal nodes. Just check that option and then put a table node after that and all the records will be classified.
You just need to apply the algorithm to whatever data set you need, and you only need to inputs to be the same (type and eventually storage).
The diamond contains the algo and you can disconnect it and connects to whatever you want.
http://beyondthearc.com/blog/wp-content/uploads/2015/02/spss.png