diff --git a/Frontend/main.py b/Frontend/main.py index c22d590d7b6c3a93e375cc591a45cb421ef6edf9..4d08a99cd7ca6981644da18fb1be8c3c02e64cfc 100644 --- a/Frontend/main.py +++ b/Frontend/main.py @@ -13,13 +13,8 @@ The following are the import for the backend. Just write the name of the script Then you can immediately use the function from the script directly in the app. """ sys.path.append(os.path.join(os.path.dirname(sys.path[0]),'backend')) -<<<<<<< HEAD import input, dqn, petrinet -import eventlog as elog -======= - -import input ->>>>>>> nour +import eventlog as elog #define the app app = Flask(__name__) @@ -60,7 +55,7 @@ def upload_file(): #if no file has been selected, flashes a warning flash('No files selected! Please select a file!') return redirect(url_for('index')) - return redirect(url_for('case_id', uploaded_file.filename)) + return redirect(url_for('case_id', filename = uploaded_file.filename)) """ The download usage. Currently just downloads fish.jpg. @@ -87,39 +82,68 @@ There is a preview functionality, when clicked will show a preview of a generate The generated image currently displays static images and not instantly generated ones from the backend. Currently it displays moyai.jpg by default and fish.jpg on case 1 and 2. Will change this later. """ -@app.route('/case.html', methods=['GET']) +@app.route('/case.html/<filename>', methods=['GET']) def case_id(filename): #temporary choice of cases until I figure out where the actual function from backend is. #give the list here in selection using functions from - selection = elog.get_active_cases(filename) + selection = elog.get_active_cases(filename) + previewid = request.args.get("selectpreview") + while request.args.get("selectpreview")!= None: + print(previewid) + previewid = request.args.get("selectpreview") + break + + preview = "../static/fish.jpg" + + if previewid != None: + result = int(previewid) + state = elog.get_state(result, filename) + rec = dqn.deploy(state) + rec = int(rec) + print(rec) + petrinet.decorate_petri_net(result, filename) + + preview = os.path.join(app.config['STATIC_FOLDER'], 'preview_net.png') + else: + print("else") + preview = "../static/fish.jpg" + + ''' if previewid == '1': preview = os.path.join(app.config['STATIC_FOLDER'], 'fish.jpg') elif previewid == '2': preview = os.path.join(app.config['STATIC_FOLDER'], 'fish.jpg') else: preview = os.path.join(app.config['STATIC_FOLDER'], 'moyai.jpg') + ''' - return render_template('case.html', selection=selection, preview=preview, filename = filename) + return render_template('case.html', selection=selection, preview=preview, filename=filename) """ Route for sending the case id towards recommendation. This is linked to the 'Optimize now' button in the case ID page. I have decided to use a separate dropdown list to avoid cross sending the http requests by accident. """ -@app.route('/case.html', methods=['POST']) -def send_caseid(): +@app.route('/case.html/<filename>', methods=['POST']) +def send_caseid(filename): result = request.form.get("selectresult") - return redirect(url_for('recommendation', result=result)) + return redirect(url_for('recommendation', result=result, filename=filename)) """ The result page. It processes "id" (for now it uses the "foo" function from input.py) using backend functions and prints out the result immediately in the page. """ -@app.route('/result.html/<result>', methods=['GET']) -def recommendation(result): - res = input.foo(result) - return render_template('result.html',res=res) +@app.route('/result.html/<filename>/<result>', methods=['GET']) +def recommendation(result, filename): + result = int(result) + state = elog.get_state(result, filename) + rec = dqn.deploy(state) + rec = int(rec) + + petrinet.decorate_petri_net_with_rec(result, rec, filename) + # time.sleep(15) + return render_template('result.html') """ Loading page. Has yet to be used. @@ -140,5 +164,3 @@ if __name__ == "__main__": app.run(debug=True, host='0.0.0.0', port=port) - - diff --git a/backend/__pycache__/dqn.cpython-311.pyc b/backend/__pycache__/dqn.cpython-311.pyc index fca2596bb6917b819255895b808c30fddb1029fd..089a4e571840d4c9f139aef698c98bca7df52cbe 100644 Binary files a/backend/__pycache__/dqn.cpython-311.pyc and b/backend/__pycache__/dqn.cpython-311.pyc differ diff --git a/backend/__pycache__/environment.cpython-311.pyc b/backend/__pycache__/environment.cpython-311.pyc index 930a99fcfd79b331cba55c3f17138f409ca55c40..94659ed7505dd39eae282fe375e57d776ea4098c 100644 Binary files a/backend/__pycache__/environment.cpython-311.pyc and b/backend/__pycache__/environment.cpython-311.pyc differ diff --git a/backend/__pycache__/eventlog.cpython-311.pyc b/backend/__pycache__/eventlog.cpython-311.pyc index d33a75c44c1df2f1e74740d27b74a2267589bfca..2d6febe6e8636c9f95540538da385a20b838660e 100644 Binary files a/backend/__pycache__/eventlog.cpython-311.pyc and b/backend/__pycache__/eventlog.cpython-311.pyc differ diff --git a/backend/__pycache__/petrinet.cpython-311.pyc b/backend/__pycache__/petrinet.cpython-311.pyc index 1a800625f7cc61acce7367fb93d8f5826dfe6810..4e816769a074371c0b68ac0602573f0181a57fef 100644 Binary files a/backend/__pycache__/petrinet.cpython-311.pyc and b/backend/__pycache__/petrinet.cpython-311.pyc differ diff --git a/backend/__pycache__/simplesimmodel.cpython-311.pyc b/backend/__pycache__/simplesimmodel.cpython-311.pyc index 2e2aa23d489d07e08be8d127421bc6e17b6dcabc..36dd67d3fec2dd972b20a2da97cca35e80cfec2d 100644 Binary files a/backend/__pycache__/simplesimmodel.cpython-311.pyc and b/backend/__pycache__/simplesimmodel.cpython-311.pyc differ diff --git a/backend/simtest.py b/backend/simtest.py index a8c8e5a0efa0b6bd1e1c916f88e67aa8f02bb12d..c88e3bdad7f1479effd0c6f619b70467c409a9d9 100644 --- a/backend/simtest.py +++ b/backend/simtest.py @@ -34,30 +34,18 @@ def main(): ressources.append(num_p_b+1) num_p_c = 3 ressources.append(num_p_c+1) -<<<<<<< HEAD - num_ds_a = 25 - ressources.append(num_ds_a+1) - num_ds_b = 40 - ressources.append(num_ds_b+1) - num_ds_c = 40 -======= num_ds_a = 30 ressources.append(num_ds_a+1) num_ds_b = 45 ressources.append(num_ds_b+1) num_ds_c = 45 ->>>>>>> nour ressources.append(num_ds_c+1) model_env = simpy.Environment() process = simmodel.BusinessProcess(model_env, ressources) model_env.process(simmodel.run_process(model_env, process)) -<<<<<<< HEAD - for i in range(2000): -======= for i in range(30000): ->>>>>>> nour model_env.step() print(simmodel.get_ressources(process)) diff --git a/backend/test.py b/backend/test.py index 66410b41437784075ae7399e55c6dd32ef1cf65a..2ef5392b27c38a5a455ed9d2356d7e20e6d635bc 100644 --- a/backend/test.py +++ b/backend/test.py @@ -3,15 +3,9 @@ import numpy as np import dqn def test_agent(): -<<<<<<< HEAD - case = [1,0,1,0,0,0,0,0,0,0,0,0,0,0,0] - event = 3 - process = [1,4,2,2,2,4,0,2,3,3,20,20,20] -======= case = [1,1,0,1,0,0,0,0,0,0,0,0,0,0,0] event = 4 process = [0,2,1,2,0,0,3,2,3,3,7,6,0] ->>>>>>> nour state = OrderedDict() state['case'] = np.asarray(case) @@ -19,10 +13,4 @@ def test_agent(): state['process'] = np.asarray(process) print(state) -<<<<<<< HEAD print(dqn.deploy(state)) - -test_agent() -======= - print(dqn.deploy(state)) ->>>>>>> nour