feat: upgrade recommended truck fleet capacity from 5T to 15T heavy compactor
Browse files- app.py +4 -5
- frontend/app.js +2 -2
- frontend/index.html +1 -1
app.py
CHANGED
|
@@ -465,13 +465,12 @@ async def predict_waste_volume(req: PredictionRequest):
|
|
| 465 |
paper_waste_ton=round(calibrated_volume*paper_r, 2), metal_waste_ton=round(calibrated_volume*metal_r, 2),
|
| 466 |
glass_waste_ton=round(calibrated_volume*glass_r, 2), textile_waste_ton=round(calibrated_volume*textile_r, 2),
|
| 467 |
other_waste_ton=round(calibrated_volume*other_r, 2),
|
| 468 |
-
recommended_trucks=max(1, int(np.ceil(calibrated_volume/
|
| 469 |
risk_status=risk, event_info=info, hourly_breakdown=hourly
|
| 470 |
))
|
| 471 |
|
| 472 |
trucks = sum([r.recommended_trucks for r in results])
|
| 473 |
msg = f"CRITICAL at {req.location}!" if max_risk == "CRITICAL" else f"WARNING at {req.location}." if max_risk == "WARNING" else "Normal conditions."
|
| 474 |
-
conf = 0.9828 if req.model_type == "gradient_boosting" else 0.92
|
| 475 |
|
| 476 |
# Return accuracy score dynamically (Chronos is default 0.92, GBR shows training test score ~0.93)
|
| 477 |
conf = 0.9325 if req.model_type == "gradient_boosting" else 0.92
|
|
@@ -483,7 +482,7 @@ async def predict_waste_volume(req: PredictionRequest):
|
|
| 483 |
logistics_plan=LogisticsPlan(
|
| 484 |
trucks_needed=trucks,
|
| 485 |
manpower=trucks*3,
|
| 486 |
-
estimated_duration_hours=round(total_vol/
|
| 487 |
efficiency_rate="85% (Optimal)"
|
| 488 |
)
|
| 489 |
)
|
|
@@ -506,7 +505,7 @@ async def predict_waste_volume_csv(req: PredictionRequest):
|
|
| 506 |
"Organic Waste (Tons)", "Plastic Waste (Tons)",
|
| 507 |
"Paper Waste (Tons)", "Metal Waste (Tons)",
|
| 508 |
"Glass Waste (Tons)", "Textile Waste (Tons)",
|
| 509 |
-
"Risk Status", "Event Info", "Recommended Trucks (
|
| 510 |
])
|
| 511 |
|
| 512 |
for r in res.data.prediction_results:
|
|
@@ -606,7 +605,7 @@ async def get_autopilot_data():
|
|
| 606 |
raw_pred = dataset_mean # Fallback
|
| 607 |
|
| 608 |
calibrated_volume = round(float(raw_pred * calibration_factor), 2)
|
| 609 |
-
trucks = max(1, int(np.ceil(calibrated_volume /
|
| 610 |
|
| 611 |
status = "CRITICAL" if calibrated_volume > config["critical_threshold"] else "WARNING" if calibrated_volume > config["warning_threshold"] else "SAFE"
|
| 612 |
|
|
|
|
| 465 |
paper_waste_ton=round(calibrated_volume*paper_r, 2), metal_waste_ton=round(calibrated_volume*metal_r, 2),
|
| 466 |
glass_waste_ton=round(calibrated_volume*glass_r, 2), textile_waste_ton=round(calibrated_volume*textile_r, 2),
|
| 467 |
other_waste_ton=round(calibrated_volume*other_r, 2),
|
| 468 |
+
recommended_trucks=max(1, int(np.ceil(calibrated_volume/15))),
|
| 469 |
risk_status=risk, event_info=info, hourly_breakdown=hourly
|
| 470 |
))
|
| 471 |
|
| 472 |
trucks = sum([r.recommended_trucks for r in results])
|
| 473 |
msg = f"CRITICAL at {req.location}!" if max_risk == "CRITICAL" else f"WARNING at {req.location}." if max_risk == "WARNING" else "Normal conditions."
|
|
|
|
| 474 |
|
| 475 |
# Return accuracy score dynamically (Chronos is default 0.92, GBR shows training test score ~0.93)
|
| 476 |
conf = 0.9325 if req.model_type == "gradient_boosting" else 0.92
|
|
|
|
| 482 |
logistics_plan=LogisticsPlan(
|
| 483 |
trucks_needed=trucks,
|
| 484 |
manpower=trucks*3,
|
| 485 |
+
estimated_duration_hours=round(total_vol/15, 1),
|
| 486 |
efficiency_rate="85% (Optimal)"
|
| 487 |
)
|
| 488 |
)
|
|
|
|
| 505 |
"Organic Waste (Tons)", "Plastic Waste (Tons)",
|
| 506 |
"Paper Waste (Tons)", "Metal Waste (Tons)",
|
| 507 |
"Glass Waste (Tons)", "Textile Waste (Tons)",
|
| 508 |
+
"Risk Status", "Event Info", "Recommended Trucks (15T)"
|
| 509 |
])
|
| 510 |
|
| 511 |
for r in res.data.prediction_results:
|
|
|
|
| 605 |
raw_pred = dataset_mean # Fallback
|
| 606 |
|
| 607 |
calibrated_volume = round(float(raw_pred * calibration_factor), 2)
|
| 608 |
+
trucks = max(1, int(np.ceil(calibrated_volume / 15)))
|
| 609 |
|
| 610 |
status = "CRITICAL" if calibrated_volume > config["critical_threshold"] else "WARNING" if calibrated_volume > config["warning_threshold"] else "SAFE"
|
| 611 |
|
frontend/app.js
CHANGED
|
@@ -468,7 +468,7 @@ function updateDashboardData(data, confScore, message) {
|
|
| 468 |
updateMarkerRisk(selectedLocation, maxRisk);
|
| 469 |
drawTransitRoute(selectedLocation);
|
| 470 |
|
| 471 |
-
if (statTrucks) statTrucks.innerHTML = `${data.logistics_plan.trucks_needed} <span class="unit">Trucks (
|
| 472 |
|
| 473 |
const startDateStr = results[0].date;
|
| 474 |
const endDateStr = results[results.length - 1].date;
|
|
@@ -724,7 +724,7 @@ async function loadAutopilotFeed() {
|
|
| 724 |
await new Promise(r => setTimeout(r, 500));
|
| 725 |
|
| 726 |
autoVol.innerHTML = `${data.total_volume_ton.toLocaleString('en-US')} <span class="unit">Tons</span>`;
|
| 727 |
-
autoTrucks.innerHTML = `${data.total_trucks.toLocaleString('en-US')} <span class="unit">Trucks (
|
| 728 |
|
| 729 |
autoRiskList.innerHTML = "";
|
| 730 |
data.top_kecamatan.forEach((item, index) => {
|
|
|
|
| 468 |
updateMarkerRisk(selectedLocation, maxRisk);
|
| 469 |
drawTransitRoute(selectedLocation);
|
| 470 |
|
| 471 |
+
if (statTrucks) statTrucks.innerHTML = `${data.logistics_plan.trucks_needed} <span class="unit">Trucks (15T)</span>`;
|
| 472 |
|
| 473 |
const startDateStr = results[0].date;
|
| 474 |
const endDateStr = results[results.length - 1].date;
|
|
|
|
| 724 |
await new Promise(r => setTimeout(r, 500));
|
| 725 |
|
| 726 |
autoVol.innerHTML = `${data.total_volume_ton.toLocaleString('en-US')} <span class="unit">Tons</span>`;
|
| 727 |
+
autoTrucks.innerHTML = `${data.total_trucks.toLocaleString('en-US')} <span class="unit">Trucks (15T)</span>`;
|
| 728 |
|
| 729 |
autoRiskList.innerHTML = "";
|
| 730 |
data.top_kecamatan.forEach((item, index) => {
|
frontend/index.html
CHANGED
|
@@ -264,7 +264,7 @@
|
|
| 264 |
</div>
|
| 265 |
<div class="panel stat-card">
|
| 266 |
<span class="card-label">RECOMMENDED FLEET</span>
|
| 267 |
-
<span id="stat-trucks" class="card-value">0 <span class="unit">Trucks (
|
| 268 |
<span class="card-meta">Logistics Fleet Suggestion</span>
|
| 269 |
</div>
|
| 270 |
</div>
|
|
|
|
| 264 |
</div>
|
| 265 |
<div class="panel stat-card">
|
| 266 |
<span class="card-label">RECOMMENDED FLEET</span>
|
| 267 |
+
<span id="stat-trucks" class="card-value">0 <span class="unit">Trucks (15T)</span></span>
|
| 268 |
<span class="card-meta">Logistics Fleet Suggestion</span>
|
| 269 |
</div>
|
| 270 |
</div>
|