<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Privacy Tuner 报告</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 40px; }
        h1 { color: #333; }
        table { border-collapse: collapse; width: 100%; }
        th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
        th { background-color: #f2f2f2; }
        img { max-width: 100%; height: auto; margin: 20px 0; }
    </style>
</head>
<body>
    <h1>Privacy Tuner 运行报告</h1>
    <p>生成时间: {{ generation_time }}</p>

    <h2>数据集信息</h2>
    <table>
        <tr><th>属性</th><th>值</th></tr>
        {% for key, value in original_info.items() %}
        <tr><td>{{ key }}</td><td>{{ value }}</td></tr>
        {% endfor %}
    </table>

    <h2>隐私机制</h2>
    <p>{{ mechanism_name }}</p>

    <h2>搜索参数空间</h2>
    <table>
        <tr><th>参数</th><th>取值范围</th></tr>
        {% for param, values in param_space.items() %}
        <tr><td>{{ param }}</td><td>{{ values }}</td></tr>
        {% endfor %}
    </table>

    <h2>风险约束</h2>
    <p>最小风险: {{ risk_constraint[0] }}, 最大风险: {{ risk_constraint[1] }}</p>

    <h2>搜索结果</h2>
    <p><strong>最优参数:</strong> {{ best_params }}</p>
    <p><strong>最优效用:</strong> {{ best_utility }}</p>
    <p><strong>对应风险:</strong> {{ best_risk }}</p>

    {% if chart_path %}
    <h2>风险-效用散点图</h2>
    <img src="{{ chart_path }}" alt="风险-效用散点图">
    {% endif %}

    <h2>所有参数组合</h2>
    <table>
        <tr><th>参数</th><th>风险</th><th>效用</th></tr>
        {% for result in all_results %}
        <tr>
            <td>{{ result.params }}</td>
            <td>{{ result.risk }}</td>
            <td>{{ result.utility }}</td>
        </tr>
        {% endfor %}
    </table>
</body>
</html>