File size: 4,707 Bytes
4a67235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# 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.")