1+ import pandas as pd
2+ import numpy as np
3+ import plotly .express as px
4+ from utils .routing .distances import (
5+ distance_picking ,
6+ next_location
7+ )
8+ from utils .routing .routes import (
9+ create_picking_route
10+ )
11+ from utils .batch .mapping_batch import (
12+ orderlines_mapping ,
13+ locations_listing
14+ )
15+ from utils .cluster .mapping_cluster import (
16+ df_mapping
17+ )
18+ from utils .batch .simulation_batch import (
19+ simulation_wave ,
20+ simulate_batch
21+ )
22+ from utils .cluster .simulation_cluster import (
23+ loop_wave ,
24+ simulation_cluster ,
25+ create_dataframe ,
26+ process_methods
27+ )
28+ from utils .results .plot import (
29+ plot_simulation1 ,
30+ plot_simulation2
31+ )
32+ import streamlit as st
33+ from streamlit import caching
34+
35+ # Set page configuration
36+ st .set_page_config (page_title = "Improve Warehouse Productivity using Order Batching" ,
37+ initial_sidebar_state = "expanded" ,
38+ layout = 'wide' ,
39+ page_icon = "🛒" )
40+
41+ # Set up the page
42+ @st .cache (persist = False ,
43+ allow_output_mutation = True ,
44+ suppress_st_warning = True ,
45+ show_spinner = True )
46+ # Preparation of data
47+ def load (filename , n ):
48+ df_orderlines = pd .read_csv (IN + filename ).head (n )
49+ return df_orderlines
50+
51+
52+ # Alley Coordinates on y-axis
53+ y_low , y_high = 5.5 , 50
54+ # Origin Location
55+ origin_loc = [0 , y_low ]
56+ # Distance Threshold (m)
57+ distance_threshold = 35
58+ distance_list = [1 ] + [i for i in range (5 , 100 , 5 )]
59+ IN = 'static/in/'
60+ # Store Results by WaveID
61+ list_wid , list_dst , list_route , list_ord , list_lines , list_pcs , list_monomult = [], [], [], [], [], [], []
62+ list_results = [list_wid , list_dst , list_route , list_ord , list_lines , list_pcs , list_monomult ] # Group in list
63+ # Store Results by Simulation (Order_number)
64+ list_ordnum , list_dstw = [], []
65+
66+ # Simulation 1: Order Batch
67+ # SCOPE SIZE
68+ st .header ("**🥇 Impact of the wave size in orders (Orders/Wave) **" )
69+ st .subheader ('''
70+ 🛠️ HOW MANY ORDER LINES DO YOU WANT TO INCLUDE IN YOUR ANALYSIS?
71+ ''' )
72+ col1 , col2 = st .beta_columns (2 )
73+ with col1 :
74+ n = st .slider (
75+ 'SIMULATION 1 SCOPE (THOUSDAND ORDERS)' , 1 , 200 , value = 5 )
76+ with col2 :
77+ lines_number = 1000 * n
78+ st .write ('''🛠️{:,} \
79+ order lines''' .format (lines_number ))
80+ # SIMULATION PARAMETERS
81+ st .subheader ('''
82+ 🛠️ SIMULATE ORDER PICKING BY WAVE OF N ORDERS PER WAVE WITH N IN [N_MIN, N_MAX] ''' )
83+ col_11 , col_22 = st .beta_columns (2 )
84+ with col_11 :
85+ n1 = st .slider (
86+ 'SIMULATION 1: N_MIN (ORDERS/WAVE)' , 0 , 20 , value = 1 )
87+ n2 = st .slider (
88+ 'SIMULATION 1: N_MAX (ORDERS/WAVE)' , n1 + 1 , 20 , value = int (np .max ([n1 + 1 , 10 ])))
89+ with col_22 :
90+ st .write ('''[N_MIN, N_MAX] = [{:,}, {:,}]''' .format (n1 , n2 ))
91+ # START CALCULATION
92+ start_1 = False
93+ if st .checkbox ('SIMULATION 1: START CALCULATION' ,key = 'show' , value = False ):
94+ start_1 = True
95+ # Calculation
96+ if start_1 :
97+ df_orderlines = load ('df_lines.csv' , lines_number )
98+ df_waves , df_results = simulate_batch (n1 , n2 , y_low , y_high , origin_loc , lines_number , df_orderlines )
99+ plot_simulation1 (df_results , lines_number )
100+
101+ # Simulation 2: Order Batch using Spatial Clustering
102+ # SCOPE SIZE
103+ st .header ("**🥈 Impact of the order batching method **" )
104+ st .subheader ('''
105+ 🛠️ HOW MANY ORDER LINES DO YOU WANT TO INCLUDE IN YOUR ANALYSIS?
106+ ''' )
107+ col1 , col2 = st .beta_columns (2 )
108+ with col1 :
109+ n_ = st .slider (
110+ 'SIMULATION 2 SCOPE (THOUSDAND ORDERS)' , 1 , 200 , value = 5 )
111+ with col2 :
112+ lines_2 = 1000 * n_
113+ st .write ('''🛠️{:,} \
114+ order lines''' .format (lines_2 ))
115+ # START CALCULATION
116+ start_2 = False
117+ if st .checkbox ('SIMULATION 2: START CALCULATION' ,key = 'show_2' , value = False ):
118+ start_2 = True
119+ # Calculation
120+ if start_2 :
121+ df_orderlines = load ('df_lines.csv' , lines_2 )
122+ df_reswave , df_results = simulation_cluster (y_low , y_high , df_orderlines , list_results , n1 , n2 ,
123+ distance_threshold )
124+ plot_simulation2 (df_reswave , lines_2 , distance_threshold )
0 commit comments