0% found this document useful (0 votes)
4 views

Report on Task Scheduling and Delay Prediction

This report analyzes task scheduling methods and delay prediction using various machine learning and deep learning models. It identifies Shortest Job First (SJF) as the most efficient traditional scheduling algorithm and Random Forest as the best performing machine learning model, with LSTM excelling in deep learning predictions. Future improvements suggested include dataset expansion, hyperparameter tuning, and exploring hybrid scheduling strategies.

Uploaded by

faysaltaysir1435
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Report on Task Scheduling and Delay Prediction

This report analyzes task scheduling methods and delay prediction using various machine learning and deep learning models. It identifies Shortest Job First (SJF) as the most efficient traditional scheduling algorithm and Random Forest as the best performing machine learning model, with LSTM excelling in deep learning predictions. Future improvements suggested include dataset expansion, hyperparameter tuning, and exploring hybrid scheduling strategies.

Uploaded by

faysaltaysir1435
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Report on Task Scheduling and Delay

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.

2. Data Generation and Preprocessing


Data Generation

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

# Set a different random seed for reproducibility


np.random.seed(99)

# Define the dimensions of the DataFrame


num_rows = 100
num_cols = 2

# Generate random integers between 1 and 100


random_data = np.random.randint(1, 101, size=(num_rows, num_cols))

# Generate random integers between 1 and 5 for the additional column


additional_column = np.random.randint(1, 6, size=num_rows)

# Create the DataFrame with all random data


df = pd.DataFrame(np.concatenate((random_data, additional_column[:,
np.newaxis]), axis=1),
columns=['input_size', 'output_size', 'priority'])

# Set the index column with a specified name


index_name = 'Index'
df.index = np.arange(1, len(df) + 1)
df.index.name = index_name
# Reset index to convert it into a regular column and assign it a name
df.reset_index(inplace=True)
df.rename(columns={'index': index_name}, inplace=True)

# Save the DataFrame as a CSV file


csv_filename = 'Task_Scheduling_Seed99.csv'
df.to_csv(csv_filename, index=False)

print("DataFrame saved to", csv_filename)

Delay Calculation

Delays were calculated based on processing time and data transfer rates using the following
equations:

 Process Delay = input_size×103PROCESSOR_SPEED\frac{{\text{{input\_size}}


\times 10^3}}{{\text{{PROCESSOR\_SPEED}}}}
 Input Delay =
input_sizeBANDWIDTH\frac{{\text{{input\_size}}}}{{\text{{BANDWIDTH}}}}
 Output Delay =
output_sizeBANDWIDTH\frac{{\text{{output\_size}}}}{{\text{{BANDWIDTH}}}}

# 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

# Compute final delay


df["final_delay"] = (df["process_delay"] +
df["calculated_input_delay"] +
df["calculated_output_delay"]).round(4)

df.head()

3. Task Scheduling Algorithms


Scheduling Algorithms

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]

Graph: (Space for cumulative delay plot for each algorithm)

Comparison of Algorithms

Graph: (Space for comparison plot of all algorithms)

plt.plot(df.index + 1, fcfs, label='FCFS', color='blue')


plt.plot(df_sjf.index + 1, sjf_cumulative, label='SJF', color='green')
plt.plot(df.index + 1, prio_cumulative, label='Priority', color='red')
plt.plot(df_ljf.index + 1, ljf_cumulative, label='LJF', color='purple')
plt.legend()
plt.show()

4. Machine Learning Models


Data Splitting

The dataset was split into 90% training and 10% testing.

from sklearn.model_selection import train_test_split

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

from sklearn.linear_model import LinearRegression

lr = LinearRegression()
lr.fit(x_train, y_train)
pred = lr.predict(x_test)

2. Decision Tree
3. Random Forest

Evaluation Metrics: R², MAE, MSE, RMSE, Adjusted R-squared

Graph: (Space for comparison bar chart of all models)


5. Deep Learning Models
Data Preparation
from sklearn.preprocessing import MinMaxScaler

scaler = MinMaxScaler()
x_scaled = scaler.fit_transform(x)

Deep Learning Models

1. SimpleRNN
2. LSTM
3. BiLSTM
4. GRU

from tensorflow.keras.models import Sequential


from tensorflow.keras.layers import SimpleRNN, Dense

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))

Evaluation Metrics: MAE, RMSE

Graph: (Space for loss curves and model comparison charts)

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.

Future improvements could include:

 Expanding the dataset for better generalization.


 Tuning hyperparameters for deep learning models.
 Exploring hybrid scheduling strategies for optimized performance.

End of Report

You might also like