How to create a ResourcePool of agents that are instances of an agent type already existing in one of AnyLogic Libraries? - anylogic

How to create a ResourcePool of agents that are instances of an agent type already existing in one of AnyLogic Libraries (for example the Conveyor agent type of the process modeling library)
I tried to do split then Conveyor and service and i combined after but it is not accurate representation of the real life and it creates lots of errors.

Related

How to communicate variables between agent populations in AnyLogic?

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.

Why resourcePool agents are not accessible from this block?

I have a resourcePool block. The resource units are Worker type.
However, I cant't access this units calling the resourcePool block from conveyor Stations nor from Service blocks. No matter if I use "agent" or "unit" (in Station -> Resource choice condition), I only can access to resourcePool.agents(), which is a list from which I can't access to Worker agent.
Does anyone knows why, and how could I access to Worker agents considering they are created as Resource Units?
You use agent populations for this. Create an empty population of Worker agents and set the Resource Pool (in its Advanced properties) to add units to a custom population (and select your population).
Now all the resource units are accessible via the population.

A question about seizing more than one ressource in Anylogic

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:

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.

AB modeling in anylogic (statechart)

I have a problem where the state of one agent depends on the states of its components. Like I have a machine which consists of 10 different components. each one has its own state chart( the states could be; Operating,failed, under manitenance...etc). So the machine will fail if at least one component fails and it will be up if all of them is operating. What I did is to create the 10 agents and create thier statecharts( please note that each component has different failure rate, repair time..etc that is why i seperate them) and i created one agent for the machine with its statechart(that is dependent on the 10 statecharts), I am stuck here, I could not find way to get the state of the machine based on its components' states.
It should be AB modeling
Thanks alot