I would like to set up an parameter variation experiment in AL. I have an agent population and a single agent in the main agent. All parameters are not stored in main but in the embedded agents. The problem I face now is that I can`t see these parameters in the experiment setup window. Is it required that all parameters are defined in main?
Thank you!
In such a case, you use "Parameter propagation" as explained in the AnyLogic help.
Related
I have a model of a supply chain in which my agents "Product" pass through blocks in some agents (i.e. "Vendor", "Factory", "Wholesaler", and "Retailer") and I have a flowchart block in which the said agents in the supply chain use it. I would like to measure the time my agent "Product" spent, which its TimeMeasureStart is in for example its "Vendor" page and its following TimeMeasureEnd is in the said flowchart block like this. Now I have difficulty defining TimeMeasureStart in the TimeMeasureEnd block in the flowchart block.
I tried to use getRootAgent() but this way I couldn't access the timeMeasureStart block of the root agent so I couldn't try this.
Also tried to define a variable in the flowchart block page like this (and I know this way is wrong but I have no idea how to define a variable to suit TimeMeasureStart)
and then use it to define the corresponding TimeMeasureBlock the "Product" had passed: timeMeasureEnd Properties
but it gave me these 2 errors:
Type mismatch: cannot convert from TimeMeasureStart[] to TimeMeasureStart.
Variable must provide either dimension expressions or an array initializer.
Also tried set_startObjects but I didn't understand how to work with it and couldn't find the documentation in AnyLogic Help.
I really would appreciate any help.
(Also so sorry if the images are blurry, I don't know why their quality gets like this when I upload them.)
Either use
((Main)getRootAgent()).timeMeasureStart()
Or simply use
main.timeMeasureStart
Both take you back to Main. The former uses type casting, the latter is a direct link created by AnyLogic (assumes your timemeasureStart is in an agent embedded in Main)
I'm using the pedistrian library in anylogic and want to implement different target locations for different agents in the block PedGoTo. I tried to use setPos(x,y) for TargetLines and setPos(x,y,z) for rectangular areas. Both did not work and the message "Markup element is already initialized and cannot be modified. Please use constructor without arguments, perform setup and finally call initialize() function" made me try another method. I tried to use point(x,y) as a target. This works fine by defining a parameter for both X and Y and overwriting the values during the simulation. Every time a value is changed the next agent has a new target location.
But, the point(x,y) has no z or level parameter. So I assume that it is only working with targets in the same level as the agent release point. There is no way to define another level for the target by using point(x,y).
My Question is: how can I define a target dynamically during runtime in a level which is different from the agent release point level?
Thanks for any help!
I want to create some charts in anylogic. I know at first we should add some condition in the "statistic". we should use "item.instate". But I do not want to use statechart. I want to use a parameter or color of agents for that.
for example I have 100 agent with different opinion. the opinion is parameter for agents. Also, I changed the the color of agent by their opinion. I want to create the chart that demonestrate the number of agent with "totally Agreed" opiniin.
how can do it?
in the following picture, what I should write in the condition?
enter image description here
You can simply type item.myOpinion == "I like x", assuming your agent's opinion parameter is called myOpinion and you want to count those that have that opinion.
If your opinion is actually a color, it would be item.myOpinion.equals(Color.red) but your myOpinion would need to be of type Color.
However, there are many things garbled in your question. If you agents change their opinion, it should not be a parameter but a variable, for example...
So, I'm pretty new with Anylogic, but have done a lot of tutorials and I have programming experience in Java. For my thesis I'm modelling a vehicle flow as a process. In the source block, I create custom agents (vehicles) with some parameters from the database. This works fine. Then I want to assign an electric parameter with randomTrue(0.5). For this, I call a setupTaxi-function, where electric ist set. The parameter for the randomTrue-function should be changeable, so I set it as an extra paramter anteilEtaxis (0.5).
After that, I want the vehicles to do different things depending on the value of electric using SelectOutput. I selected the Condition and test on agent.electric.
I basically did the exact same thing as described in the Anylogic help. And yet the framework always chooses the true Output port, no matter if the parameter ist set to true or false.
See the image for setup and parameters. I tested this via console (the first line is a println-call in source, the second a println-call in selectOutput.). Plus you can see that the parameter is set to different values, because the 3D visualisation model depends on it:
enter image description here
Also, I tried a few different combinations of setting the parameters, reading them etc... The only thing that will work is putting randomTrue(0.5) directly in the Condition box. This is not what I want though. So if you have an idea, what is wrong, please tell me.
This is a typical beginners problem.
I will assume you are calling the setupTaxi-function in your source in the "on exit" action... If you are doing that, then it's too late and the agent already made its decision on where it will go after the select output block.
You have to call your setupTaxi-function in 2 possible places:
1) In your source on the "on at exit" action
2) In your vehicle agent on the "on startup" action
Or even.. just make electric variable have a default value of randomTrue(main.anteilEtaxis)... that will also work.
I am working on anylogic as beginner, and I have issue with adding statistic into analysis.
I am unable to find any obvious question.
Please, let me clarify on this.
The matter illustrate in the image
Thank you
Asanka
Function is name of another class, used in AnyLogic. Using this name, you refer to the class, not to the agent type. Use full name of the agent type — modelPackageName.Function.Working. Also, you may simply rename Function agent type to FunctionAgent or other one.