Jahidul Hasan Razib
Jahidul Hasan Razib

Reputation: 312

How to sort agents in ascending order in Statechart transition condition?

I am working on an agent based simulation for an auction strategy simulation. Here are the details,

I have a population (100) of agents with a parameter budget with a value uniform(70,100) billion Euro.

enter image description here

You can see the statechart flow in the above image. In the statechart combineBids, I want to rank the first three agents with the lowest budget, and the other agents should exit to the notEligible state.

Upvotes: 0

Views: 57

Answers (1)

Felipe
Felipe

Reputation: 9421

make a variable called doSomething instead of your agent type and make it type boolean

List <MyAgent> ags=sortAscending(myAgents,m->m.parameter).subList(0, 2);
for(MyAgent a : ags){
    a.willDoSomething=true;
}

that code can go on the startup agent where the agents live (probably main)

then you need to add a branch after the combine bids and use the willDoSomething value to take them further down the statecharts or to not eligible state

Upvotes: 1

Related Questions