Unable to assign values to a parameter using Custom Distribution in Anylogic - simulation

I have an agent Container which has a parameter carrier; carrier can have two values Truck or Train which I have assigned using an option list. I have created an instance of Container in Main which is a population of 10 containers. I've created a custom distribution to assign values(Truck/Train) to carrier where no. of observations for Truck is 30 & for Train is 70.
When I run the model, I can see only a single value for carrier(Train). I want to have 10 values where Truck-Train will be in a ratio of 30-70. How can I do that? A snapshot of the properties of agent and carrier distribution is attached below.
Thank you in advance.
carrierDistribution properties
container-agent properties

I figured out that I wasn't looking at the right place for the parameter values. So, I have an instance of my agent Container in Main which is a population of 10 agents. When I run the model and go to developer pannel, there will be agent numbers(0-9). When I scrolled through each agent, I could see different values for my parameter carrier.

Related

AnyLogic if condition selectOutput

I'm modelling a manufacturing line in anylogic. Two agents are being processed and transported via the same conveyor. Both Agents need to spend diffent delay times in a service station. Because of that i added two parallel services and now i want to sort the agents arriving on the conveyor to their corrosponding service stations.
flowchart
Agent1 needs to go to service and Agent2 to serviceT.
I assigned parameters to both Agents, Agent1 has the boolean parameter "S" set to true and Agent2 the same parameter set to false.
To sort the Agents in the selectOutput block i typed in the if condition agent.S == true as seen in the next screenshot.
selectOutput
Anylogic prompts following error: "Unresolved compilation problem: S cannot be resolved or is not a field"
What can i do about this?
Thank you!
I would like to answer this question in two parts:
Instead of using a selectOutput to model different delay times for the SAME station, it would be more reasonable to have only ONE service representing that ONE station. To model different times, set the delay time equal to agent.S where S is the delay time for each agent.
Regardless of whether you choose what I suggested or what you are already using, you will still get the same error. The reason for this error is most likely that you haven't specified the agent type going through the select output properly. In fact, if you look at the image of the select output properties you shared, under the "Advanced" tab, the agent type is set as the default type Agent. Make sure to replace that by the agent type that contains the parameter S.

How to compare conditions of an agent with all connected agents in statechart

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

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