Hire Experts For Answers
Order NowRelated Study Services
- Homework Answers
- Coursework writing help
- Term paper writing help
- Writing Help
- Paper Writing Help
- Research paper help
- Thesis Help
- Dissertation Help
- Case study writing service
- Capstone Project Writing Help
- Lab report Writing
- Take my online class
- Take my online exam
- Do my test for me
- Do my homework
- Do my math homework
- Online Assignment Help
- Do my assignment
- Essay Writing Help
- Write my college essay
- Write my essay for me
DESCRIPTION
Posted
Modified
Viewed
19
You are provided with the file ‘Auto Grader.py’. You are also provided with a few test cases that allow you to check your answers before handing them in. To check if your code gives correct solutions on the supplied test cases, first put your code in the ‘Submissions’ folder, which should be contained in the same folder as Auto Grader.py and make sure that the file ‘test cases.txt’ is in the same folder as Auto Grader.py. If you then run Auto Grader.py, it should create a file ‘results.xlsx’. Here you can check if you obtain the correct solutions to the questions for the test cases we provided you with. For every test case, a 0 means the answer is wrong, and a 1 means the answer is correct. Your grade will be determined by the percentage of correct test cases. The first exercise will count for approximately half of your grade. The second exercise will count for more then 25% of the grade.
Python programming exercises:
Exercise 1:
In this exercise, you will use the Critical Path Method (CPM) to determine theshortest time in which a project can be completed by finding the critical path.The input consists of a dictionary activities with information about the ac-tivities. This is based on an AON network. Each row represents an activity,identified by a capital letter, in alphabetical order. The columns are: activity(string), predecessors (a list of strings), and normal duration (float). This dic-tionary will have the same order of columns for every test case.Your task is to output a list of lists of the critical paths CP (list of lists ofstrings), as well as the project duration duration (integer). A list of a criticalpath consists of the activities on the critical path in order from start to finish. Ifthere are multiple critical paths, you should report both of them. For example,if you have the critical paths [’C’, ’D’, ’G’, ’H’, ’M’,] and [’C’, ’D’, ’G’, ’J’, ’N’],you should report it as [[’C’, ’D’, ’G’, ’H’, ’M’], [’C’, ’D’, ’G’, ’J’, ’N’]]. Note thatthe order of the lists is not of importance.
Exercise 2:
In this Exercise, the normal durations are not known. Instead, you receive in-formation about the pessimistic, most likely, and optimistic durations. Assumethat the data follows a beta distribution. Use the PERT technique to calculatethe duration that can be promised for a certain probability. You are allowed touse scipy.stats by importing it as ’from scipy import stats’ in your file. You canuse the PERT assumption that the test cases will have one critical path.The input consists of a dictionary activities with information about the activities. The dictionary contains the columns: activity (string), predecessors (a list of strings), optimistic duration (float), most likely duration (float), and pes-simistic duration (float). This dictionary will have the same order of columnsfor every test case. In addition, the input contains the probability prob (float)that we want to look into represented as a fraction, i.e., 80% is represented as0.80.Your task is to output the minimal project duration duration (integer) thatcan be promised.
Exercise 3:
In this Exercise, we want you to do MinCostDueDate Crashing. Your task isto use the CPM heuristics to determine which activities need to be crashed tofinish the project within a certain duedate. Partial crashing is allowed, butbacktracking is not needed.The input consists of a dictionary activities with information about the ac-tivities, as well as a duedate duedate (float). The columns of the dictionary are:activity (string), predecessors (a list of strings), normal duration (float), crashduration (float), normal cost (float), and crash cost (float). This dictionary willhave the same order of columns for every test case.Your task is to output the total costs of crashing cost (float).
This order does not have tags, yet.
Attachments
import os # , sys
import sys
import pandas
import numpy
from copy import deepcopy
# Write functions to check if two answers are close enough together.
# Check if two numbers are close.
def match_number(n1,n2,allowed_error=0.01):
if n1!=0:
return abs((n1-n2)/n1)<allowed_error
else:
return abs(n1-n2)<allowed_error
# Check if two lists of numbers are close.
# Note the lists should consist of numbers.
def match_list(list1,list2,allowed_error=0.01):
# Lists must be of the same length.
if len(list1)!=len(list2):
return False
for i in range(len(list1)):
l1 = list1[i]
l2 = list2[i]
# Check if the dictionary we are comparing to has the correct data structure.
if not (isinstance(l2, int) or isinstance(l2, float)
or isinstance(l2, numpy.float64)):
return False
# If the items are not close enough together return False.
if not match_number(l1,l2):
return False
return True
# Check if two lists of strings are close.
# Note the lists should consist of strings
def match_list_string(list1, list2, allowed_error=0.01):
# Lists must be of the same length.
if len(list1) != len(list2):
return False
for i in range(len(list1)):
l1 = list1[i]
l2 = list2[i]
# # Check if the dictionary we are comparing to has the correct data structure.
# if not (isinstance(l2, int) or isinstance(l2, float) or isinstance(l2, numpy.float64)):
# print('not the correct data structure')
# return False
# If the items are not similar return False.
if not l1==l2:
print('items are not similar')
return False
return True
# Checks if two lists partially match.
# It returns the fraction of positions at which the lists match.
def partial_match_list(list1,list2,allowed_error=0.01):
# Lists must be of the same length.
if len(list1)!=len(list2):
return 0
matches = 0 # Check how many elements in the lists match.
for i in range(len(list1)):
l1 = list1[i]
l2 = list2[i]
# Check if the dictionary we are comparing to has the correct data structure.
if not (isinstance(l2, int) or isinstance(l2, float)
or isinstance(l2, numpy.float64)):
continue
# If the items are not close enough together return False.
if not match_number(l1,l2,allowed_error):
continue
matches+=1
return matches/len(list1)
# Check if two dictionaries of numbers are close.
# Note the dictionaries should consist of numbers.
def match_dict(dict1,dict2,allowed_error=0.01):
# Lists must be of the same length.
if dict1.keys()!=dict1.keys():
return False
for k in dict1.keys():
d1 = dict1[k]
d2 = dict2[k]
# Check if the dictionary we are comparing to has the correct data structure.
if type(1)!=type(d2) and type(0.9)!=type(d2):
return False
# If the items are not close enough together return False.
if not match_number(d1,d2):
return False
return True
# Add the folder submission to the path of files where our scipt looks.
# This allows us to call the students' script as student(.py).
# The students' code should be in the Submissions.
sys.path.insert(0, 'Submissions/')
# Generate a list of all the submissions by students.
files = []
for file in os.listdir(r"Submissions"):
if file.endswith(".py"):
files.append(os.path.splitext(file)[0])
# The following dictionary will have as keys the different questions and
# for each question it will have a list of lists corresponding to test cases.
# So test_cases_dict[1][1] is the first test case of the first problem.
# test_cases_dict[1][1] is a list of two lists. The first list is the input and
# the second list is the output.
test_cases_original = dict()
# test_cases should be in the same folder as the auto grader.
f = open("test_cases.txt", "r")
lines = f.readlines()
question = 0
reading = 0 # 0 for input, 1 for output
for l in lines:
test_case = -1
# Set the current question being read in.
if l[0]=="Q":
# Q indicates that the next question
question = l.strip("\n")
test_cases_original[question]=[]
elif l[0:5]=="Input":
reading = 0
test_case +=1
# Add a list to store input
# One could argue that the list containing the answers is unnecessary.
test_cases_original[question].append([[],[]])
elif l[0:6]=="Output":
reading = 1
# Skip over white lines.
elif l[0]=="\n":
continue
else:
# The eval function evaluates text and interprets it as a variable.
test_cases_original[question][test_case][reading].append(eval(l))
# If the line start with a "{" it is a dictionary
# Create a data frame to store the results in.
df = pandas.DataFrame(files,columns=["File name"])
# Records the points awarded for each test case.
# If you're not interesting in this you can remove this (and related) code.
test_case_points = dict()
test_case_points['Q1']=[len(files)]*len(test_cases_original['Q1'])
test_case_points['Q2']=[len(files)]*len(test_cases_original['Q2'])
test_case_points['Q3']=[len(files)]*len(test_cases_original['Q3'])
for i in range(len(files)):
student = __import__(files[i])
# The students total score. You can modify this at the end to reflect a grade.
total_points = 0
# Sometimes students modify the input. This ensures our test cases are not modified.
test_cases = deepcopy(test_cases_original)
# Helps in debugging when students make errors.
print(i, files[i])
# Write the student information to the file.
df.at[i,'student 1 name']=student.student1_name
df.at[i,'student 1 surname']=student.student1_surname
df.at[i,'student 2 name']=student.student2_name
df.at[i,'student 2 surname']=student.student2_surname
# QUESTION 1
total_points_Q1 = 2
number_of_test_cases_Q1 = len(test_cases['Q1'])
df.at[i, 'Q1'] = total_points_Q1
for j in range(len(test_cases['Q1'])):
current_test_case = test_cases['Q1'][j]
try:
activities = current_test_case[0][0]
CP,duration = student.Q1(activities)
result = duration
if not match_number(current_test_case[1][0],result):
df.at[i, 'Q1'] -= total_points_Q1/number_of_test_cases_Q1
test_case_points['Q1'][j]-=1
print('Q1-pd incorrect')
result = CP
for list in result:
if list not in current_test_case[1][1]:
# if not match_list_string(current_test_case[1][1], result):
df.at[i, 'Q1'] -= total_points_Q1 / number_of_test_cases_Q1
test_case_points['Q1'][j] -= 1
print('Q1-cp incorrect')
except Exception as e:
print(e)
df.at[i, 'Q1'] -= total_points_Q1/number_of_test_cases_Q1
df.at[i, 'E1'] = str(e)
test_case_points['Q1'][j]-=1
total_points += df.at[i, 'Q1']
# QUESTION 2
total_points_Q2 = 1
number_of_test_cases_Q2 = len(test_cases['Q2'])
df.at[i, 'Q2'] = total_points_Q2
for j in range(len(test_cases['Q2'])):
current_test_case = test_cases['Q2'][j]
try:
prob, activities =current_test_case[0][0]
result = student.Q2(activities, prob)
if not match_number(current_test_case[1][0],result):
df.at[i, 'Q2'] -= total_points_Q2/number_of_test_cases_Q2
test_case_points['Q2'][j]-=1
print('Q2 incorrect')
except Exception as e:
df.at[i, 'Q2'] -= total_points_Q2/number_of_test_cases_Q2
df.at[i, 'E2'] = str(e)
test_case_points['Q2'][j]-=1
total_points += df.at[i, 'Q2']
# QUESTION 3
total_points_Q3 = 1
number_of_test_cases_Q3 = len(test_cases['Q3'])
df.at[i, 'Q3'] = total_points_Q3
for j in range(len(test_cases['Q3'])):
current_test_case = test_cases['Q3'][j]
try:
duedate, activities= current_test_case[0][0]
cost = student.Q3(activities, duedate)
result = cost
if not match_number(current_test_case[1][0], result):
df.at[i, 'Q3'] -= total_points_Q3 / number_of_test_cases_Q3
test_case_points['Q3'][j] -= 1
print('Q3-cp incorrect')
except Exception as e:
print(e)
df.at[i, 'Q3'] -= total_points_Q3 / number_of_test_cases_Q3
df.at[i, 'E3'] = str(e)
test_case_points['Q3'][j] -= 1
total_points += df.at[i, 'Q3']
df.at[i, 'Total'] = total_points
df.to_excel("results.xlsx")
# Some code to check how the students performed.
print("\nAverage points per test case\n")
n_students = len(files)
print("Question 1")
for i in range(len(test_case_points['Q1'])):
print("Test case {}: {}".format(i,str(test_case_points['Q1'][i]/n_students)))
print("\nQuestion 2")
for i in range(len(test_case_points['Q2'])):
print("Test case {}: {}".format(i,str(test_case_points['Q2'][i]/n_students)))
print("\nQuestion 3")
for i in range(len(test_case_points['Q3'])):
print("Test case {}: {}".format(i,str(test_case_points['Q3'][i]/n_students)))
import sys
# Please fill out the information below
student1_name = ""
student1_surname = ""
student2_name = ""
student2_surname = ""
print("check")
# Fill in your personal information before continuing.
if ( student1_name == "" or student1_surname == "" or student2_name == "" or student2_surname == ""):
print("Please enter your personal information before continuing.")
sys.exit()
def Q1(activities):
"""
calculation of the critical path and its duration
:param:
activities: dictionary
:return:
CP: a list of lists of the activities of the critical path, in order from start to end.
duration: project duration (integer)
"""
CP = []
duration = 0
# YOUR CODE GOES HERE.
return CP, duration
def Q2(activities, prob):
"""
PERT
calculation of the project duration based on a probability of finishing
if the company wants to promise a duration with a certain probability,
based on the probability, what duration can they promise?
:param:
activities: dictionary
prob: probability of finishing (float between 0 and 1)
:return:
duration: duration of the project for that probability (integer)
"""
duration = 0
# YOUR CODE GOES HERE.
return duration
def Q3(activities, duedate):
"""
Crashing
calculation of the project duration when activities are cost
partial crashing is allowed
backtracking is not needed
the new project duration should become lower than or equal to the duedate
:param:
activities: dictionary
duedate: aimed project duration (integer)
:return:
cost: total costs of crashing (integer)
"""
cost = 0
# YOUR CODE GOES HERE.
return cost
Q1
Input
{ 'A' : [[], 14],'B' : [[], 10],'C' : [['A', 'B'], 3], 'D' : [['B'], 7], 'E' : [['C', 'D'], 4],'F' : [['E'], 10]}
Output
31
[['A', 'C', 'E', 'F'], ['B', 'D', 'E', 'F']]
Input
{ 'A': [[], 110], 'B': [[], 260], 'C': [[], 180], 'D': [['A', 'B', 'C'], 30], 'E': [['D'], 60], 'F': [['A', 'B', 'C'], 140], 'G': [['D'], 150], 'H': [['G'], 270], 'I': [['D', 'F'], 100], 'J': [['G'], 330], 'K': [['E'], 240], 'L': [['K'], 300], 'M': [['K', 'H'], 190], 'N': [['H', 'J'], 60]}
Output
900
[['B', 'D', 'G', 'H', 'M']]
Q2
Input
0.014, { 'A':[[], 6.5,7.5,14.5], 'B':[[],8.5,10.5,12.5], 'C':[['A'],2.5,3.5,4.5], 'D': [['A'],6.5,7.5,8.5], 'E':[['B', 'C'],5.5,5.5,9.5], 'F':[['B','C'],5.5,7.5,9.5], 'G':[['D', 'E'],4.5,6.5,8.5], 'H':[['F'],2.5,3.5,3.5]}
Output
21
Q3
Input
16, { 'A' : [[], 3, 3, 30, 30], 'B' : [[], 6, 6, 60, 60], 'C' : [[], 8, 7, 80, 120], 'D' : [['A'], 7, 7, 70, 70], 'E' : [['B'], 5, 5, 50, 50], 'F' : [['C'], 10, 6, 100, 180], 'G' : [['C'], 4, 4, 40, 40], 'H' : [['D', 'E', 'F'], 5, 2, 50, 80], 'I' : [['G'], 6, 3, 60, 150]}
Output
700
Explanations and Answers
0
No answers posted
Post your Answer - free or at a fee
NB: Post a homework question for free and get answers - free or paid homework help.
Get answers to: Cpm And Pert Programming Python or similar questions only at Tutlance.
Related Questions
- Inverse Word Search Recursion In C++
- Arcgis Python Homework Adding Feature Class
- Research Proposal For First Generation College Students
- T-Test For Single Sample And T-Test For 2 Independent Samples Topics Using T-Distribution Table
- Sec.330 Penetration Mid Term Report
- Statistical Analysis Of Data For Both Qualitative And Quantitative
- The While Loop Of A Primed Loops
- ● Plan, Design, Prototype, And Test An Original Web Application
- Biostatistical Data Interpretation Assignment
- Matlab Probability Assignment Due Monday
- I Have A Exam Submission Tomorrow And For That I Need To Solve The Attached Questionaire.
- Math Rstudio Psychology Statistics
- Problem Solving Through Ansys Software
- Expanding The Data Story Tableau
- A Study On Retrieval And Variability Of Precipitable Water Vapour Using Gps Observations
- Operations And Project Management
- Elemental Superhero Project Jr Hs Work
- Chemical Compounds Molar Mass Research Project Jr Hs Work
- Sql Data Science Assignments
- 5 Homework Assignments For Data Science To Be Completed
- Write My Embedded Systems Midterm Paper For Me
- Its Question On Retirement Plan Where All Expenses Are Included From The Start Of Work To Retire Of Work In Excel
- Python Coding Assignment - Need Help Creating
- Answering Questions And Visualizing In Excel
- Getting Past An Error In A Go Build
- Spreadsheet Visualization Problems
- Simple Java Coding, Assignment
- Java Programming Assignment ,Simple Coding
- Evaluating An Exponential Function That Models A Real-World Situation
- Clock Project For School Need It Done Tomorrow
- Clock Project For School Need It Done Tomorrow
- Gis 4121 (Geospatial Analysis)/Gis 6116 (Gis Analysis)
- Create A Map Using Coding To Employ Arcgis Operations
- Quantitative Test (Includes Linear Algebra, Calculus, Statistics, Basic Python)
- The Goal Of This Project Is To Build A Scanner For A Version Of The Core Language
- Finish My Lab Homework (Codding)- Information Technology- It 2750 - Scripting Fundamentals For Cybersecurity
- Machine Learning Homework Assignments
- Engg*1500 Module 2: Circuit Applications: Solving Sles And Rref
- E/R Diagram, Sql Script And Front-End
- Control Theory Course Work Calculation Works
- Axisymmetric Model Of Pressure Vessel
- C Coding Assignment For Beginner
- Ms Excel Assisgements Open The File And The Request Are Written There
- Introduction To Computer Concepts Online Course – Spring 2023
- Inventory Management System - Need Help Fixing 1 File In Project
- Setting Up Hbase And Hadoop (Windows 10)
- Randomized Controlled Trial Of Photobiomodulation Wavelengths 650 Nm And 850 Nm For The Treatment Of Obesity
- Autodesk Cad Inventor - Revit
- Autodesk Revit / Inventor Cad.
- Minimising A Function That Contains Numerical Integration In Matlab