HierarchyWeighting.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // Created by lenovo on 2023/10/18.
  3. //
  4. #ifndef ALGORITHM_HIERARCHYWEIGHTING_H
  5. #define ALGORITHM_HIERARCHYWEIGHTING_H
  6. #include <QVector>
  7. #include <QString>
  8. #include <QDebug>
  9. #include <QtMath>
  10. typedef QVector<QVector<qreal> > HWMat;
  11. typedef QVector<QVector<qreal> > SMat;
  12. struct HWWeight
  13. {
  14. QString node;
  15. QString name;
  16. QVector<qreal> weights;
  17. QVector<int> node_number;
  18. };
  19. struct HWNode
  20. {
  21. QString node; // 1.1 , 1.1.1
  22. QString name;
  23. HWMat mat;
  24. QVector<int> node_number; // [1, 1] , [1, 1, 1]
  25. };
  26. class HierarchyWeighting
  27. {
  28. public:
  29. HierarchyWeighting(const SMat& smat); //
  30. void evaluate();
  31. void push(const QString& node, const QString& name, const HWMat& value);
  32. bool isFull() const;
  33. const QVector<double>& getsampleweight() const
  34. {
  35. return smat_cv_;
  36. }
  37. int getBestIndex() const
  38. {
  39. return best_index_;
  40. }
  41. private:
  42. void EvaluateNodeWeight(const HWNode& hwnode);
  43. void LastLevelWeight();
  44. void BestSample();
  45. const qreal RI[10]
  46. = {0, 0, 0.58, 0.90, 1.12, 1.24, 1.32, 1.41, 1.45, 1.49};
  47. const qreal thd = 0.1;
  48. qreal m_CI;
  49. qreal m_CR;
  50. QVector<HWNode> mat_; //各节点
  51. QVector<HWWeight> weights_node_; //各节点计算出的权重
  52. SMat smat_; //样本
  53. int sam_num_; //样本数量
  54. int best_index_; //最好的样本索引
  55. QVector<double> smat_cv_;
  56. QVector<double> weights_; //最后一层综合权重
  57. };
  58. #endif //ALGORITHM_HIERARCHYWEIGHTING_H