Repast Simphony:将全局行为安排为具有随机间隔的泊松过程

Repast Simphony: Scheduling a global behavior as Poisson process with random intervals

我有一个功能模型,我想强制随机代理在不同的时间间隔内更改状态,建模为泊松到达过程。我根据常见问题解答设置了全局行为,方法是在 Build() 中包含一个看起来像这样的块(其中 ab 被外部化在 parameters.xml):

ISchedule schedule = RunEnvironment.getInstance().getCurrentSchedule();
ScheduleParameters arrival = ScheduleParameters.createPoissonProbabilityRepeating(a, b, 1);
schedule.schedule(arrival , this, "arrivalEvent");

然后我有一个如下所示的上下文方法:

public void arrivalEvent() {
    // stuff
    double tick = RunEnvironment.getInstance().getCurrentSchedule().getTickCount();
    System.out.println("New arrival on tick: " + tick);
}

这似乎有效,除了它在调试文本中显示对所有重复使用相同的 b 值。有没有办法让每次重复使用新的随机抽奖?还是有另一种(更好的)方法来实现这一目标?

如果您希望 b 每次都不同,一种方法是在 arrivalEvent 本身中重新安排 arrivalEvent。最清晰的方法是将 arrivalEvent 实现为实现 IAction.

的 class
public class ArrivalEvent implements IAction {
    
    private Poisson poisson;
    
    public ArrivalEvent(Poisson poisson) {
        this.poisson = poisson;
    }
    
    public void execute() {
        // execute whatever the actual arrival event is
        
        
        // reschedule
        double next = poisson.nextDouble() + RunEnvironment.getInstance().getCurrentSchedule().getTickCount();
        RunEnvironment.getInstance().getCurrentSchedule().schedule(ScheduleParameters.createOneTime(next, 1), this);
    }
}

并第一次使用类似

的方式安排它
Poisson poisson = RandomHelper.getPoisson();
double next = poisson.nextDouble();
RunEnvironment.getInstance().getCurrentSchedule().schedule(ScheduleParameters.createOneTime(next, 1), new ArrivalEvent(poisson));

尼克