Print

Print


Candy Sansores wrote:
> Hello, I am simulating a reproduction mechanism on agents every a
> determine number of ticks, the re-secheduling mechanism work fine, I
> created a steppable that schedules the new agents to execute the next
> tick, but there is a problem. I schedule the new agents the same
> order number as their parents but this doesn´t work as I expected
> because the step mechanism first call the parents (order 0) and then
> all the new agents (also order 0). This introduces some biases on the
> result. I would expect all agents scheduled for order 0 be stepped
> randomly, even if they were scheduled dynamically. Is this a missing
> mechanism? I found a way to solve this issue but this meant not
> scheduling every agent but an agent that call them, so my agents are
> not steppables.

This sounds like a bug; but, are you sure that you're not just seeing
the parents being executed at the current cycle and everyone (parents
and children) are randomized for the next cycle?  I only ask because the
docs state "If objects are scheduled for the _same_time_ and have the
same ordering value, their execution will be randomly ordered with
respect to one another."

Do you schedule each agent separately or as a group (like with a
Sequence or a MultiStep)?

I think you should be able to use Bag.shuffle() to reschedule
them manually.  E.g. in your SimState.step() method, you would say
something like:

public Bag agents;  // filled with parents and children
public void step() {
    agents.shuffle(this.random);
    for (int agentNdx=0 ; agentNdx<agents.numObjs ; agentNdx++ ) {
       schedule.scheduleOnce(agents.objs[agentNdx]);
    }
}

--
glen e. p. ropella              =><=                Hail Eris!
H: 503-630-4505                       http://ropella.net/~gepr
M: 503-971-3846                        http://tempusdictum.com