31 """Test the calibration system with synthetic data"""
34 global_system = MultivariateBayesianCalibration(num_sensors=16, order=3)
37 test_pressures = [0.0, 50.0, 100.0, 200.0, 500.0, 800.0]
39 logger.info(
"=== Testing Calibration System ===")
42 logger.info(
"Adding calibration points for PT1...")
43 for i, pressure
in enumerate(test_pressures):
44 voltage = 0.5 + pressure / 1000.0
46 calibration_point = CalibrationPoint(
50 environmental_state=EnvironmentalState(),
54 global_system.multivariate_calibration_update(1, calibration_point)
56 logger.info(f
" PT1: {pressure} PSI at {voltage:.3f}V")
57 logger.info(f
" Population strength: {global_system.population_strength:.2f}")
58 logger.info(f
" PT1 autonomy: {global_system.autonomy_levels[1]:.2f}")
61 logger.info(
"\nAdding calibration points for PT3...")
62 for i, pressure
in enumerate(test_pressures):
63 voltage = 0.52 + pressure / 1000.0
65 calibration_point = CalibrationPoint(
69 environmental_state=EnvironmentalState(),
73 global_system.multivariate_calibration_update(3, calibration_point)
75 logger.info(f
" PT3: {pressure} PSI at {voltage:.3f}V")
76 logger.info(f
" Population strength: {global_system.population_strength:.2f}")
77 logger.info(f
" PT3 autonomy: {global_system.autonomy_levels[3]:.2f}")
80 logger.info(
"\n=== Testing Consensus ===")
81 voltages = {1: 0.8, 3: 0.82}
82 consensus = global_system.compute_consensus_pressure(voltages, EnvironmentalState())
84 logger.info(f
"Consensus pressure: {consensus.pressure:.1f} PSI")
85 logger.info(f
"Consensus uncertainty: {consensus.uncertainty:.2f} PSI")
86 logger.info(f
"Agreement score: {consensus.agreement_score:.2f}")
87 logger.info(f
"Consensus confidence: {global_system.consensus_confidence:.2f}")
90 logger.info(
"\n=== Testing Uncertainty Evolution ===")
93 noisy_point = CalibrationPoint(
97 environmental_state=EnvironmentalState(),
101 global_system.multivariate_calibration_update(1, noisy_point)
103 inflation_before = global_system.uncertainty_inflation_factor[1]
104 logger.info(f
"PT1 uncertainty inflation after disagreement: {inflation_before:.2f}")
107 logger.info(
"\n=== Testing Quality History ===")
108 quality_history = global_system.quality_history[1]
109 logger.info(f
"PT1 quality records: {len(quality_history)}")
112 latest = quality_history[-1]
113 logger.info(f
"Latest RMSE: {latest['rmse']:.3f}")
114 logger.info(f
"Latest MAE: {latest['mae']:.3f}")
115 logger.info(f
"Latest autonomy: {latest['autonomy']:.2f}")
117 logger.info(
"\n=== Test Complete ===")