forked from miranalmehrab/project-resource-leveling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
81 lines (61 loc) · 2.48 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import os
import json
# import yaml
from flask_cors import CORS, cross_origin
from flask import Flask, render_template, request, jsonify
from cpm import *
from burgess_procedure import *
from estimated_resource_smoothing import *
app = Flask(__name__, template_folder='templates')
CORS(app, resources={ r"/postDataset/": {"origins": "*"} })
app.config['UPLOAD_FOLDER'] = "dataset"
app.static_folder = 'static'
@app.route('/postDataset/', methods=['POST', 'PUT'])
@cross_origin()
def post_dataset():
if request.method == "POST":
_file = request.files['file']
if _file.filename != '':
_file.save( os.path.join(app.config['UPLOAD_FOLDER'], _file.filename) )
result = main( os.path.join(app.config['UPLOAD_FOLDER'], _file.filename) )
response = { "estimated": result["estimated"], "burgess1": result["burgess1"], "burgess2": result["burgess2"] }
# print(response["estimated"]["node_matrix"])
# print(response["burgess1"]["node_matrix"])
# print(response["burgess2"]["node_matrix"])
# with open(r'dataset/resp.yaml', 'w') as file:
# documents = yaml.dump(response, file)
return jsonify(response)
@app.route('/')
def index():
return render_template('index.html')
def main(filepath):
# input_file = 'input1.csv'
input_file = filepath
cpm = None
node_matrix = None
result = {"estimated": None, "burgess1": None, "burgess2": None}
cpm = CPM()
cpm.find_all_activity_informations(input_file)
node_matrix = cpm.get_node_matrix()
# print(node_matrix)
print("EST --- \n")
# ==== Estimated Method ===== #
estimatedSmoothing = EstimatedResourceSmoothing(node_matrix)
result["estimated"] = estimatedSmoothing.estimate_optimal_schedule()
print("BUR 1 --- \n")
# ==== Burgess Procedure ===== #
burgessProcedure1 = BurgessProcedure(node_matrix)
result["burgess1"] = burgessProcedure1.estimate_optimal_schedule_burgess1()
print("BUR 2 --- \n")
burgessProcedure2 = BurgessProcedure(node_matrix)
result["burgess2"] = burgessProcedure2.estimate_optimal_schedule_burgess2()
# print(result["estimated"]["node_matrix"])
# print(result["burgess1"]["node_matrix"])
# print(result["burgess2"]["node_matrix"])
# print("\n\n")
return result
if __name__ == "__main__":
# Threaded option to enable multiple instances for multiple user access support
app.run(threaded=True, port=5000)
# method = input()
# main(method.strip())