MBG0903 commited on
Commit
278af33
·
verified ·
1 Parent(s): 9e58632

Update agents/reasoner.py

Browse files
Files changed (1) hide show
  1. agents/reasoner.py +14 -29
agents/reasoner.py CHANGED
@@ -26,46 +26,34 @@ def run_slotting_analysis(message, slotting_df):
26
  scenario = detect_slotting_scenario(message)
27
 
28
  reasoning_steps = []
 
29
 
30
- # Step 1 — Understand user goal
31
- reasoning_steps.append("Interpreting the slotting request and identifying SKU velocity priorities.")
32
-
33
- # Step 2 — Identify strategy based on scenario
34
  if scenario == "reduce_congestion":
35
- strategy = "Spread picks away from congested aisles and rebalance traffic."
36
  elif scenario == "prioritize_fast":
37
- strategy = "Move fast movers towards golden-zone near outbound docks."
38
  elif scenario == "move_slow_out":
39
- strategy = "Push slow movers to far aisles to free premium picking space."
40
  elif scenario == "balance_zones":
41
- strategy = "Distribute SKUs evenly to reduce localized load."
42
- elif scenario == "improve_efficiency":
43
- strategy = "Optimize SKU placement to minimize walking distances."
44
  else:
45
- strategy = "Apply general slotting best practices based on SKU velocity."
46
 
47
  reasoning_steps.append(f"Selected strategy: {strategy}")
48
 
49
- # Step 3 — Apply dynamic slotting rules
 
50
  fast_zone = (1, 5)
51
  medium_zone = (6, 14)
52
  slow_zone = (15, 22)
53
 
54
- aisles = []
55
- racks = []
56
-
57
  for _, row in slotting_df.iterrows():
58
- sku = row["SKU"]
59
  velocity = row["Velocity"].lower()
60
 
61
- # Dynamic rules based on scenario
62
  if scenario == "reduce_congestion":
63
- # Push away from aisles 10–12
64
- if velocity == "fast":
65
- aisle = np.random.randint(1, 4)
66
- else:
67
- aisle = np.random.choice([6, 7, 8, 13, 14, 15, 16, 17])
68
- elif scenario == "prioritize_fast":
69
  aisle = np.random.randint(fast_zone[0], fast_zone[1])
70
  elif scenario == "move_slow_out" and velocity == "slow":
71
  aisle = np.random.randint(slow_zone[0], slow_zone[1])
@@ -84,14 +72,11 @@ def run_slotting_analysis(message, slotting_df):
84
  slotting_df["Aisle"] = aisles
85
  slotting_df["Rack"] = racks
86
 
87
- reasoning_steps.append("Generated new slotting plan with optimized aisle and rack placements.")
88
-
89
- # Step 4 — Evaluate impact
90
- reasoning_steps.append("Evaluated impact: reduced walking distance + improved zone balance.")
91
 
92
- explanation = "\n".join(simulate_reasoning_chain(reasoning_steps))
93
 
94
- return explanation, slotting_df, None # no heatmap yet
95
 
96
 
97
  # ---------------------------------------------------------
 
26
  scenario = detect_slotting_scenario(message)
27
 
28
  reasoning_steps = []
29
+ reasoning_steps.append("Interpreting slotting optimization request.")
30
 
31
+ # select strategy
 
 
 
32
  if scenario == "reduce_congestion":
33
+ strategy = "Reduce congestion by redistributing picks away from busy aisles"
34
  elif scenario == "prioritize_fast":
35
+ strategy = "Prioritize fast movers by placing them in golden zone aisles"
36
  elif scenario == "move_slow_out":
37
+ strategy = "Move slow movers outward to free prime space"
38
  elif scenario == "balance_zones":
39
+ strategy = "Balance workload across aisles by spreading SKU distribution"
 
 
40
  else:
41
+ strategy = "Apply generic velocity-based slotting optimization"
42
 
43
  reasoning_steps.append(f"Selected strategy: {strategy}")
44
 
45
+ aisles, racks = [], []
46
+
47
  fast_zone = (1, 5)
48
  medium_zone = (6, 14)
49
  slow_zone = (15, 22)
50
 
 
 
 
51
  for _, row in slotting_df.iterrows():
 
52
  velocity = row["Velocity"].lower()
53
 
 
54
  if scenario == "reduce_congestion":
55
+ aisle = np.random.choice([1,2,3,7,8,13,14,15])
56
+ elif scenario == "prioritize_fast" and velocity == "fast":
 
 
 
 
57
  aisle = np.random.randint(fast_zone[0], fast_zone[1])
58
  elif scenario == "move_slow_out" and velocity == "slow":
59
  aisle = np.random.randint(slow_zone[0], slow_zone[1])
 
72
  slotting_df["Aisle"] = aisles
73
  slotting_df["Rack"] = racks
74
 
75
+ reasoning_steps.append("Generated optimized slotting plan.")
 
 
 
76
 
77
+ explanation = "\n".join(reasoning_steps)
78
 
79
+ return explanation, slotting_df
80
 
81
 
82
  # ---------------------------------------------------------