Anylogic: How can you link a population with a source - anylogic

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.

Related

Multiple agents arrival based on Variable and database column

In my source block I want to be the amount of agents based on two different factors namely the amount of beds and visitors per bed. The visitors per bed is just a variable (e.g. visitors=3) and the amount of beds is loaded from the database table which is an excel file (see first image). Now I want to code this in the code block as shown in the example in image 2, but I do not know the correct code and do not know if it is even possible.
Simplest solution is just to do the pre-calcs in the input file and have in the dbase.
The more complex solution is to set the Source arrivals as:
Now, you read your dbase code at the start of the model using SQL (i.e. the query constructor). Make the necessary computations and create a Dynamic Event for each arrival when you want it to happen, relative to the model start. Each dynamic event then calls the source.inject(1) method.
Better still is to not use Source at all but a simple Enter block. The dynamic event creates the agent with all relevant properties from your dbase and pushes it into the Enter block using enter.take(myNewAgent)
But as I said: this is not trivial

how to custom drop-off block according to agent type

Using previous pick-up blocks, i have an container agent with two different agent types inside (Myagent and Myagent1). I want to insert two different drop-off blocks,the first for Myagent and the second for Myagent1. the problem is which element type i should choose for the drop-off block. For example, if i chose Myagent, it would give me error because of Myagent1:
If i chose Agent then:
Both the agent have a parameter named cc.
(I read other answers on the forum like Drop-off specific custom agents using drop-off block in anylogic, but i still have this error).
thanks for the help.
The best option here is to create a parent agent type that has 'cc' property and have the two types of agents inherit from it as described here. Also as a side note, you should probably take care to name the agents and properties with something meaningful as it will help to understand the model and explain it should you need to ask for help in the future.

AnyLogic: Use arrival table and a parameter database together in one source block

for an analysis of a production process, I want to spawn agents in my source block according to past real data.
For that, I want to use an arrival table to make sure that the agents spawn at the correct time.
But I also need to give my agents different parameter variations.
For that, I want to use the "Set agent parameters from DB" checkmark.
However, it seems that I can't use both of them combined. Is there a way to use an arrival table and a parameter DB combined?
Thanks a lot in advance.
Yes, you can. You need to use a single table for all the information regarding the agent.
See the example table below
You also need to create a customer agent for your source with parameters you want to populate from the DB
Then in the source you can select to generate this agent at the "new Agent" dropdown. Then you will be able to populate all the agent parameters from table you specified

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 - pedestrian library

Is there a way to add agents through pedSource but give them nominal values for added parameters?
We have different parameters within a specific agent that are in a DB and want them to be initialized when agent is created in population.
We tried doing it using the advanced option in pedSource but the "from DB " option does not have our added parameters, only the default ones for pedestrian agent.
good to see you here :-)
Sounds like you need to create your own Agent Type to be used for your pedestrians. Create a new agent type and set it up to be used as pedestrians as below:
Next, make your PedSource object create these MyPeds and not the default peds:
Now, you can add your parameters to MyPed as you like. Let's say it has 1 param myParam. To load values from the dbase, also create a MyPed population (drag in the MyPed class onto Main), set it as below:
Last, you need to tell the source object to add any MyPed created to your new population as it will fill the params:
hope this helps