MrD
MrD

Reputation: 5086

Reducing Complexity of Agent-Based Models

I am developing an agent based model simulating the growth in-vitro of a cell culture.

I am using the MASON library (Java), but I guess by question could be applicable to different implementations.

Essentially, my agents are programmed to divide every 12 +/- 2 timesteps after their creation. Every time an agent divides, a new one is added to the simulation.

This leads to a very rapid growth of the problem's complexity, which quickly makes the simulation particularly slow.

In order to solve this problem, I decided agents should 'die' after t timesteps from creation.

However, MASON's schedule is built on a BinaryHeap which does not easily allow the removal objects (agents) once they have been added. My solution has been to set a boolean flag:

dead = false;

Which is set to true after t time-steps.

So

if(t == 50)
    dead = true;

I then begin my step method, that is the method called each time an agent is stepped, as follows:

if(dead)
    return;

However, I understand that simply accessing the object in the schedule is enough to slow the simulation down.

Does anybody have any suggestions as to how I could unset the agent or prevent it from being called?

Thanks, Dario

Upvotes: 0

Views: 156

Answers (1)

Vyncent
Vyncent

Reputation: 1205

Taken from MASON documentation page 94

If your agent is scheduled repeating, the scheduleRepeating(...) method returned a sim.engine.Stoppable object. To prevent the agent from having its step(...) method ever called again, just call stop() on the Stoppable. This will also make the agent able to be garbage collected.

Upvotes: 4

Related Questions