Export specific agent trajectory in Anylogic? - anylogic

I'm new to AnyLogic. I'm trying to export the pedestrian trajectory from my model. I used an event updated every simulation time unit with code: traceln("When time is "+ (int) time()+ " ," + getId()+"is at ("+getX()+","+getY()+")"), and get several agents' id and location information with specific time.
Anylogic console image
But when I use textFile.println() with same command to export them, the information I get in outside text file is only one agent.
text file image
Is there anyway I can export all of them?

Simply call the code from within the pedestrian agent (if you defined a custom agent) or use the ped keyword within pedestrian-library blocks code sections (ped.getX()/Y).

Related

How can I pass simulationClass as a parmeter in gatling

please I have several simulation Classes and I want to give the users possibility to enter the name of simulation he / she wants to run from a jenkins pipline
For that I want to parametrize the simulation name so insted that user write the command : mvn gatling -Dgatling.simulationClass=package.theNameofSimulation ( here the name is static) , I want him directy enter the name of simulation he choose, enter image description here
because I guess that the user doesn't know the code and commands
so we have the possibility to passing in parameter the numberOfVirtuelUsers I want to do the same thing for simulation
Thanks you
Maybe if you create an environment variable, you could paramatize the simulation classes. I'm very note sure because i'm newbie in gatling but i do that on other things like URL, users, time etc... and that's work so why not the simulation class.
String nameSimulation = String.format("Dgatling.simulationClass=package.%s", System.getenv("NAME"));

How to assign specific technician to solve specific problem in AnyLogic?

I have a agent "customer" with the parameter "BatteryProblem" randomTrue (0.5), and I have a agent "Technician" with population of 3. How can I assign one technique to solve only "BatteryProblem" and the other two techniques to solve the remaining problems that are not battery related?
My model details are given below:
Create a variable inside technician agent called problemsSolved of type String. In the main agent, on startup, manually assign what each technician does. Like technicians(0).problemsSolved = "battery".
You can use the "custom resource choice" setting.
Then the incoming agent can choose to only seize resources where unit.problemsSolved.equals("battery"). Like this;

How to inject (in a source) multiple agents but with different parameter settings

I am currently building a model on a manufacture process line and I am trying to inject multiple agents in the model in a specific moment. The agents are components and there are different types of it (blades and tower). What I want to implement is for example injecting 6 new agents in the source and then specify that 2 of them are component.type='blade' and 4 of them are
component.type='tower'. Is this possible?
Yes, it is possible through Enter block. You can't join it to a Source block (because it acts like a Source block), but for the next block in the sequence. Create programmatically new agents, then send them to the Enter block.
Component component = new Component (param1, param2,...);
component.type = 'blade'
enterComponent.take(component);

Store pedestrian agents position in a txt

I'm new on AnyLogic, I'm a universitary student, I'm working in my title project and I still can't get to save the coordinates of my agents in time. I've been working with this tool for near 3 months and just started to seek for help.
I tried with traceln(getX and getY), propperly written, but it only shows me the entrance position, how could I create a function to store this information onto a txt file? Or how could I create a new agent type to apply the steps above described
Please your help
Here is a simple example to show you how to do this.
I have a custom pedestrian agent that gets created in the ped source block and a population, which starts of empty where all the pedestrians that gets created get added to.
This is just so that I can have the event to record the location inside the agent and the file object to write to is on main. So we need to access main from inside the agent.
In the file object, I just set it to write and selected a blank .txt file that I created.
You can read more about using the text file from the help - https://anylogic.help/anylogic/connectivity/text-file.html
Inside the pedestrian agent, I have an event that simply saves the location to the file in a new line.
I make use of the "\t" so that the txt file is tab-separated. You can use whatever separator you prefer.
You must remember to call the close command on the text file when you have finished writing to it. I simply called it on the destroy code of main. So it only "writes" the data to the text file when you close the model.
Here is the output from this very simple example
Calling getX() and getY() on agents does definitely give their current coordinates (assuming they are in a continuous space and not GIS/discrete space) so it's likely you're calling this on the wrong agents (e.g., calling it for your instance of Main instead of for some agents living in a population inside it).
Or you're not actually calling it at different simulation times (via, say, a cyclic event), so you're only getting the initial values.

Rundeck implicit variable

Run dick gives us the ability to define options to be entered by the its GUI, is there any capability to have job variable based on the input without the end user of the job seeing it?
E.g, if the the user choose the product and the environment and the product behind LB, I want to use a script internally to define new job variable and assign it the port number that could be used later on within the job steps.
Yes, there is.
You can add a new option whith Allowed Values set to Remote URL, then put the URL to your script which will return the actual value based on other options.
For exmaple
http://localhost/cgi-bin/getPort.py?environment=${option.environment.value}&product=${option.product.value}
Rundeck Manual option-model-provider