diff --git a/frontend/index.html b/frontend/index.html index bd2c184..46d22b9 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,6 +4,9 @@ + + + BFL diff --git a/frontend/src/components/Map.vue b/frontend/src/components/Map.vue index 50d1e13..6b24ba8 100644 --- a/frontend/src/components/Map.vue +++ b/frontend/src/components/Map.vue @@ -109,7 +109,8 @@ export default { addPushpin() { var ref = this; google.maps.event.addListener(this.map, 'click', function(event) { - var typeName = prompt(ref.name + " Name", this.name); + var typeName = prompt(ref.name + " Name", this.name); + // console.log(event.latLng.lat(), event.latLng.lng(), typeName); if (typeName !== null) ref.placeMarker(event.latLng, typeName); }); }, diff --git a/frontend/src/components/S_BFLS.vue b/frontend/src/components/S_BFLS.vue index c48bbcc..029d338 100644 --- a/frontend/src/components/S_BFLS.vue +++ b/frontend/src/components/S_BFLS.vue @@ -36,7 +36,7 @@ { + NProgress.done(); var r = response.data this.op_response = r.op_response; this.$refs.csv_download.generateCsv(this.op_response.solution); @@ -343,6 +400,8 @@ export default { this.parseApplyRoutes(this.op_response); this.$refs.map.show_results(this.op_response["summary"]["cost"]); }) + this.new_input = false; + } }, @@ -351,7 +410,7 @@ export default { this.$refs.map.hide_results(); }, changeProportion() { - this.model.proportion_devoted = (this.model.demand * 1.0) / 6666666; + this.model.field.proportion_devoted = (this.model.demand * 1.0) / 6666666; console.log(this.model.demand); console.log(this.model.proportion_devoted); } diff --git a/myapp.py b/myapp.py index b090774..f7400e8 100644 --- a/myapp.py +++ b/myapp.py @@ -46,6 +46,8 @@ class CustomFlask(Flask): # mail = Mail(app) +my_sim = Simulation() + @app.route('/s-bfls/', methods=['POST']) @cross_origin(supports_credentials=True) def Sbfl(): @@ -56,7 +58,7 @@ def Sbfl(): print(my_s_bfl.optimization_result) response_dict = dict() response_dict['op_response'] = my_s_bfl.optimization_result - my_sim = Simulation(input_data,my_s_bfl.optimization_result) + my_sim.new_input(input_data,my_s_bfl.optimization_result) my_sim.main() response_dict['sim_response'] = my_sim.sim_results response = jsonify(response_dict) diff --git a/production.py b/production.py index 4c12eca..4e41015 100644 --- a/production.py +++ b/production.py @@ -10,4 +10,4 @@ import myapp if __name__ == '__main__': - serve(myapp.app, listen='*:8081') \ No newline at end of file + serve(myapp.app, listen='*:5000') \ No newline at end of file diff --git a/simulation/sim.py b/simulation/sim.py index 98e00da..5993e6a 100644 --- a/simulation/sim.py +++ b/simulation/sim.py @@ -25,7 +25,10 @@ class Simulation(object): -this is a combination of data from the algorithms input and output ''' - def __init__(self, algo_input_data, output_data): + def __init__(self): + print(" * Created new simulation") + + def new_input(self, algo_input_data, output_data): self.algo_input_data = algo_input_data self.output_data = output_data @@ -43,8 +46,6 @@ def __init__(self, algo_input_data, output_data): self.coord_s = self.output_data['params']['Coord_ssls'] # coordinates x,y for ssl (all possible) self.ssl_configurations = self.output_data['params']['SSL_configuration'] # ssl size and equipment loadout configurations self.harvest_schedule = np.array(self.output_data['params']['harvested']) # 26 harvest schedule (yield for each farm in each period Mg) - #self.harvest_schedule = self.harvest_schedule[1:] + [self.harvest_schedule[0]] - #print(self.harvest_schedule) self.ue = self.output_data['params']['upperbound_equip_proc_rate'] # processing rate of non-chopping methods self.sysnum = self.output_data['params']['Sysnum'] self.solutions = self.output_data['solution'] # holds the algorithms solution dictionary @@ -57,25 +58,28 @@ def __init__(self, algo_input_data, output_data): self.loadout_rates_module_jit = [] self.loadout_rate_module_new = 0 self.loadout_rate_standard_new = 0 - for equipment in self.configuration: - if equipment == 'loadout': - self.loadout_rate_standard = self.equipment_data[equipment][4]/self.work_week - self.loadout_rate_standard_new = self.loadout_rate_standard - elif equipment == 'press': - self.config_rate.update({'press':self.equipment_data[equipment][4]/self.work_week}) - self.press_rate = [] - elif equipment == 'chopper': - self.config_rate.update({'chopper':self.equipment_data[equipment][4]/self.work_week}) - self.chopper_rate = [] - elif equipment == 'bagger': - self.config_rate.update({'bagger':self.equipment_data[equipment][4]/self.work_week}) - self.bagger_rate = [] - elif equipment == 'module_former': - self.config_rate.update({'module_former':self.equipment_data[equipment][4]/self.work_week}) - self.former_rate = [] - elif equipment == 'module_hauler': - self.loadout_rate_module = self.equipment_data[equipment][4]/self.work_week - self.loadout_rate_module_new = self.loadout_rate_module + print(algo_input_data["new_input"]) + if algo_input_data["new_input"]: + print("new!!!!!") + for equipment in self.configuration: + if equipment == 'loadout': + self.loadout_rate_standard = self.equipment_data[equipment][4]/self.work_week + self.loadout_rate_standard_new = self.loadout_rate_standard + elif equipment == 'press': + self.config_rate.update({'press':self.equipment_data[equipment][4]/self.work_week}) + self.press_rate = [] + elif equipment == 'chopper': + self.config_rate.update({'chopper':self.equipment_data[equipment][4]/self.work_week}) + self.chopper_rate = [] + elif equipment == 'bagger': + self.config_rate.update({'bagger':self.equipment_data[equipment][4]/self.work_week}) + self.bagger_rate = [] + elif equipment == 'module_former': + self.config_rate.update({'module_former':self.equipment_data[equipment][4]/self.work_week}) + self.former_rate = [] + elif equipment == 'module_hauler': + self.loadout_rate_module = self.equipment_data[equipment][4]/self.work_week + self.loadout_rate_module_new = self.loadout_rate_module self.breakdown ={'loadout':[], 'press':[], 'chopper':[], 'bagger':[], 'module former':[], 'module hauler': []} for trial in range(self.num_trials): @@ -247,7 +251,7 @@ def preprocessing(self, period, farm): def use_equipment(self, period, farm, x): i=1 for equipment in self.config_rate: - equipment_rate = max(1/10*self.config_rate[equipment],np.random.normal(self.config_rate[equipment],1/2*self.config_rate[equipment])) + equipment_rate = min(1.25*self.config_rate[equipment],max(1/10*self.config_rate[equipment],np.random.normal(self.config_rate[equipment],1/5*self.config_rate[equipment]))) if equipment == 'press': self.press_rate.append(equipment_rate) if equipment == 'chopper': @@ -299,9 +303,7 @@ def refinery_transport(self, ssl, period): pass yield self.env.timeout(1) - - - if self.ssl_container[ssl].level > 0: + '''if self.ssl_container[ssl].level > 0: z = self.ssl_container[ssl].level self.ssl_container[ssl].get(z) if 'module_hauler' in self.configuration: @@ -312,7 +314,7 @@ def refinery_transport(self, ssl, period): with self.ssl[ssl][0].request() as req: yield req yield self.env.timeout(z/(self.equip_in_ssl[ssl][0]*self.loadout_rate_standard_new)) - self.refinery.put(z) + self.refinery.put(z)''' @@ -332,9 +334,9 @@ def JIT_delivery(self, period, farm): def create_loadout_rate(self): for period in range(self.m): if 'module_hauler' in self.configuration: - self.loadout_rate_module_new = max(1/10*self.loadout_rate_module,np.random.normal(self.loadout_rate_module, 1/2*self.loadout_rate_module)) + self.loadout_rate_module_new = min(1.25*self.loadout_rate_module,max(1/10*self.loadout_rate_module,np.random.normal(self.loadout_rate_module, 1/5*self.loadout_rate_module))) self.loadout_rates_module.append(self.loadout_rate_module_new) - self.loadout_rate_standard_new = max(1/10*self.loadout_rate_standard,np.random.normal(self.loadout_rate_standard, 1/2*self.loadout_rate_standard)) + self.loadout_rate_standard_new = min(1.25*self.loadout_rate_standard,max(1/10*self.loadout_rate_standard,np.random.normal(self.loadout_rate_standard, 1/5*self.loadout_rate_standard))) self.loadout_rates_standard.append(self.loadout_rate_standard_new) yield self.env.timeout(self.work_week) @@ -437,7 +439,7 @@ def schedules(self): self.ssl_graph = np.mean(self.all_ssl_actual, axis=0) self.farm_graph = np.mean(self.all_farm_level, axis=0) self.harvest_actual = np.mean(self.harvest_actual, axis=0) - print(self.harvest_actual) + #print(self.harvest_actual) def record_data(self): total = 0 @@ -460,7 +462,7 @@ def record_data(self): self.refinery_actual.append(self.refinery.level) #print('harvested amount @ ',self.env.now,'acutal: ', total, ' hypothetical: ', total2) #print('total ssl inventory @ ',self.env.now, ' acutal: ', total5, ' hypothetical: ', total4) - print('refinery level @ ',self.env.now, ' ', self.refinery.level) + #print('refinery level @ ',self.env.now, ' ', self.refinery.level) total5 = 0 total7 = 0 self.all_farm_level.append(self.actual_farm) diff --git a/warm_starts/base_sys2.mst b/warm_starts/base_sys2.mst index 06a1a66..c800756 100644 --- a/warm_starts/base_sys2.mst +++ b/warm_starts/base_sys2.mst @@ -1,8 +1,8 @@ # MIP start -ssl_configuration_selection[0,0] 0 +ssl_configuration_selection[0,0] 1 ssl_configuration_selection[0,1] 0 ssl_configuration_selection[0,2] 0 -ssl_configuration_selection[0,3] 1 +ssl_configuration_selection[0,3] 0 ssl_configuration_selection[0,4] 0 ssl_configuration_selection[0,5] 0 ssl_configuration_selection[0,6] 0 @@ -26,116 +26,4 @@ ssl_configuration_selection[0,23] 0 ssl_configuration_selection[0,24] 0 ssl_configuration_selection[0,25] 0 ssl_configuration_selection[0,26] 0 -ssl_configuration_selection[1,0] 1 -ssl_configuration_selection[1,1] 0 -ssl_configuration_selection[1,2] 0 -ssl_configuration_selection[1,3] 0 -ssl_configuration_selection[1,4] 0 -ssl_configuration_selection[1,5] 0 -ssl_configuration_selection[1,6] 0 -ssl_configuration_selection[1,7] 0 -ssl_configuration_selection[1,8] 0 -ssl_configuration_selection[1,9] 0 -ssl_configuration_selection[1,10] 0 -ssl_configuration_selection[1,11] 0 -ssl_configuration_selection[1,12] 0 -ssl_configuration_selection[1,13] 0 -ssl_configuration_selection[1,14] 0 -ssl_configuration_selection[1,15] 0 -ssl_configuration_selection[1,16] 0 -ssl_configuration_selection[1,17] 0 -ssl_configuration_selection[1,18] 0 -ssl_configuration_selection[1,19] 0 -ssl_configuration_selection[1,20] 0 -ssl_configuration_selection[1,21] 0 -ssl_configuration_selection[1,22] 0 -ssl_configuration_selection[1,23] 0 -ssl_configuration_selection[1,24] 0 -ssl_configuration_selection[1,25] 0 -ssl_configuration_selection[1,26] 0 -ssl_configuration_selection[2,0] 1 -ssl_configuration_selection[2,1] 0 -ssl_configuration_selection[2,2] 0 -ssl_configuration_selection[2,3] 0 -ssl_configuration_selection[2,4] 0 -ssl_configuration_selection[2,5] 0 -ssl_configuration_selection[2,6] 0 -ssl_configuration_selection[2,7] 0 -ssl_configuration_selection[2,8] 0 -ssl_configuration_selection[2,9] 0 -ssl_configuration_selection[2,10] 0 -ssl_configuration_selection[2,11] 0 -ssl_configuration_selection[2,12] 0 -ssl_configuration_selection[2,13] 0 -ssl_configuration_selection[2,14] 0 -ssl_configuration_selection[2,15] 0 -ssl_configuration_selection[2,16] 0 -ssl_configuration_selection[2,17] 0 -ssl_configuration_selection[2,18] 0 -ssl_configuration_selection[2,19] 0 -ssl_configuration_selection[2,20] 0 -ssl_configuration_selection[2,21] 0 -ssl_configuration_selection[2,22] 0 -ssl_configuration_selection[2,23] 0 -ssl_configuration_selection[2,24] 0 -ssl_configuration_selection[2,25] 0 -ssl_configuration_selection[2,26] 0 -ssl_configuration_selection[3,0] 1 -ssl_configuration_selection[3,1] 0 -ssl_configuration_selection[3,2] 0 -ssl_configuration_selection[3,3] 0 -ssl_configuration_selection[3,4] 0 -ssl_configuration_selection[3,5] 0 -ssl_configuration_selection[3,6] 0 -ssl_configuration_selection[3,7] 0 -ssl_configuration_selection[3,8] 0 -ssl_configuration_selection[3,9] 0 -ssl_configuration_selection[3,10] 0 -ssl_configuration_selection[3,11] 0 -ssl_configuration_selection[3,12] 0 -ssl_configuration_selection[3,13] 0 -ssl_configuration_selection[3,14] 0 -ssl_configuration_selection[3,15] 0 -ssl_configuration_selection[3,16] 0 -ssl_configuration_selection[3,17] 0 -ssl_configuration_selection[3,18] 0 -ssl_configuration_selection[3,19] 0 -ssl_configuration_selection[3,20] 0 -ssl_configuration_selection[3,21] 0 -ssl_configuration_selection[3,22] 0 -ssl_configuration_selection[3,23] 0 -ssl_configuration_selection[3,24] 0 -ssl_configuration_selection[3,25] 0 -ssl_configuration_selection[3,26] 0 farm_to_ssl[0,0] 1 -farm_to_ssl[0,1] 0 -farm_to_ssl[0,2] 0 -farm_to_ssl[0,3] 0 -farm_to_ssl[1,0] 1 -farm_to_ssl[1,1] 0 -farm_to_ssl[1,2] 0 -farm_to_ssl[1,3] 0 -farm_to_ssl[2,0] 1 -farm_to_ssl[2,1] 0 -farm_to_ssl[2,2] 0 -farm_to_ssl[2,3] 0 -farm_to_ssl[3,0] 0 -farm_to_ssl[3,1] 1 -farm_to_ssl[3,2] 0 -farm_to_ssl[3,3] 0 -farm_to_ssl[4,0] 0 -farm_to_ssl[4,1] 0 -farm_to_ssl[4,2] 1 -farm_to_ssl[4,3] 0 -farm_to_ssl[5,0] 0 -farm_to_ssl[5,1] 0 -farm_to_ssl[5,2] 0 -farm_to_ssl[5,3] 1 -farm_to_ssl[6,0] 0 -farm_to_ssl[6,1] 0 -farm_to_ssl[6,2] 0 -farm_to_ssl[6,3] 1 -farm_to_ssl[7,0] 0 -farm_to_ssl[7,1] 0 -farm_to_ssl[7,2] 0 -farm_to_ssl[7,3] 1 diff --git a/warm_starts/start.mst b/warm_starts/start.mst index 06a1a66..c800756 100644 --- a/warm_starts/start.mst +++ b/warm_starts/start.mst @@ -1,8 +1,8 @@ # MIP start -ssl_configuration_selection[0,0] 0 +ssl_configuration_selection[0,0] 1 ssl_configuration_selection[0,1] 0 ssl_configuration_selection[0,2] 0 -ssl_configuration_selection[0,3] 1 +ssl_configuration_selection[0,3] 0 ssl_configuration_selection[0,4] 0 ssl_configuration_selection[0,5] 0 ssl_configuration_selection[0,6] 0 @@ -26,116 +26,4 @@ ssl_configuration_selection[0,23] 0 ssl_configuration_selection[0,24] 0 ssl_configuration_selection[0,25] 0 ssl_configuration_selection[0,26] 0 -ssl_configuration_selection[1,0] 1 -ssl_configuration_selection[1,1] 0 -ssl_configuration_selection[1,2] 0 -ssl_configuration_selection[1,3] 0 -ssl_configuration_selection[1,4] 0 -ssl_configuration_selection[1,5] 0 -ssl_configuration_selection[1,6] 0 -ssl_configuration_selection[1,7] 0 -ssl_configuration_selection[1,8] 0 -ssl_configuration_selection[1,9] 0 -ssl_configuration_selection[1,10] 0 -ssl_configuration_selection[1,11] 0 -ssl_configuration_selection[1,12] 0 -ssl_configuration_selection[1,13] 0 -ssl_configuration_selection[1,14] 0 -ssl_configuration_selection[1,15] 0 -ssl_configuration_selection[1,16] 0 -ssl_configuration_selection[1,17] 0 -ssl_configuration_selection[1,18] 0 -ssl_configuration_selection[1,19] 0 -ssl_configuration_selection[1,20] 0 -ssl_configuration_selection[1,21] 0 -ssl_configuration_selection[1,22] 0 -ssl_configuration_selection[1,23] 0 -ssl_configuration_selection[1,24] 0 -ssl_configuration_selection[1,25] 0 -ssl_configuration_selection[1,26] 0 -ssl_configuration_selection[2,0] 1 -ssl_configuration_selection[2,1] 0 -ssl_configuration_selection[2,2] 0 -ssl_configuration_selection[2,3] 0 -ssl_configuration_selection[2,4] 0 -ssl_configuration_selection[2,5] 0 -ssl_configuration_selection[2,6] 0 -ssl_configuration_selection[2,7] 0 -ssl_configuration_selection[2,8] 0 -ssl_configuration_selection[2,9] 0 -ssl_configuration_selection[2,10] 0 -ssl_configuration_selection[2,11] 0 -ssl_configuration_selection[2,12] 0 -ssl_configuration_selection[2,13] 0 -ssl_configuration_selection[2,14] 0 -ssl_configuration_selection[2,15] 0 -ssl_configuration_selection[2,16] 0 -ssl_configuration_selection[2,17] 0 -ssl_configuration_selection[2,18] 0 -ssl_configuration_selection[2,19] 0 -ssl_configuration_selection[2,20] 0 -ssl_configuration_selection[2,21] 0 -ssl_configuration_selection[2,22] 0 -ssl_configuration_selection[2,23] 0 -ssl_configuration_selection[2,24] 0 -ssl_configuration_selection[2,25] 0 -ssl_configuration_selection[2,26] 0 -ssl_configuration_selection[3,0] 1 -ssl_configuration_selection[3,1] 0 -ssl_configuration_selection[3,2] 0 -ssl_configuration_selection[3,3] 0 -ssl_configuration_selection[3,4] 0 -ssl_configuration_selection[3,5] 0 -ssl_configuration_selection[3,6] 0 -ssl_configuration_selection[3,7] 0 -ssl_configuration_selection[3,8] 0 -ssl_configuration_selection[3,9] 0 -ssl_configuration_selection[3,10] 0 -ssl_configuration_selection[3,11] 0 -ssl_configuration_selection[3,12] 0 -ssl_configuration_selection[3,13] 0 -ssl_configuration_selection[3,14] 0 -ssl_configuration_selection[3,15] 0 -ssl_configuration_selection[3,16] 0 -ssl_configuration_selection[3,17] 0 -ssl_configuration_selection[3,18] 0 -ssl_configuration_selection[3,19] 0 -ssl_configuration_selection[3,20] 0 -ssl_configuration_selection[3,21] 0 -ssl_configuration_selection[3,22] 0 -ssl_configuration_selection[3,23] 0 -ssl_configuration_selection[3,24] 0 -ssl_configuration_selection[3,25] 0 -ssl_configuration_selection[3,26] 0 farm_to_ssl[0,0] 1 -farm_to_ssl[0,1] 0 -farm_to_ssl[0,2] 0 -farm_to_ssl[0,3] 0 -farm_to_ssl[1,0] 1 -farm_to_ssl[1,1] 0 -farm_to_ssl[1,2] 0 -farm_to_ssl[1,3] 0 -farm_to_ssl[2,0] 1 -farm_to_ssl[2,1] 0 -farm_to_ssl[2,2] 0 -farm_to_ssl[2,3] 0 -farm_to_ssl[3,0] 0 -farm_to_ssl[3,1] 1 -farm_to_ssl[3,2] 0 -farm_to_ssl[3,3] 0 -farm_to_ssl[4,0] 0 -farm_to_ssl[4,1] 0 -farm_to_ssl[4,2] 1 -farm_to_ssl[4,3] 0 -farm_to_ssl[5,0] 0 -farm_to_ssl[5,1] 0 -farm_to_ssl[5,2] 0 -farm_to_ssl[5,3] 1 -farm_to_ssl[6,0] 0 -farm_to_ssl[6,1] 0 -farm_to_ssl[6,2] 0 -farm_to_ssl[6,3] 1 -farm_to_ssl[7,0] 0 -farm_to_ssl[7,1] 0 -farm_to_ssl[7,2] 0 -farm_to_ssl[7,3] 1