Report on Task Scheduling and Delay Prediction
Report on Task Scheduling and Delay Prediction
Prediction
1. Introduction
This report aims to analyze task scheduling methods and predict delays using machine learning
and deep learning models. The purpose is to identify the most efficient scheduling algorithms
and predictive models to minimize task delays. The study covers traditional scheduling
algorithms like Shortest Job First (SJF), Longest Job First (LJF), First Come First Serve (FCFS),
Last Come First Serve (LCFS), and Priority-based scheduling. Additionally, machine learning
models (Linear Regression, Decision Tree, Random Forest) and deep learning models
(SimpleRNN, LSTM, BiLSTM, GRU) are used to predict task delays.
The dataset was generated to simulate various tasks with different input/output sizes and priority
levels. A total of 100 tasks were created with random input and output sizes ranging from 1 to
100 and priority levels from 1 to 5.
import numpy as np
import pandas as pd
Delay Calculation
Delays were calculated based on processing time and data transfer rates using the following
equations:
# Define constants
PROCESSOR_SPEED = 32 * 10**6 # 32 MHz
BANDWIDTH = 100 * 10**6 # 100 Mbps
# Calculate delays
df["process_delay"] = (df["input_size"] * 10**3) / PROCESSOR_SPEED
df["calculated_input_delay"] = df["input_size"] / BANDWIDTH
df["calculated_output_delay"] = df["output_size"] / BANDWIDTH
df.head()
1. Shortest Job First (SJF): Tasks with the smallest delay are scheduled first.
2. Longest Job First (LJF): Tasks with the longest delay are scheduled first.
3. First Come First Serve (FCFS): Tasks are executed in the order they arrive.
4. Last Come First Serve (LCFS): The most recent task is executed first.
5. Priority-based Scheduling: Tasks are scheduled based on their priority.
# Example for SJF
df_sjf = df.sort_values('final_delay', ignore_index=True)
sorted_sjf = df_sjf['final_delay'].to_numpy()
sjf_cumulative = np.zeros(len(sorted_sjf))
for i in range(1, len(sorted_sjf)):
sjf_cumulative[i] = sjf_cumulative[i-1] + sorted_sjf[i]
Comparison of Algorithms
The dataset was split into 90% training and 10% testing.
x = df[['calculated_input_delay', 'calculated_output_delay']]
y = df['final_delay']
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.10,
random_state=1)
ML Models
1. Linear Regression
lr = LinearRegression()
lr.fit(x_train, y_train)
pred = lr.predict(x_test)
2. Decision Tree
3. Random Forest
scaler = MinMaxScaler()
x_scaled = scaler.fit_transform(x)
1. SimpleRNN
2. LSTM
3. BiLSTM
4. GRU
model = Sequential()
model.add(SimpleRNN(50, activation='relu', input_shape=(x_train.shape[1],
1)))
model.add(Dense(1))
model.compile(optimizer='adam', loss='mse')
model.fit(x_train, y_train, epochs=50, validation_data=(x_test, y_test))
6. Conclusion
This analysis identified the most efficient task scheduling algorithm and predictive models for
delay prediction. SJF minimized delays best among traditional algorithms, while Random Forest
outperformed other machine learning models. Among deep learning models, LSTM provided the
most accurate delay predictions.
End of Report