Bläddra i källkod

调通算法。

Ulric 2 dagar sedan
förälder
incheckning
4832657109
3 ändrade filer med 88 tillägg och 31 borttagningar
  1. 19 6
      QFD/algorithm/test_main.cpp
  2. 24 8
      QFD/common/DataEvaluator.cpp
  3. 45 17
      QFD/main.cpp

+ 19 - 6
QFD/algorithm/test_main.cpp

@@ -294,27 +294,40 @@ void testSPA()
         };
         // 等级1
         ranges << QVector<MEARange> {
-            { 0, 1, 1.5 }, { 1, 0, 2 }, { 2, 0, 15 }, { 3, 0, 2 }, { 4, 40, 20 }, { 5, 0, 0.003 }, { 6, 0, 2 },
+            { 0, true, false, 1, 1.5 }, { 1, true, false, 0, 2 },   { 2, true, false, 0, 15 },
+            { 3, true, false, 0, 2 },   { 4, true, false, 40, 20 }, { 5, true, false, 0, 0.003 },
+            { 6, true, false, 0, 2 },
         };
+
         // 等级2
         ranges << QVector<MEARange> {
-            { 0, 1.5, 2 }, { 1, 2, 4 }, { 2, 15, 25 }, { 3, 2, 5 }, { 4, 20, 10 }, { 5, 0.003, 0.005 }, { 6, 2, 4 },
+            { 0, true, false, 1.5, 2 }, { 1, true, false, 2, 4 },   { 2, true, false, 15, 25 },
+            { 3, true, false, 2, 5 },   { 4, true, false, 20, 10 }, { 5, true, false, 0.003, 0.005 },
+            { 6, true, false, 2, 4 },
         };
         // 等级3
         ranges << QVector<MEARange> {
-            { 0, 2, 2.5 }, { 1, 4, 6 }, { 2, 25, 35 }, { 3, 5, 15 }, { 4, 10, 6 }, { 5, 0.005, 0.016 }, { 6, 4, 6 },
+            { 0, true, false, 2, 2.5 }, { 1, true, false, 4, 6 },  { 2, true, false, 25, 35 },
+            { 3, true, false, 5, 15 },  { 4, true, false, 10, 6 }, { 5, true, false, 0.005, 0.016 },
+            { 6, true, false, 4, 6 },
         };
         // 等级4
         ranges << QVector<MEARange> {
-            { 0, 2.5, 3 }, { 1, 6, 8 }, { 2, 35, 45 }, { 3, 15, 45 }, { 4, 6, 4 }, { 5, 0.016, 0.03 }, { 6, 6, 7 },
+            { 0, true, false, 2.5, 3 }, { 1, true, false, 6, 8 }, { 2, true, false, 35, 45 },
+            { 3, true, false, 15, 45 }, { 4, true, false, 6, 4 }, { 5, true, false, 0.016, 0.03 },
+            { 6, true, false, 6, 7 },
         };
         // 等级5
         ranges << QVector<MEARange> {
-            { 0, 3, 4 }, { 1, 8, 10 }, { 2, 45, 55 }, { 3, 45, 90 }, { 4, 4, 3 }, { 5, 0.03, 0.06 }, { 6, 7, 8 },
+            { 0, true, false, 3, 4 },   { 1, true, false, 8, 10 }, { 2, true, false, 45, 55 },
+            { 3, true, false, 45, 90 }, { 4, true, false, 4, 3 },  { 5, true, false, 0.03, 0.06 },
+            { 6, true, false, 7, 8 },
         };
         // 等级范围p
         ranges << QVector<MEARange> {
-            { 0, 1, 4 }, { 1, 0, 10 }, { 2, 0, 55 }, { 3, 0, 90 }, { 4, 40, 3 }, { 5, 0, 0.06 }, { 6, 0, 8 },
+            { 0, true, false, 1, 4 },  { 1, true, false, 0, 10 }, { 2, true, false, 0, 55 },
+            { 3, true, false, 0, 90 }, { 4, true, false, 40, 3 }, { 5, true, false, 0, 0.06 },
+            { 6, true, false, 0, 8 },
         };
         // 等级
         MatterElementAnalysis me(mat, ranges);

+ 24 - 8
QFD/common/DataEvaluator.cpp

@@ -443,15 +443,23 @@ bool DataEvaluator::evaluateEfficiencyMEA()
     QList<GradeIndexInfo *> rangeList;
     bool gradeRet = GradeIndexInfoService().QueryGradeIndexInfoByProjectId(&rangeList, m_process.projectId);
     /// 整理物元配置数据, int:层级 QString:指标名称 QPair:区间左右值
-    QMap<QString, QMap<int, QPair<double, double>>> rangeData;
+    QMap<QString, QMap<int, MEARange>> rangeData;
     for (GradeIndexInfo *info : rangeList) {
         if (rangeData.keys().contains(info->gradeIndexName) == false) {
-            rangeData[info->gradeIndexName] = QMap<int, QPair<double, double>>();
+            rangeData[info->gradeIndexName] = QMap<int, MEARange>();
         }
         QString v = info->gradeIndexValue;
         if (v.length() > 2 && v.contains(", ")) {
             QStringList l = v.mid(1, v.length() - 2).split(", ");
-            QPair<double, double> range(l.first().toDouble(), l.last().toDouble());
+            double left   = l.first().toDouble();
+            double right  = l.last().toDouble();
+
+            bool leftClosed  = v[0] == "[";
+            bool rightClosed = v.right(1) == "]";
+
+            int tempIndex  = -1;
+            MEARange range = MEARange { tempIndex, leftClosed, rightClosed, left, right };
+
             rangeData[info->gradeIndexName][info->gradeLevel] = range;
         }
     }
@@ -487,15 +495,23 @@ bool DataEvaluator::evaluateEfficiencyMEA()
     for (int level = 1; level < domainLevel + 1; ++level) {
         QVector<MEARange> levelRanges;
         for (int i = 0; i < indexList.size(); ++i) {
-            QPair<double, double> p = rangeData[indexList[i].name][level];
-            MEARange levRange       = MEARange { i, p.first, p.second };
+            MEARange levRange = rangeData[indexList[i].name][level];
+            levRange.index    = i;
             levelRanges.append(levRange);
 
             if (level == 1) {
-                MEARange jointRange = MEARange { i, p.first };
-                jointRanges.append(jointRange);
+                jointRanges.append(levRange);
             } else if (level == domainLevel) {
-                jointRanges[i].max_value = p.second;
+                MEARange jointRange = jointRanges[i];
+                if (levRange.min_value < jointRange.min_value) {
+                    jointRange.min_value  = levRange.min_value;
+                    jointRange.left_close = levRange.left_close;
+                }
+                if (levRange.max_value > jointRange.max_value) {
+                    jointRange.max_value   = levRange.max_value;
+                    jointRange.right_close = levRange.right_close;
+                }
+                jointRanges[i] = jointRange;
             }
         }
         ranges.append(levelRanges);

+ 45 - 17
QFD/main.cpp

@@ -14,6 +14,8 @@
 #include "algorithm/GreyClusterEvaluation.h"
 #include <algorithm/MatterElementAnalysis.h>
 
+#include <windows.h>
+
 void test()
 {
     MEAMat mat;
@@ -26,34 +28,55 @@ void test()
     qDebug() << mat[0].size() << mat[1].size();
     // 等级1
     ranges << QVector<MEARange> {
-        { 0, 0, 1 },     { 1, 50, 100 }, { 2, 0, 1 },   { 3, 60, 100 }, { 4, 3, 100 },   { 5, 0, 30 },  { 6, 0, 60 },
-        { 7, 0, 1 },     { 8, 0, 30 },   { 9, 0, 60 },  { 10, 2, 100 }, { 11, 0, 60 },   { 12, 0, 30 }, { 13, 0, 1 },
-        { 14, 60, 100 }, { 15, 0, 1 },   { 16, 0, 30 }, { 17, 0, 5 },   { 18, 50, 100 }, { 19, 0, 1 },
+        { 0, true, false, 0, 1 },     { 1, true, false, 50, 100 }, { 2, true, false, 0, 1 },
+        { 3, true, false, 60, 100 },  { 4, true, false, 3, 100 },  { 5, true, false, 0, 30 },
+        { 6, true, false, 0, 60 },    { 7, true, false, 0, 1 },    { 8, true, false, 0, 30 },
+        { 9, true, false, 0, 60 },    { 10, true, false, 2, 100 }, { 11, true, false, 0, 60 },
+        { 12, true, false, 0, 30 },   { 13, true, false, 0, 1 },   { 14, true, false, 60, 100 },
+        { 15, true, false, 0, 1 },    { 16, true, false, 0, 30 },  { 17, true, false, 0, 5 },
+        { 18, true, false, 50, 100 }, { 19, true, false, 0, 1 },
     };
 
     // 等级1
     ranges << QVector<MEARange> {
-        { 0, 2, 3 },    { 1, 5, 100 }, { 2, 1, 2 },    { 3, 45, 60 },  { 4, 2, 3 },    { 5, 30, 50 },  { 6, 60, 80 },
-        { 7, 1, 1.5 },  { 8, 30, 50 }, { 9, 60, 80 },  { 10, 1.5, 2 }, { 11, 60, 80 }, { 12, 30, 50 }, { 13, 1, 3 },
-        { 14, 45, 60 }, { 15, 1, 2 },  { 16, 30, 50 }, { 17, 5, 10 },  { 18, 30, 50 }, { 19, 1, 2 },
+        { 0, true, false, 2, 3 },    { 1, true, false, 5, 100 },  { 2, true, false, 1, 2 },
+        { 3, true, false, 45, 60 },  { 4, true, false, 2, 3 },    { 5, true, false, 30, 50 },
+        { 6, true, false, 60, 80 },  { 7, true, false, 1, 1.5 },  { 8, true, false, 30, 50 },
+        { 9, true, false, 60, 80 },  { 10, true, false, 1.5, 2 }, { 11, true, false, 60, 80 },
+        { 12, true, false, 30, 50 }, { 13, true, false, 1, 3 },   { 14, true, false, 45, 60 },
+        { 15, true, false, 1, 2 },   { 16, true, false, 30, 50 }, { 17, true, false, 5, 10 },
+        { 18, true, false, 30, 50 }, { 19, true, false, 1, 2 },
     };
 
     ranges << QVector<MEARange> {
-        { 1, 3, 4 },    { 1, 20, 30 }, { 2, 2, 3 },    { 3, 30, 45 },  { 4, 1, 2 },    { 5, 50, 80 },  { 6, 80, 95 },
-        { 7, 1.5, 2 },  { 8, 50, 80 }, { 9, 80, 95 },  { 10, 1, 1.5 }, { 11, 80, 95 }, { 12, 50, 80 }, { 13, 3, 5 },
-        { 14, 30, 45 }, { 15, 2, 3 },  { 16, 50, 80 }, { 17, 10, 20 }, { 18, 20, 30 }, { 19, 2, 3 },
+        { 1, true, false, 3, 4 },    { 1, true, false, 20, 30 },  { 2, true, false, 2, 3 },
+        { 3, true, false, 30, 45 },  { 4, true, false, 1, 2 },    { 5, true, false, 50, 80 },
+        { 6, true, false, 80, 95 },  { 7, true, false, 1.5, 2 },  { 8, true, false, 50, 80 },
+        { 9, true, false, 80, 95 },  { 10, true, false, 1, 1.5 }, { 11, true, false, 80, 95 },
+        { 12, true, false, 50, 80 }, { 13, true, false, 3, 5 },   { 14, true, false, 30, 45 },
+        { 15, true, false, 2, 3 },   { 16, true, false, 50, 80 }, { 17, true, false, 10, 20 },
+        { 18, true, false, 20, 30 }, { 19, true, false, 2, 3 },
     };
     // 2
-    ranges << QVector<MEARange> { { 0, 5, 100 },  { 1, 0, 20 },    { 2, 3, 100 },   { 3, 0, 30 },   { 4, 0, 1 },
-                                  { 5, 80, 100 }, { 6, 95, 100 },  { 7, 2, 100 },   { 8, 80, 100 }, { 9, 95, 100 },
-                                  { 10, 0, 1 },   { 11, 95, 100 }, { 12, 80, 100 }, { 13, 5, 100 }, { 14, 0, 30 },
-                                  { 15, 3, 100 }, { 16, 80, 100 }, { 17, 20, 100 }, { 18, 0, 20 },  { 19, 3, 100 } };
+    ranges << QVector<MEARange> {
+        { 0, true, false, 5, 100 },   { 1, true, false, 0, 20 },    { 2, true, false, 3, 100 },
+        { 3, true, false, 0, 30 },    { 4, true, false, 0, 1 },     { 5, true, false, 80, 100 },
+        { 6, true, false, 95, 100 },  { 7, true, false, 2, 100 },   { 8, true, false, 80, 100 },
+        { 9, true, false, 95, 100 },  { 10, true, false, 0, 1 },    { 11, true, false, 95, 100 },
+        { 12, true, false, 80, 100 }, { 13, true, false, 5, 100 },  { 14, true, false, 0, 30 },
+        { 15, true, false, 3, 100 },  { 16, true, false, 80, 100 }, { 17, true, false, 20, 100 },
+        { 18, true, false, 0, 20 },   { 19, true, false, 3, 100 }
+    };
 
     // 等级范围p
     ranges << QVector<MEARange> {
-        { 0, 0, 140 },  { 1, 120, 0 },  { 2, 0, 140 },  { 3, 140, 0 },  { 4, 140, 0 },  { 5, 0, 100 },  { 6, 0, 100 },
-        { 7, 0, 140 },  { 8, 0, 100 },  { 9, 0, 100 },  { 10, 0, 100 }, { 11, 0, 100 }, { 12, 0, 100 }, { 13, 0, 140 },
-        { 14, 140, 0 }, { 15, 0, 140 }, { 16, 0, 100 }, { 17, 0, 140 }, { 18, 140, 0 }, { 19, 0, 140 },
+        { 0, true, false, 0, 140 },  { 1, true, false, 120, 0 },  { 2, true, false, 0, 140 },
+        { 3, true, false, 140, 0 },  { 4, true, false, 140, 0 },  { 5, true, false, 0, 100 },
+        { 6, true, false, 0, 100 },  { 7, true, false, 0, 140 },  { 8, true, false, 0, 100 },
+        { 9, true, false, 0, 100 },  { 10, true, false, 0, 100 }, { 11, true, false, 0, 100 },
+        { 12, true, false, 0, 100 }, { 13, true, false, 0, 140 }, { 14, true, false, 140, 0 },
+        { 15, true, false, 0, 140 }, { 16, true, false, 0, 100 }, { 17, true, false, 0, 140 },
+        { 18, true, false, 140, 0 }, { 19, true, false, 0, 140 },
     };
 
     // 等级
@@ -129,7 +152,12 @@ int main(int argc, char *argv[])
     font.setPointSize(14);
     a.setFont(font);
 
-    //    cTest();
+    setbuf(stdout, NULL);
+
+    DWORD processId = GetCurrentProcessId();
+    qDebug() << __FUNCTION__ << __LINE__ << processId << endl;
+
+    printf("Process ID: %u\n", processId);
 
     int ret = a.exec();
     delete w;