From f5ee933d05259a007798d934a02183da7ab67dcd Mon Sep 17 00:00:00 2001
From: Tian jianyong <11429339@qq.com>
Date: Fri, 1 Nov 2024 16:40:19 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=9B=B4=E6=8E=A5?=
=?UTF-8?q?=E8=B5=8B=E6=9D=83=E6=A8=A1=E5=9E=8B=EF=BC=8C=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=E4=BA=86=20cursor=20=E8=A7=84=E5=88=99=EF=BC=8C=E8=A6=81?=
=?UTF-8?q?=E6=B1=82=E4=B8=80=E7=9B=B4=E4=BD=BF=E7=94=A8=20UTF-8=20?=
=?UTF-8?q?=E7=BC=96=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.cursorrules | 24 ++++++++-
README.md | 50 ++++++++++---------
src/Evaluation/DirectWeightModel.cs | 63 ++++++++++++++++++++++++
src/Evaluation/EvaluationExample.cs | 20 ++++++++
src/Evaluation/EvaluationModelFactory.cs | 5 ++
5 files changed, 137 insertions(+), 25 deletions(-)
create mode 100644 src/Evaluation/DirectWeightModel.cs
diff --git a/.cursorrules b/.cursorrules
index ec908e3..0782fbb 100644
--- a/.cursorrules
+++ b/.cursorrules
@@ -1,4 +1,3 @@
-
# Cursor Rules
You are an expert in C#, Unity, and scalable game development.
@@ -62,4 +61,27 @@ You are an expert in C#, Unity, and scalable game development.
3. Maintain a clear and logical project structure to enhance readability and asset management.
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.
\ No newline at end of file
diff --git a/README.md b/README.md
index 3f03d52..2e50c20 100644
--- a/README.md
+++ b/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方法
diff --git a/src/Evaluation/DirectWeightModel.cs b/src/Evaluation/DirectWeightModel.cs
new file mode 100644
index 0000000..08cc1b9
--- /dev/null
+++ b/src/Evaluation/DirectWeightModel.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace ActiveProtect.Evaluation
+{
+ ///
+ /// 直接赋权评估模型
+ /// 最简单的评估方法,直接通过权重进行加权计算
+ ///
+ 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 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;
+ }
+
+ ///
+ /// 验证权重的有效性
+ ///
+ 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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Evaluation/EvaluationExample.cs b/src/Evaluation/EvaluationExample.cs
index 5ebb945..8dd27a6 100644
--- a/src/Evaluation/EvaluationExample.cs
+++ b/src/Evaluation/EvaluationExample.cs
@@ -32,6 +32,9 @@ namespace ActiveProtect.Evaluation
// 4. 贝叶斯网络模型示例
DemoBayesianEvaluation(evaluationData);
+
+ // 5. 直接赋权模型示例
+ DemoDirectWeightEvaluation(evaluationData);
}
///
@@ -126,5 +129,22 @@ namespace ActiveProtect.Evaluation
float result = bayesianModel.Evaluate(evaluationData);
Console.WriteLine($"贝叶斯网络评价结果: {result:F4}");
}
+
+ ///
+ /// 直接赋权模型示例
+ ///
+ private static void DemoDirectWeightEvaluation(Dictionary 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}");
+ }
}
}
\ No newline at end of file
diff --git a/src/Evaluation/EvaluationModelFactory.cs b/src/Evaluation/EvaluationModelFactory.cs
index 6f0bc96..edeb41a 100644
--- a/src/Evaluation/EvaluationModelFactory.cs
+++ b/src/Evaluation/EvaluationModelFactory.cs
@@ -36,6 +36,11 @@ namespace ActiveProtect.Evaluation
(Dictionary>)parameters[2]
);
+ case "direct":
+ return new DirectWeightModel(
+ (float[])parameters[0]
+ );
+
default:
throw new ArgumentException($"不支持的评估模型类型: {modelType}");
}