I am having this issue with Anylogic, hope to get some help :)
The situation is the following: I have a population of agents X that has 10 different agents inside it, I need to pick up these different agents and put them in the "container agent" which is my pallet, and finally store them in the Pallet Rack.
The agents are different products being produced in the same location. There is a database stating each product when will it be produced and the amount of it.
I have created the agent X, how can I create 10 different agents within it?
If you want to have an agent population within an agent population, do this:
Have an agent type "Containers"
drag that into Main to create a population "pop_Containers". Load it as you like
Create another agent type "Products"
Open the "Containers" agent type and drag in "Products" to create a "pop_Products" within "Containers"
Load your products for each container as you see fit. This depends on your specifics of your database structure.
For the other questions, please create new questions. StackOverflow works best with specific questions in each topic, see https://stackoverflow.com/help/how-to-ask
Related
I am working on my thesis associated with modeling farmers' behaviors in a river basin. I am having 6
agents that contain different populations of farmers. These farmers have been located on the GIS map as the environment (main) in anylogic. I also defined the connection between populations of 6 agents by coding on the main startup and using "Link to Agent". Now, I'd like to define agents' behaviors through statecharts. But I have some difficulties. I have to compare the income of each farmer to the income of all connected farmers. How can I do that? What I have tried to define condition transition and write (for example if the income of each farmer is less than the income of all connected farmers in its network then do specific action):
IncomeT<ALL_CONNECTED.IncomeT
but it didn't work. Got any suggestions?
Thanks.
not quite clear who is your agent for which you are designing your state chart. Is it some entity (say Area) which contains a population of farmers? If yes, then why would you connect/link one Area to another? If you agent is a famer (which is not how you described it, but seems logical) then you would just store (and update) "minimum population income" in some variable and compare individual income with that stored value.
Alternatively you can use min() function. More on that: https://help.anylogic.com/index.jsp?topic=%2Fcom.anylogic.help%2Fhtml%2Fdata%2Fcollections-statistics-api.html
I'm working on a supply chain project with AnyLogic. In my model which is similar to product delivery example in AnyLogic examples, there are two agents which are Retailer and Fulfillment center. Both have their own vehicles. What I'm trying to do is to share vehicles so retailers and Fulfillment centers use the vehicles of each others. What I did is to create two Ressource Pool in each agent. So in the seize block as it shown below in picture, I added two ressource sets . In each statechart of each vehicle as it shown below and after delievering products, I informed my vehicle to go back to his initial location and in this case it can be Retailer or Fulfillment center. However after simulation, I got an error message in console that tells me that my agent which is the vehicle is trying to move to unknown source
If you put 2 ResourcePools into 2 agents, you have 4 pools in total. But you only want 1 shared pool, right?
Only add 1 ResourcePool to Main and use that from both agent's Seize elements. You will not be able to select the pool in the usual dropdown list (as there is no pool in either agent) but you can easily use the dynamic code to specify it. Note that the code below assumes both agents are embedded in Main:
I would like to store pallets with the forklift where id=1. I create a database with the different IDs and connect it with my forklift population. After that I create a custom resource choice condition where the forklift with id=1 should store the pallets. It doesn't work, the process stuck and the forklift doesn't move.
database
agentpopulation
resourcepool
rackstore_resourcechoicecondition
this is the typical error in which you created a population of Forklifts and then you think they will magically become part of your resourcepool... but they don't... they are just forklifts that will not even show in your simulation and will do nothing... the forklifts that are shown in your simulation are the ones generated throught the resourcepool NOT using the database... using custom population doesn't mean that the resourcepool will use the population you created with your database.
SOLUTION
To do what you want to do, first be SURE to erase that population you just created... forklifts will be nothing but a resource type
Second be sure that your database doesn't have the same name than your forklift agent type or population.
Then in your resourcepool capacity use:
(int) selectFrom(forklifts_db).count()
note that im using forklifts_db as your database to be sure you are using a different name
Then on new unit, use this
((Forklift)unit).id=(int) selectFrom(forklifts_db)
.where(forklifts_db.id.goe(self.size()))
.firstResult(forklifts_db.id);
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.
A big container has 100 open boxes in a row, and each box has 3 items in it. There is a trolley which picks up items in a specific box(say based on its Id) one by one and drops them at another location and then goes to another box and so on. Basically, the trolley has the order in which it has to pick boxes.
I am new to anylogic. I might be having wrong thinking, but here is my idea.
I thought of modelling Big container as one agent type, Box as another agent type, item as another agent type and create a collection of 3 items in box agent, collection of 100 boxes in big container agent. Is this a right way to model? Also, I am not knowing how to animate the big container with boxes which have items in it.
Please let me know if there are any ideas on how to model this scenario. Thanks.
correct approach, I would say.
To embed Agent B into Agent A, open Agent A and drag in Agent B from the "Projects" view. That creates a population of B within A. Set its properties accordingly (i.e. the number of B's in A...)
Re animation: You need to understand relative coordinates with embedded agents. Play around with adding an image to A, B and C at their center coordinates and check out how it looks at runtime (it will be all on top of each other).
Then, experiment with changing the location to see the impact. AnyLogic help also has good explanations how it works.