Spaces:
Sleeping
Sleeping
File size: 5,509 Bytes
b4ce589 | 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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | #!/usr/bin/env python3
"""
Real-time Fleet Resource Optimization Simulator Launcher
Simple launcher script for the comprehensive fleet optimization system
"""
import sys
import os
import subprocess
import time
from pathlib import Path
def check_dependencies():
"""Check if required dependencies are installed"""
required_packages = [
'pandas', 'numpy', 'plotly', 'gradio', 'requests',
'google-generativeai', 'aiohttp'
]
missing_packages = []
for package in required_packages:
try:
__import__(package.replace('-', '_'))
except ImportError:
missing_packages.append(package)
if missing_packages:
print("โ Missing required packages:")
for package in missing_packages:
print(f" - {package}")
print("\n๐ฆ Install missing packages with:")
print(" pip install -r requirements.txt")
return False
print("โ
All required packages are installed")
return True
def test_api_connections():
"""Test API connections"""
print("๐ Testing API connections...")
try:
from realtime_api_client import test_api_connections
test_api_connections()
print("โ
API connections successful")
return True
except Exception as e:
print(f"โ ๏ธ API connection issues: {e}")
print(" The simulator will continue with simulated data")
return False
def launch_demo():
"""Launch the comprehensive demo interface"""
print("๐ Launching Real-time Fleet Optimization Demo...")
try:
from demo_realtime_simulator import main
main()
except KeyboardInterrupt:
print("\n๐ Demo stopped by user")
except Exception as e:
print(f"โ Error launching demo: {e}")
return False
return True
def launch_optimizer():
"""Launch the real-time optimizer only"""
print("๐ Launching Real-time Fleet Optimizer...")
try:
from realtime_fleet_optimizer import create_realtime_fleet_interface
demo = create_realtime_fleet_interface()
demo.launch(share=True, server_name="0.0.0.0", server_port=7860)
except KeyboardInterrupt:
print("\n๐ Optimizer stopped by user")
except Exception as e:
print(f"โ Error launching optimizer: {e}")
return False
return True
def show_menu():
"""Show the main menu"""
print("\n" + "="*60)
print("๐ Real-time Fleet Resource Optimization Simulator")
print("="*60)
print("Choose an option:")
print("1. ๐ฎ Launch Full Demo Interface (Recommended)")
print("2. ๐ Launch Real-time Optimizer Only")
print("3. ๐ Test API Connections")
print("4. ๐ View Analytics Dashboard")
print("5. โ Show Help")
print("6. ๐ช Exit")
print("="*60)
def show_help():
"""Show help information"""
print("\n๐ Help Information")
print("-" * 40)
print("๐ฎ Full Demo Interface:")
print(" - Comprehensive demo with multiple scenarios")
print(" - Rush hour, weather impact, AI optimization demos")
print(" - Interactive testing and validation")
print(" - Access at: http://localhost:7860")
print()
print("๐ Real-time Optimizer:")
print(" - Core fleet optimization system")
print(" - Live dashboard with real-time data")
print(" - AI-powered vehicle allocation")
print(" - Access at: http://localhost:7860")
print()
print("๐ API Connections:")
print(" - Test Google Maps, OpenWeather, and Gemini APIs")
print(" - Verify API keys and connectivity")
print(" - Check rate limiting and caching")
print()
print("๐ Analytics Dashboard:")
print(" - Performance metrics and trends")
print(" - Historical data analysis")
print(" - Export capabilities")
print()
print("๐ง Configuration:")
print(" - API keys are pre-configured")
print(" - Fleet size: 50 vehicles (configurable)")
print(" - Update interval: 30 seconds")
print(" - AI optimization: Enabled by default")
def main():
"""Main launcher function"""
print("๐ Real-time Fleet Resource Optimization Simulator")
print("Initializing...")
# Check dependencies
if not check_dependencies():
sys.exit(1)
# Test API connections
api_status = test_api_connections()
while True:
show_menu()
try:
choice = input("\nEnter your choice (1-6): ").strip()
if choice == '1':
launch_demo()
elif choice == '2':
launch_optimizer()
elif choice == '3':
test_api_connections()
elif choice == '4':
print("๐ Analytics Dashboard")
print(" Run the demo or optimizer to collect analytics data")
print(" Analytics are automatically collected during simulation")
elif choice == '5':
show_help()
elif choice == '6':
print("๐ Goodbye!")
break
else:
print("โ Invalid choice. Please enter 1-6.")
except KeyboardInterrupt:
print("\n๐ Goodbye!")
break
except Exception as e:
print(f"โ Error: {e}")
input("\nPress Enter to continue...")
if __name__ == "__main__":
main()
|