Spaces:
Running
Running
| # app.py | |
| # TripAI β Intelligent Four-Step Travel Demand Modelling | |
| # Main Entry Point for the Multi-Page Streamlit Application | |
| import streamlit as st | |
| st.set_page_config( | |
| page_title="TripAI β Intelligent Four-Step Travel Demand Model", | |
| page_icon="π¦", | |
| layout="wide" | |
| ) | |
| # ========================================================== | |
| # HEADER | |
| # ========================================================== | |
| st.title("π¦ TripAI") | |
| st.markdown("### Intelligent Four-Step Travel Demand Modelling with AI, XAI, and Optimization") | |
| st.markdown( | |
| """ | |
| TripAI is a **research-oriented platform** implementing a complete, synthetic | |
| **four-step travel demand model**, augmented with: | |
| - Classical **Trip Generation β Trip Distribution β Mode Choice β Route Assignment** | |
| - **User Equilibrium (UE)** using FrankβWolfe | |
| - **Machine Learning** (Regression + Classification) | |
| - **Explainable AI** (SHAP) for behavioural insights | |
| - **AI Link Flow Emulator** for fast demand scaling | |
| - **Policy Scenario Engine** with congestion charge, TOD, MRT improvements | |
| - **Scenario Optimization** over policy parameters | |
| Use the **left sidebar** to navigate between phases of the workflow. | |
| """ | |
| ) | |
| # ========================================================== | |
| # SESSION STATUS PANEL | |
| # ========================================================== | |
| st.markdown("---") | |
| st.subheader("π Current Session Status") | |
| col1, col2, col3 = st.columns(3) | |
| # ----- Column 1 ----- | |
| with col1: | |
| st.markdown("**1. Synthetic City**") | |
| if "city" in st.session_state: | |
| taz = st.session_state["city"].taz | |
| st.success(f"Generated ({len(taz)} TAZs)") | |
| st.caption("Go to: `π Generate Synthetic City`") | |
| else: | |
| st.info("Not generated") | |
| st.markdown("**2. Trip Generation**") | |
| if "productions" in st.session_state and "attractions" in st.session_state: | |
| st.success("Done") | |
| st.caption("Go to: `πΆ Trip Generation`") | |
| else: | |
| st.info("Not run") | |
| # ----- Column 2 ----- | |
| with col2: | |
| st.markdown("**3. Trip Distribution**") | |
| if "od" in st.session_state: | |
| st.success("OD matrices available") | |
| st.caption("Go to: `π Trip Distribution`") | |
| else: | |
| st.info("Not run") | |
| st.markdown("**4. Mode Choice**") | |
| if "mode_choice" in st.session_state: | |
| st.success("Mode choice available") | |
| st.caption("Go to: `π Mode Choice`") | |
| else: | |
| st.info("Not run") | |
| # ----- Column 3 ----- | |
| with col3: | |
| st.markdown("**5. Route Assignment**") | |
| if "link_flows" in st.session_state: | |
| st.success("Assignment complete") | |
| st.caption("Go to: `π£οΈ Route Assignment`") | |
| else: | |
| st.info("Not run") | |
| st.markdown("**6. AI / Scenario / Visualization**") | |
| status = [] | |
| if "ai_tripgen_model" in st.session_state: | |
| status.append("AI TripGen") | |
| if "ai_modechoice_model" in st.session_state: | |
| status.append("AI ModeChoice") | |
| if "link_flow_emulator" in st.session_state: | |
| status.append("AI Emulator") | |
| if "opt_results" in st.session_state: | |
| status.append("Optimization") | |
| if status: | |
| st.success(" / ".join(status)) | |
| st.caption("See: `π€ AI`, `π§ Emulator`, `π― Optimization`, `π Visualization`") | |
| else: | |
| st.info("No AI/Scenario modules executed") | |
| # ========================================================== | |
| # WORKFLOW EXPLANATION | |
| # ========================================================== | |
| st.markdown("---") | |
| st.subheader("π§ Recommended Workflow") | |
| st.markdown( | |
| """ | |
| 1. **π Generate Synthetic City** | |
| Build a 20-zone synthetic metro with socio-economic + land-use attributes. | |
| 2. **πΆ Trip Generation** | |
| Compute productions & attractions for HBW, HBE, HBS. | |
| 3. **π Trip Distribution** | |
| Doubly-constrained gravity model with IPF. | |
| 4. **π Mode Choice** | |
| Multinomial Logit (Car / Metro / Bus). | |
| 5. **π£οΈ Route Assignment** | |
| AON or User Equilibrium (FrankβWolfe). | |
| 6. **π€ AI-Enhanced Models** | |
| ML Regression + Classification + SHAP explanations. | |
| 7. **βοΈ Policy Scenario Engine** | |
| Metro improvements, congestion charge, fare changes, TOD. | |
| 8. **π§ AI Link Flow Emulator** | |
| Predict link flows without running UE. | |
| 9. **π― Scenario Optimization** | |
| Search policy space to minimize congestion or car use. | |
| 10. **π Visualization & π¦ Export** | |
| Create research-grade figures & download complete datasets. | |
| """ | |
| ) | |
| st.markdown("---") | |
| st.caption("TripAI β Developed by Mahbub Hassan, BβDeshi Emerging Research Lab.") | |