Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Extended test script for Fleet Resource Optimization Simulator | |
| """ | |
| from fleet_optimizer import FleetOptimizer | |
| import time | |
| import json | |
| def test_extended_simulation(): | |
| """Test the fleet optimizer with extended simulation""" | |
| print("π Extended Fleet Resource Optimization Test") | |
| print("=" * 60) | |
| # Create optimizer | |
| optimizer = FleetOptimizer() | |
| print(f"β Initialized {optimizer.config.num_vehicles} vehicles") | |
| print(f"β Vehicle capacity: {optimizer.config.vehicle_capacity} passengers") | |
| # Run simulation for more steps to generate demand | |
| print(f"\nπ Running extended simulation (50 steps)...") | |
| print(" This will simulate demand generation and vehicle allocation") | |
| for i in range(50): | |
| optimizer.run_simulation_step() | |
| if i % 5 == 0: # Print stats every 5 steps | |
| stats = optimizer.get_simulation_stats() | |
| print(f" Step {i+1:2d}: {stats['available_vehicles']:2d} available, " | |
| f"{stats['busy_vehicles']:2d} busy, " | |
| f"{stats['pending_demands']:2d} pending, " | |
| f"${stats['total_earnings']:6.2f} earnings") | |
| # Final statistics | |
| final_stats = optimizer.get_simulation_stats() | |
| print(f"\nπ Final Statistics:") | |
| print(json.dumps(final_stats, indent=2)) | |
| # Show some vehicle details | |
| print(f"\nπ Vehicle Details (first 5 vehicles):") | |
| for i, vehicle in enumerate(optimizer.vehicles[:5]): | |
| print(f" Vehicle {vehicle.id}: {vehicle.status}, " | |
| f"Earnings: ${vehicle.earnings:.2f}, " | |
| f"Distance: {vehicle.total_distance:.1f}km") | |
| # Show some demand details | |
| if optimizer.demands: | |
| print(f"\nπ Demand Details (first 5 demands):") | |
| for i, demand in enumerate(optimizer.demands[:5]): | |
| print(f" Demand {demand.id}: {demand.status}, " | |
| f"Priority: {demand.priority}, " | |
| f"Passengers: {demand.passengers}") | |
| # Performance metrics | |
| total_vehicles = len(optimizer.vehicles) | |
| utilization_rate = (final_stats['busy_vehicles'] / total_vehicles) * 100 | |
| avg_earnings_per_vehicle = final_stats['total_earnings'] / total_vehicles | |
| print(f"\nπ Performance Metrics:") | |
| print(f" Vehicle Utilization Rate: {utilization_rate:.1f}%") | |
| print(f" Average Earnings per Vehicle: ${avg_earnings_per_vehicle:.2f}") | |
| print(f" Total Demands Generated: {final_stats['total_demands']}") | |
| print(f" Pending Demands: {final_stats['pending_demands']}") | |
| print(f"\nπ Extended fleet optimization test completed successfully!") | |
| if __name__ == "__main__": | |
| test_extended_simulation() | |