Browse Source

Merge branch 'master' of http://101.43.129.26:10880/chengxr/QFD2

zsf 1 year ago
parent
commit
03d817c821

+ 1 - 1
ExpertClient/EXConfig.cpp

@@ -6,7 +6,7 @@ QSettings *EXConfig::defaultConfig()
 {
     static QSettings *config = nullptr;
     if (config == nullptr) {
-        config = new QSettings("config.ini", QSettings::IniFormat);
+        config = new QSettings("clientConfig.ini", QSettings::IniFormat);
         config->setIniCodec("UTF-8");
     }
     return config;

+ 4 - 6
QFD/widgets/DataCollectionWidget.cpp

@@ -190,13 +190,11 @@ void DataCollectionWidget::slotTabCurrentChanged(int index)
 void DataCollectionWidget::slotCalc()
 {
     DataTableWidget *table = dynamic_cast<DataTableWidget *>(m_tab->currentWidget());
-    if (table == nullptr) {
-        return;
-    }
+    if (table != nullptr) { }
 
-    GreyClusteringConfigWidget *gc = dynamic_cast<GreyClusteringConfigWidget *>(m_tab->currentWidget());
-    if (gc != nullptr) {
-        qDebug() << __FUNCTION__ << __LINE__ << "gc" << endl;
+    GreyClusteringSampleTable *gcSample = dynamic_cast<GreyClusteringSampleTable *>(m_tab->currentWidget());
+    if (gcSample != nullptr) {
+        gcSample->compute();
     }
 }
 

+ 60 - 0
QFD/widgets/GreyClusteringSampleTable.cpp

@@ -4,10 +4,12 @@
 #include "CMind.h"
 #include "dbService/GradeInfoService.h"
 #include "dbService/EffectIndexInfoService.h"
+#include "algorithm/GreyClusterEvaluation.h"
 
 #include <QHeaderView>
 #include <QDebug>
 #include <QMessageBox>
+#include <QtMath>
 
 /**
  * example
@@ -255,6 +257,64 @@ void GreyClusteringSampleTable::refreshTableView()
     }
 }
 
+void GreyClusteringSampleTable::compute()
+{
+    GCEMat mat;
+    GCERangeMat ranges;
+
+    QVector<GCEmat> samples;
+    int colCount = m_nodeDepth + 4 + m_grayNumber;
+    for (int r = 0; r < m_rowCount; ++r) {
+        samples << GCEmat { m_model->item(r, colCount)->text().toDouble(),
+                            m_model->item(r, colCount + 1)->text().toDouble() };
+    }
+    mat = samples;
+
+    // 指标
+    for (const auto &item : m_greyClusterings) {
+        if (!item.value.isNull()) {
+            QVector<GCERange> rg;
+
+            QSet<double> fullSet;
+            fullSet << item.value->leftExtension;
+            for (const auto &grange : item.value->greyRanges) {
+                fullSet << grange.leftValue << grange.rightValue;
+            }
+            fullSet << item.value->rightExtension;
+            QList<double> full = fullSet.toList();
+            std::sort(full.begin(), full.end());
+
+            for (int i = 0; i < item.value->greyRanges.size(); ++i) {
+                double left;
+                double right;
+                int lloc = full.indexOf(item.value->greyRanges.at(i).leftValue);
+                int rloc = full.indexOf(item.value->greyRanges.at(i).rightValue);
+
+                if (lloc == 0) {
+                    left = full[0];
+                } else {
+                    left = full[lloc - 1];
+                }
+
+                if (rloc == full.size() - 1) {
+                    right = full.last();
+                } else {
+                    right = full[rloc + 1];
+                }
+                rg << GCERange { i, left, item.value->greyRanges.at(i).leftValue,
+                                 item.value->greyRanges.at(i).rightValue, right };
+            }
+
+            ranges << rg;
+        }
+    }
+
+    QScopedPointer<GreyClusterEvaluation> gc(new GreyClusterEvaluation(mat, ranges));
+    gc->evaluate({ 0.2, 0.15, 0.05, 0.4, 0.2 });
+    BestIndex index = gc->getBestIndex();
+    qDebug() << index.front_index << index.back_index;
+}
+
 void GreyClusteringSampleTable::init()
 {
     setAlternatingRowColors(false);

+ 2 - 0
QFD/widgets/GreyClusteringSampleTable.h

@@ -50,6 +50,8 @@ public:
 
     void refreshTableView();
 
+    void compute();
+
 private:
     void init();
     void initClusteringItems();

+ 10 - 0
bin/clientConfig.ini

@@ -0,0 +1,10 @@
+[USERCONFIG]
+UserName=admin
+Password=123456
+RememberPassword=true
+Project=\x65e0\x4eba\x5e73\x53f0\x80fd\x529b\x5c42\x6b21\x5206\x6790\x6cd5\x7edf\x8ba1
+RoleType=1
+DbPath=/data
+TechMessaureConfig=9, 5, 4, 3, 1
+PasswordModified=true
+DbType=1