如何批量处理具有相似参数但批量大小不同的代理? [英] How to batch agents with similar parameters with different batch size?

查看:29
本文介绍了如何批量处理具有相似参数但批量大小不同的代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为products的代理,在这个代理中,我分配了一个名为sp的参数;在模拟中,我有相同的代理,不同的 sp 范围从 1 到 5.我想在同一批次中批处理具有相同 sp 的代理,具体取决于sp.因此,如果我有 200 个代理,其中 49 个 sp 等于 1,我想将它们分成 4 个批次,因为此 sp 的批次大小为 10,并且剩下 9 个代理等待下一个周期,对于 sp 等于 2,我有 33 个代理,批量大小为 7,我想将它们分 4 个批次进行批处理,剩下的 5 个代理等待下一个循环等等.

I have an agent called products, and in this agent, I assigned a parameter called sp; in the simulation, I have the same agent with a different sp range from 1 to 5. I want to batch the agents with the same sp in the same batch, depending on the sp. So if I have 200 agents, 49 of them with sp equals 1, I would like to batch them in 4 batches since the batch size for this sp is 10, and the left 9 agents wait till next cycle, and for sp equals 2, I have 33 agents, and the batch size is 7, I would like to batch them in 4 batches and the left 5 agents wait till next cycle, and so on.

非常感谢您能提供的任何帮助.

I really appreciate any help you can provide.

这是我的最后一个问题,类似于这个问题:Anylogic:如何批量处理具有相似参数的代理?

here is my last question, which is similar to this question: Anylogic: how to Batch agents with similar parameters?

推荐答案

按照与上一个问题的答案相同的逻辑,在您需要的等待块的输入时使用等待块,然后是批处理块...检查是否满足批处理条件...

follow the same logic as the answer from the previous question with a wait block followed by a batch block... on the on enter of the wait block you need to check if the conditions to batch are met...

List <Product> sameSpProducts=findAll(self,s->s.sp==agent.sp);
if(agent.sp==1 && sameSpProducts.size()==10){
    theBatchBlock.set_batchSize(10);
    for(Product p : sameSpProducts){
       self.free(p);
    }
}

对于所有其他 sp 值都相同……您可以通过使用带有 sp 值的数组并循环遍历该数组(与上一个问题中的回答相同)来提高效率……这代表了一般理想

same for all the others sp values... you can make this more efficient by having an array with the sp values and looping through that array (same as answered in the previous question)... this represents the general ideal

这篇关于如何批量处理具有相似参数但批量大小不同的代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆