1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- //
- // Created by lenovo on 2023/10/18.
- //
- #ifndef ALGORITHM_HIERARCHYWEIGHTING_H
- #define ALGORITHM_HIERARCHYWEIGHTING_H
- #include <QVector>
- #include <QString>
- #include <QDebug>
- #include <QtMath>
- typedef QVector<QVector<qreal>> HWMat;
- typedef QVector<QVector<qreal>> SMat;
- struct HWWeight
- {
- QString node;
- QString name;
- QVector<qreal> weights;
- QVector<int> node_number;
- };
- struct HWNode
- {
- QString node; // 1.1 , 1.1.1
- QString name;
- HWMat mat;
- QVector<int> node_number; // [1, 1] , [1, 1, 1]
- };
- /**
- * @brief 层次加权法
- */
- class HierarchyWeighting
- {
- public:
- HierarchyWeighting(const SMat &smat); //
- void evaluate();
- void push(const QString &node, const QString &name, const HWMat &value);
- bool isFull() const;
- const QVector<double> &getsampleweight() const { return smat_cv_; }
- int getBestIndex() const { return best_index_; }
- private:
- void EvaluateNodeWeight(const HWNode &hwnode);
- void LastLevelWeight();
- void BestSample();
- const qreal RI[10] = { 0, 0, 0.58, 0.90, 1.12, 1.24, 1.32, 1.41, 1.45, 1.49 };
- const qreal thd = 0.1;
- qreal m_CI;
- qreal m_CR;
- QVector<HWNode> mat_; // 各节点
- QVector<HWWeight> weights_node_; // 各节点计算出的权重
- SMat smat_; // 样本
- int sam_num_; // 样本数量
- int best_index_; // 最好的样本索引
- QVector<double> smat_cv_;
- QVector<double> weights_; // 最后一层综合权重
- };
- #endif // ALGORITHM_HIERARCHYWEIGHTING_H
|