-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathdisciplines.py
52 lines (36 loc) · 1.33 KB
/
disciplines.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from typing import List
from ciw.individual import Individual
from ciw.auxiliary import random_choice
def FIFO(individuals: List[Individual], t: float) -> Individual:
"""
FIFO: First In, First Out (FIFO)
Returns the individual at the head of the queue.
Parameters:
- individuals (List[Individual]): List of individuals in the queue.
- t (float): The current simulation time
Returns:
- Individual: The individual at the head of the queue.
"""
return individuals[0]
def SIRO(individuals: List[Individual], t: float) -> Individual:
"""
SIRO: Service In Random Order (SIRO)
Returns a random individual from the queue.
Parameters:
- individuals (List[Individual]): List of individuals in the queue.
- t (float): The current simulation time
Returns:
- Individual: A randomly selected individual from the queue.
"""
return random_choice(individuals)
def LIFO(individuals: List[Individual], t: float) -> Individual:
"""
LIFO: Last In, First Out (LIFO)
Returns the individual who joined the queue most recently.
Parameters:
- individuals (List[Individual]): List of individuals in the queue.
- t (float): The current simulation time
Returns:
- Individual: The individual who joined the queue most recently.
"""
return individuals[-1]