SchemePlanManager.cpp 4.4 KB

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