#include #include #include "EntropyWeights.h" #include "MatterElementAnalysis.h" #include "GreyClusterEvaluation.h" #include "SetPairAnalysis.h" #include "HierarchicalAnalysis.h" #include "HierarchyWeighting.h" void testHW() { SMat sam_mat = { { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, }, { 1, 16, 3, 4, 5, 6, 10, 8, 9, 7, 11, 12, 13, 14, 15, 2, 17, }, }; HierarchyWeighting hw(sam_mat); HWMat mat = { { 1 } }; HWMat mat1 = { { 1.0, 2.0, }, { 1.0 / 2.0, 1.0 } }; HWMat mat2 = { { 1.0, 2.0, 3.0, }, { 1.0 / 2.0, 1.0, 2.0 }, { 1.0 / 3.0, 1.0 / 2.0, 1.0 } }; HWMat mat3 = { { 1.0, 2.0, 2.0, 3.0, 3.0, }, { 1.0 / 2.0, 1.0, 2.0, 2.0, 3.0 }, { 1.0 / 2.0, 1.0 / 2.0, 1.0, 2.0, 2.0 }, { 1.0 / 3.0, 1.0 / 2.0, 1.0 / 2.0, 1.0, 2.0 }, { 1.0 / 3.0, 1.0 / 3.0, 1.0 / 2.0, 1.0 / 2.0, 1.0 }, }; hw.push("1", "临床", mat1); hw.push("1.1", "医疗", mat1); hw.push("1.2", "管理", mat2); hw.push("1.1.1", "医疗质量", mat3); hw.push("1.1.2", "护理质量", mat3); hw.push("1.2.1", "经济管理", mat); hw.push("1.2.2", "行政管理", mat2); hw.push("1.2.3", "精神文明", mat2); qDebug() << hw.isFull(); hw.evaluate(); int best = hw.getBestIndex(); // qDebug() << best; } void testHA() { QStringList ll = { "展开时间", "撤收时间", "携行重量", "操作人数", "防护能力", "保密能力" }; QVector nn = { 1, 1.0 / 3.0, 1.0 / 5.0, 1.0 / 3.0, 1.0 / 5.0, 1.0 / 3.0, 3, 1, 1.0 / 3.0, 3, 1.0 / 5.0, 1.0 / 3.0, 5, 3, 1, 5, 3, 3, 3, 1.0 / 3.0, 1.0 / 5.0, 1, 1.0 / 7.0, 1.0 / 3.0, 5, 5, 1.0 / 3.0, 7, 1, 3, 3, 3, 1.0 / 3.0, 3, 1.0 / 3.0, 1 }; HierarchicalAnalysis cc(ll.size(), nn); qDebug() << cc.consitst(); QVector m_weights = cc.getWeights(); qDebug() << m_weights; } void testSPA() { QVector rmat; #ifdef cxn // 指标1 rmat << QVector { 2.5, 3.0, 3.5, 4.0, 3.5, }; // 指标2 rmat << QVector { 66, 79, 85, 98, 83, }; // 指标3 rmat << QVector { 80, 77, 90, 92, 88, }; // 指标4 rmat << QVector { 800, 810, 900, 920, 780, #else // 样本1 rmat << QVector { 2.5, 66, 80, 800, }; // 样本2 rmat << QVector { 3.0, 79, 77, 810, }; // 样本3 rmat << QVector { 3.5, 85, 90, 900, }; // 样本4 rmat << QVector { 4.0, 98, 92, 920, }; // 样本4 rmat << QVector { 3.5, 83, 88, 780, }; #endif // 权重 QVector wmat = { 0.3, 0.5, 0.15, 0.05 }; // 同异反系数矩阵 QVector eMat = { 1, 1, 1, 1, 1 }; QVector dir = { false, true, false, false }; SetPairAnalysis spa(rmat, wmat, eMat, dir); Relations r = spa.getRelations(); qDebug() << r; }; void testEntropyWeights() { EntropyMat em; #if 0 //指标1 em << QVector{ 50625, 19600, 90000, 12500, 13500, 40000, 17408, }; //指标2 em << QVector{ 23.3330000000000, 52.6670000000000, 37.3300000000000, 18, 15, 31.6000000000000, 17.0667000000000, }; //指标3 em << QVector{ 3.50000000000000, 8, 14, 11, 15, 22, 20, }; #else em << QVector { 0.2662, 0.3595, 0.4755, 0.8027, 0.3368, 0.5047, 0.6996, 0.5941, }; em << QVector { 0.5977, 0.4208, 0.2756, 0.9144, 0.4421, 0.2021, 0.1581, 0.3003, }; em << QVector { 0.2623, 0.1796, 0.1004, 0.0179, 0.1841, 0.0633, 0.0494, 0.1296, }; #endif QVector direction = { true, true, true }; EntropyWeights ew(em, direction); QVector weights, score; ew.compute(weights, score); qDebug() << weights << score; } void testGCElementAnalysis() { GCEMat mat; GCERangeMat ranges; // 样本1 mat << QVector { { 85, 105 }, { 785, 950 }, { 0.6, 0.89 }, { 1041, 1700 }, { 47, 38 }, }; // 指标1 ranges << QVector { { 0, 70, 85, 100, 115 }, { 1, 85, 100, 115, 125 }, { 2, 100, 115, 125, 140 }, }; // 指标2 ranges << QVector { { 0, 400, 500, 650, 800 }, { 1, 500, 650, 800, 1000 }, { 2, 650, 800, 1000, 1100 }, }; // 指标3 ranges << QVector { { 0, 0.45, 0.5, 0.65, 0.75 }, { 1, 0.5, 0.65, 0.75, 0.9 }, { 2, 0.65, 0.75, 0.9, 0.95 }, }; // 指标4 ranges << QVector { { 0, 500, 800, 1200, 1600 }, { 1, 800, 1200, 1600, 2200 }, { 2, 1200, 1600, 2200, 2500 }, }; // 指标5 ranges << QVector { { 0, 28, 30, 40, 50 }, { 1, 30, 40, 50, 65 }, { 2, 40, 50, 65, 70 }, }; GreyClusterEvaluation gc(mat, ranges); gc.evaluate({ 0.2, 0.15, 0.05, 0.4, 0.2 }); BestIndex index = gc.getBestIndex(); qDebug() << index.front_index << index.back_index; } void testMEvaluation() { MEAMat mat; MEARangeMat ranges; // 样本1 mat << QVector { 3.16, 5.3, 10, 3.8, 25, 0.0041, 3, }; // 样本2 mat << QVector { 2.41, 1.8, 2.6, 5.2, 10, 0.0021, 3, }; // 样本3 mat << QVector { 3.5, 6.4, 23, 28, 6, 0.025, 3, }; // 等级1 ranges << QVector { { 0, 1, 1.5 }, { 1, 0, 2 }, { 2, 0, 15 }, { 3, 0, 2 }, { 4, 40, 20 }, { 5, 0, 0.003 }, { 6, 0, 2 }, }; // 等级2 ranges << QVector { { 0, 1.5, 2 }, { 1, 2, 4 }, { 2, 15, 25 }, { 3, 2, 5 }, { 4, 20, 10 }, { 5, 0.003, 0.005 }, { 6, 2, 4 }, }; // 等级3 ranges << QVector { { 0, 2, 2.5 }, { 1, 4, 6 }, { 2, 25, 35 }, { 3, 5, 15 }, { 4, 10, 6 }, { 5, 0.005, 0.016 }, { 6, 4, 6 }, }; // 等级4 ranges << QVector { { 0, 2.5, 3 }, { 1, 6, 8 }, { 2, 35, 45 }, { 3, 15, 45 }, { 4, 6, 4 }, { 5, 0.016, 0.03 }, { 6, 6, 7 }, }; // 等级5 ranges << QVector { { 0, 3, 4 }, { 1, 8, 10 }, { 2, 45, 55 }, { 3, 45, 90 }, { 4, 4, 3 }, { 5, 0.03, 0.06 }, { 6, 7, 8 }, }; // 等级范围p ranges << QVector { { 0, 1, 4 }, { 1, 0, 10 }, { 2, 0, 55 }, { 3, 0, 90 }, { 4, 40, 3 }, { 5, 0, 0.06 }, { 6, 0, 8 }, }; // 等级 MatterElementAnalysis me(mat, ranges); me.evaluate({ 0.189, 0.203, 0.052, 0.162, 0.202, 0.151, 0.041 }); QVector index = me.getBestIndex(); qDebug() << index; }