HaLim commited on
Commit ·
131af7c
1
Parent(s): ac5a7da
Add streamlit
Browse filesFiles changed (5)
- app.py+4-6
- config_page.py+413-68
- optimization_results.pyAdded+311
- src/config/optimization_config.py+97-68
- src/models/optimizer_real.py+21-10
24 unmodified lines2526272829303132333435363 unmodified lines4041424344454624 unmodified lines# Navigationpage = st.sidebar.selectbox("Navigate to:",["⚙️ Configuration", "📊 Optimization Results"],index=0)# Main app contentif page == "⚙️ Configuration":# Import and render the config pagefrom config_page import render_config_page3 unmodified linesrender_config_page()elif page == "📊 Optimization Results":# Import and render the optimization pagefrom optimization_page import render_optimization_pagerender_optimization_page()24 unmodified lines2526272829303132333435363 unmodified lines404142434424 unmodified lines# Navigationpage = st.sidebar.selectbox("Navigate to:",["⚙️ Settings", "📊 Optimization Results"],index=0)# Main app contentif page == "⚙️ Settings":# Import and render the config pagefrom config_page import render_config_page3 unmodified linesrender_config_page()elif page == "📊 Optimization Results":st.title("📊 Optimization Results")st.info("🚧 Optimization results page is under development. Please use the Settings page to configure your optimization parameters.")
13 unmodified lines14151617181920212217 unmodified lines404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293110 unmodified lines2042052062072082092103 unmodified lines2142152162172182192203 unmodified lines22422522622722822923080 unmodified lines31131231331431531631731831932032132232332432532632732832933033133233333433533633733822 unmodified lines36136236336436536636736836937037137237337437537637737837913 unmodified linesdef render_config_page():"""Render the configuration page with all user input controls"""st.title("⚙️ Configuration")st.markdown("---")st.markdown("Configure optimization parameters and constraints for roster planning.")# Initialize session state for all configuration valuesinitialize_session_state()17 unmodified linesst.markdown("---")col1, col2, col3 = st.columns([1, 1, 1])with col2:if st.button("💾 Save Configuration", type="primary", use_container_width=True):save_configuration()st.success("✅ Configuration saved successfully!")def initialize_session_state():"""Initialize session state with default values from config"""# Default values based on optimization_config.pydefaults = {# Schedule configuration'start_date': datetime.date(2025, 7, 7),'end_date': datetime.date(2025, 7, 11),'schedule_type': 'daily',# Shift configuration'evening_shift_mode': 'normal','evening_shift_threshold': 0.9,# Fixed staff configuration'fixed_staff_mode': 'priority',# Payment configuration'payment_mode_shift_1': 'bulk','payment_mode_shift_2': 'bulk','payment_mode_shift_3': 'partial',# Workforce limits'max_unicef_per_day': 8,'max_humanizer_per_day': 10,# Operations'max_parallel_workers_long_line': 15,'max_parallel_workers_mini_load': 15,'max_hour_per_person_per_day': 14,# Shift hours'max_hours_shift_1': 7.5,'max_hours_shift_2': 7.5,'max_hours_shift_3': 5.0,# Line counts (will be loaded from data)'line_count_long_line': 6,'line_count_mini_load': 7,}# Initialize session state with defaults if not already setfor key, value in defaults.items():if key not in st.session_state:st.session_state[key] = valuedef render_schedule_config():110 unmodified lines"Max Hours - Shift 1 (Regular)",min_value=1.0,max_value=12.0,value=st.session_state.max_hours_shift_1,step=0.5,help="Maximum hours per person for regular shift")3 unmodified lines"Max Hours - Shift 2 (Evening)",min_value=1.0,max_value=12.0,value=st.session_state.max_hours_shift_2,step=0.5,help="Maximum hours per person for evening shift")3 unmodified lines"Max Hours - Shift 3 (Overtime)",min_value=1.0,max_value=12.0,value=st.session_state.max_hours_shift_3,step=0.5,help="Maximum hours per person for overtime shift")80 unmodified lineshelp="Payment mode for overtime shift")# Cost information display (read-only from config)st.subheader("💵 Hourly Rates (From Configuration)")# Display current cost configurationcost_info = """**UNICEF Fixed Term:**- Shift 1 (Regular): €43.27/hour- Shift 2 (Evening): €43.27/hour- Shift 3 (Overtime): €64.91/hour**Humanizer:**- Shift 1 (Regular): €27.94/hour- Shift 2 (Evening): €27.94/hour- Shift 3 (Overtime): €41.91/hour"""st.info(cost_info)def save_configuration():"""Save current configuration to session state and potentially to file"""# Create configuration dictionaryconfig = {'date_range': {'start_date': st.session_state.start_date,22 unmodified lines},'operations': {'line_counts': {'long_line': st.session_state.line_count_long_line,'mini_load': st.session_state.line_count_mini_load,},'max_parallel_workers': {6: st.session_state.max_parallel_workers_long_line, # long line id7: st.session_state.max_parallel_workers_mini_load, # mini load id}}}# Store in session state for other pages to accessst.session_state.optimization_config = config# Display configuration summarywith st.expander("📋 Configuration Summary", expanded=False):st.json(config)13 unmodified lines14151617181920212217 unmodified lines404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140110 unmodified lines2512522532542552562573 unmodified lines2612622632642652662673 unmodified lines27127227327427527627780 unmodified lines35835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450522 unmodified lines52852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372413 unmodified linesdef render_config_page():"""Render the configuration page with all user input controls"""st.title("⚙️ Settings")st.markdown("---")st.markdown("Adjust the settings for your workforce optimization. These settings control how the system schedules employees and calculates costs.")# Initialize session state for all configuration valuesinitialize_session_state()17 unmodified linesst.markdown("---")col1, col2, col3 = st.columns([1, 1, 1])with col2:if st.button("💾 Save Settings", type="primary", use_container_width=True):config = save_configuration()st.success("✅ Settings saved successfully!")# Display settings summary at full width (outside columns)st.markdown("---")if 'optimization_config' in st.session_state:with st.expander("📋 Settings Summary", expanded=False):display_user_friendly_summary(st.session_state.optimization_config)# Optimization sectionst.markdown("---")st.header("🚀 Run Optimization")st.markdown("Once you've configured your settings, run the optimization to generate the optimal workforce schedule.")col1, col2, col3 = st.columns([1, 1, 1])with col2:if st.button("🚀 Optimize Schedule", type="primary", use_container_width=True):run_optimization()# Display optimization results if availableif 'optimization_results' in st.session_state and st.session_state.optimization_results is not None:st.markdown("---")display_optimization_results(st.session_state.optimization_results)def initialize_session_state():"""Initialize session state with values from optimization_config.py (single source of truth)"""# Load ALL values from optimization_config.py - NO hard-coded defaults heretry:sys.path.append('src')from config.optimization_config import (# Import the actual computed values, not just constantsEVENING_SHIFT_MODE, EVENING_SHIFT_DEMAND_THRESHOLD,FIXED_STAFF_CONSTRAINT_MODE, DAILY_WEEKLY_SCHEDULE,MAX_HOUR_PER_PERSON_PER_DAY, MAX_HOUR_PER_SHIFT_PER_PERSON,MAX_PARALLEL_WORKERS, COST_LIST_PER_EMP_SHIFT,PAYMENT_MODE_CONFIG, LINE_CNT_PER_TYPE,MAX_EMPLOYEE_PER_TYPE_ON_DAY, start_date, end_date)# Get the actual computed default values from optimization_config.pydefaults = {# Schedule configuration - from optimization_config.py'start_date': start_date.date() if hasattr(start_date, 'date') else start_date,'end_date': end_date.date() if hasattr(end_date, 'date') else end_date,'schedule_type': DAILY_WEEKLY_SCHEDULE,# Shift configuration - from optimization_config.py'evening_shift_mode': EVENING_SHIFT_MODE,'evening_shift_threshold': EVENING_SHIFT_DEMAND_THRESHOLD,# Fixed staff configuration - from optimization_config.py'fixed_staff_mode': FIXED_STAFF_CONSTRAINT_MODE,# Payment configuration - from optimization_config.py'payment_mode_shift_1': PAYMENT_MODE_CONFIG.get(1),'payment_mode_shift_2': PAYMENT_MODE_CONFIG.get(2),'payment_mode_shift_3': PAYMENT_MODE_CONFIG.get(3),# Working hours - from optimization_config.py'max_hour_per_person_per_day': MAX_HOUR_PER_PERSON_PER_DAY,'max_hours_shift_1': MAX_HOUR_PER_SHIFT_PER_PERSON.get(1),'max_hours_shift_2': MAX_HOUR_PER_SHIFT_PER_PERSON.get(2),'max_hours_shift_3': MAX_HOUR_PER_SHIFT_PER_PERSON.get(3),# Operations - from optimization_config.py'max_parallel_workers_long_line': MAX_PARALLEL_WORKERS.get(6),'max_parallel_workers_mini_load': MAX_PARALLEL_WORKERS.get(7),# Workforce limits - from optimization_config.py (computed values)'max_unicef_per_day': list(MAX_EMPLOYEE_PER_TYPE_ON_DAY.get("UNICEF Fixed term", {}).values())[0] if MAX_EMPLOYEE_PER_TYPE_ON_DAY.get("UNICEF Fixed term") else 8,'max_humanizer_per_day': list(MAX_EMPLOYEE_PER_TYPE_ON_DAY.get("Humanizer", {}).values())[0] if MAX_EMPLOYEE_PER_TYPE_ON_DAY.get("Humanizer") else 10,# Line counts - from optimization_config.py (data-driven)'line_count_long_line': LINE_CNT_PER_TYPE.get(6),'line_count_mini_load': LINE_CNT_PER_TYPE.get(7),# Cost rates - from optimization_config.py (computed or default values)'unicef_rate_shift_1': COST_LIST_PER_EMP_SHIFT.get("UNICEF Fixed term", {}).get(1),'unicef_rate_shift_2': COST_LIST_PER_EMP_SHIFT.get("UNICEF Fixed term", {}).get(2),'unicef_rate_shift_3': COST_LIST_PER_EMP_SHIFT.get("UNICEF Fixed term", {}).get(3),'humanizer_rate_shift_1': COST_LIST_PER_EMP_SHIFT.get("Humanizer", {}).get(1),'humanizer_rate_shift_2': COST_LIST_PER_EMP_SHIFT.get("Humanizer", {}).get(2),'humanizer_rate_shift_3': COST_LIST_PER_EMP_SHIFT.get("Humanizer", {}).get(3),}except Exception as e:st.error(f"❌ Could not load values from optimization_config.py: {e}")st.error("Please check that the optimization_config.py file is working correctly.")st.stop() # Stop execution - we shouldn't have fallback values here# Initialize session state with values from optimization_config.pyfor key, value in defaults.items():if key not in st.session_state and value is not None:st.session_state[key] = valuedef render_schedule_config():110 unmodified lines"Max Hours - Shift 1 (Regular)",min_value=1.0,max_value=12.0,value=float(st.session_state.max_hours_shift_1),step=0.5,help="Maximum hours per person for regular shift")3 unmodified lines"Max Hours - Shift 2 (Evening)",min_value=1.0,max_value=12.0,value=float(st.session_state.max_hours_shift_2),step=0.5,help="Maximum hours per person for evening shift")3 unmodified lines"Max Hours - Shift 3 (Overtime)",min_value=1.0,max_value=12.0,value=float(st.session_state.max_hours_shift_3),step=0.5,help="Maximum hours per person for overtime shift")80 unmodified lineshelp="Payment mode for overtime shift")# Hourly rates configuration - editable with defaults from configst.subheader("💵 Hourly Rates Configuration")st.markdown("**UNICEF Fixed Term Hourly Rates:**")col1, col2, col3 = st.columns(3)with col1:st.session_state.unicef_rate_shift_1 = st.number_input("Shift 1 (Regular) - UNICEF",min_value=0.0,max_value=200.0,value=float(st.session_state.unicef_rate_shift_1),step=0.01,format="%.2f",help="Hourly rate for UNICEF Fixed Term staff during regular shift")with col2:st.session_state.unicef_rate_shift_2 = st.number_input("Shift 2 (Evening) - UNICEF",min_value=0.0,max_value=200.0,value=float(st.session_state.unicef_rate_shift_2),step=0.01,format="%.2f",help="Hourly rate for UNICEF Fixed Term staff during evening shift")with col3:st.session_state.unicef_rate_shift_3 = st.number_input("Shift 3 (Overtime) - UNICEF",min_value=0.0,max_value=200.0,value=float(st.session_state.unicef_rate_shift_3),step=0.01,format="%.2f",help="Hourly rate for UNICEF Fixed Term staff during overtime shift")st.markdown("**Humanizer Hourly Rates:**")col1, col2, col3 = st.columns(3)with col1:st.session_state.humanizer_rate_shift_1 = st.number_input("Shift 1 (Regular) - Humanizer",min_value=0.0,max_value=200.0,value=float(st.session_state.humanizer_rate_shift_1),step=0.01,format="%.2f",help="Hourly rate for Humanizer staff during regular shift")with col2:st.session_state.humanizer_rate_shift_2 = st.number_input("Shift 2 (Evening) - Humanizer",min_value=0.0,max_value=200.0,value=float(st.session_state.humanizer_rate_shift_2),step=0.01,format="%.2f",help="Hourly rate for Humanizer staff during evening shift")with col3:st.session_state.humanizer_rate_shift_3 = st.number_input("Shift 3 (Overtime) - Humanizer",min_value=0.0,max_value=200.0,value=float(st.session_state.humanizer_rate_shift_3),step=0.01,format="%.2f",help="Hourly rate for Humanizer staff during overtime shift")def render_data_selection_config():"""Render data selection configuration section"""st.header("📊 Data Selection Configuration")st.markdown("Configure which data elements to include in the optimization.")# Employee types selectionst.subheader("👥 Employee Types")available_employee_types = ["UNICEF Fixed term", "Humanizer"]if 'selected_employee_types' not in st.session_state:st.session_state.selected_employee_types = available_employee_typesselected_employee_types = st.multiselect("Select Employee Types to Include",available_employee_types,default=st.session_state.get('selected_employee_types', available_employee_types),help="Choose which employee types to include in the optimization")st.session_state.selected_employee_types = selected_employee_types# Shifts selectionst.subheader("🕐 Shifts")available_shifts = [1, 2, 3]shift_names = {1: "Regular", 2: "Evening", 3: "Overtime"}if 'selected_shifts' not in st.session_state:st.session_state.selected_shifts = available_shiftsselected_shifts = st.multiselect("Select Shifts to Include",available_shifts,default=st.session_state.get('selected_shifts', available_shifts),format_func=lambda x: f"Shift {x} ({shift_names[x]})",help="Choose which shifts to include in the optimization")st.session_state.selected_shifts = selected_shifts# Production lines selectionst.subheader("🏭 Production Lines")available_lines = [6, 7]line_names = {6: "Long Line", 7: "Mini Load"}if 'selected_lines' not in st.session_state:st.session_state.selected_lines = available_linesselected_lines = st.multiselect("Select Production Lines to Include",available_lines,default=st.session_state.get('selected_lines', available_lines),format_func=lambda x: f"Line {x} ({line_names[x]})",help="Choose which production lines to include in the optimization")st.session_state.selected_lines = selected_lines# Validation warningsif not selected_employee_types:st.error("⚠️ At least one employee type must be selected!")if not selected_shifts:st.error("⚠️ At least one shift must be selected!")if not selected_lines:st.error("⚠️ At least one production line must be selected!")def save_configuration():"""Save current configuration to session state and potentially to file"""# Create comprehensive configuration dictionaryconfig = {'date_range': {'start_date': st.session_state.start_date,22 unmodified lines},'operations': {'line_counts': {6: st.session_state.line_count_long_line, # Use line IDs directly7: st.session_state.line_count_mini_load,},'max_parallel_workers': {6: st.session_state.max_parallel_workers_long_line, # long line id7: st.session_state.max_parallel_workers_mini_load, # mini load id}},'cost_rates': {'UNICEF Fixed term': {1: st.session_state.unicef_rate_shift_1,2: st.session_state.unicef_rate_shift_2,3: st.session_state.unicef_rate_shift_3,},'Humanizer': {1: st.session_state.humanizer_rate_shift_1,2: st.session_state.humanizer_rate_shift_2,3: st.session_state.humanizer_rate_shift_3,}},'data_selection': {'selected_employee_types': st.session_state.get('selected_employee_types', []),'selected_shifts': st.session_state.get('selected_shifts', []),'selected_lines': st.session_state.get('selected_lines', []),}}# Store individual items in session state for optimization_config.py to accessst.session_state.line_counts = config['operations']['line_counts']st.session_state.cost_list_per_emp_shift = config['cost_rates']st.session_state.payment_mode_config = config['payment_mode_config']st.session_state.max_employee_per_type_on_day = {"UNICEF Fixed term": {t: st.session_state.max_unicef_per_day for t in range(1, 6)},"Humanizer": {t: st.session_state.max_humanizer_per_day for t in range(1, 6)}}# Store complete configurationst.session_state.optimization_config = config# Return config for use in main functionreturn configdef display_user_friendly_summary(config):"""Display a user-friendly summary of the configuration settings"""# Schedule Settingsst.subheader("📅 Schedule Settings")col1, col2, col3, col4 = st.columns(4)with col1:st.write(f"**Start Date:** {config['date_range']['start_date']}")with col2:st.write(f"**End Date:** {config['date_range']['end_date']}")with col3:st.write(f"**Schedule Type:** {config['schedule_type'].title()}")with col4:st.write(f"**Evening Shift Mode:** {config['evening_shift_mode'].replace('_', ' ').title()}")# Show additional schedule details if evening shift threshold is relevantif config['evening_shift_mode'] == 'activate_evening':st.write(f"**Evening Shift Threshold:** {config['evening_shift_threshold']:.0%} demand capacity")# Workforce Settingsst.subheader("👥 Workforce Settings")col1, col2 = st.columns(2)with col1:st.write(f"**Max UNICEF Staff per Day:** {config['workforce_limits']['max_unicef_per_day']} people")st.write(f"**Max Humanizer Staff per Day:** {config['workforce_limits']['max_humanizer_per_day']} people")with col2:st.write(f"**Staff Management Mode:** {config['fixed_staff_mode'].replace('_', ' ').title()}")st.write(f"**Max Hours per Person per Day:** {config['working_hours']['max_hour_per_person_per_day']} hours")# Operations Settingsst.subheader("🏭 Operations Settings")col1, col2 = st.columns(2)with col1:st.write(f"**Long Lines Available:** {config['operations']['line_counts'][6]} lines")st.write(f"**Mini Load Lines Available:** {config['operations']['line_counts'][7]} lines")with col2:st.write(f"**Max Workers per Long Line:** {config['operations']['max_parallel_workers'][6]} people")st.write(f"**Max Workers per Mini Load Line:** {config['operations']['max_parallel_workers'][7]} people")# Cost Settingsst.subheader("💰 Cost Settings")st.write("**Hourly Rates:**")col1, col2 = st.columns(2)with col1:st.write("*UNICEF Fixed Term Staff:*")st.write(f"• Regular Shift: €{config['cost_rates']['UNICEF Fixed term'][1]:.2f}/hour")st.write(f"• Evening Shift: €{config['cost_rates']['UNICEF Fixed term'][2]:.2f}/hour")st.write(f"• Overtime Shift: €{config['cost_rates']['UNICEF Fixed term'][3]:.2f}/hour")with col2:st.write("*Humanizer Staff:*")st.write(f"• Regular Shift: €{config['cost_rates']['Humanizer'][1]:.2f}/hour")st.write(f"• Evening Shift: €{config['cost_rates']['Humanizer'][2]:.2f}/hour")st.write(f"• Overtime Shift: €{config['cost_rates']['Humanizer'][3]:.2f}/hour")# Payment Settingsst.write("**Payment Modes:**")payment_descriptions = {'bulk': 'Full shift payment (even for partial hours)','partial': 'Pay only for actual hours worked'}col1, col2, col3 = st.columns(3)with col1:mode = config['payment_mode_config'][1]st.write(f"• **Regular Shift:** {mode.title()}")st.caption(payment_descriptions[mode])with col2:mode = config['payment_mode_config'][2]st.write(f"• **Evening Shift:** {mode.title()}")st.caption(payment_descriptions[mode])with col3:mode = config['payment_mode_config'][3]st.write(f"• **Overtime Shift:** {mode.title()}")st.caption(payment_descriptions[mode])# Data Selection Settings (if available)if 'data_selection' in config:st.subheader("📊 Data Selection")col1, col2, col3 = st.columns(3)with col1:employee_types = config['data_selection']['selected_employee_types']st.write(f"**Employee Types:** {len(employee_types)} selected")for emp_type in employee_types:st.write(f"• {emp_type}")with col2:shifts = config['data_selection']['selected_shifts']shift_names = {1: "Regular", 2: "Evening", 3: "Overtime"}st.write(f"**Shifts:** {len(shifts)} selected")for shift in shifts:st.write(f"• Shift {shift} ({shift_names.get(shift, 'Unknown')})")with col3:lines = config['data_selection']['selected_lines']line_names = {6: "Long Line", 7: "Mini Load"}st.write(f"**Production Lines:** {len(lines)} selected")for line in lines:st.write(f"• Line {line} ({line_names.get(line, 'Unknown')})")# Summary totalsst.subheader("📊 Quick Summary")col1, col2, col3, col4 = st.columns(4)with col1:duration = (config['date_range']['end_date'] - config['date_range']['start_date']).days + 1st.metric("Planning Period", f"{duration} days")with col2:total_staff = config['workforce_limits']['max_unicef_per_day'] + config['workforce_limits']['max_humanizer_per_day']st.metric("Max Daily Staff", f"{total_staff} people")with col3:total_lines = config['operations']['line_counts'][6] + config['operations']['line_counts'][7]st.metric("Production Lines", f"{total_lines} lines")with col4:avg_unicef_rate = sum(config['cost_rates']['UNICEF Fixed term'].values()) / 3st.metric("Avg UNICEF Rate", f"€{avg_unicef_rate:.2f}/hr")def run_optimization():"""Run the optimization model and store results"""try:st.info("🔄 Running optimization... This may take a few moments.")# Import and run the optimizationsys.path.append('src')from models.optimizer_real import solve_fixed_team_weekly# Run the optimizationwith st.spinner('Optimizing workforce schedule...'):results = solve_fixed_team_weekly()if results is None:st.error("❌ Optimization failed! The problem may be infeasible with current settings.")st.error("Try adjusting your workforce limits, line counts, or evening shift settings.")return# Store results in session statest.session_state.optimization_results = resultsst.success("✅ Optimization completed successfully!")st.experimental_rerun() # Refresh to show resultsexcept Exception as e:st.error(f"❌ Error during optimization: {str(e)}")st.error("Please check your settings and data files.")def display_optimization_results(results):"""Import and display optimization results"""from optimization_results import display_optimization_results as display_resultsdisplay_results(results)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311"""Optimization Results Display Functions for StreamlitHandles visualization of optimization results with charts and tables"""
import streamlit as stimport pandas as pdimport plotly.express as pximport plotly.graph_objects as goimport sys
def display_optimization_results(results): """Display comprehensive optimization results with visualizations""" st.header("📊 Optimization Results") # Create tabs for different views tab1, tab2, tab3, tab4, tab5 = st.tabs([ "📈 Weekly Summary", "📅 Daily Deep Dive", "🏭 Line Schedules", "📦 Kit Production", "💰 Cost Analysis" ]) with tab1: display_weekly_summary(results) with tab2: display_daily_deep_dive(results) with tab3: display_line_schedules(results) with tab4: display_kit_production(results) with tab5: display_cost_analysis(results)
def display_weekly_summary(results): """Display weekly summary with key metrics and charts""" st.subheader("📈 Weekly Performance Summary") # Key metrics col1, col2, col3, col4 = st.columns(4) with col1: total_cost = results['objective'] st.metric("Total Cost", f"€{total_cost:,.2f}") with col2: total_production = sum(results['weekly_production'].values()) st.metric("Total Production", f"{total_production:,.0f} units") with col3: # Calculate fulfillment rate sys.path.append('src') from config.optimization_config import DEMAND_DICTIONARY total_demand = sum(DEMAND_DICTIONARY.values()) fulfillment_rate = (total_production / total_demand * 100) if total_demand > 0 else 0 st.metric("Fulfillment Rate", f"{fulfillment_rate:.1f}%") with col4: # Calculate cost per unit cost_per_unit = total_cost / total_production if total_production > 0 else 0 st.metric("Cost per Unit", f"€{cost_per_unit:.2f}") # Production vs Demand Chart st.subheader("🎯 Production vs Demand") from config.optimization_config import DEMAND_DICTIONARY prod_demand_data = [] for product, production in results['weekly_production'].items(): demand = DEMAND_DICTIONARY.get(product, 0) prod_demand_data.append({ 'Product': product, 'Production': production, 'Demand': demand, 'Gap': production - demand }) df_prod = pd.DataFrame(prod_demand_data) if not df_prod.empty: # Bar chart comparing production vs demand fig = go.Figure() fig.add_trace(go.Bar(name='Production', x=df_prod['Product'], y=df_prod['Production'], marker_color='lightblue')) fig.add_trace(go.Bar(name='Demand', x=df_prod['Product'], y=df_prod['Demand'], marker_color='orange')) fig.update_layout( title='Weekly Production vs Demand by Product', xaxis_title='Product', yaxis_title='Units', barmode='group', height=400 ) st.plotly_chart(fig, use_container_width=True)
def display_daily_deep_dive(results): """Display daily breakdown with workforce utilization""" st.subheader("📅 Daily Workforce Utilization") # Workforce utilization by day workforce_data = [] for row in results['person_hours_by_day']: workforce_data.append({ 'Day': f"Day {row['day']}", 'Employee Type': row['emp_type'], 'Used Hours': row['used_person_hours'], 'Available Hours': row['cap_person_hours'], 'Utilization %': (row['used_person_hours'] / row['cap_person_hours'] * 100) if row['cap_person_hours'] > 0 else 0 }) df_workforce = pd.DataFrame(workforce_data) if not df_workforce.empty: # Utilization percentage chart fig = px.bar(df_workforce, x='Day', y='Utilization %', color='Employee Type', title='Daily Workforce Utilization by Employee Type', height=400) fig.update_layout(yaxis_title='Utilization Percentage') st.plotly_chart(fig, use_container_width=True) # Detailed table st.subheader("📋 Daily Workforce Details") st.dataframe(df_workforce, use_container_width=True)
def display_line_schedules(results): """Display line schedules showing what runs when and with how many workers""" st.subheader("🏭 Production Line Schedules") # Process schedule data schedule_data = [] sys.path.append('src') from config.optimization_config import TEAM_REQ_PER_PRODUCT, shift_code_to_name, line_code_to_name # Get the mapping dictionaries shift_names = shift_code_to_name() line_names = line_code_to_name() for row in results['run_schedule']: # Get team requirements for this product unicef_workers = TEAM_REQ_PER_PRODUCT.get('UNICEF Fixed term', {}).get(row['product'], 0) humanizer_workers = TEAM_REQ_PER_PRODUCT.get('Humanizer', {}).get(row['product'], 0) total_workers = unicef_workers + humanizer_workers # Convert codes to readable names line_name = line_names.get(row['line_type_id'], f"Line {row['line_type_id']}") shift_name = shift_names.get(row['shift'], f"Shift {row['shift']}") schedule_data.append({ 'Day': f"Day {row['day']}", 'Line': f"{line_name} {row['line_idx']}", 'Shift': shift_name, 'Product': row['product'], 'Hours': round(row['run_hours'], 2), 'Units': round(row['units'], 0), 'UNICEF Workers': unicef_workers, 'Humanizer Workers': humanizer_workers, 'Total Workers': total_workers }) df_schedule = pd.DataFrame(schedule_data) if not df_schedule.empty: # Timeline view st.subheader("⏰ Production Timeline") # Create a Gantt-like chart fig = px.bar(df_schedule, x='Hours', y='Line', color='Product', facet_col='Day', orientation='h', title='Production Schedule by Line and Day', height=500) fig.update_layout(showlegend=True) st.plotly_chart(fig, use_container_width=True) # Detailed schedule table st.subheader("📋 Detailed Production Schedule") st.dataframe(df_schedule, use_container_width=True)
def display_kit_production(results): """Display kit production details""" st.subheader("📦 Kit Production Analysis") # Weekly production summary production_data = [] sys.path.append('src') from config.optimization_config import DEMAND_DICTIONARY for product, production in results['weekly_production'].items(): demand = DEMAND_DICTIONARY.get(product, 0) production_data.append({ 'Product': product, 'Production': production, 'Demand': demand, 'Fulfillment %': (production / demand * 100) if demand > 0 else 0, 'Over/Under': production - demand }) df_production = pd.DataFrame(production_data) if not df_production.empty: # Fulfillment rate chart fig = px.bar(df_production, x='Product', y='Fulfillment %', title='Kit Fulfillment Rate by Product', color='Fulfillment %', color_continuous_scale=['red', 'yellow', 'green'], height=400) fig.add_hline(y=100, line_dash="dash", line_color="black", annotation_text="100% Target") st.plotly_chart(fig, use_container_width=True) # Production summary table st.subheader("📋 Kit Production Summary") st.dataframe(df_production, use_container_width=True)
def display_cost_analysis(results): """Display cost breakdown and analysis""" st.subheader("💰 Cost Breakdown Analysis") # Calculate cost breakdown sys.path.append('src') from config.optimization_config import COST_LIST_PER_EMP_SHIFT, TEAM_REQ_PER_PRODUCT, shift_code_to_name, line_code_to_name # Get the mapping dictionaries shift_names = shift_code_to_name() line_names = line_code_to_name() cost_data = [] total_cost_by_type = {} for row in results['run_schedule']: product = row['product'] hours = row['run_hours'] shift = row['shift'] shift_name = shift_names.get(shift, f"Shift {shift}") line_name = line_names.get(row['line_type_id'], f"Line {row['line_type_id']}") # Calculate costs for this production run (accounting for payment mode) from config.optimization_config import PAYMENT_MODE_CONFIG, MAX_HOUR_PER_SHIFT_PER_PERSON for emp_type in ['UNICEF Fixed term', 'Humanizer']: workers_needed = TEAM_REQ_PER_PRODUCT.get(emp_type, {}).get(product, 0) hourly_rate = COST_LIST_PER_EMP_SHIFT.get(emp_type, {}).get(shift, 0) # Check payment mode for this shift payment_mode = PAYMENT_MODE_CONFIG.get(shift, "partial") if payment_mode == "bulk" and hours > 0: # Bulk payment: pay for full shift hours if workers are active shift_hours = MAX_HOUR_PER_SHIFT_PER_PERSON.get(shift, hours) cost = workers_needed * shift_hours * hourly_rate display_hours = shift_hours # Show full shift hours in display else: # Partial payment: pay for actual hours worked cost = workers_needed * hours * hourly_rate display_hours = hours # Show actual hours in display if emp_type not in total_cost_by_type: total_cost_by_type[emp_type] = 0 total_cost_by_type[emp_type] += cost if cost > 0: # Add payment mode indicator to shift name for clarity payment_indicator = f" ({payment_mode})" if payment_mode == "bulk" else "" cost_data.append({ 'Employee Type': emp_type, 'Day': f"Day {row['day']}", 'Shift': f"{shift_name}{payment_indicator}", 'Line': f"{line_name} {row['line_idx']}", 'Product': product, 'Actual Hours': round(hours, 2), 'Paid Hours': round(display_hours, 2), 'Workers': workers_needed, 'Hourly Rate': f"€{hourly_rate:.2f}", 'Cost': round(cost, 2) }) # Total cost metrics total_cost = results['objective'] col1, col2, col3, col4 = st.columns(4) with col1: st.metric("Total Cost", f"€{total_cost:,.2f}") with col2: unicef_cost = total_cost_by_type.get('UNICEF Fixed term', 0) st.metric("UNICEF Cost", f"€{unicef_cost:,.2f}") with col3: humanizer_cost = total_cost_by_type.get('Humanizer', 0) st.metric("Humanizer Cost", f"€{humanizer_cost:,.2f}") with col4: avg_daily_cost = total_cost / len(set(row['day'] for row in results['run_schedule'])) if results['run_schedule'] else 0 st.metric("Avg Daily Cost", f"€{avg_daily_cost:,.2f}") # Cost breakdown pie chart if total_cost_by_type: fig = px.pie(values=list(total_cost_by_type.values()), names=list(total_cost_by_type.keys()), title='Cost Distribution by Employee Type') st.plotly_chart(fig, use_container_width=True) # Detailed cost table if cost_data: df_costs = pd.DataFrame(cost_data) st.subheader("📋 Detailed Cost Breakdown") st.dataframe(df_costs, use_container_width=True)12 unmodified lines131415161718192021222324252627282930313233343536373845 unmodified lines84858687888990918 unmodified lines1001011021031041051061071081091101114 unmodified lines11611711811912012112261 unmodified lines18418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523658 unmodified lines2952962972982993003013023033043053063073083093103113123134 unmodified lines31831932032132232332432532632732832912 unmodified linesdef get_date_span():print(f"🔧 FORCING NEW DATE RANGE FOR TESTING")# Force use new date range to match user's datafrom datetime import datetimereturn list(range(1, 6)), datetime(2025, 7, 7), datetime(2025, 7, 11) # Force 5 days for user's data# Original logic (commented out for testing)# try:# start_date = dashboard.start_date# end_date = dashboard.end_date# date_span = list(range(1, (end_date - start_date).days + 2))# print(f"date from user input")# print("date span",date_span)# print("start date",start_date)# print("end date",end_date)# return date_span, start_date, end_date# except Exception as e:# print(f"using default value for date span")# # Updated to match the user's data in COOIS_Released_Prod_Orders.csv# from datetime import datetime# return list(range(1, 6)), datetime(2025, 7, 7), datetime(2025, 7, 11) # Default 5 days#fetch date from streamlit or default value. The streamlit and default references the demand data (COOIS_Planned_and_Released.csv)45 unmodified lines# Evening shift activation mode - define early to avoid circular dependency# Options:# "normal" - Only use regular shift (1) and overtime shift (2)# "activate_evening" - Allow evening shift (3) when demand is too high or cost-effective# "always_available" - Evening shift always available as optionEVENING_SHIFT_MODE = "normal" # Default: only regular + overtime8 unmodified linesall_shifts = get_shift_list()if EVENING_SHIFT_MODE == "normal":# Only regular (1) and overtime (2) shiftsactive_shifts = [s for s in all_shifts if s in [1, 2]]print(f"[SHIFT MODE] Normal mode: Using shifts {active_shifts} (Regular + Overtime only)")elif EVENING_SHIFT_MODE == "activate_evening":# All shifts including evening (3)active_shifts = list(all_shifts)print(f"[SHIFT MODE] Evening activated: Using all shifts {active_shifts}")4 unmodified lineselse:# Default to normal modeactive_shifts = [s for s in all_shifts if s in [1, 2]]print(f"[SHIFT MODE] Unknown mode '{EVENING_SHIFT_MODE}', defaulting to normal: {active_shifts}")return active_shifts61 unmodified linesdef get_line_cnt_per_type():try:streamlit_line_cnt_per_type = dashboard.line_cnt_per_typereturn streamlit_line_cnt_per_typeexcept Exception as e:print(f"using default value for line cnt per type")line_df = extract.read_packaging_line_data()line_cnt_per_type = line_df.set_index("id")["line_count"].to_dict()print("line cnt per type")print(line_cnt_per_type)return line_cnt_per_typeLINE_CNT_PER_TYPE = get_line_cnt_per_type()print("line cnt per type",LINE_CNT_PER_TYPE)def get_demand_dictionary():try:streamlit_demand_dictionary = dashboard.demand_dictionaryreturn streamlit_demand_dictionaryexcept Exception as e:# Use released orders instead of planned orders for demanddemand_df = extract.read_released_orders_data(start_date=start_date, end_date=end_date)demand_dictionary = demand_df.groupby('Material Number')["Order quantity (GMEIN)"].sum().to_dict()print(f"📈 DEMAND DATA: {len(demand_dictionary)} products with total demand {sum(demand_dictionary.values())}")return demand_dictionaryDEMAND_DICTIONARY = get_demand_dictionary()print(f"🎯 FINAL DEMAND: {DEMAND_DICTIONARY}")def get_cost_list_per_emp_shift():try:streamlit_cost_list_per_emp_shift = dashboard.cost_list_per_emp_shiftreturn streamlit_cost_list_per_emp_shiftexcept Exception as e:print(f"using default value for cost list per emp shift")shift_cost_df = extract.read_shift_cost_data()#question - Important : there is multiple type of employment type in terms of the cost#Shift 1 = normal, 2 = evening, 3 = overtimereturn {"UNICEF Fixed term":{1:43.27,2:43.27,3:64.91},"Humanizer":{1:27.94,2:27.94,3:41.91}}def shift_code_to_name():shift_code_to_name_dict = {1: "normal",2: "evening",3: "overtime"}return shift_code_to_name_dictCOST_LIST_PER_EMP_SHIFT = get_cost_list_per_emp_shift()# print("cost list per emp shift",COST_LIST_PER_EMP_SHIFT)58 unmodified linesdef get_max_employee_per_type_on_day():try:max_employee_per_type_on_day = dashboard.max_employee_per_type_on_dayreturn max_employee_per_type_on_dayexcept Exception as e:print(f"using default value for max employee per type on day")max_employee_per_type_on_day = {"UNICEF Fixed term": {t: 8 for t in DATE_SPAN},"Humanizer": {t: 10 for t in DATE_SPAN}}return max_employee_per_type_on_dayMAX_EMPLOYEE_PER_TYPE_ON_DAY = get_max_employee_per_type_on_day()print("max employee per type on day",MAX_EMPLOYEE_PER_TYPE_ON_DAY)4 unmodified linesMAX_HOUR_PER_SHIFT_PER_PERSON = {1: 7.5, 2: 7.5, 3: 5} #1 = normal, 2 = evening, 3 = overtimedef get_per_product_speed():try:streamlit_per_product_speed = dashboard.per_product_speedreturn streamlit_per_product_speedexcept Exception as e:print(f"using default value for per product speed")per_product_speed = extract.read_package_speed_data()return per_product_speed# Get per product speed - will use actual product names from PRODUCT_LIST12 unmodified lines13141516171819202122232425262728293031323334353645 unmodified lines82838485868788898 unmodified lines98991001011021031041051061071081094 unmodified lines11411511611711811912061 unmodified lines18218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425558 unmodified lines3143153163173183193203213223233243253263273283293303313323333343353363374 unmodified lines34234334434534634734834935035135235335435535635735812 unmodified linesdef get_date_span():try:# Try to get from streamlit session state (from config page)import streamlit as stif hasattr(st, 'session_state') and 'start_date' in st.session_state and 'end_date' in st.session_state:from datetime import datetimestart_date = datetime.combine(st.session_state.start_date, datetime.min.time())end_date = datetime.combine(st.session_state.end_date, datetime.min.time())date_span = list(range(1, (end_date - start_date).days + 2))print(f"Using dates from config page: {start_date} to {end_date}")print("date span", date_span)return date_span, start_date, end_dateexcept Exception as e:print(f"Could not get dates from streamlit session: {e}")print(f"Loading default date values")# Default to match the user's data in COOIS_Released_Prod_Orders.csvfrom datetime import datetimereturn list(range(1, 6)), datetime(2025, 7, 7), datetime(2025, 7, 11) # Default 5 days#fetch date from streamlit or default value. The streamlit and default references the demand data (COOIS_Planned_and_Released.csv)45 unmodified lines# Evening shift activation mode - define early to avoid circular dependency# Options:# "normal" - Only use regular shift (1) and overtime shift (3) - NO evening shift# "activate_evening" - Allow evening shift (2) when demand is too high or cost-effective# "always_available" - Evening shift always available as optionEVENING_SHIFT_MODE = "normal" # Default: only regular + overtime8 unmodified linesall_shifts = get_shift_list()if EVENING_SHIFT_MODE == "normal":# Only regular (1) and overtime (3) shifts - NO evening shiftactive_shifts = [s for s in all_shifts if s in [1, 3]]print(f"[SHIFT MODE] Normal mode: Using shifts {active_shifts} (Regular + Overtime only, NO evening)")elif EVENING_SHIFT_MODE == "activate_evening":# All shifts including evening (2)active_shifts = list(all_shifts)print(f"[SHIFT MODE] Evening activated: Using all shifts {active_shifts}")4 unmodified lineselse:# Default to normal modeactive_shifts = [s for s in all_shifts if s in [1, 3]]print(f"[SHIFT MODE] Unknown mode '{EVENING_SHIFT_MODE}', defaulting to normal: {active_shifts}")return active_shifts61 unmodified linesdef get_line_cnt_per_type():try:# Try to get from streamlit session state (from config page)import streamlit as stif hasattr(st, 'session_state') and 'line_counts' in st.session_state:print(f"Using line counts from config page: {st.session_state.line_counts}")return st.session_state.line_countsexcept Exception as e:print(f"Could not get line counts from streamlit session: {e}")print(f"Loading default line count values from data files")line_df = extract.read_packaging_line_data()line_cnt_per_type = line_df.set_index("id")["line_count"].to_dict()print("line cnt per type", line_cnt_per_type)return line_cnt_per_typeLINE_CNT_PER_TYPE = get_line_cnt_per_type()print("line cnt per type",LINE_CNT_PER_TYPE)def get_demand_dictionary():try:# Try to get from streamlit session state (from config page)import streamlit as stif hasattr(st, 'session_state') and 'demand_dictionary' in st.session_state:print(f"Using demand dictionary from config page: {len(st.session_state.demand_dictionary)} products")return st.session_state.demand_dictionaryexcept Exception as e:print(f"Could not get demand dictionary from streamlit session: {e}")print(f"Loading default demand values from data files")# Use released orders instead of planned orders for demanddemand_df = extract.read_released_orders_data(start_date=start_date, end_date=end_date)demand_dictionary = demand_df.groupby('Material Number')["Order quantity (GMEIN)"].sum().to_dict()print(f"📈 DEMAND DATA: {len(demand_dictionary)} products with total demand {sum(demand_dictionary.values())}")return demand_dictionaryDEMAND_DICTIONARY = get_demand_dictionary()print(f"🎯 FINAL DEMAND: {DEMAND_DICTIONARY}")def get_cost_list_per_emp_shift():try:# Try to get from streamlit session state (from config page)import streamlit as stif hasattr(st, 'session_state') and 'cost_list_per_emp_shift' in st.session_state:print(f"Using cost list from config page: {st.session_state.cost_list_per_emp_shift}")return st.session_state.cost_list_per_emp_shiftexcept Exception as e:print(f"Could not get cost list from streamlit session: {e}")print(f"Loading default cost values")# Default hourly rates - Important: multiple employment types with different costs# Shift 1 = normal, 2 = evening, 3 = overtimereturn {"UNICEF Fixed term":{1:43.27,2:43.27,3:64.91},"Humanizer":{1:27.94,2:27.94,3:41.91}}def shift_code_to_name():shift_code_to_name_dict = {1: "Regular",2: "Evening",3: "Overtime"}return shift_code_to_name_dictdef line_code_to_name():"""Convert line type IDs to readable names"""line_code_to_name_dict = {6: "Long Line",7: "Mini Load"}return line_code_to_name_dictCOST_LIST_PER_EMP_SHIFT = get_cost_list_per_emp_shift()# print("cost list per emp shift",COST_LIST_PER_EMP_SHIFT)58 unmodified linesdef get_max_employee_per_type_on_day():try:# Try to get from streamlit session state (from config page)import streamlit as stif hasattr(st, 'session_state') and 'max_employee_per_type_on_day' in st.session_state:print(f"Using max employee counts from config page: {st.session_state.max_employee_per_type_on_day}")return st.session_state.max_employee_per_type_on_dayexcept Exception as e:print(f"Could not get max employee counts from streamlit session: {e}")print(f"Loading default max employee values")max_employee_per_type_on_day = {"UNICEF Fixed term": {t: 8 for t in DATE_SPAN},"Humanizer": {t: 10 for t in DATE_SPAN}}return max_employee_per_type_on_dayMAX_EMPLOYEE_PER_TYPE_ON_DAY = get_max_employee_per_type_on_day()print("max employee per type on day",MAX_EMPLOYEE_PER_TYPE_ON_DAY)4 unmodified linesMAX_HOUR_PER_SHIFT_PER_PERSON = {1: 7.5, 2: 7.5, 3: 5} #1 = normal, 2 = evening, 3 = overtimedef get_per_product_speed():try:# Try to get from streamlit session state (from config page)import streamlit as stif hasattr(st, 'session_state') and 'per_product_speed' in st.session_state:print(f"Using per product speed from config page: {st.session_state.per_product_speed}")return st.session_state.per_product_speedexcept Exception as e:print(f"Could not get per product speed from streamlit session: {e}")print(f"Loading default per product speed from data files")per_product_speed = extract.read_package_speed_data()return per_product_speed# Get per product speed - will use actual product names from PRODUCT_LIST
147 unmodified lines148149150151152153154161 unmodified lines316317318319320321322323324325326327328329330147 unmodified linestotal_demand = sum(DEMAND_DICTIONARY.get(p, 0) for p in P)# Calculate maximum capacity with regular + overtime shifts onlyregular_overtime_shifts = [s for s in S if s in [1, 2]] # Only shifts 1, 2max_capacity = 0for p in P:161 unmodified lines<= MAX_HOUR_PER_PERSON_PER_DAY * N_day[e][t])# 7) OT after usual (optional but kept)for e in E:for t in D:solver.Add(solver.Sum(TEAM_REQ_PER_PRODUCT[e][p] * T[p, ell, 2, t] for p in P for ell in L)<=solver.Sum(TEAM_REQ_PER_PRODUCT[e][p] * T[p, ell, 1, t] for p in P for ell in L))# (if needed, evening(3) after usual(1): sum(...)_s=3 ≤ sum(...)_s=1)# 7.5) Bulk payment linking constraints are now handled inline in the cost calculation147 unmodified lines148149150151152153154161 unmodified lines316317318319320321322323324325326327328329330331332333334335336337338339340341147 unmodified linestotal_demand = sum(DEMAND_DICTIONARY.get(p, 0) for p in P)# Calculate maximum capacity with regular + overtime shifts onlyregular_overtime_shifts = [s for s in S if s in [1, 3]] # Only shifts 1, 3 (regular + overtime)max_capacity = 0for p in P:161 unmodified lines<= MAX_HOUR_PER_PERSON_PER_DAY * N_day[e][t])# 7) Shift ordering constraints (only apply if shifts are available)# Evening shift (2) after regular shift (1)if 2 in S and 1 in S: # Only if both shifts are availablefor e in E:for t in D:solver.Add(solver.Sum(TEAM_REQ_PER_PRODUCT[e][p] * T[p, ell, 2, t] for p in P for ell in L)<=solver.Sum(TEAM_REQ_PER_PRODUCT[e][p] * T[p, ell, 1, t] for p in P for ell in L))# Overtime shift (3) after regular shift (1)if 3 in S and 1 in S: # Only if both shifts are availablefor e in E:for t in D:solver.Add(solver.Sum(TEAM_REQ_PER_PRODUCT[e][p] * T[p, ell, 3, t] for p in P for ell in L)<=solver.Sum(TEAM_REQ_PER_PRODUCT[e][p] * T[p, ell, 1, t] for p in P for ell in L))# 7.5) Bulk payment linking constraints are now handled inline in the cost calculation
app.py+4-6
config_page.py+413-68
optimization_results.pyAdded+311
src/config/optimization_config.py+97-68
src/models/optimizer_real.py+21-10