Update app.py
Browse files
app.py
CHANGED
@@ -60,23 +60,22 @@ def app_function(input_json):
|
|
60 |
# Parse the input JSON string
|
61 |
inputs = json.loads(input_json)
|
62 |
|
63 |
-
#
|
64 |
-
df_distances = pd.
|
65 |
|
66 |
-
#
|
67 |
df_attractiveness = pd.Series(inputs["df_attractiveness"])
|
68 |
alpha = inputs["alpha"]
|
69 |
beta = inputs["beta"]
|
70 |
df_capacity = pd.Series(inputs["df_capacity"])
|
71 |
|
72 |
-
# Check if 'df_population' is
|
73 |
df_population = pd.Series(inputs["df_population"]) if "df_population" in inputs else None
|
74 |
|
75 |
iterations = inputs.get("iterations", 5)
|
76 |
crowding_threshold = inputs.get("crowding_threshold", 1.0)
|
77 |
|
78 |
-
#
|
79 |
-
# Ensure 'dynamic_huff_model' is defined and ready to accept these parameters
|
80 |
result = dynamic_huff_model(df_distances, df_attractiveness, alpha, beta, df_capacity, df_population, iterations, crowding_threshold)
|
81 |
|
82 |
# Convert the result DataFrame to a JSON string for output
|
|
|
60 |
# Parse the input JSON string
|
61 |
inputs = json.loads(input_json)
|
62 |
|
63 |
+
# Convert 'df_distances' from a list of lists into a DataFrame directly
|
64 |
+
df_distances = pd.DataFrame(inputs["df_distances"])
|
65 |
|
66 |
+
# 'inputs["df_attractiveness"]' and others are directly usable as lists
|
67 |
df_attractiveness = pd.Series(inputs["df_attractiveness"])
|
68 |
alpha = inputs["alpha"]
|
69 |
beta = inputs["beta"]
|
70 |
df_capacity = pd.Series(inputs["df_capacity"])
|
71 |
|
72 |
+
# Check if 'df_population' is provided and convert to Series
|
73 |
df_population = pd.Series(inputs["df_population"]) if "df_population" in inputs else None
|
74 |
|
75 |
iterations = inputs.get("iterations", 5)
|
76 |
crowding_threshold = inputs.get("crowding_threshold", 1.0)
|
77 |
|
78 |
+
# Assuming dynamic_huff_model function is correctly defined to accept these parameters
|
|
|
79 |
result = dynamic_huff_model(df_distances, df_attractiveness, alpha, beta, df_capacity, df_population, iterations, crowding_threshold)
|
80 |
|
81 |
# Convert the result DataFrame to a JSON string for output
|