Spaces:
Running
Running
Commit ·
ed62651
1
Parent(s): 95b8c77
Simplify and reorganize sidebar controls
Browse filesNew structure by question:
- 💰 Pricing: Monthly lease price
- ♻️ Circularity: Return rate, % needing repair
- 💵 Costs: Manufacturing, avg refurb, logistics
Changes:
- Removed "Customers per month" (doesn't affect per-product economics)
- Combined Grade A/B/C into single "Products Needing Repair" slider
- Combined Refurb A/B costs into single "Avg. Refurbishment Cost"
- Added € formatting to cost sliders
- Added % formatting to rate sliders
- Cleaner category headers with icons
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -113,103 +113,96 @@ selected_product = st.sidebar.selectbox(
|
|
| 113 |
config = products[selected_product]
|
| 114 |
|
| 115 |
# ============================================================
|
| 116 |
-
# SIDEBAR CONTROLS
|
| 117 |
# ============================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
st.sidebar.markdown("---")
|
| 119 |
-
st.sidebar.header("
|
| 120 |
|
| 121 |
-
# Sliders for key parameters
|
| 122 |
return_rate = st.sidebar.slider(
|
| 123 |
"Return Rate",
|
| 124 |
min_value=0.50,
|
| 125 |
max_value=1.00,
|
| 126 |
value=config["return_assumptions"]["return_rate"],
|
| 127 |
step=0.05,
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
grade_a_pct = st.sidebar.slider(
|
| 132 |
-
"Grade A (Reusable) %",
|
| 133 |
-
min_value=0.30,
|
| 134 |
-
max_value=0.90,
|
| 135 |
-
value=config["return_assumptions"]["grade_distribution"]["a"],
|
| 136 |
-
step=0.05,
|
| 137 |
-
help="Products needing only wash + inspect",
|
| 138 |
)
|
| 139 |
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
|
| 142 |
min_value=0.05,
|
| 143 |
max_value=0.50,
|
| 144 |
-
value=
|
| 145 |
step=0.05,
|
| 146 |
-
|
| 147 |
-
)
|
| 148 |
-
|
| 149 |
-
grade_c_pct = 1.0 - grade_a_pct - grade_b_pct
|
| 150 |
-
if grade_c_pct < 0:
|
| 151 |
-
st.sidebar.error("Grade A + B cannot exceed 100%")
|
| 152 |
-
grade_c_pct = 0.0
|
| 153 |
-
grade_a_pct = 0.5
|
| 154 |
-
grade_b_pct = 0.5
|
| 155 |
-
|
| 156 |
-
lease_price = st.sidebar.slider(
|
| 157 |
-
"Monthly Lease Price (EUR)",
|
| 158 |
-
min_value=10,
|
| 159 |
-
max_value=50,
|
| 160 |
-
value=config["pricing"]["lease_monthly"],
|
| 161 |
-
step=1,
|
| 162 |
)
|
| 163 |
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
value=10,
|
| 169 |
-
step=1,
|
| 170 |
-
help="Monthly customer acquisition rate",
|
| 171 |
-
)
|
| 172 |
|
| 173 |
-
#
|
| 174 |
st.sidebar.markdown("---")
|
| 175 |
-
st.sidebar.header("
|
| 176 |
|
| 177 |
mfg_cost = st.sidebar.slider(
|
| 178 |
-
"Manufacturing Cost
|
| 179 |
min_value=50,
|
| 180 |
-
max_value=
|
| 181 |
value=config["costs"]["manufacturing_unit_cost"],
|
| 182 |
-
step=
|
|
|
|
| 183 |
help="Cost to manufacture a new unit",
|
| 184 |
)
|
| 185 |
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
)
|
| 194 |
-
|
| 195 |
-
refurb_b = st.sidebar.slider(
|
| 196 |
-
"Refurb Cost - Grade B (EUR)",
|
| 197 |
-
min_value=20,
|
| 198 |
-
max_value=100,
|
| 199 |
-
value=config["costs"]["refurbishment"]["grade_b"],
|
| 200 |
step=5,
|
| 201 |
-
|
|
|
|
| 202 |
)
|
| 203 |
|
| 204 |
logistics = st.sidebar.slider(
|
| 205 |
-
"Logistics
|
| 206 |
min_value=5,
|
| 207 |
max_value=40,
|
| 208 |
value=config["costs"]["logistics"]["delivery"] + config["costs"]["logistics"]["return"],
|
| 209 |
-
step=
|
|
|
|
| 210 |
help="Delivery + return shipping",
|
| 211 |
)
|
| 212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
# ============================================================
|
| 214 |
# PRODUCT HEADER (uses slider values)
|
| 215 |
# ============================================================
|
|
@@ -255,12 +248,11 @@ with header_col2:
|
|
| 255 |
|
| 256 |
st.markdown("---")
|
| 257 |
|
| 258 |
-
# Calculate EoLRR
|
| 259 |
eolrr = return_rate * (grade_a_pct + grade_b_pct)
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
avg_refurb_cost = refurb_a
|
| 264 |
|
| 265 |
# Unit costs
|
| 266 |
new_unit_cost = mfg_cost + logistics
|
|
|
|
| 113 |
config = products[selected_product]
|
| 114 |
|
| 115 |
# ============================================================
|
| 116 |
+
# SIDEBAR CONTROLS
|
| 117 |
# ============================================================
|
| 118 |
+
|
| 119 |
+
# --- PRICING ---
|
| 120 |
+
st.sidebar.header("💰 Pricing")
|
| 121 |
+
lease_price = st.sidebar.slider(
|
| 122 |
+
"Monthly Lease Price",
|
| 123 |
+
min_value=10,
|
| 124 |
+
max_value=60,
|
| 125 |
+
value=config["pricing"]["lease_monthly"],
|
| 126 |
+
step=1,
|
| 127 |
+
format="€%d",
|
| 128 |
+
help="What customers pay per month",
|
| 129 |
+
)
|
| 130 |
+
|
| 131 |
+
# --- CIRCULARITY ---
|
| 132 |
st.sidebar.markdown("---")
|
| 133 |
+
st.sidebar.header("♻️ Circularity")
|
| 134 |
|
|
|
|
| 135 |
return_rate = st.sidebar.slider(
|
| 136 |
"Return Rate",
|
| 137 |
min_value=0.50,
|
| 138 |
max_value=1.00,
|
| 139 |
value=config["return_assumptions"]["return_rate"],
|
| 140 |
step=0.05,
|
| 141 |
+
format="%.0f%%",
|
| 142 |
+
help="% of products returned at end of lease",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
)
|
| 144 |
|
| 145 |
+
# Simplified: What % of returned products need significant repair?
|
| 146 |
+
default_refurb_pct = config["return_assumptions"]["grade_distribution"]["b"] + config["return_assumptions"]["grade_distribution"].get("c", 0.05)
|
| 147 |
+
refurb_needed_pct = st.sidebar.slider(
|
| 148 |
+
"Products Needing Repair",
|
| 149 |
min_value=0.05,
|
| 150 |
max_value=0.50,
|
| 151 |
+
value=min(0.50, default_refurb_pct),
|
| 152 |
step=0.05,
|
| 153 |
+
format="%.0f%%",
|
| 154 |
+
help="% of returns that need parts replacement (rest just need cleaning)",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
)
|
| 156 |
|
| 157 |
+
# Derive grade distribution from single slider
|
| 158 |
+
grade_a_pct = 1.0 - refurb_needed_pct - 0.05 # 5% always scrap
|
| 159 |
+
grade_b_pct = refurb_needed_pct
|
| 160 |
+
grade_c_pct = 0.05 # Fixed 5% scrap rate
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
+
# --- COSTS ---
|
| 163 |
st.sidebar.markdown("---")
|
| 164 |
+
st.sidebar.header("💵 Costs")
|
| 165 |
|
| 166 |
mfg_cost = st.sidebar.slider(
|
| 167 |
+
"Manufacturing Cost",
|
| 168 |
min_value=50,
|
| 169 |
+
max_value=250,
|
| 170 |
value=config["costs"]["manufacturing_unit_cost"],
|
| 171 |
+
step=10,
|
| 172 |
+
format="€%d",
|
| 173 |
help="Cost to manufacture a new unit",
|
| 174 |
)
|
| 175 |
|
| 176 |
+
# Simplified: single refurb cost (weighted average handled internally)
|
| 177 |
+
default_avg_refurb = (config["costs"]["refurbishment"]["grade_a"] * 0.7 +
|
| 178 |
+
config["costs"]["refurbishment"]["grade_b"] * 0.3)
|
| 179 |
+
avg_refurb_cost_input = st.sidebar.slider(
|
| 180 |
+
"Avg. Refurbishment Cost",
|
| 181 |
+
min_value=10,
|
| 182 |
+
max_value=80,
|
| 183 |
+
value=int(default_avg_refurb),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
step=5,
|
| 185 |
+
format="€%d",
|
| 186 |
+
help="Average cost to refurbish a returned product",
|
| 187 |
)
|
| 188 |
|
| 189 |
logistics = st.sidebar.slider(
|
| 190 |
+
"Logistics (per cycle)",
|
| 191 |
min_value=5,
|
| 192 |
max_value=40,
|
| 193 |
value=config["costs"]["logistics"]["delivery"] + config["costs"]["logistics"]["return"],
|
| 194 |
+
step=5,
|
| 195 |
+
format="€%d",
|
| 196 |
help="Delivery + return shipping",
|
| 197 |
)
|
| 198 |
|
| 199 |
+
# Derive individual refurb costs from average (for calculations that need them)
|
| 200 |
+
refurb_a = int(avg_refurb_cost_input * 0.4) # Grade A is ~40% of average
|
| 201 |
+
refurb_b = int(avg_refurb_cost_input * 1.8) # Grade B is ~180% of average
|
| 202 |
+
|
| 203 |
+
# Fixed simulation parameter (not exposed)
|
| 204 |
+
customers_per_month = 10
|
| 205 |
+
|
| 206 |
# ============================================================
|
| 207 |
# PRODUCT HEADER (uses slider values)
|
| 208 |
# ============================================================
|
|
|
|
| 248 |
|
| 249 |
st.markdown("---")
|
| 250 |
|
| 251 |
+
# Calculate EoLRR (End-of-Life Recovery Rate)
|
| 252 |
eolrr = return_rate * (grade_a_pct + grade_b_pct)
|
| 253 |
+
|
| 254 |
+
# Use the slider value directly for avg refurb cost
|
| 255 |
+
avg_refurb_cost = avg_refurb_cost_input
|
|
|
|
| 256 |
|
| 257 |
# Unit costs
|
| 258 |
new_unit_cost = mfg_cost + logistics
|