serJD commited on
Commit
d53f142
1 Parent(s): e46c84a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -27,23 +27,27 @@ def dynamic_huff_model(df_distances, df_attractiveness, alpha, beta, df_capacity
27
  df_population_per_iteration = df_population / iterations
28
 
29
  # Run the iterative distribution process
30
- for _ in range(int(iterations)):
 
31
  attractiveness = df_attractiveness.copy()
32
  current_visitors = df_visitors.sum(axis=0)
33
 
34
  # Calculate the decay based on the relative share of free capacity
 
35
  relative_crowding = current_visitors / df_capacity
36
  decay_factor = np.where(relative_crowding < crowding_threshold, 1, 1 - (relative_crowding - crowding_threshold) / (1 - crowding_threshold))
37
  attractiveness *= decay_factor
38
 
39
  # Calculate Huff model probabilities
 
40
  distance_term = df_distances ** -beta
41
  # If df_distances is a DataFrame and df_attractiveness is a Series, you might need an operation like:
42
  numerator = df_distances.multiply(df_attractiveness, axis=0) # Adjust based on actual intent
43
 
44
  denominator = numerator.sum(axis='columns')
45
  probabilities = numerator.div(denominator, axis='index').fillna(0)
46
-
 
47
  # Distribute visitors based on probabilities and population
48
  visitors_this_iteration = probabilities.multiply(df_population_per_iteration, axis='index')
49
 
 
27
  df_population_per_iteration = df_population / iterations
28
 
29
  # Run the iterative distribution process
30
+ for i in range(int(iterations)):
31
+ print("iteration " + str(i) + "/"+str(int(iterations)))
32
  attractiveness = df_attractiveness.copy()
33
  current_visitors = df_visitors.sum(axis=0)
34
 
35
  # Calculate the decay based on the relative share of free capacity
36
+ print(" Calculate the decay based on the relative share of free capacity")
37
  relative_crowding = current_visitors / df_capacity
38
  decay_factor = np.where(relative_crowding < crowding_threshold, 1, 1 - (relative_crowding - crowding_threshold) / (1 - crowding_threshold))
39
  attractiveness *= decay_factor
40
 
41
  # Calculate Huff model probabilities
42
+ print("Calculate Huff model probabilities")
43
  distance_term = df_distances ** -beta
44
  # If df_distances is a DataFrame and df_attractiveness is a Series, you might need an operation like:
45
  numerator = df_distances.multiply(df_attractiveness, axis=0) # Adjust based on actual intent
46
 
47
  denominator = numerator.sum(axis='columns')
48
  probabilities = numerator.div(denominator, axis='index').fillna(0)
49
+
50
+ print("Distribute visitors based on probabilities and population")
51
  # Distribute visitors based on probabilities and population
52
  visitors_this_iteration = probabilities.multiply(df_population_per_iteration, axis='index')
53