123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- #include <QCoreApplication>
- #include <QDebug>
- #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<qreal> 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<qreal> m_weights = cc.getWeights();
- qDebug() << m_weights;
- }
- void testSPA()
- {
- QVector<EvaluateIndex> rmat;
- #ifdef cxn
- // 指标1
- rmat << QVector<double> {
- 2.5, 3.0, 3.5, 4.0, 3.5,
- };
- // 指标2
- rmat << QVector<double> {
- 66, 79, 85, 98, 83,
- };
- // 指标3
- rmat << QVector<double> {
- 80, 77, 90, 92, 88,
- };
- // 指标4
- rmat << QVector<double>
- {
- 800, 810, 900, 920, 780,
- #else
- // 样本1
- rmat << QVector<double> {
- 2.5,
- 66,
- 80,
- 800,
- };
- // 样本2
- rmat << QVector<double> {
- 3.0,
- 79,
- 77,
- 810,
- };
- // 样本3
- rmat << QVector<double> {
- 3.5,
- 85,
- 90,
- 900,
- };
- // 样本4
- rmat << QVector<double> {
- 4.0,
- 98,
- 92,
- 920,
- };
- // 样本4
- rmat << QVector<double> {
- 3.5,
- 83,
- 88,
- 780,
- };
- #endif
- // 权重
- QVector<qreal> wmat = { 0.3, 0.5, 0.15, 0.05 };
- // 同异反系数矩阵
- QVector<qreal> eMat = { 1, 1, 1, 1, 1 };
- QVector<bool> 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<double>{
- 50625,
- 19600,
- 90000,
- 12500,
- 13500,
- 40000,
- 17408,
- };
- //指标2
- em << QVector<double>{
- 23.3330000000000,
- 52.6670000000000,
- 37.3300000000000,
- 18,
- 15,
- 31.6000000000000,
- 17.0667000000000,
- };
- //指标3
- em << QVector<double>{
- 3.50000000000000,
- 8,
- 14,
- 11,
- 15,
- 22,
- 20,
- };
- #else
- em << QVector<double> {
- 0.2662, 0.3595, 0.4755, 0.8027, 0.3368, 0.5047, 0.6996, 0.5941,
- };
- em << QVector<double> {
- 0.5977, 0.4208, 0.2756, 0.9144, 0.4421, 0.2021, 0.1581, 0.3003,
- };
- em << QVector<double> {
- 0.2623, 0.1796, 0.1004, 0.0179, 0.1841, 0.0633, 0.0494, 0.1296,
- };
- #endif
- QVector<bool> direction = { true, true, true };
- EntropyWeights ew(em, direction);
- QVector<double> weights, score;
- ew.compute(weights, score);
- qDebug() << weights << score;
- }
- void testGCElementAnalysis()
- {
- GCEMat mat;
- GCERangeMat ranges;
- // 样本1
- mat << QVector<GCEmat> {
- { 85, 105 }, { 785, 950 }, { 0.6, 0.89 }, { 1041, 1700 }, { 47, 38 },
- };
- // 指标1
- ranges << QVector<GCERange> {
- { 0, 70, 85, 100, 115 },
- { 1, 85, 100, 115, 125 },
- { 2, 100, 115, 125, 140 },
- };
- // 指标2
- ranges << QVector<GCERange> {
- { 0, 400, 500, 650, 800 },
- { 1, 500, 650, 800, 1000 },
- { 2, 650, 800, 1000, 1100 },
- };
- // 指标3
- ranges << QVector<GCERange> {
- { 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<GCERange> {
- { 0, 500, 800, 1200, 1600 },
- { 1, 800, 1200, 1600, 2200 },
- { 2, 1200, 1600, 2200, 2500 },
- };
- // 指标5
- ranges << QVector<GCERange> {
- { 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<double> {
- 3.16, 5.3, 10, 3.8, 25, 0.0041, 3,
- };
- // 样本2
- mat << QVector<double> {
- 2.41, 1.8, 2.6, 5.2, 10, 0.0021, 3,
- };
- // 样本3
- mat << QVector<double> {
- 3.5, 6.4, 23, 28, 6, 0.025, 3,
- };
- // 等级1
- ranges << QVector<MEARange> {
- { 0, true, false, 1, 1.5 }, { 1, true, false, 0, 2 }, { 2, true, false, 0, 15 },
- { 3, true, false, 0, 2 }, { 4, true, false, 40, 20 }, { 5, true, false, 0, 0.003 },
- { 6, true, false, 0, 2 },
- };
- // 等级2
- ranges << QVector<MEARange> {
- { 0, true, false, 1.5, 2 }, { 1, true, false, 2, 4 }, { 2, true, false, 15, 25 },
- { 3, true, false, 2, 5 }, { 4, true, false, 20, 10 }, { 5, true, false, 0.003, 0.005 },
- { 6, true, false, 2, 4 },
- };
- // 等级3
- ranges << QVector<MEARange> {
- { 0, true, false, 2, 2.5 }, { 1, true, false, 4, 6 }, { 2, true, false, 25, 35 },
- { 3, true, false, 5, 15 }, { 4, true, false, 10, 6 }, { 5, true, false, 0.005, 0.016 },
- { 6, true, false, 4, 6 },
- };
- // 等级4
- ranges << QVector<MEARange> {
- { 0, true, false, 2.5, 3 }, { 1, true, false, 6, 8 }, { 2, true, false, 35, 45 },
- { 3, true, false, 15, 45 }, { 4, true, false, 6, 4 }, { 5, true, false, 0.016, 0.03 },
- { 6, true, false, 6, 7 },
- };
- // 等级5
- ranges << QVector<MEARange> {
- { 0, true, false, 3, 4 }, { 1, true, false, 8, 10 }, { 2, true, false, 45, 55 },
- { 3, true, false, 45, 90 }, { 4, true, false, 4, 3 }, { 5, true, false, 0.03, 0.06 },
- { 6, true, false, 7, 8 },
- };
- // 等级范围p
- ranges << QVector<MEARange> {
- { 0, true, false, 1, 4 }, { 1, true, false, 0, 10 }, { 2, true, false, 0, 55 },
- { 3, true, false, 0, 90 }, { 4, true, false, 40, 3 }, { 5, true, false, 0, 0.06 },
- { 6, true, false, 0, 8 },
- };
- // 等级
- MatterElementAnalysis me(mat, ranges);
- me.evaluate({ 0.189, 0.203, 0.052, 0.162, 0.202, 0.151, 0.041 });
- QVector<int> index = me.getBestIndex();
- qDebug() << index;
- }
|