Reputation: 312
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
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