HierarchicalAnalysis.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef CONSISTENCYCHECK_H
  2. #define CONSISTENCYCHECK_H
  3. #include <QString>
  4. #include <QVector>
  5. /**
  6. * @brief AHP层次分析法
  7. */
  8. class HierarchicalAnalysis
  9. {
  10. public:
  11. /**
  12. * @brief 构造函数
  13. * @param 输入节点信息
  14. * @param 输入节点列表,必须满足n^2
  15. * @example:
  16. * QStringList ll = { "展开时间", "撤收时间", "携行重量", "操作人数", "防护能力", "保密能力" };
  17. * QVector<qreal> nn = { 1, 1.0 / 3.0, 1.0 / 5.0, 1.0 / 3.0, 1.0 / 5.0, 1.0 / 3.0, 3, 1,
  18. * 1.0 / 3.0, 3, 1.0/ 5.0, 1.0 / 3.0, 5, 3, 1, 5, 3, 3, 3, 1.0 / 3.0,
  19. * 1.0 / 5.0, 1, 1.0 / 7.0, 1.0 / 3.0, 5, 5, 1.0 / 3.0, 7, 1, 3, 3,
  20. * 3,1.0 / 3.0, 3, 1.0 / 3.0, 1 };
  21. * HierarchicalAnalysis cc(ll, nn);
  22. * qDebug() << cc.consitst();
  23. */
  24. HierarchicalAnalysis(int columnCount, const QVector<qreal> &nxnValus);
  25. const QVector<qreal> &getWeights() const { return m_weights; }
  26. const QVector<qreal> &getaverageWeights() const { return m_averageWeights; }
  27. qreal CI() const { return m_CI; }
  28. qreal CR() const { return m_CR; }
  29. /**
  30. * @brief 一致性判断
  31. */
  32. bool consitst() const
  33. {
  34. return true; // return m_CR < thd;
  35. }
  36. private:
  37. const qreal RI[10] = { 0, 0, 0.58, 0.90, 1.12, 1.24, 1.32, 1.41, 1.45, 1.49 };
  38. const qreal thd = 0.1;
  39. void calc(const QVector<qreal> &nxnValus);
  40. int m_columnCount;
  41. QVector<qreal> m_sqartnValues;
  42. QVector<qreal> m_weights;
  43. QVector<qreal> m_averageWeights;
  44. qreal m_CI;
  45. qreal m_CR;
  46. };
  47. #endif // CONSISTENCYCHECK_H