增加了直接赋权模型,修改了 cursor 规则,要求一直使用 UTF-8 编码
This commit is contained in:
parent
07df86d407
commit
f5ee933d05
24
.cursorrules
24
.cursorrules
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# Cursor Rules
|
# Cursor Rules
|
||||||
|
|
||||||
You are an expert in C#, Unity, and scalable game development.
|
You are an expert in C#, Unity, and scalable game development.
|
||||||
@ -63,3 +62,26 @@ You are an expert in C#, Unity, and scalable game development.
|
|||||||
|
|
||||||
Refer to Unity documentation and C# programming guides for best practices in scripting, game architecture, and performance optimization.
|
Refer to Unity documentation and C# programming guides for best practices in scripting, game architecture, and performance optimization.
|
||||||
|
|
||||||
|
Text Encoding Guidelines
|
||||||
|
|
||||||
|
- Ensure all output uses UTF-8 encoding, avoiding special or rare characters.
|
||||||
|
- When encountering content that cannot be represented using standard characters, use common characters or descriptive text as substitutes.
|
||||||
|
- For Chinese content, use standard simplified Chinese characters and avoid rare characters or special symbols.
|
||||||
|
- For code comments, use only basic ASCII characters and standard UTF-8 Chinese characters.
|
||||||
|
- In Markdown documents, use standard UTF-8 character set to ensure correct display across different platforms and editors.
|
||||||
|
- When formatting is required, prefer basic Markdown syntax over special characters.
|
||||||
|
- Validate all text content for proper encoding before output.
|
||||||
|
- When dealing with multilingual content, ensure consistent encoding across all languages.
|
||||||
|
- For system messages and logs, use ASCII characters whenever possible.
|
||||||
|
- Test all text output in different environments to ensure consistent display.
|
||||||
|
|
||||||
|
Key Text Handling Principles
|
||||||
|
|
||||||
|
1. Always validate character encoding before processing or displaying text.
|
||||||
|
2. Use standard character sets to ensure cross-platform compatibility.
|
||||||
|
3. Implement proper error handling for text encoding issues.
|
||||||
|
4. Maintain consistent encoding throughout the project.
|
||||||
|
5. Document any special character handling requirements.
|
||||||
|
|
||||||
|
Refer to Unicode standards and encoding best practices for text handling in C# applications.
|
||||||
|
|
||||||
50
README.md
50
README.md
@ -204,7 +204,27 @@ ActiveProtect/
|
|||||||
|
|
||||||
系统提供了多种评估模型,用于评估防护系统的性能:
|
系统提供了多种评估模型,用于评估防护系统的性能:
|
||||||
|
|
||||||
### 1. 模糊评价模型
|
### 1. 直接赋权模型
|
||||||
|
|
||||||
|
最基础的评估方法,通过直接指定权重进行加权计算。
|
||||||
|
|
||||||
|
特点:
|
||||||
|
|
||||||
|
- 计算简单直观
|
||||||
|
- 权重确定过程透明
|
||||||
|
- 适用于评价指标较少的情况
|
||||||
|
- 权重需满足:
|
||||||
|
- 非负性:所有权重 ≥ 0
|
||||||
|
- 归一性:所有权重之和 = 1
|
||||||
|
|
||||||
|
适用场景:
|
||||||
|
|
||||||
|
- 评价指标较少(通常≤5个)
|
||||||
|
- 各指标重要性差异明显
|
||||||
|
- 有充分的专家经验支持
|
||||||
|
- 需要快速得出评估结果
|
||||||
|
|
||||||
|
### 2. 模糊评价模型
|
||||||
|
|
||||||
适用于不确定性强的指标评估。通过建立隶属度矩阵,对多个评价指标进行综合评估。
|
适用于不确定性强的指标评估。通过建立隶属度矩阵,对多个评价指标进行综合评估。
|
||||||
|
|
||||||
@ -214,17 +234,17 @@ ActiveProtect/
|
|||||||
- 支持多指标综合评价
|
- 支持多指标综合评价
|
||||||
- 通过隶属度函数量化定性指标
|
- 通过隶属度函数量化定性指标
|
||||||
|
|
||||||
### 2. AHP层次分析模型
|
### 3. AHP层次分析模型
|
||||||
|
|
||||||
适用于层次分明的指标体系,通过建立判断矩阵进行评估。
|
适用于层次分明的指标体系,通过建立判断矩阵进行评估。
|
||||||
|
|
||||||
特点:
|
特点:
|
||||||
|
|
||||||
- 层次结构清晰
|
- 层次结构清晰
|
||||||
- 考虑指标间的相对重要性
|
- 考虑指标间的对重要性
|
||||||
- 结果具有较好的可解释性
|
- 结果具有较好的可解释性
|
||||||
|
|
||||||
### 3. 灰色关联分析模型
|
### 4. 灰色关联分析模型
|
||||||
|
|
||||||
适用于数据不完整的情况,通过计算评估指标与参考序列的关联度进行评估。
|
适用于数据不完整的情况,通过计算评估指标与参考序列的关联度进行评估。
|
||||||
|
|
||||||
@ -234,7 +254,7 @@ ActiveProtect/
|
|||||||
- 计算简单直观
|
- 计算简单直观
|
||||||
- 能反映系统发展趋势
|
- 能反映系统发展趋势
|
||||||
|
|
||||||
### 4. 贝叶斯网络模型
|
### 5. 贝叶斯网络模型
|
||||||
|
|
||||||
适用于具有不确定性和条件依赖关系的指标评估。
|
适用于具有不确定性和条件依赖关系的指标评估。
|
||||||
|
|
||||||
@ -244,27 +264,9 @@ ActiveProtect/
|
|||||||
- 支持先验知识的引入
|
- 支持先验知识的引入
|
||||||
- 可进行概率推理和预测
|
- 可进行概率推理和预测
|
||||||
|
|
||||||
### 评估指标体系
|
|
||||||
|
|
||||||
主要评估维度包括:
|
|
||||||
|
|
||||||
1. 时间维度
|
|
||||||
- 告警响应时间
|
|
||||||
- 干扰启动时间
|
|
||||||
- 系统反应延迟
|
|
||||||
|
|
||||||
2. 空间维度
|
|
||||||
- 探测覆盖范围
|
|
||||||
- 干扰防护范围
|
|
||||||
- 方位角覆盖
|
|
||||||
|
|
||||||
3. 可靠性维度
|
|
||||||
- 探测可靠性
|
|
||||||
- 干扰可靠性
|
|
||||||
- 系统稳定性
|
|
||||||
|
|
||||||
### 评估模型选择建议
|
### 评估模型选择建议
|
||||||
|
|
||||||
|
- 对于简单且指标较少的评估任务,可以使用直接赋权法
|
||||||
- 对于不确定性强的指标,优先使用模糊评价或贝叶斯网络
|
- 对于不确定性强的指标,优先使用模糊评价或贝叶斯网络
|
||||||
- 对于有大量历史数据的指标,可以使用神经网络模型
|
- 对于有大量历史数据的指标,可以使用神经网络模型
|
||||||
- 对于层次分明的指标体系,适合使用AHP方法
|
- 对于层次分明的指标体系,适合使用AHP方法
|
||||||
|
|||||||
63
src/Evaluation/DirectWeightModel.cs
Normal file
63
src/Evaluation/DirectWeightModel.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace ActiveProtect.Evaluation
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 直接赋权评估模型
|
||||||
|
/// 最简单的评估方法,直接通过权重进行加权计算
|
||||||
|
/// </summary>
|
||||||
|
public class DirectWeightModel : IEvaluationModel
|
||||||
|
{
|
||||||
|
private readonly float[] weights; // 权重向量
|
||||||
|
|
||||||
|
public string ModelName => "直接赋权模型";
|
||||||
|
|
||||||
|
public DirectWeightModel(float[] weights)
|
||||||
|
{
|
||||||
|
this.weights = weights;
|
||||||
|
|
||||||
|
if (!ValidateWeights())
|
||||||
|
{
|
||||||
|
throw new ArgumentException("权重无效:权重必须为非负数且和为1");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float Evaluate(Dictionary<string, float> evaluationData)
|
||||||
|
{
|
||||||
|
if (evaluationData.Count != weights.Length)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("评估数据数量与权重数量不匹配");
|
||||||
|
}
|
||||||
|
|
||||||
|
float result = 0;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
foreach (var data in evaluationData)
|
||||||
|
{
|
||||||
|
result += weights[i] * data.Value;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证权重的有效性
|
||||||
|
/// </summary>
|
||||||
|
private bool ValidateWeights()
|
||||||
|
{
|
||||||
|
// 检查权重是否都为非负数
|
||||||
|
if (weights.Any(w => w < 0))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查权重之和是否为1
|
||||||
|
const float tolerance = 0.0001f;
|
||||||
|
float sum = weights.Sum();
|
||||||
|
return Math.Abs(sum - 1) < tolerance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -32,6 +32,9 @@ namespace ActiveProtect.Evaluation
|
|||||||
|
|
||||||
// 4. 贝叶斯网络模型示例
|
// 4. 贝叶斯网络模型示例
|
||||||
DemoBayesianEvaluation(evaluationData);
|
DemoBayesianEvaluation(evaluationData);
|
||||||
|
|
||||||
|
// 5. 直接赋权模型示例
|
||||||
|
DemoDirectWeightEvaluation(evaluationData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -126,5 +129,22 @@ namespace ActiveProtect.Evaluation
|
|||||||
float result = bayesianModel.Evaluate(evaluationData);
|
float result = bayesianModel.Evaluate(evaluationData);
|
||||||
Console.WriteLine($"贝叶斯网络评价结果: {result:F4}");
|
Console.WriteLine($"贝叶斯网络评价结果: {result:F4}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 直接赋权模型示例
|
||||||
|
/// </summary>
|
||||||
|
private static void DemoDirectWeightEvaluation(Dictionary<string, float> evaluationData)
|
||||||
|
{
|
||||||
|
Console.WriteLine("\n=== 直接赋权模型示例 ===");
|
||||||
|
|
||||||
|
// 设置权重
|
||||||
|
float[] weights = new float[] { 0.4f, 0.3f, 0.3f };
|
||||||
|
|
||||||
|
var directModel = EvaluationModelFactory.CreateModel("direct",
|
||||||
|
new object[] { weights });
|
||||||
|
|
||||||
|
float result = directModel.Evaluate(evaluationData);
|
||||||
|
Console.WriteLine($"直接赋权评价结果: {result:F4}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,6 +36,11 @@ namespace ActiveProtect.Evaluation
|
|||||||
(Dictionary<string, List<string>>)parameters[2]
|
(Dictionary<string, List<string>>)parameters[2]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
case "direct":
|
||||||
|
return new DirectWeightModel(
|
||||||
|
(float[])parameters[0]
|
||||||
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException($"不支持的评估模型类型: {modelType}");
|
throw new ArgumentException($"不支持的评估模型类型: {modelType}");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user