enter image description here
hello,
i splitted agent 1 into agent 1 and a copy of agent 1 therefore i assigned an ID to the agent 1. Now i need to assemble agent 1 with agent 2 the new agent 3 needs to have the same ID like agent 1. So that in the end i can match and combine agent 3 with the copy of agent 1. I need help to find the right code to assign the ID in the assemble block to the new agent. Or a different solution to solve the Problem. Thanks :)
One solution you could try is to make a new variable, I might call it "tempID", then on enter 1 in your assembly block, store agent1's ID in tempID. Then to assign the ID to the new agent on exit of the assembly block.
Here's how that would look:
Related
I am simulating last-mile delivery and I want to iteratively evaluate the co2 emissions between stops. The numbers of the first route evaluation add up i.e. it correctly counts/removes each stop embedded within the route. The problem is that when the first route is finished, the model should consider the next route embedded in a new agent of type 'Order', in 'toConsumer' but it does not. From what I can see, is that the order agent is not updated after the condition in the select block has been met. I am not sure however, why it does this. When the condition is satisfied the agent does continue to the sink. Does anybody know how i can ensure this updating of the agent?
The anylogic model looks as follows:
In the source block I create agents following optimization results via:
int r = 0;
agent.routeVeh = (int) parVehicle.get(r);
agent.route = (List) parRoute.get(r);
agent.routeDep = (int) parDepot.get(r);
r++;
And in the select block i have:
The to consumer block:
If you are doing this operation in the Main agent, you need to define routeCount and consumerCount inside your Order agent (or if you have a Vehicle agent defined, inside that). Because they are defined for each order. Then in the routeFinished you need update the variable as agent.consumerCount++;
I create a spreadsheet with some properties (columns); then in Anylogic create an agent (population of agents) and load it from DB. Run model. Works perfectly, it shows I have an Agent population "products" with 6 agents.. (model has FluidSource, Pipe, Tank, Valve, FluidDispose, all basic configuration)
So now I open the FluidSource, select Custom batch and for Batch: products.get[0].productName (productName is parameter of type string). I have also tried:
products[0];
products[0].productName;
products.get(0);
Now run again.. in model window it says "Error while drawing animation frame..." (orange block top right)
and in model.Console it says: Error during model creation:
Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 ...
What am I doing wrong? How do I assign my FluidSource batch to one of my "Product" agents?
The problem is the order of initialization: your FluidSource object is trying to access the products population before that population is actually filled with agents.
Make your FluidSource account for this by using this conditional check:
products.size() == 0 ? "InitialBatch" : products[0].productName
[Screenshot]
I'm sorry it's in german..
1I have a problem with a pickup element in AnyLogic. I have two agents: pallets and pieces.
If an order arrives I combine the two with a pickup element (pallet in inPort) with "at least 4 pieces" and I also set up a parameter on the Agent pallet with the name amountofpieces.
I now want to know exactly how many pieces there are in the container pallet, so that I can add the amount of pieces to my stock variable.
With: Agent.amountofpieces = container.contents().size() I get a error note.
Also Agent.amountofpieces = pallet.contents().size() is not working.
I later want to add it to a variable (name: stock). My code now is: stock += + Agent.amountofpieces.
Do you maybe have an idea how to solve it?
Or is there another posibility to get the amount of agents that went out as "one" new agent?
I found a solution :)
agent.contents().size() works without any parameters or anything else.
My source has the following code in "On at exit" field:
TRUCK.ID_number = parameter;
parameter = parameter + 1;
Then, each truck will receive an ID: 1, 2, 3, ...
The problem is that All the trucks are circulating at the same time and it looks like everytime a new truck is generated and the code runs it resets the ID for all trucks.
For example: When truck 4 (ID = 4) is created at the source all the other trucks receive ID 4 so I cannot know the correct ID of each truck.
What am I doing wrong?
a few things. First, you need to use the keyword agent in the onExit code box. So in your case, agent.ID_number=parameter. Please read up on these specific keywords that pop up everywhere in AnyLogic code boxes. I call it the "magic lightbulb", also see my blog on that topic:
The magic lightbulb
Second, newly created agents automatically get a unique index (if they belong to the same population). You can access that using the getIndex() method inside your truck agent.
The answer is: Use entity.ID_number=parameter
So here's a scenario. I have a table say X with the below structure
COLUMN1 COLUMN2
1 T
2 F
3 T
4 T
5 F
I want to send an E-MAIL to a specific mail-id saying 'PASS' if there is no 'F' in COLUMN2 and an E-MAIL saying 'ALERT' if there is even a single 'F' in column2.
TIA!! :)
If you must do this in Informatica PowerCenter, below is a possible solution:
Create a mapping with a mapping variable (say var_m_F_COUNT(int)). Using a aggregator transformation count the number of Fs and set the variable with the count.
Now create a workflow as follows:
start ---> assignment task ---> session ---condition---> email task
Create a workflow variable (say var_wkf_F_COUNT). In the assignment task set var_wkf_F_COUNT = 0.
In the session, in Pre-session variable assignment, assign var_m_F_COUNT=var_wkf_F_COUNT. In post-session on success variable assignment, assign var_wkf_F_COUNT=var_m_F_COUNT.
Now, double click the link to the email task(for 'ALERT') and write the codition var_wkf_F_COUNT>0
You can create another email task with the link condition as var_wkf_F_COUNT=0 for 'PASS'