# predict/fusion_engine.py
import math


class FusionDiagnosticAgent:
    @staticmethod
    def calculate(visual_severity, temp, hum, expert):

        temp_risk = max(0, 1 - abs(temp - expert.optimum_temp) / 15)
        hum_risk = 1.0 if hum > expert.optimum_hum else (hum / expert.optimum_hum)
        env_score = (temp_risk * expert.temp_weight) + (hum_risk * expert.hum_weight)

        fused_risk = (visual_severity * 0.6) + (env_score * 0.4)

        k = 0.02 * env_score
        future_48h = visual_severity * math.exp(k * 48)

        return {
            'fused_score': round(fused_risk * 100, 2),
            'prediction_48h': round(min(1.0, future_48h) * 100, 2),
            'env_status': "高风险" if env_score > 0.7 else "一般"
        }