add starting point for mosis 2024 assignment
This commit is contained in:
parent
3404c782a9
commit
4b959bc98b
9 changed files with 441 additions and 0 deletions
61
assignment/system.py
Normal file
61
assignment/system.py
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
|
||||
### EDIT THIS FILE ###
|
||||
|
||||
from pypdevs.DEVS import CoupledDEVS
|
||||
from atomicdevs import *
|
||||
|
||||
STRATEGY_ROUND_ROBIN = 0
|
||||
STRATEGY_FILL_ER_UP = 1
|
||||
|
||||
class LockQueueingSystem(CoupledDEVS):
|
||||
def __init__(self,
|
||||
# See runner.py for an explanation of these parameters!!
|
||||
seed,
|
||||
gen_num,
|
||||
gen_rate,
|
||||
gen_types,
|
||||
load_balancer_strategy,
|
||||
lock_capacities,
|
||||
priority,
|
||||
lock_max_wait,
|
||||
passthrough_duration,
|
||||
):
|
||||
super().__init__("LockQueueingSystem")
|
||||
|
||||
# Instantiate sub-models with the right parameters, and add them to the CoupledDEVS:
|
||||
|
||||
generator = self.addSubModel(Generator(
|
||||
seed=seed, # random seed
|
||||
lambd=gen_rate,
|
||||
gen_types=gen_types,
|
||||
gen_num=gen_num,
|
||||
))
|
||||
|
||||
if load_balancer_strategy == STRATEGY_ROUND_ROBIN:
|
||||
LoadBalancer = RoundRobinLoadBalancer
|
||||
elif load_balancer_strategy == STRATEGY_FILL_ER_UP:
|
||||
LoadBalancer = FillErUpLoadBalancer
|
||||
|
||||
load_balancer = self.addSubModel(LoadBalancer(
|
||||
lock_capacities=lock_capacities,
|
||||
priority=priority,
|
||||
))
|
||||
|
||||
locks = [ self.addSubModel(Lock(
|
||||
capacity=lock_capacity,
|
||||
max_wait_duration=lock_max_wait,
|
||||
passthrough_duration=passthrough_duration))
|
||||
for lock_capacity in lock_capacities ]
|
||||
|
||||
sink = self.addSubModel(Sink())
|
||||
|
||||
# Don't forget to connect the input/output ports of the different sub-models:
|
||||
# for instance:
|
||||
# self.connectPorts(generator.out_ship, queue.in_ship)
|
||||
# ...
|
||||
|
||||
# Our runner.py script needs access to the 'sink'-state after completing the simulation:
|
||||
self.sink = sink
|
||||
|
||||
|
||||
### EDIT THIS FILE ###
|
||||
Loading…
Add table
Add a link
Reference in a new issue