File indexing completed on 2025-01-31 09:21:59
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #include "DamageClassifier.hh"
0031
0032 #include <iostream>
0033 #include <algorithm>
0034
0035
0036
0037 std::vector<ClassifiedDamage> DamageClassifier::MakeCluster(
0038 std::vector<Damage>& pListDamage,unsigned int pDSBLength, bool pBase)
0039 {
0040 unsigned long int copyNb;
0041 unsigned long int lastCopyNb = -pDSBLength-1;
0042
0043
0044 std::sort(pListDamage.begin(), pListDamage.end(),
0045 [](const Damage& a, const Damage& b) {
0046 return a.GetCopyNb() < b.GetCopyNb();
0047 });
0048
0049 std::vector<ClassifiedDamage> listClassifiedDamage;
0050 ClassifiedDamage classDamage;
0051
0052 for(auto it=pListDamage.begin();it!=pListDamage.end();it++)
0053 {
0054 classDamage.SetIncludeBase(pBase);
0055 Damage tempDamage = (*it);
0056
0057 if(tempDamage.GetDamageType()==Damage::DamageType::fBackbone)
0058 {
0059
0060 copyNb=tempDamage.GetCopyNb();
0061
0062 if(classDamage.GetNumDamage()<=0)
0063 {
0064 classDamage.AddDamage(tempDamage);
0065 lastCopyNb = copyNb;
0066 }
0067 else
0068 {
0069
0070 if(copyNb>lastCopyNb+pDSBLength)
0071 {
0072 classDamage.ComputeBp();
0073 classDamage.ComputeType();
0074 classDamage.ComputeComplexity();
0075 listClassifiedDamage.push_back(classDamage);
0076 classDamage.Reset();
0077 }
0078
0079 classDamage.AddDamage(tempDamage);
0080 lastCopyNb = copyNb;
0081 }
0082 }
0083 }
0084
0085 if(classDamage.GetNumDamage()>0)
0086 {
0087 classDamage.ComputeBp();
0088 classDamage.ComputeType();
0089 classDamage.ComputeComplexity();
0090 listClassifiedDamage.push_back(classDamage);
0091 }
0092
0093
0094
0095 return listClassifiedDamage;
0096 }
0097
0098
0099
0100 unsigned int DamageClassifier::GetNumSSB(
0101 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0102 {
0103 unsigned int numSSB = 0;
0104 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0105 {
0106 if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fSSB)
0107 {
0108 numSSB++;
0109 }
0110 }
0111 return numSSB;
0112 }
0113
0114
0115
0116 unsigned int DamageClassifier::GetNumDSB(
0117 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0118 {
0119 unsigned int numDSB = 0;
0120 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0121 {
0122 if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB)
0123 {
0124 numDSB++;
0125 }
0126 }
0127 return numDSB;
0128 }
0129
0130
0131
0132 unsigned int DamageClassifier::GetNumComplexDSB(
0133 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0134 {
0135 unsigned int numComplexDSB = 0;
0136
0137 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0138 {
0139 if(((it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB))&&(it->GetComplexity()>1))
0140 {
0141 numComplexDSB++;
0142 }
0143 }
0144 return numComplexDSB;
0145 }
0146
0147
0148
0149
0150 std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > DamageClassifier::SortDamageByEvent(
0151 const std::vector<Damage>& pListDamage)
0152 {
0153 std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > mapDamage;
0154 for(auto it=pListDamage.begin();it!=pListDamage.end();it++)
0155 {
0156 mapDamage[it->GetEvt()][it->GetChromo()].push_back((*it));
0157 }
0158 return mapDamage;
0159 }
0160
0161
0162
0163 std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > DamageClassifier::SortDamageByChromo(
0164 const std::vector<Damage>& pListDamage)
0165 {
0166 std::map<unsigned int,std::map<unsigned int,std::vector<Damage> > > mapDamage;
0167 for(auto it=pListDamage.begin();it!=pListDamage.end();it++)
0168 {
0169 mapDamage[it->GetChromo()][it->GetEvt()].push_back((*it));
0170 }
0171 return mapDamage;
0172 }
0173
0174
0175
0176 unsigned int DamageClassifier::GetNumDSBwithDirectDamage(
0177 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0178 {
0179 unsigned int numDSBwDir = 0;
0180 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0181 {
0182 if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB &&
0183 it->GetIsThereDirectComponentContribution())
0184 {
0185 numDSBwDir++;
0186 }
0187 }
0188 return numDSBwDir;
0189 }
0190
0191
0192
0193 unsigned int DamageClassifier::GetNumDSBwithIndirectDamage(
0194 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0195 {
0196 unsigned int numDSBwIn = 0;
0197 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0198 {
0199 if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB &&
0200 it->GetIsThereIndirectComponentContribution())
0201 {
0202 numDSBwIn++;
0203 }
0204 }
0205 return numDSBwIn;
0206 }
0207
0208
0209
0210 unsigned int DamageClassifier::GetNumDSBwithBothDirectIndirectDamage(
0211 const std::vector<ClassifiedDamage>& pListClassifiedDamage) const
0212 {
0213 unsigned int numDSBwDirIn = 0;
0214 for(auto it=pListClassifiedDamage.begin();it!=pListClassifiedDamage.end();it++)
0215 {
0216 if(it->GetClassifiedDamageType()==ClassifiedDamage::ClassifiedDamageType::fDSB &&
0217 it->GetIsThereDirectComponentContribution() &&
0218 it->GetIsThereIndirectComponentContribution())
0219 {
0220 numDSBwDirIn++;
0221 }
0222 }
0223 return numDSBwDirIn;
0224 }
0225
0226