how to custom drop-off block according to agent type - anylogic

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.

Related

Different delay time for different agents in Anylogic

I'd like to know a very simple function of the software Anylogic: I have to set different delay times for different agents in a model, but the software let me see only one boxe and there's no possibilities to specificate what kind of delay time I prefer for every agents. How could I do? Thank you
I tried with some code of Java script but I think that scripture could be available only for the section "Actions" in the different boxes
This is one of the most basic functionalities so check the tutorials as well, but here goes:
Add a parameter 'myParameter' in your agent type of type double.
Give the agents different values for that parameter (cab be dine in the source or where ever you instantiate your agents)
In the delay block code section, use 'agent.myParameter' to access and apply that agent-specific duration.

Moving two agents together

I am creating a model that includes both Material Handling and ABM components. I have an Agent Type that is called "Box" and there are 5 boxes that are placed on a conveyor in main. I have another Agent Type called "Product". The boxes are expected to carry the product. As a result, the box and product are expected to move on the conveyor as one. So, I was looking for something similar to move to agent, but that only works if the agent is not moving (i.e. it won't follow the agent everywhere it would just move to its position at the time the function is called). I can think of many solutions, none being ideal. Some include:
Not really moving the product agent, instead adding an animation shape of the product in the Box agent type and turn it on and off depending on the Product's state.
Using DES blocks (pickup/dropoff), but the problem with these is they convert the two agents to one... I am looking to keep both agents, but have them move together
Using something similar to Attach Resource, but then I'll have to define my Box or Product agent as a resource type
These are some of the solutions that came to mind, but I feel there must be a smoother solution. Any suggestions? Is there an ABM function that can resolve this?
Thanks!

Which are the default attributes of an agent in Anylogic? What is the proper way to copy an agent?

I am trying to figure out which are the main default attributes of agents in Anylogic, e.g., the Id, the position and the index. So far I haven't found them in the help or at stackoverflow.
1) Do you know where this can be found or can you summarize the main you know? For instance the id used as unique identifier or the index used as the position inside of the population.
2) Are there any attributes regarding the agent history? For example time stamps as the creation time or the blocks it has passed through?
3) Is it possible to change the default id attribute of an agent? Can two agents have the same id?
4) As the split block doesn't copy any of the parameters or variables values to the copy, what is the proper way to copy an agent? I noticed in other publication Benjamin mentioned using agent.set_MyParam(original.MyParam). What would be "MyParam" in this code? Would this copy the value of parameters, variables and the current state in the statechart? Is it possible to make a copy and initialize its current state in the statechart as the original agent's current state?
Thank you for your help.
There are many things that are generated when you generate an agent... the best you can do is to check the api for the agent here: agent api
You can only see these things on the log if you activate it, but not from the API
the id is a unique identifier and i've never been in a situation where i need to change it,but if you want to change it, you can use the setId method, in which case, 2 or more agents may have the same id.
you can only use set_MyParam if the MyParam is a parameter, you can't do the same with variables. Nevertheless, if you want to copy an agent, you need to do it variable by variable, state by state, everything from scratch. There's no magical way to copy the exact same agent with all its current values and states and connections etc

How do I seize a subset of seized resources?

I have a pool of 25 agents (Operators). When an Order is generated, I seize a few Operators and move them to one of many different ProductionSuites as determined by a parameter in the Order.
Within the ProductionSuite, I have a variable of type ResourcePool that I would like to use to have these Operators perform tasks.
In the main window, I put this code in the "On seize unit:" code box:
agent.assignedSuite.suiteOperatorPool.addAgentToContents(unit);
but this triggers a NullPointerException error. Am I using the addAgentToContents method incorrectly?
You have not initialized your suiteOperatorPool variable, it's "initial value" field is empty. Hence, this is just an empty shell of type ResourcePool that cannot do anything, including adding agents to it.
You would need to initialize it properly using the ResourcePool API, but I don't think that is possible.
Also, you cannot have resources be part of 2 resource pools, as you are trying to do. You should think of a different way to solve your problem. Maybe rephrase the issue so we can think of alternatives. You might not need a RP at all but just use pure agent functionality...?

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