From f4831c3f2277a05b8a000c54725a014b2c9cbf6c Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 30 Apr 2019 14:58:11 -0400 Subject: [PATCH] backend comments and clean up --- algorithm/optimization_template.py | 0 algorithm/tsp.py | 9 ++++ frontend/src/components/S_BFLS.vue | 8 +++- frontend/src/components/Template.vue | 68 ++++++++++++++++++++++++++++ myapp.py | 16 ++++--- 5 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 algorithm/optimization_template.py create mode 100644 frontend/src/components/Template.vue diff --git a/algorithm/optimization_template.py b/algorithm/optimization_template.py new file mode 100644 index 0000000..e69de29 diff --git a/algorithm/tsp.py b/algorithm/tsp.py index 47ea2aa..b643410 100644 --- a/algorithm/tsp.py +++ b/algorithm/tsp.py @@ -4,6 +4,15 @@ Created on Sat Jun 30 21:01:11 2018 @author: Fangzhou Sun + +This file is intended to show an example of how Gurobipy can be used +to create optimization algorithms in an object oriented way. In structure, +it is very similar to s_bfl.py and should be a starting point for writing +additional optimizations. Writting optimizations in an object oriented way +makes it much easier to utilize the code within a project because we can +simply import the class into another python file and create an instance of +the class to run the optimization. + """ import numpy as np from scipy.spatial import distance_matrix diff --git a/frontend/src/components/S_BFLS.vue b/frontend/src/components/S_BFLS.vue index f2bcdb7..8cc7a4e 100644 --- a/frontend/src/components/S_BFLS.vue +++ b/frontend/src/components/S_BFLS.vue @@ -442,7 +442,13 @@ export default { this.model.input_format = mapInfo.mode; this.model.refinery_location = mapInfo.refinery_location; this.model.new_input = this.new_input; - console.log(this.model); + /* + axios is a 3rd party module that allows us to communicate with the backend API. + In this case, we issue a post method and provide axios the port our server is running + on (http://localhost:5000) with the route we want to access (/s-bfls/) plus the data we + want to send it (this.model). We then instruct axios what to do onec it gets a response + from the backend server sends in the .then() section. + */ axios .post('http://localhost:5000/s-bfls/', this.model) .then(response => { diff --git a/frontend/src/components/Template.vue b/frontend/src/components/Template.vue new file mode 100644 index 0000000..7ec8904 --- /dev/null +++ b/frontend/src/components/Template.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/myapp.py b/myapp.py index f7400e8..f6fa521 100644 --- a/myapp.py +++ b/myapp.py @@ -11,15 +11,16 @@ from flask import Flask, render_template, request, send_from_directory, jsonify, send_file from algorithm.tsp import tsp from algorithm.s_bfl import s_bfl -# from email_credentials import credentials -# from flask_mail import Mail -# from flask_mail import Message from flask_cors import CORS, cross_origin -# from simulation.sim import Simulation from algorithm.geo import Geo from simulation.sim import Simulation import json +""" for email feature +# from email_credentials import credentials +# from flask_mail import Mail +# from flask_mail import Message +""" class CustomFlask(Flask): jinja_options = Flask.jinja_options.copy() jinja_options.update(dict( @@ -31,10 +32,10 @@ class CustomFlask(Flask): app = CustomFlask(__name__) # This replaces your existing "app = Flask(__name__)" CORS(app, supports_credentials = True) +""" for email feature # c = credentials() # c.setPassword() - # app.config.update( # DEBUG = True, # MAIL_SERVER = 'smtp.gmail.com', @@ -45,7 +46,7 @@ class CustomFlask(Flask): # ) # mail = Mail(app) - +""" my_sim = Simulation() @app.route('/s-bfls/', methods=['POST']) @@ -62,6 +63,8 @@ def Sbfl(): my_sim.main() response_dict['sim_response'] = my_sim.sim_results response = jsonify(response_dict) + + """ for email feature # response.headers.add('Access-Control-Allow-Origin', '*') # msg = Message('S-BFLS', @@ -69,6 +72,7 @@ def Sbfl(): # recipients=["robes98@vt.edu"]) # msg.body = "Thanks for using SBFLS! Attached are our results." # mail.send(msg) + """ return response @app.errorhandler(404)