Jahidul Hasan Razib
Jahidul Hasan Razib

Reputation: 312

How to change the variable of agents that I filtered using sortAscending in Anylogic?

I have an agent population of 100. The population has a parameter called budget which has a value between 100 to 200.

Now I sorted this population and filtered out the 1st 3 agents with the maximum budget using the following function on the startup function of Main agent.

List ags =sortAscending(main.bidders,m->m.Budget).subList(0,1);
for(Bidder m : main.bidders){
    m.willDoSomething=true;
}

Now, next i want to change the value of a variable of type boolean to true for those three agents only. But the above code, changes the variable to true for all agents. I dont know what is wrong here.

Upvotes: 0

Views: 39

Answers (1)

Felipe
Felipe

Reputation: 9421

List ags =sortAscending(main.bidders,m->m.Budget).subList(0,1);
for(Bidder m : ags){
    m.willDoSomething=true;
}

the for loop changed main.biders with ags

Upvotes: 0

Related Questions