MinMaxAnalysis.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #include "MinMaxAnalysis.h"
  2. #include "MathUtil.h"
  3. MinMaxAnalysis::MinMaxAnalysis(const QVector<MinMaxAnalysis::EvaluateIndex> &rMat, MinMaxAnalysis::AnalysisType type,
  4. qreal _k, qreal _q)
  5. : analysisType(type), originMat(rMat), k(_k), q(_q)
  6. {
  7. calcNormalMat();
  8. }
  9. const QVector<MinMaxAnalysis::EvaluateIndex> &MinMaxAnalysis::normalization()
  10. {
  11. return normalMat;
  12. }
  13. MinMaxAnalysis::Relations MinMaxAnalysis::getRelations() const
  14. {
  15. return Relations();
  16. }
  17. void MinMaxAnalysis::calcNormalMat()
  18. {
  19. switch (analysisType) {
  20. case Min_Analysis: {
  21. for (auto index : originMat) {
  22. double minVal = Helper::minvec(index);
  23. EvaluateIndex ei;
  24. for (auto v : index) {
  25. ei << v / minVal;
  26. }
  27. normalMat << ei;
  28. }
  29. } break;
  30. case Max_Analysis: {
  31. for (auto index : originMat) {
  32. double maxVal = Helper::maxvec(index);
  33. EvaluateIndex ei;
  34. for (auto v : index) {
  35. ei << v / maxVal;
  36. }
  37. normalMat << ei;
  38. }
  39. } break;
  40. case Analysis_THD1: {
  41. for (auto index : originMat) {
  42. double minVal = Helper::minvec(index);
  43. double maxVal = Helper::maxvec(index);
  44. EvaluateIndex ei;
  45. for (auto v : index) {
  46. ei << (minVal + maxVal - v) / maxVal;
  47. }
  48. normalMat << ei;
  49. }
  50. } break;
  51. case Analysis_THD2: {
  52. for (auto index : originMat) {
  53. double minVal = Helper::minvec(index);
  54. double maxVal = Helper::maxvec(index);
  55. EvaluateIndex ei;
  56. for (auto v : index) {
  57. ei << (maxVal - v) / (maxVal - minVal);
  58. }
  59. normalMat << ei;
  60. }
  61. } break;
  62. case Analysis_THD3: {
  63. for (auto index : originMat) {
  64. double minVal = Helper::minvec(index);
  65. double maxVal = Helper::maxvec(index);
  66. EvaluateIndex ei;
  67. for (auto v : index) {
  68. ei << (v - minVal) / (maxVal - minVal);
  69. }
  70. normalMat << ei;
  71. }
  72. } break;
  73. case Analysis_THD4: {
  74. for (auto index : originMat) {
  75. double minVal = Helper::minvec(index);
  76. double maxVal = Helper::maxvec(index);
  77. EvaluateIndex ei;
  78. for (auto v : index) {
  79. ei << (v - minVal) * k / (maxVal - minVal) + q;
  80. }
  81. normalMat << ei;
  82. }
  83. } break;
  84. }
  85. }