84 lines
2.4 KiB
Python
84 lines
2.4 KiB
Python
import argparse
|
|
import numpy as np
|
|
import schedTests.LiuAndLaylandBound as LLB
|
|
import schedTests.TimeDemandAnalysis as TDA
|
|
import schedTests.HyperbolicBound as HB
|
|
import include.TasksHelper as TH
|
|
# This function Parses the Input Arguments
|
|
|
|
|
|
def parse_args():
|
|
# Instantiate the parser
|
|
parser = argparse.ArgumentParser(
|
|
description='A small Scheduling test Framework.')
|
|
|
|
# Required argument
|
|
parser.add_argument('--i', type=str, required=True,
|
|
help='Path to the file containing task sets.')
|
|
# Required argument
|
|
parser.add_argument('--n', type=int, required=False, default=10,
|
|
help='Number of tasks per set.')
|
|
|
|
return parser.parse_args()
|
|
|
|
# Read Tasksets in to numpy array from text files
|
|
|
|
|
|
def get_tasksets(filename: str, NrSets: int):
|
|
input = np.genfromtxt(filename, dtype=float, delimiter=",", comments=";")
|
|
shape = input.shape
|
|
tasksets = input.reshape(int(shape[0]/NrSets), NrSets, 3)
|
|
return tasksets
|
|
|
|
|
|
def main():
|
|
# Parse Arguments
|
|
args = parse_args()
|
|
print(args.i)
|
|
|
|
# Read Tasksets from txt files
|
|
tasksets = get_tasksets(args.i, args.n)
|
|
print("Successfully parsed Task Sets")
|
|
shape = tasksets.shape
|
|
print("Nr. of Task Sets: " + str(shape[0]))
|
|
print("Nr. of Tasks per Set: " + str(shape[1]))
|
|
|
|
# Starting the analysis
|
|
print("Starting Liu and Layland bound analysis!")
|
|
stubLLB = []
|
|
for _ in range(shape[0]):
|
|
stubLLB.append(False)
|
|
LLBresults = np.array(stubLLB)
|
|
for i in range(shape[0]):
|
|
if LLB.test(tasksets[i]):
|
|
LLBresults[i] = True
|
|
print("Task Set: " + str(i) +
|
|
" fulfills necessary the Liu and Layland Bound!")
|
|
print()
|
|
|
|
print("Starting Hyperbolic bound analysis!")
|
|
stubHB = []
|
|
for _ in range(shape[0]):
|
|
stubHB.append(False)
|
|
HBresults = np.array(stubHB)
|
|
for i in range(shape[0]):
|
|
if HB.test(tasksets[i]):
|
|
HBresults[i] = True
|
|
print("Task Set: " + str(i) +
|
|
" fulfills the sufficient Hyperbolic Bound!")
|
|
print()
|
|
|
|
print("Starting Time Demand Analysis!")
|
|
stubTDA = []
|
|
for _ in range(shape[0]):
|
|
stubTDA.append(False)
|
|
TDAresults = np.array(stubTDA)
|
|
for i in range(shape[0]):
|
|
if TDA.test(tasksets[i]) > 0:
|
|
TDAresults[i] = True
|
|
print("Task Set: " + str(i) + " is feasible by TDA analysis!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|