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
91
assignment/atomicdevs.py
Normal file
91
assignment/atomicdevs.py
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
|
||||
### EDIT THIS FILE ###
|
||||
|
||||
from pypdevs.DEVS import AtomicDEVS
|
||||
from environment import *
|
||||
import random
|
||||
import dataclasses
|
||||
|
||||
class Queue(AtomicDEVS):
|
||||
def __init__(self, ship_sizes):
|
||||
super().__init__("Queue")
|
||||
# self.state = QueueState(...)
|
||||
|
||||
# def extTransition(self, inputs):
|
||||
# pass
|
||||
|
||||
# def timeAdvance(self):
|
||||
# pass
|
||||
|
||||
# def outputFnc(self):
|
||||
# pass
|
||||
|
||||
# def intTransition(self):
|
||||
# pass
|
||||
|
||||
PRIORITIZE_BIGGER_SHIPS = 0
|
||||
PRIORITIZE_SMALLER_SHIPS = 1
|
||||
|
||||
class RoundRobinLoadBalancer(AtomicDEVS):
|
||||
def __init__(self,
|
||||
lock_capacities=[3,2], # two locks of capacities 3 and 2.
|
||||
priority=PRIORITIZE_BIGGER_SHIPS,
|
||||
):
|
||||
super().__init__("RoundRobinLoadBalancer")
|
||||
# self.state = LoadBalancerState(...)
|
||||
|
||||
# def extTransition(self, inputs):
|
||||
# pass
|
||||
|
||||
# def timeAdvance(self):
|
||||
# pass
|
||||
|
||||
# def outputFnc(self):
|
||||
# pass
|
||||
|
||||
# def intTransition(self):
|
||||
# pass
|
||||
|
||||
class FillErUpLoadBalancer(AtomicDEVS):
|
||||
def __init__(self,
|
||||
lock_capacities=[3,2], # two locks of capacities 3 and 2.
|
||||
priority=PRIORITIZE_BIGGER_SHIPS,
|
||||
):
|
||||
super().__init__("FillErUpLoadBalancer")
|
||||
# self.state = LoadBalancerState(...)
|
||||
|
||||
# def extTransition(self, inputs):
|
||||
# pass
|
||||
|
||||
# def timeAdvance(self):
|
||||
# pass
|
||||
|
||||
# def outputFnc(self):
|
||||
# pass
|
||||
|
||||
# def intTransition(self):
|
||||
# pass
|
||||
|
||||
class Lock(AtomicDEVS):
|
||||
def __init__(self,
|
||||
capacity=2, # lock capacity (2 means: 2 ships of size 1 will fit, or 1 ship of size 2)
|
||||
max_wait_duration=60.0,
|
||||
passthrough_duration=60.0*15.0, # how long does it take for the lock to let a ship pass through it
|
||||
):
|
||||
super().__init__("Lock")
|
||||
# self.state = LockState(...)
|
||||
|
||||
# def extTransition(self, inputs):
|
||||
# pass
|
||||
|
||||
# def timeAdvance(self):
|
||||
# pass
|
||||
|
||||
# def outputFnc(self):
|
||||
# pass
|
||||
|
||||
# def intTransition(self):
|
||||
# pass
|
||||
|
||||
|
||||
### EDIT THIS FILE ###
|
||||
Loading…
Add table
Add a link
Reference in a new issue