from mesa import Agent class ProductAgent(Agent): def __init__(self, unique_id, model, code, name): # 调用超类的 __init__ 方法 super().__init__(unique_id, model) # 初始化代理属性 self.code = code self.name = name self.product_network = self.model.product_network def a_successors(self): # Find successors of the current product and return them as a list of ProductAgent successors = list(self.product_network.successors(self)) return [self.model.schedule.agents[successor] for successor in successors] def a_predecessors(self): # Find predecessors of the current product and return them as a list of ProductAgent predecessors = list(self.product_network.predecessors(self)) return [self.model.schedule.agents[predecessor] for predecessor in predecessors] def step(self): # 在每个时间步进行的操作 pass