a877aed45f
Change-Id: I16cd7730c1e0732253ac52f51010f6b813295aa7
35 lines
1.1 KiB
Python
Executable File
35 lines
1.1 KiB
Python
Executable File
"""
|
|
Author: Weisen Pan
|
|
Date: 2023-10-24
|
|
"""
|
|
# The Episode class in episode is used for episodic simulation experiments
|
|
|
|
import simpy
|
|
from core.cluster import Cluster
|
|
from core.scheduler import Scheduler
|
|
from core.broker import Broker
|
|
from core.simulation import Simulation
|
|
|
|
class Episode:
|
|
def __init__(self, machine_configs, task_configs, algorithm, event_file):
|
|
# Create a simulation environment
|
|
self.env = simpy.Environment()
|
|
|
|
# Create a cluster and add machines based on machine_configs
|
|
cluster = Cluster()
|
|
cluster.add_machines(machine_configs)
|
|
|
|
# Create a task broker with the provided task_configs
|
|
task_broker = Broker(self.env, task_configs)
|
|
|
|
# Create a scheduler with the specified algorithm
|
|
scheduler = Scheduler(self.env, algorithm)
|
|
|
|
# Create a simulation instance with the environment, cluster, task broker, scheduler, and event_file
|
|
self.simulation = Simulation(self.env, cluster, task_broker, scheduler, event_file)
|
|
|
|
def run(self):
|
|
# Run the simulation and the environment
|
|
self.simulation.run()
|
|
self.env.run()
|