| import streamlit as st |
|
|
| |
| st.set_page_config( |
| page_title="SD Roster Tool - Home", |
| page_icon="π ", |
| layout="wide", |
| initial_sidebar_state="expanded" |
| ) |
|
|
| |
| import pandas as pd |
| import sys |
| import os |
| from datetime import datetime |
|
|
| |
| sys.path.append(os.path.join(os.path.dirname(__file__), 'src')) |
|
|
| |
| st.markdown(""" |
| <style> |
| .main-header { |
| font-size: 3rem; |
| font-weight: bold; |
| color: #1f77b4; |
| margin-bottom: 2rem; |
| text-align: center; |
| } |
| .section-header { |
| font-size: 1.8rem; |
| font-weight: bold; |
| color: #2c3e50; |
| margin: 1.5rem 0; |
| } |
| .feature-card { |
| background-color: #ffffff; |
| padding: 1.5rem; |
| border-radius: 0.8rem; |
| border-left: 5px solid #1f77b4; |
| margin-bottom: 1.5rem; |
| box-shadow: 0 2px 4px rgba(0,0,0,0.15); |
| color: #2c3e50; |
| border: 1px solid #e9ecef; |
| } |
| .feature-card h3 { |
| color: #1f77b4; |
| margin-top: 0; |
| } |
| .feature-card p { |
| color: #2c3e50; |
| } |
| .feature-card ul { |
| color: #2c3e50; |
| } |
| .navigation-button { |
| width: 100%; |
| height: 80px; |
| font-size: 1.2rem; |
| margin: 10px 0; |
| } |
| </style> |
| """, unsafe_allow_html=True) |
|
|
| |
| if 'data_path' not in st.session_state: |
| st.session_state.data_path = "data/my_roster_data" |
| if 'target_date' not in st.session_state: |
| st.session_state.target_date = "" |
|
|
| |
| st.markdown('<h1 class="main-header">π SD Roster Optimization Tool</h1>', unsafe_allow_html=True) |
|
|
| |
| col1, col2 = st.columns([2, 1]) |
|
|
| with col1: |
| st.markdown(""" |
| ## π Welcome to the Supply Chain Roster Optimization Tool |
| |
| This comprehensive tool helps you optimize workforce allocation and production scheduling |
| using advanced mathematical optimization techniques. Navigate through the different sections |
| to analyze your data and run optimizations. |
| |
| ### π§ Key Features: |
| - **Advanced Optimization Engine**: Built on Google OR-Tools for mixed-integer programming |
| - **Multi-constraint Support**: Handle complex business rules and staffing requirements |
| - **Real-time Data Integration**: Work with your existing CSV data files |
| - **Interactive Visualizations**: Rich charts and analytics for decision making |
| - **Flexible Configuration**: Adjust parameters for different business scenarios |
| """) |
|
|
| with col2: |
| st.markdown("### π Quick Start") |
| |
| |
| if st.button("π View Dataset Metadata", key="nav_metadata", help="Explore your data overview"): |
| st.switch_page("pages/1_π_Dataset_Metadata.py") |
| |
| if st.button("π― Run Optimization", key="nav_optimization", help="Configure and run optimization"): |
| st.switch_page("pages/2_π―_Optimization.py") |
|
|
| |
| st.markdown("---") |
| st.markdown('<h2 class="section-header">π Global Settings</h2>', unsafe_allow_html=True) |
|
|
| col_set1, col_set2 = st.columns(2) |
|
|
| with col_set1: |
| st.markdown("### π Data Configuration") |
| new_data_path = st.text_input( |
| "Data Path", |
| value=st.session_state.data_path, |
| help="Path to your CSV data files. This setting is shared across all pages." |
| ) |
| |
| if new_data_path != st.session_state.data_path: |
| st.session_state.data_path = new_data_path |
| st.success("β
Data path updated globally!") |
| |
| st.info(f"**Current data path:** `{st.session_state.data_path}`") |
|
|
| with col_set2: |
| st.markdown("### π
Date Configuration") |
| |
| |
| try: |
| sys.path.append(os.path.join(os.path.dirname(__file__), 'src')) |
| import src.etl.transform as transform |
| |
| date_ranges = transform.get_date_ranges() |
| if date_ranges: |
| date_range_options = [""] + [f"{start.strftime('%Y-%m-%d')} to {end.strftime('%Y-%m-%d')}" for start, end in date_ranges] |
| selected_range_str = st.selectbox( |
| "Available Date Ranges:", |
| options=date_range_options, |
| help="Select from available date ranges in your data" |
| ) |
| |
| if selected_range_str: |
| selected_index = date_range_options.index(selected_range_str) - 1 |
| start_date, end_date = date_ranges[selected_index] |
| st.session_state.date_range = (start_date, end_date) |
| st.success(f"β
Selected: {start_date} to {end_date}") |
| |
| except Exception as e: |
| st.warning(f"Could not load date ranges: {e}") |
| st.info("Date ranges will be available when data is properly configured.") |
|
|
| |
| st.markdown("---") |
|
|
| col_info1, col_info2, col_info3 = st.columns(3) |
|
|
| with col_info1: |
| st.markdown(""" |
| <div class="feature-card"> |
| <h3>π Dataset Metadata</h3> |
| <p>Comprehensive overview of your data including:</p> |
| <ul> |
| <li>Demand analysis and forecasting</li> |
| <li>Employee availability and costs</li> |
| <li>Production line capacities</li> |
| <li>Historical performance data</li> |
| </ul> |
| </div> |
| """, unsafe_allow_html=True) |
|
|
| with col_info2: |
| st.markdown(""" |
| <div class="feature-card"> |
| <h3>π― Optimization Engine</h3> |
| <p>Advanced optimization features:</p> |
| <ul> |
| <li>Multi-objective optimization</li> |
| <li>Constraint satisfaction</li> |
| <li>Scenario analysis</li> |
| <li>Cost minimization</li> |
| </ul> |
| </div> |
| """, unsafe_allow_html=True) |
|
|
| with col_info3: |
| st.markdown(""" |
| <div class="feature-card"> |
| <h3>π Analytics & Reports</h3> |
| <p>Rich visualization and reporting:</p> |
| <ul> |
| <li>Interactive dashboards</li> |
| <li>Cost analysis charts</li> |
| <li>Performance metrics</li> |
| <li>Export capabilities</li> |
| </ul> |
| </div> |
| """, unsafe_allow_html=True) |
|
|
| |
| st.markdown("---") |
| st.markdown("### π System Status") |
|
|
| col_status1, col_status2, col_status3, col_status4 = st.columns(4) |
|
|
| |
| try: |
| import ortools |
| ortools_status = "β
Available" |
| except: |
| ortools_status = "β Not installed" |
|
|
| try: |
| import plotly |
| plotly_status = "β
Available" |
| except: |
| plotly_status = "β Not installed" |
|
|
| data_status = "β
Configured" if os.path.exists(st.session_state.data_path) else "β οΈ Path not found" |
|
|
| with col_status1: |
| st.metric("OR-Tools", ortools_status) |
| with col_status2: |
| st.metric("Plotly", plotly_status) |
| with col_status3: |
| st.metric("Data Path", data_status) |
| with col_status4: |
| st.metric("Session State", "β
Active") |
|
|
| |
| st.markdown("---") |
| st.markdown(""" |
| <div style='text-align: center; color: gray; padding: 2rem;'> |
| <small>SD Roster Optimization Tool | Built with Streamlit & OR-Tools | Version 1.0</small> |
| </div> |
| """, unsafe_allow_html=True) |
|
|