Spaces:
Sleeping
Sleeping
update
Browse files- __pycache__/utils.cpython-311.pyc +0 -0
- app.py +4 -3
- utils.py +4 -4
__pycache__/utils.cpython-311.pyc
CHANGED
Binary files a/__pycache__/utils.cpython-311.pyc and b/__pycache__/utils.cpython-311.pyc differ
|
|
app.py
CHANGED
@@ -88,6 +88,7 @@ with gr.Blocks() as demo:
|
|
88 |
opt_battery_arrival = gr.Slider(minimum=0, maximum=100, value=50, step=0.1, label="Desired battery level at destination (%)", info='Input your desired battery level at destination in %.', interactive=True)
|
89 |
with gr.Row():
|
90 |
opt_charging_ports = gr.CheckboxGroup(["Type1", "Type2", "CCS2", "CHAdeMO", 'Superchargers'], value=["Type2", "CCS2", "CHAdeMO"], label="Usable charging connectors", info="Select your usable charging connectors.",interactive=True)
|
|
|
91 |
with gr.Row():
|
92 |
opt_submit_btn = gr.Button("Submit", variant='primary')
|
93 |
with gr.Row():
|
@@ -110,9 +111,9 @@ with gr.Blocks() as demo:
|
|
110 |
[origin_address, destination_address, search_type, radius, plotcircle_radius],
|
111 |
[fmap_route, total_distance, total_duration, route_df, stations_df, file1, file2])
|
112 |
|
113 |
-
opt_submit_btn.click(lambda originaddress, destinationaddress, batcapacity, batinit, batarival, ports :
|
114 |
-
plot_optimization(originaddress, destinationaddress, batcapacity, batinit, batarival, ports, gmaps=gmaps, data=data),
|
115 |
-
[opt_origin_address, opt_destination_address, opt_battery_capacity, opt_battery_initial, opt_battery_arrival, opt_charging_ports],
|
116 |
[opt_fmap, opt_distance, opt_driving_time, opt_charging_time, opt_total_time])
|
117 |
|
118 |
demo.launch(debug=False)
|
|
|
88 |
opt_battery_arrival = gr.Slider(minimum=0, maximum=100, value=50, step=0.1, label="Desired battery level at destination (%)", info='Input your desired battery level at destination in %.', interactive=True)
|
89 |
with gr.Row():
|
90 |
opt_charging_ports = gr.CheckboxGroup(["Type1", "Type2", "CCS2", "CHAdeMO", 'Superchargers'], value=["Type2", "CCS2", "CHAdeMO"], label="Usable charging connectors", info="Select your usable charging connectors.",interactive=True)
|
91 |
+
opt_method = gr.Radio(['forward', 'backward'], value="forward", label='Optimization Method', info="Select your optimization method.", interactive=True)
|
92 |
with gr.Row():
|
93 |
opt_submit_btn = gr.Button("Submit", variant='primary')
|
94 |
with gr.Row():
|
|
|
111 |
[origin_address, destination_address, search_type, radius, plotcircle_radius],
|
112 |
[fmap_route, total_distance, total_duration, route_df, stations_df, file1, file2])
|
113 |
|
114 |
+
opt_submit_btn.click(lambda originaddress, destinationaddress, batcapacity, batinit, batarival, ports, method :
|
115 |
+
plot_optimization(originaddress, destinationaddress, batcapacity, batinit, batarival, ports, method,gmaps=gmaps, data=data),
|
116 |
+
[opt_origin_address, opt_destination_address, opt_battery_capacity, opt_battery_initial, opt_battery_arrival, opt_charging_ports, opt_method],
|
117 |
[opt_fmap, opt_distance, opt_driving_time, opt_charging_time, opt_total_time])
|
118 |
|
119 |
demo.launch(debug=False)
|
utils.py
CHANGED
@@ -173,7 +173,7 @@ def get_polyline(origin_address:tuple[float,float], destination_address:tuple[fl
|
|
173 |
|
174 |
# ********************** Optimization Function **********************
|
175 |
def plot_optimization(origin_address: str, destination_address: str, battery_capacity: float,
|
176 |
-
battery_initial: float, battery_arrival: float, charging_ports: list, gmaps:googlemaps.Client,
|
177 |
data:pd.DataFrame, progress=gr.Progress()) -> tuple:
|
178 |
|
179 |
def validate_inputs(origin_address, destination_address, battery_capacity, battery_initial, battery_arrival, charging_ports):
|
@@ -234,7 +234,7 @@ def plot_optimization(origin_address: str, destination_address: str, battery_cap
|
|
234 |
ports_str = ports_str + i + ', '
|
235 |
ports_str = ports_str[:-2].replace(' ','')
|
236 |
|
237 |
-
responce = request_optimize(origin_address, destination_address, battery_capacity, battery_initial, battery_arrival, ports_str)
|
238 |
|
239 |
if responce is None or responce['solution data'] is None:
|
240 |
gr.Warning('API ERROR. Please try again later or check your input.')
|
@@ -377,7 +377,7 @@ def plot_optimization(origin_address: str, destination_address: str, battery_cap
|
|
377 |
|
378 |
# ********************** Utils Fucntion for Optimization **********************
|
379 |
def request_optimize(origin_address: str, destination_address: str, battery_capacity: float, battery_initial: float,
|
380 |
-
battery_arrival: float, charging_ports: str) -> dict:
|
381 |
|
382 |
optimizer_api_url = os.getenv('OPTIMIZER_API_URL')
|
383 |
headers = {
|
@@ -390,7 +390,7 @@ def request_optimize(origin_address: str, destination_address: str, battery_capa
|
|
390 |
"battery_arrival": battery_arrival,
|
391 |
"battery_capacity": battery_capacity,
|
392 |
"charging_ports": charging_ports,
|
393 |
-
"method":
|
394 |
}
|
395 |
|
396 |
response = requests.post(optimizer_api_url, json=data, headers=headers)
|
|
|
173 |
|
174 |
# ********************** Optimization Function **********************
|
175 |
def plot_optimization(origin_address: str, destination_address: str, battery_capacity: float,
|
176 |
+
battery_initial: float, battery_arrival: float, charging_ports: list, method: str, gmaps:googlemaps.Client,
|
177 |
data:pd.DataFrame, progress=gr.Progress()) -> tuple:
|
178 |
|
179 |
def validate_inputs(origin_address, destination_address, battery_capacity, battery_initial, battery_arrival, charging_ports):
|
|
|
234 |
ports_str = ports_str + i + ', '
|
235 |
ports_str = ports_str[:-2].replace(' ','')
|
236 |
|
237 |
+
responce = request_optimize(origin_address, destination_address, battery_capacity, battery_initial, battery_arrival, ports_str, method)
|
238 |
|
239 |
if responce is None or responce['solution data'] is None:
|
240 |
gr.Warning('API ERROR. Please try again later or check your input.')
|
|
|
377 |
|
378 |
# ********************** Utils Fucntion for Optimization **********************
|
379 |
def request_optimize(origin_address: str, destination_address: str, battery_capacity: float, battery_initial: float,
|
380 |
+
battery_arrival: float, charging_ports: str, method: str) -> dict:
|
381 |
|
382 |
optimizer_api_url = os.getenv('OPTIMIZER_API_URL')
|
383 |
headers = {
|
|
|
390 |
"battery_arrival": battery_arrival,
|
391 |
"battery_capacity": battery_capacity,
|
392 |
"charging_ports": charging_ports,
|
393 |
+
"method": method,
|
394 |
}
|
395 |
|
396 |
response = requests.post(optimizer_api_url, json=data, headers=headers)
|