| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- /**
- * evaluateExpressionLite 测试 — 基于 RAW 数据集
- *
- * 使用方式:
- * npx jest tests/eva.test.ts
- */
- import { evaluateExpressionLite } from '../src/views/system/algorithm/utils/evaluator';
- import { DEFAULT_DISPLAY_MAP, DEFAULT_OPERAND_SET } from '../src/views/system/algorithm/utils/config';
- const RAW = [
- {
- name: '压差测试陕西益东矿业有限责任公司',
- expr: 'sourcePressureChange>80',
- reasons: ['sourcePressureChange'],
- },
- {
- name: '闭内火灾测试陕西益东矿业有限责任公司',
- expr: '((coRzl>20 && coRzl<=50) || (0.5*coAvg<coZf && coZf<=coAvg) || (coVal>10 && coVal<=50) || (temperatureDifference>=2 && temperatureDifference<=4)) && co2Val<0.5',
- reasons: ['coVal', 'co2Val'],
- },
- {
- name: '闭外火灾测试陕西益东矿业有限责任公司',
- expr: '(temperatureDifferenceOut>10 && temperatureOut>=30) || (ch4ValOut>=1.5 && ch4ValOut<2) || coValOut>=24 || c2h2ValOut>0',
- reasons: ['coValOut'],
- },
- {
- name: '压差测试陕西益东矿业有限责任公司',
- expr: 'sourcePressureChange>80',
- reasons: ['sourcePressureChange'],
- },
- {
- name: '闭内火灾测试陕西益东矿业有限责任公司',
- 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)',
- reasons: ['c2h2Val', 'co2Val', 'coRzl'],
- },
- {
- name: '闭外火灾测试陕西益东矿业有限责任公司',
- expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
- reasons: ['o2ValOut', 'coValOut'],
- },
- {
- name: '压差测试陕西益东矿业有限责任公司',
- expr: 'sourcePressureChange>80',
- reasons: ['sourcePressureChange'],
- },
- {
- name: '闭内火灾测试陕西益东矿业有限责任公司',
- expr: '(((coRzl<=20 || coZf<=0.5*coAvg) && coVal<=10)||o2Val<=5 ) && temperatureDifference<2 && co2Val<0.5',
- reasons: ['coVal', 'coZf', 'coRzl'],
- },
- {
- name: '闭外火灾测试陕西益东矿业有限责任公司',
- expr: '(temperatureDifferenceOut>10 && temperatureOut>=30) || (ch4ValOut>=1.5 && ch4ValOut<2) || coValOut>=24 || c2h2ValOut>0',
- reasons: ['coValOut'],
- },
- {
- name: '压差测试陕西益东矿业有限责任公司',
- expr: 'sourcePressureChange>80',
- reasons: ['sourcePressureChange'],
- },
- {
- name: '闭内火灾测试陕西益东矿业有限责任公司',
- expr: '((coRzl>20 && coRzl<=50) || (0.5*coAvg<coZf && coZf<=coAvg) || (coVal>10 && coVal<=50) || (temperatureDifference>=2 && temperatureDifference<=4)) && co2Val<0.5',
- reasons: ['coVal', 'co2Val'],
- },
- {
- name: '闭外火灾测试陕西益东矿业有限责任公司',
- expr: '(temperatureDifferenceOut>4 && temperatureDifferenceOut<=10 && temperatureOut>=26) || (ch4ValOut>=1 && ch4ValOut<1.5) || (coValOut>=10 && coValOut<24) || (c2h4ValOut>0 && c2h2ValOut==0)',
- reasons: ['c2h2ValOut', 'coValOut'],
- },
- {
- name: '压差测试陕西益东矿业有限责任公司',
- expr: 'sourcePressureChange>80',
- reasons: ['sourcePressureChange'],
- },
- {
- name: '闭内火灾测试陕西益东矿业有限责任公司',
- expr: '((coRzl>20 && coRzl<=50) || (0.5*coAvg<coZf && coZf<=coAvg) || (coVal>10 && coVal<=50) || (temperatureDifference>=2 && temperatureDifference<=4)) && co2Val<0.5',
- reasons: ['coVal', 'co2Val', 'coRzl'],
- },
- {
- name: '闭外火灾测试陕西益东矿业有限责任公司',
- expr: '(temperatureDifferenceOut>=2 && temperatureDifferenceOut<=4) || (ch4ValOut>=0.5 && ch4ValOut <=1) || (coValOut>=5 && coValOut<10)',
- reasons: ['coValOut'],
- },
- {
- name: '闭外火灾测试红柳林煤矿',
- expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
- reasons: ['coValOut'],
- },
- {
- name: '闭外火灾测试红柳林煤矿',
- expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
- reasons: ['coValOut'],
- },
- {
- name: '闭外火灾测试红柳林煤矿',
- expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
- reasons: ['coValOut'],
- },
- {
- name: '闭外火灾测试红柳林煤矿',
- expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
- reasons: ['coValOut'],
- },
- {
- name: '闭外火灾测试红柳林煤矿',
- expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
- reasons: ['coValOut'],
- },
- {
- name: '闭外火灾测试红柳林煤矿',
- expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
- reasons: ['coValOut'],
- },
- {
- name: '闭外火灾测试红柳林煤矿',
- expr: 'temperatureDifferenceOut<2 || (ch4ValOut>0 && ch4ValOut<0.5) || (coValOut>=0 && coValOut<5) || o2ValOut < 20',
- reasons: ['coValOut'],
- },
- ];
- describe('evaluateExpressionLite', () => {
- RAW.forEach(({ name, expr, reasons }) => {
- const result = evaluateExpressionLite(expr, reasons, DEFAULT_OPERAND_SET, DEFAULT_DISPLAY_MAP);
- // 验证每个 reason 关键字都在 summary 中被提及
- it(name, () => {
- console.log(`[${name}]预警原因:${reasons}`);
- console.log(result);
- expect(result.length).toBeGreaterThanOrEqual(0);
- // DEFAULT_OPERAND_SET.
- });
- });
- });
|