SchemePlanManager.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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::stringFromIndexCostType(SchemePlanManager::IndexCostType t)
  42. {
  43. switch (t) {
  44. case IndexCostTypeCost:
  45. return "成本型";
  46. case IndexCostTypeBenefit:
  47. return "效益型";
  48. }
  49. }
  50. QString SchemePlanManager::processName(const SchemeProcessInfo &process)
  51. {
  52. QList<QString> l1 = { "构建权重分析指标体系", "收集权重分析数据", "指标体系优化", "指标权重计算", "", "",
  53. "分析结果展示", "生成分析评估报告" };
  54. QList<QString> l2 = {
  55. "构建技术措施指标体系", "", "", "", "收集评估数据", "评估计算", "评估结果展示", "生成评估报告"
  56. };
  57. QList<QString> l3 = { "构建方案优选指标体系", "收集方案优选权重分析数据",
  58. "指标体系优化", "指标权重计算",
  59. "评估数据采集", "方案优选计算",
  60. "方案优选结果展示", "生成方案优选报告" };
  61. QList<QString> l4 = { "构建效能评估指标体系", "收集效能评估权重分析数据", "指标体系优化",
  62. "效能评估权重计算", "收集效能评估数据", "效能评估计算",
  63. "效能评估结果展示", "生成效能评估报告" };
  64. QList<QList<QString>> names = { l1, l2, l3, l4 };
  65. /// 获取指标类型枚举值 index
  66. /// 由于枚举值不是连续自然数, 故不能作为下表来索引数组
  67. /// 故须使用 index 替代
  68. int index = 0;
  69. QMetaEnum indexEnum = QMetaEnum::fromType<ProjectManager::IndexType>();
  70. for (int i = 0; i < indexEnum.keyCount(); i++) {
  71. if (indexEnum.value(i) == process.indexType) {
  72. index = i;
  73. break;
  74. }
  75. }
  76. if (index >= 0 && index < names.count() && process.type >= 0 && process.type < names[index].count()) {
  77. return names[index][process.type];
  78. }
  79. return "";
  80. }
  81. QList<SchemePlanManager::SchemeDataSource>
  82. SchemePlanManager::processOptionalDataSource(const SchemeProcessInfo &process)
  83. {
  84. if (process.type == ImportEvalData && process.indexType == ProjectManager::EfficiencyIndex) {
  85. return { FromMeasurement };
  86. }
  87. if (process.type == ImportEvalData && process.indexType == ProjectManager::OptimalIndex) {
  88. return { FromScheme };
  89. }
  90. if (process.type == ImportWeightData || process.type == ImportEvalData) {
  91. return { FromExpert, FromMeasurement };
  92. }
  93. return {};
  94. }
  95. /**
  96. * 根据指标体系类型和方案步骤类型, 返回可选算法
  97. * date: 2023-11-03 by chengxr
  98. */
  99. QList<SchemePlanManager::Algorithm> SchemePlanManager::processOptionalAlgorithms(const SchemeProcessInfo &process)
  100. {
  101. switch (process.type) {
  102. case OptimizeIndex:
  103. return { PrincipalComponents };
  104. case CalculateWeight: {
  105. return { AHP, Entropy, PrincipalComponents };
  106. }
  107. case RunEvaluate: {
  108. if (process.indexType == ProjectManager::TechIndex) {
  109. return { WeightedSum };
  110. } else if (process.indexType == ProjectManager::OptimalIndex) {
  111. return { HWM, SPA };
  112. } else if (process.indexType == ProjectManager::EfficiencyIndex) {
  113. return { MEA, GCE };
  114. }
  115. return {};
  116. }
  117. case IndexSystem:
  118. case ImportWeightData:
  119. case ImportEvalData:
  120. case ShowEvalResult:
  121. case GenerateReport:
  122. return {};
  123. }
  124. }
  125. bool SchemePlanManager::processIsOptional(const SchemeProcessInfo &process)
  126. {
  127. return (process.type == GenerateReport);
  128. }
  129. SchemePlanManager::SchemePlanManager(QObject *parent) : QObject(parent) { }