使用Agentpy,如何在模拟过程中创建代理
我使用 Agentpypy 。它在建模促销方面做得很好,但我也希望能够为加入并离开公司的人们建模。
离开很容易,我可以将标志设置为 之类的东西,但是加入更为复杂。我是否需要在设置过程中制作一堆代理,并将其状态设置为尚未知道的,还是可以在一步中创建代理并添加它们?
这样的人的班级是这样的:
class PersonAgent(ap.Agent):
def setup(self):
p = PEOPLE_DF.iloc[self.id] #
I have a simple simulation of a company using agentpy. It is doing a great job of modelling promotions, but I'd also like to be able to model people joining and leaving the company.
Leaving is easy, I can just set a flag to inactive or something, but joining is more complicated. Do I need to make a bunch of agents during setup and set their state to as yet unknown, or can I create an agent during a step and add them in?
The person class is defined like this:
class PersonAgent(ap.Agent):
def setup(self):
p = PEOPLE_DF.iloc[self.id] # ???? the existing people are in a spreadsheet
self.name = p.full_name
self.gender = get_gender(p.gender)
self.bvn_rank = get_rank(p.b_rank)
# self.capability = float(p.capability)
print()
def rank_transition(self):
self.bvn_rank = transition(self.b_rank, self.gender)
I'm guessing I'd do something with the __init__
, but I've had no luck figuring that out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以在模拟步骤中启动新代理。
这里有一些例子:
Yes, you can initiate new agents during a simulation step.
Here are some examples: