Customize resource choice to transport the pallets with a specific forklift - anylogic

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);

Related

How do i recreate a loading truck case with a limited number of trucks?

I have a warehouse with many palletrack which contains raw materials that have to be loaded on trucks and moved to a second warehouse. The loading zones (where trucks are loaded) are the green rectangular nodes (see image). The problem is that I don't know how to recreate the loading. If I use a seize then every single agent will seize a truck, but if I used the pickup block (like the pickup model tutorial), the source would create more trucks than I want(they are limited).
Any tips? (i want to say thanks to all the people who are helping me this week by the way)
Although there are many ways to model this I think the best option would be to batch your agents into truckloads and then to seize the trucks. Trucks must live inside a resource pool, so that you can have a fixed number of trucks.
Since you are using a network model I would then suggest you attach the truck to the batch you created and move it around and then detach the truck and release it afterward. You can however simply seize the truck and have the batch object use the animation of a truck.

Connect the if-else function to a database to get the different ids for storing the pallet types

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 can I create agent populations within an agent population

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

Anylogic: How can you link a population with a source

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.

Anylogic: how to individually address to resources within a Resource Pool

I am using Anylogic where I have just one ResourcePool made by just one Resource Type unit (created through the command "Resource Agent" in the Process Library).
I define the capacity of the ResourcePool, let's say, to 20 and I would like to have each of the single element (or some of them) within the Pool with a different value for the same parameter (e.g 3 units have parameter=1 , other 4 units parameter=2 ...).
First of all how can I set individually each of this parameter? Do I need to use a population of agent? If yes how can I do that? And how can I call the resourcePoolPopulation in other location within the model?
Is there a clevere way to do that?
Hope it is clear, thanks!
That is a weak spot of resource pools, IMO. They are designed to hold a homogeneous "soup" of similar resources and it is hard to pull in a specific element.
However, not impossible, there are various ways. You can create your resource agents manually in an agent population first and add them to the pool manually after creation. Then, in the service object, tick "manual resource unit choice" (or similar) and use a criteria that matches your resource params.