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

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

Related

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;

Export specific agent trajectory in 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).

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

How can I create a Hierarchical block with GNURadio Companion?

I am trying to create a Hierarchical block using the GNURadio Companion GUI. Answers I've found in other posts say to select the blocks you want to incorporate, then go to More -> Create Hier. Then a new screen is supposed to appear. However, doing "Create Hier" with any combinations of blocks selected seems to do nothing.
Am I doing something wrong, or is there a problem with my GRC?
It's very simple. You just start with a new flow graph in GRC, and use Pad Sources as input, and Pad Sinks as output.
If you want to let the user configure something, use a Parameter GRC block.
You must set the Generate Options in the Options block to Hier Block, and set a sensible ID there, too – don't stick with top_block, but use something (without spaces or -; it needs to work as a python name) that won't conflict with something else.
Here's an example:
You can then Generate button (or press [F5]), and then, after you've done a rescan of your block library with the refresh button you can find (and use) your new block in the Block Category you specified.