SchemePlanManager.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #include "SchemePlanManager.h"
  2. #include "ProjectManager.h"
  3. #include <QMetaEnum>
  4. #include <QDebug>
  5. QString SchemePlanManager::stringFromDataSource(SchemePlanManager::SchemeDataSource src)
  6. {
  7. switch (src) {
  8. case NoData:
  9. return "无";
  10. case FromExpert:
  11. return "导入专家数据";
  12. case FromMeasurement:
  13. return "添加实测数据";
  14. }
  15. }
  16. QString SchemePlanManager::stringFromAlgorithm(SchemePlanManager::Algorithm alg)
  17. {
  18. switch (alg) {
  19. case NoAlg:
  20. return "无";
  21. case PrincipalComponents:
  22. return "主成分分析法";
  23. case Entropy:
  24. return "熵值法";
  25. case AHP:
  26. return "层次分析法";
  27. case HWM:
  28. return "层次加权法";
  29. case SPA:
  30. return "集对分析法";
  31. case MEA:
  32. return "物元分析法";
  33. case GCE:
  34. return "灰色聚类评估法";
  35. case WeightedSum:
  36. return "加权求和法";
  37. }
  38. }
  39. QString SchemePlanManager::processName(const SchemeProcessInfo &process)
  40. {
  41. QList<QString> l1 = { "构建权重分析指标体系", "收集权重分析数据", "指标体系优化", "指标权重计算", "", "",
  42. "分析结果展示", "生成分析评估报告" };
  43. QList<QString> l2 = {
  44. "构建技术措施指标体系", "", "", "", "收集评估数据", "评估计算", "评估结果展示", "生成评估报告"
  45. };
  46. QList<QString> l3 = { "构建方案优选指标体系", "收集方案优选权重分析数据",
  47. "指标体系优化", "指标权重计算",
  48. "评估数据采集", "方案优选计算",
  49. "方案优选结果展示", "生成方案优选报告" };
  50. QList<QString> l4 = { "构建效能评估指标体系", "收集效能评估权重分析数据", "指标体系优化",
  51. "效能评估权重计算", "收集效能评估数据", "效能评估计算",
  52. "效能评估结果展示", "生成效能评估报告" };
  53. QList<QList<QString>> names = { l1, l2, l3, l4 };
  54. /// 获取指标类型枚举值 index
  55. /// 由于枚举值不是连续自然数, 故不能作为下表来索引数组
  56. /// 故须使用 index 替代
  57. int index = 0;
  58. QMetaEnum indexEnum = QMetaEnum::fromType<ProjectManager::IndexType>();
  59. for (int i = 0; i < indexEnum.keyCount(); i++) {
  60. if (indexEnum.value(i) == process.indexType) {
  61. index = i;
  62. break;
  63. }
  64. }
  65. if (index >= 0 && index < names.count() && process.type >= 0 && process.type < names[index].count()) {
  66. return names[index][process.type];
  67. }
  68. return "";
  69. }
  70. QList<SchemePlanManager::SchemeDataSource>
  71. SchemePlanManager::processOptionalDataSource(const SchemeProcessInfo &process)
  72. {
  73. if (process.type == ImportEvalData && process.indexType == ProjectManager::EfficiencyIndex) {
  74. return { FromMeasurement };
  75. }
  76. if (process.type == ImportWeightData || process.type == ImportEvalData) {
  77. return { FromExpert, FromMeasurement };
  78. }
  79. return {};
  80. }
  81. /**
  82. * 根据指标体系类型和方案步骤类型, 返回可选算法
  83. * date: 2023-11-03 by chengxr
  84. */
  85. QList<SchemePlanManager::Algorithm> SchemePlanManager::processOptionalAlgorithms(const SchemeProcessInfo &process)
  86. {
  87. switch (process.type) {
  88. case OptimizeIndex:
  89. return { PrincipalComponents };
  90. case CalculateWeight: {
  91. return { AHP, Entropy, PrincipalComponents };
  92. }
  93. case RunEvaluate: {
  94. if (process.indexType == ProjectManager::TechIndex) {
  95. return { WeightedSum };
  96. } else if (process.indexType == ProjectManager::OptimalIndex) {
  97. return { HWM, SPA };
  98. } else if (process.indexType == ProjectManager::EfficiencyIndex) {
  99. return { MEA, GCE };
  100. }
  101. return {};
  102. }
  103. case IndexSystem:
  104. case ImportWeightData:
  105. case ImportEvalData:
  106. case ShowEvalResult:
  107. case GenerateReport:
  108. return {};
  109. }
  110. }
  111. bool SchemePlanManager::processIsOptional(const SchemeProcessInfo &process)
  112. {
  113. return (process.type == GenerateReport);
  114. }
  115. SchemePlanManager::SchemePlanManager(QObject *parent) : QObject(parent) { }