1
0
mirror of https://github.com/gsi-upm/soil synced 2024-11-14 23:42:29 +00:00
soil/benchmarks/noop/soilent_async_pqueue.py
2023-05-19 16:19:50 +02:00

28 lines
637 B
Python

from soil import Agent, Environment
from soil.time import SoilentPQueueActivation
class NoopAgent(Agent):
num_calls = 0
async def step(self):
while True:
self.num_calls += 1
await self.delay()
class NoopEnvironment(Environment):
num_agents = 100
schedule_class = SoilentPQueueActivation
def init(self):
self.add_agents(NoopAgent, k=self.num_agents)
self.add_agent_reporter("num_calls")
if __name__ == "__main__":
from _config import *
res = run_sim(model=NoopEnvironment)
for r in res:
assert isinstance(r.schedule, SoilentPQueueActivation)