#!/usr/bin/env python3 """ Venue Evaluation and Selection System Technical Requirements Analysis and Scoring Algorithm """ import json import math import hashlib import datetime from typing import Dict, List, Optional, Any, Tuple from dataclasses import dataclass, asdict import collections @dataclass class VenueTechnicalSpecs: """Technical specifications for venue evaluation""" power_capacity_kw: float network_bandwidth_mbps: float load_bearing_kg_m2: float area_m2: float ceiling_height_m: float accessibility_score: float acoustic_rating: float emergency_exits: int parking_spaces: int hvac_capacity: float @dataclass class VenueScore: """Venue scoring results""" venue_id: str technical_score: float capacity_score: float accessibility_score: float logistics_score: float overall_score: float risk_factors: List[str] recommendations: List[str] class VenueEvaluationEngine: """Main venue evaluation and selection engine""" def __init__(self): self.weights = { 'technical': 0.35, 'capacity': 0.25, 'accessibility': 0.20, 'logistics': 0.20 } self.min_requirements = { 'power_capacity_kw': 100.0, 'network_bandwidth_mbps': 1000.0, 'load_bearing_kg_m2': 500.0, 'area_m2': 500.0, 'ceiling_height_m': 3.0, 'accessibility_score': 0.8, 'emergency_exits': 2 } def technical_audit(self, venue_specs: VenueTechnicalSpecs) -> Dict[str, Any]: """Conduct technical audit of venue specifications""" audit_results = { 'power_adequate': venue_specs.power_capacity_kw >= self.min_requirements['power_capacity_kw'], 'network_adequate': venue_specs.network_bandwidth_mbps >= self.min_requirements['network_bandwidth_mbps'], 'load_adequate': venue_specs.load_bearing_kg_m2 >= self.min_requirements['load_bearing_kg_m2'], 'area_adequate': venue_specs.area_m2 >= self.min_requirements['area_m2'], 'height_adequate': venue_specs.ceiling_height_m >= self.min_requirements['ceiling_height_m'], 'accessibility_adequate': venue_specs.accessibility_score >= self.min_requirements['accessibility_score'], 'safety_adequate': venue_specs.emergency_exits >= self.min_requirements['emergency_exits'] } audit_results['compliance_score'] = sum(audit_results.values()) / len(audit_results) audit_results['critical_issues'] = [k for k, v in audit_results.items() if not v and k != 'compliance_score'] return audit_results def calculate_technical_score(self, venue_specs: VenueTechnicalSpecs) -> float: """Calculate technical capability score""" scores = [] # Power capacity scoring (0-100) power_score = min(100, (venue_specs.power_capacity_kw / self.min_requirements['power_capacity_kw']) * 100) scores.append(power_score) # Network bandwidth scoring network_score = min(100, (venue_specs.network_bandwidth_mbps / self.min_requirements['network_bandwidth_mbps']) * 100) scores.append(network_score) # Load bearing capacity load_score = min(100, (venue_specs.load_bearing_kg_m2 / self.min_requirements['load_bearing_kg_m2']) * 100) scores.append(load_score) # Acoustic rating acoustic_score = venue_specs.acoustic_rating * 100 scores.append(acoustic_score) # HVAC capacity hvac_score = min(100, (venue_specs.hvac_capacity / (venue_specs.area_m2 * 0.1)) * 100) scores.append(hvac_score) return sum(scores) / len(scores) def calculate_capacity_score(self, venue_specs: VenueTechnicalSpecs, expected_attendees: int) -> float: """Calculate capacity and space utilization score""" # Area per person calculation (assuming 2m² per person) max_capacity = venue_specs.area_m2 / 2.0 capacity_ratio = expected_attendees / max_capacity if max_capacity > 0 else 0 # Optimal capacity is 70-85% of max if capacity_ratio <= 0.7: capacity_score = 80 elif capacity_ratio <= 0.85: capacity_score = 100 elif capacity_ratio <= 1.0: capacity_score = 90 - (capacity_ratio - 0.85) * 200 else: capacity_score = max(0, 50 - (capacity_ratio - 1.0) * 100) # Ceiling height bonus height_bonus = min(20, (venue_specs.ceiling_height_m - 3.0) * 10) return min(100, capacity_score + height_bonus) def calculate_accessibility_score(self, venue_specs: VenueTechnicalSpecs) -> float: """Calculate accessibility compliance score""" base_score = venue_specs.accessibility_score * 100 # Emergency exits bonus exits_bonus = min(20, venue_specs.emergency_exits * 5) # Parking accessibility parking_ratio = venue_specs.parking_spaces / (venue_specs.area_m2 / 10) if venue_specs.area_m2 > 0 else 0 parking_score = min(20, parking_ratio * 100) return min(100, base_score + exits_bonus + parking_score) def calculate_logistics_score(self, venue_specs: VenueTechnicalSpecs) -> float: """Calculate logistics and operational score""" scores = [] # Load bearing for equipment load_score = min(100, (venue_specs.load_bearing_kg_m2 / 500.0) * 100) scores.append(load_score * 0.3) # Parking availability parking_score = min(100, (venue_specs.parking_spaces / 100.0) * 100) scores.append(parking_score * 0.2) # HVAC for crowd management hvac_score = min(100, (venue_specs.hvac_capacity / (venue_specs.area_m2 * 0.05)) * 100) scores.append(hvac_score * 0.3) # Network for operations network_score = min(100, (venue_specs.network_bandwidth_mbps / 500.0) * 100) scores.append(network_score * 0.2) return sum(scores) def identify_risk_factors(self, venue_specs: VenueTechnicalSpecs, audit_results: Dict) -> List[str]: """Identify potential risk factors""" risks = [] if venue_specs.power_capacity_kw < 150: risks.append("Insufficient power capacity for high-demand equipment") if venue_specs.network_bandwidth_mbps < 2000: risks.append("Limited network bandwidth may affect connectivity") if venue_specs.load_bearing_kg_m2 < 750: risks.append("Load bearing limits restrict heavy equipment setup") if venue_specs.emergency_exits < 4: risks.append("Limited emergency exits may affect safety compliance") if venue_specs.accessibility_score < 0.9: risks.append("Accessibility compliance below optimal standards") if audit_results['compliance_score'] < 0.8: risks.append("Multiple technical requirements not met") return risks def generate_recommendations(self, venue_specs: VenueTechnicalSpecs, scores: Dict[str, float]) -> List[str]: """Generate improvement recommendations""" recommendations = [] if scores['technical'] < 80: if venue_specs.power_capacity_kw < 200: recommendations.append("Upgrade power infrastructure to minimum 200kW") if venue_specs.network_bandwidth_mbps < 2000: recommendations.append("Install high-speed network infrastructure (2Gbps+)") if scores['accessibility'] < 85: recommendations.append("Improve accessibility features to meet compliance standards") if venue_specs.parking_spaces < 200: recommendations.append("Expand parking facilities to accommodate expected attendance") if venue_specs.hvac_capacity < (venue_specs.area_m2 * 0.1): recommendations.append("Upgrade HVAC system for proper climate control") return recommendations def evaluate_venue(self, venue_id: str, venue_specs: VenueTechnicalSpecs, expected_attendees: int) -> VenueScore: """Complete venue evaluation with scoring""" # Technical audit audit_results = self.technical_audit(venue_specs) # Calculate individual scores technical_score = self.calculate_technical_score(venue_specs) capacity_score = self.calculate_capacity_score(venue_specs, expected_attendees) accessibility_score = self.calculate_accessibility_score(venue_specs) logistics_score = self.calculate_logistics_score(venue_specs) # Calculate weighted overall score overall_score = ( technical_score * self.weights['technical'] + capacity_score * self.weights['capacity'] + accessibility_score * self.weights['accessibility'] + logistics_score * self.weights['logistics'] ) # Identify risks and recommendations risk_factors = self.identify_risk_factors(venue_specs, audit_results) recommendations = self.generate_recommendations(venue_specs, { 'technical': technical_score, 'capacity': capacity_score, 'accessibility': accessibility_score, 'logistics': logistics_score }) return VenueScore( venue_id=venue_id, technical_score=technical_score, capacity_score=capacity_score, accessibility_score=accessibility_score, logistics_score=logistics_score, overall_score=overall_score, risk_factors=risk_factors, recommendations=recommendations ) def rank_venues(self, venue_scores: List[VenueScore]) -> List[VenueScore]: """Rank venues by overall score""" return sorted(venue_scores, key=lambda x: x.overall_score, reverse=True) def export_results(self, venue_scores: List[VenueScore], filename: str = "venue_evaluation_results"): """Export evaluation results to JSON""" results = { 'evaluation_timestamp': datetime.datetime.now().isoformat(), 'evaluation_engine_version': '1.0', 'venues_evaluated': len(venue_scores), 'ranked_venues': [asdict(score) for score in self.rank_venues(venue_scores)] } # Create results file results_json = json.dumps(results, indent=2) results_hash = hashlib.sha256(results_json.encode()).hexdigest()[:16] output_file = f"{filename}_{results_hash}.json" return output_file, results_json # Test data and demonstration def create_test_venues(): """Create test venue data for demonstration""" venues = [ ("CONVENTION_CENTER_A", VenueTechnicalSpecs( power_capacity_kw=500.0, network_bandwidth_mbps=5000.0, load_bearing_kg_m2=1000.0, area_m2=2000.0, ceiling_height_m=8.0, accessibility_score=0.95, acoustic_rating=0.9, emergency_exits=6, parking_spaces=500, hvac_capacity=300.0 )), ("HOTEL_BALLROOM_B", VenueTechnicalSpecs( power_capacity_kw=150.0, network_bandwidth_mbps=1000.0, load_bearing_kg_m2=500.0, area_m2=800.0, ceiling_height_m=4.5, accessibility_score=0.85, acoustic_rating=0.7, emergency_exits=3, parking_spaces=200, hvac_capacity=80.0 )), ("STADIUM_C", VenueTechnicalSpecs( power_capacity_kw=1000.0, network_bandwidth_mbps=10000.0, load_bearing_kg_m2=2000.0, area_m2=5000.0, ceiling_height_m=25.0, accessibility_score=0.98, acoustic_rating=0.6, emergency_exits=12, parking_spaces=2000, hvac_capacity=800.0 )) ] return venues def main(): """Main demonstration function""" print("🏟️ Venue Evaluation and Selection System") print("=" * 50) # Initialize evaluation engine engine = VenueEvaluationEngine() # Create test venues test_venues = create_test_venues() expected_attendees = 1000 print(f"\nEvaluating {len(test_venues)} venues for {expected_attendees} attendees...") # Evaluate all venues venue_scores = [] for venue_id, specs in test_venues: score = engine.evaluate_venue(venue_id, specs, expected_attendees) venue_scores.append(score) print(f"\n📍 {venue_id}") print(f" Technical Score: {score.technical_score:.1f}") print(f" Capacity Score: {score.capacity_score:.1f}") print(f" Accessibility Score: {score.accessibility_score:.1f}") print(f" Logistics Score: {score.logistics_score:.1f}") print(f" Overall Score: {score.overall_score:.1f}") if score.risk_factors: print(f" ⚠️ Risks: {len(score.risk_factors)} identified") if score.recommendations: print(f" 💡 Recommendations: {len(score.recommendations)} suggested") # Rank and display results ranked_venues = engine.rank_venues(venue_scores) print(f"\n🏆 VENUE RANKINGS") print("=" * 50) for i, venue in enumerate(ranked_venues, 1): print(f"{i}. {venue.venue_id} - Score: {venue.overall_score:.1f}") # Export results output_file, results_json = engine.export_results(ranked_venues) print(f"\n📊 Results exported to: {output_file}") # Display summary statistics scores = [v.overall_score for v in venue_scores] print(f"\n📈 SUMMARY STATISTICS") print(f" Average Score: {sum(scores)/len(scores):.1f}") print(f" Highest Score: {max(scores):.1f}") print(f" Lowest Score: {min(scores):.1f}") print(f" Venues Meeting Standards: {sum(1 for s in scores if s >= 80)}/{len(scores)}") return venue_scores, output_file if __name__ == "__main__": main()