eva.test.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * evaluateExpressionLite 测试 — 基于 RAW 数据集
  3. *
  4. * 使用方式:
  5. * npx jest tests/eva.test.ts
  6. */
  7. import { evaluateExpressionLite } from '../src/views/system/algorithm/utils/evaluator';
  8. import { DEFAULT_DISPLAY_MAP, DEFAULT_OPERAND_SET } from '../src/views/system/algorithm/utils/config';
  9. const RAW = [
  10. {
  11. name: '压差测试陕西益东矿业有限责任公司',
  12. expr: 'sourcePressureChange>80',
  13. reasons: ['sourcePressureChange'],
  14. },
  15. {
  16. name: '闭内火灾测试陕西益东矿业有限责任公司',
  17. expr: '((coRzl>20 && coRzl<=50) || (0.5*coAvg<coZf && coZf<=coAvg) || (coVal>10 && coVal<=50) || (temperatureDifference>=2 && temperatureDifference<=4)) && co2Val<0.5',
  18. reasons: ['coVal', 'co2Val'],
  19. },
  20. {
  21. name: '闭外火灾测试陕西益东矿业有限责任公司',
  22. expr: '(temperatureDifferenceOut>10 && temperatureOut>=30) || (ch4ValOut>=1.5 && ch4ValOut<2) || coValOut>=24 || c2h2ValOut>0',
  23. reasons: ['coValOut'],
  24. },
  25. {
  26. name: '压差测试陕西益东矿业有限责任公司',
  27. expr: 'sourcePressureChange>80',
  28. reasons: ['sourcePressureChange'],
  29. },
  30. {
  31. name: '闭内火灾测试陕西益东矿业有限责任公司',
  32. expr: '((coRzl>50 && coRzl<=100) || (coAvg<coZf && coZf<=2*coAvg) || (coVal>=50 && coVal<=100) || (temperatureDifference>4 && temperatureDifference<=10)) && co2Val<0.5 || (c2h4Val>0 && c2h2Val==0)',
  33. reasons: ['c2h2Val', 'co2Val', 'coRzl'],
  34. },
  35. {
  36. name: '闭外火灾测试陕西益东矿业有限责任公司',
  37. expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
  38. reasons: ['o2ValOut', 'coValOut'],
  39. },
  40. {
  41. name: '压差测试陕西益东矿业有限责任公司',
  42. expr: 'sourcePressureChange>80',
  43. reasons: ['sourcePressureChange'],
  44. },
  45. {
  46. name: '闭内火灾测试陕西益东矿业有限责任公司',
  47. expr: '(((coRzl<=20 || coZf<=0.5*coAvg) && coVal<=10)||o2Val<=5 ) && temperatureDifference<2 && co2Val<0.5',
  48. reasons: ['coVal', 'coZf', 'coRzl'],
  49. },
  50. {
  51. name: '闭外火灾测试陕西益东矿业有限责任公司',
  52. expr: '(temperatureDifferenceOut>10 && temperatureOut>=30) || (ch4ValOut>=1.5 && ch4ValOut<2) || coValOut>=24 || c2h2ValOut>0',
  53. reasons: ['coValOut'],
  54. },
  55. {
  56. name: '压差测试陕西益东矿业有限责任公司',
  57. expr: 'sourcePressureChange>80',
  58. reasons: ['sourcePressureChange'],
  59. },
  60. {
  61. name: '闭内火灾测试陕西益东矿业有限责任公司',
  62. expr: '((coRzl>20 && coRzl<=50) || (0.5*coAvg<coZf && coZf<=coAvg) || (coVal>10 && coVal<=50) || (temperatureDifference>=2 && temperatureDifference<=4)) && co2Val<0.5',
  63. reasons: ['coVal', 'co2Val'],
  64. },
  65. {
  66. name: '闭外火灾测试陕西益东矿业有限责任公司',
  67. expr: '(temperatureDifferenceOut>4 && temperatureDifferenceOut<=10 && temperatureOut>=26) || (ch4ValOut>=1 && ch4ValOut<1.5) || (coValOut>=10 && coValOut<24) || (c2h4ValOut>0 && c2h2ValOut==0)',
  68. reasons: ['c2h2ValOut', 'coValOut'],
  69. },
  70. {
  71. name: '压差测试陕西益东矿业有限责任公司',
  72. expr: 'sourcePressureChange>80',
  73. reasons: ['sourcePressureChange'],
  74. },
  75. {
  76. name: '闭内火灾测试陕西益东矿业有限责任公司',
  77. expr: '((coRzl>20 && coRzl<=50) || (0.5*coAvg<coZf && coZf<=coAvg) || (coVal>10 && coVal<=50) || (temperatureDifference>=2 && temperatureDifference<=4)) && co2Val<0.5',
  78. reasons: ['coVal', 'co2Val', 'coRzl'],
  79. },
  80. {
  81. name: '闭外火灾测试陕西益东矿业有限责任公司',
  82. expr: '(temperatureDifferenceOut>=2 && temperatureDifferenceOut<=4) || (ch4ValOut>=0.5 && ch4ValOut <=1) || (coValOut>=5 && coValOut<10)',
  83. reasons: ['coValOut'],
  84. },
  85. {
  86. name: '闭外火灾测试红柳林煤矿',
  87. expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
  88. reasons: ['coValOut'],
  89. },
  90. {
  91. name: '闭外火灾测试红柳林煤矿',
  92. expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
  93. reasons: ['coValOut'],
  94. },
  95. {
  96. name: '闭外火灾测试红柳林煤矿',
  97. expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
  98. reasons: ['coValOut'],
  99. },
  100. {
  101. name: '闭外火灾测试红柳林煤矿',
  102. expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
  103. reasons: ['coValOut'],
  104. },
  105. {
  106. name: '闭外火灾测试红柳林煤矿',
  107. expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
  108. reasons: ['coValOut'],
  109. },
  110. {
  111. name: '闭外火灾测试红柳林煤矿',
  112. expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
  113. reasons: ['coValOut'],
  114. },
  115. {
  116. name: '闭外火灾测试红柳林煤矿',
  117. expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
  118. reasons: ['coValOut'],
  119. },
  120. ];
  121. describe('evaluateExpressionLite', () => {
  122. RAW.forEach(({ name, expr, reasons }) => {
  123. const result = evaluateExpressionLite(expr, reasons, DEFAULT_OPERAND_SET, DEFAULT_DISPLAY_MAP);
  124. // 验证每个 reason 关键字都在 summary 中被提及
  125. it(name, () => {
  126. console.log(`[${name}]预警原因:${reasons}`);
  127. console.log(result);
  128. expect(result.length).toBeGreaterThanOrEqual(0);
  129. // DEFAULT_OPERAND_SET.
  130. });
  131. });
  132. });