BEGIN { split("flex pmat prec resl team",ScaleFactors," ") split("acap aexp cplx data docu ltex pcap pcon "\ "plex pvol rely ruse sced site stor time tool",EffortMultipliers," ") split("aa etat pr",DefectRemovers," ") if (seed) {srand(seed)} else {srand()} OUTSEP = " " CONVFMT = "%.1f" main() } function main() { readModel(Model) readInputColumns(Cols) writeHeader(Cols) writeEstimations(Model,Cols) writeEstimationRanges(4) } function writeEstimationRanges(skips, i, numDefects, numMonths, prev) { numDefects = Defects[0] delete Defects[0] #Destroy the old size indicator so it isn't sorted asort(Defects) printf "@attribute defects" for (i = 1; i < numDefects; i++) { printf " ""%.0f",Defects[i] } numMonths = Months[0] delete Months[0] #Destroy the old size indicator so it isn't sorted asort(Months) printf "\n@attribute months" for (i = 1; i < numMonths; i++) { printf " ""%.1f",Months[i] } } function writeHeader(Cols, c) { print Relation print "" for (c = 1; c <= Cols[0]; c++) { print Cols["range",c] } # print "@attribute defects" # print "@attribute months" print "" print "@data" } function readInputColumns(cols) { while (getline) { if ($1 ~ /^[ /t]$/) { next } if ($1 ~ /^@relation/) { Relation = $0 } if ($1 ~ /^@attribute/) { addColumn(cols) } if ($1 ~ /^@data/) { break } } } function addColumn(cols) { cols[0]++ cols[Cols[0]] = $2 cols["range",Cols[0]] = $0 } function writeEstimations(Model,Cols, project,i,effort,months) { split("",project,"") #clear old project #read a project, estimate while (getline) { for (i = 1; i <= Cols[0]; i++) project[Cols[i]] = $i effort = getEffort(project, Model) def = totalDefects(project, Model) months = getMonths(effort, project, Model) Defects[++Defects[0]] = def Months[++Months[0]] = months printf project[Cols[1]] #hack to avoid trailing spaces on output for (i = 2; i <= Cols[0]; i++) { printf OUTSEP project[Cols[i]] } printf OUTSEP "%.0f",def printf OUTSEP months printf "\n" # print "DEBUG: historical->"project["effort"] " "effort"<-predicted" } } function getEffort(project, model, key,indx,a,b,ksloc,sfsum,emprod,em) { emprod = 1 #to avoid multiplying by zero ksloc = project["kloc"] a = project["a"] ? project["a"] : 4.5 b = project["b"] ? project["b"] : 1.0 for (indx in ScaleFactors) { key = ScaleFactors[indx] sfsum = sfsum + Model["SF",key,project[key]] } for (indx in EffortMultipliers) { key = EffortMultipliers[indx] if(project[key] == "") { em = 1.0 } else { em = Model["EM",key,project[key]] # printf ":"key"-"em } emprod = emprod * em } return a * (ksloc^( b + 0.01 * sfsum ) ) * emprod } function getMonths(effort, project, model, c,d,f,indx,\ sced,scedPercent,pmNs,sfkeys,sfsum,elessb,key) { c = 3.67 d = 0.28 sced = project["sced"] if (sced == 1) scedPercent = 75 if (sced == 2) scedPercent = 85 if (sced == 3) scedPercent = 100 if (sced == 4) scedPercent = 130 if (sced == 5) scedPercent = 160 pmNs = effort / Model["EM","sced",project["sced"]] for (indx in ScaleFactors) { key = ScaleFactors[indx] sfsum = sfsum + Model["SF",key,project[key]] } elessb = 0.01 * sfsum f = d + (0.2 * elessb) return c * (pmNs^f) * (scedPercent / 100) } #----------------------DEFECTS-------------------------# function totalDefects(project, model) { return defects("requirements", project, model) + \ defects("design", project, model) + \ defects("code", project, model) } function defects(type, project, model, percentRemoved,introduced,ksloc) { ksloc = project["kloc"] if (type == "requirements") introduced = 10 * ksloc * defectsIntroduced(type, project, model) if (type == "design") introduced = 20 * ksloc * defectsIntroduced(type, project, model) if (type == "code") introduced = 30 * ksloc * defectsIntroduced(type, project, model) percentRemoved = defectsRemovedRatio(type, project, model) return introduced * percentRemoved } function defectsRemovedRatio(type, project, model, product,drkeys,key,indx) { product = 1 for (indx in DefectRemovers) { key = DefectRemovers[indx] if (type == "requirements") product *= (1 - Model["DefRemoval-Reqs",key,project[key]]) if (type == "design") product *= (1 - Model["DefRemoval-Design",key,project[key]]) if (type == "code") product *= (1 - Model["DefRemoval-Coding",key,project[key]]) } return product } function totalDefectsIntroduced(project, model, ksloc) { ksloc = project["kloc"] return 10 * ksloc * defectsIntroduced("requirements", project, model) + \ 20 * ksloc * defectsIntroduced("design", project, model) + \ 30 * ksloc * defectsIntroduced("code", project, model) } function defectsIntroduced(type, project, model, sfkeys,emkeys,key,indx,product) { product = 1 for (indx in ScaleFactors) { key = ScaleFactors[indx] if (project[key]) { if (type == "requirements") product *= Model["DefIntro-Reqs",key,project[key]] if (type == "design") product *= Model["DefIntro-Design",key,project[key]] if (type == "code") product *= Model["DefIntro-Coding",key,project[key]] } else { # print "Err: "key" not defined in source input" } } for (indx in EffortMultipliers) { key = EffortMultipliers[indx] if (project[key]) { if (type == "requirements") product *= Model["DefIntro-Reqs",key,project[key]] if (type == "design") product *= Model["DefIntro-Design",key,project[key]] if (type == "code") product *= Model["DefIntro-Coding",key,project[key]] } else { # print "Err: "key" not defined in source input" } } return product } function table2Array(arr,name,str, rows,numRows,cells,i,j) { numRows = split(str,rows,",") for (i = 1; i <= numRows; i++) { split(rows[i],cells," ") for (j = 1; j <= cells[3]-cells[2] + 1; j++) { arr[name,cells[1],j+cells[2]-1] = cells[j+3] } } } function readModel(Model) { #CoCoMo Scale Factors table2Array(Model,"SF", "flex 1 5 5.04 4.05 3.04 2.03 1.01,"\ "pmat 1 5 7.80 6.24 4.68 3.12 1.56,"\ "prec 1 5 6.20 4.96 3.72 2.48 1.24,"\ "resl 1 5 7.07 5.65 4.24 2.83 1.41,"\ "team 1 5 5.48 4.38 3.29 2.19 1.01") #CoCoMo Effort Multipliers table2Array(Model,"EM", "acap 1 5 1.42 1.19 1.00 0.85 0.71,"\ "aexp 1 5 1.22 1.10 1.00 0.88 0.81,"\ "cplx 1 6 0.73 0.87 1.00 1.17 1.34 1.74,"\ "data 2 5 0.90 1.00 1.14 1.28,"\ "docu 1 5 0.81 0.91 1.00 1.11 1.23,"\ "ltex 1 5 1.20 1.09 1.00 1.11 1.23,"\ "pcap 1 5 1.34 1.15 1.00 0.88 0.76,"\ "pcon 1 5 1.29 1.12 1.00 0.90 0.81,"\ "plex 1 5 1.19 1.09 1.00 0.91 0.85,"\ "pvol 2 5 0.87 1.00 1.15 1.30,"\ "rely 1 5 0.82 0.92 1.00 1.10 1.26,"\ "ruse 2 6 0.95 1.00 1.07 1.15 1.24,"\ "sced 1 5 1.43 1.14 1.00 1.00 1.00,"\ "site 1 6 1.22 1.09 1.00 0.93 0.86 0.80,"\ "stor 3 6 1.00 1.05 1.17 1.46,"\ "time 3 6 1.00 1.11 1.29 1.63,"\ "tool 1 5 1.17 1.09 1.00 0.90 0.78") #CoQualMo Defect Introduction (Requirements) table2Array(Model,"DefIntro-Reqs", "flex 1 6 1.00 1.00 1.00 1.00 1.00 1.00,"\ "pmat 1 6 1.38 1.19 1.00 0.93 0.85 0.73,"\ "prec 1 6 1.43 1.22 1.00 0.92 0.84 0.70,"\ "resl 1 6 1.32 1.16 1.00 0.94 0.87 0.76,"\ "team 1 6 1.34 1.17 1.00 0.94 0.87 0.75,"\ "acap 1 5 1.33 1.17 1.00 0.87 0.75,"\ "aexp 1 5 1.24 1.12 1.00 0.91 0.81,"\ "cplx 1 6 0.76 0.88 1.00 1.10 1.21 1.32,"\ "data 2 5 0.93 1.00 1.04 1.07,"\ "docu 1 5 1.16 1.08 1.00 0.93 0.86,"\ "ltex 1 5 1.07 1.04 1.00 0.97 0.93,"\ "pcap 1 5 1.00 1.00 1.00 1.00 1.00,"\ "pcon 1 5 1.22 1.11 1.00 0.91 0.82,"\ "plex 1 5 1.11 1.05 1.00 0.95 0.90,"\ "pvol 2 6 0.86 1.00 1.05 1.10 1.16,"\ "rely 1 5 1.43 1.22 1.00 0.85 0.70,"\ "ruse 2 6 0.95 1.00 1.02 1.03 1.05,"\ "sced 1 5 1.18 1.09 1.00 0.92 0.85,"\ "site 1 6 1.20 1.10 1.00 0.95 0.89 0.83,"\ "stor 3 6 1.00 1.03 1.05 1.08,"\ "time 3 6 1.00 1.03 1.05 1.08,"\ "tool 1 5 1.09 1.05 1.00 0.96 0.92") #CoQualMo Defect Introduction (Design) table2Array(Model,"DefIntro-Design",\ "flex 1 6 1.00 1.00 1.00 1.00 1.00 1.00,"\ "pmat 1 6 1.65 1.33 1.00 0.89 0.78 0.61,"\ "prec 1 6 1.43 1.22 1.00 0.92 0.84 0.70,"\ "resl 1 6 1.32 1.16 1.00 0.94 0.87 0.76,"\ "team 1 6 1.34 1.17 1.00 0.94 0.87 0.75,"\ "acap 1 5 1.20 1.10 1.00 0.91 0.83,"\ "aexp 1 5 1.22 1.11 1.00 0.91 0.82,"\ "cplx 1 6 0.71 0.86 1.00 1.13 1.27 1.41,"\ "data 2 5 0.91 1.00 1.05 1.10,"\ "docu 1 5 1.18 1.09 1.00 0.93 0.85,"\ "ltex 1 5 1.13 1.07 1.00 0.91 0.88,"\ "pcap 1 5 1.17 1.09 1.00 0.93 0.85,"\ "pcon 1 5 1.25 1.13 1.00 0.90 0.80,"\ "plex 1 5 1.17 1.09 1.00 0.93 0.86,"\ "pvol 2 6 0.86 1.00 1.05 1.10 1.16,"\ "rely 1 5 1.45 1.23 1.00 0.85 0.69,"\ "ruse 2 6 0.98 1.00 1.00 1.01 10.2,"\ "sced 1 5 1.19 1.10 1.00 0.92 0.84,"\ "site 1 6 1.20 1.10 1.00 0.95 0.89 0.83,"\ "stor 3 6 1.00 1.06 1.12 1.18,"\ "time 3 6 1.00 1.06 1.13 1.20,"\ "tool 1 5 1.10 1.05 1.00 0.96 0.91") #CoQualMo Defect Introduction (Coding) table2Array(Model,"DefIntro-Coding",\ "flex 1 6 1.00 1.00 1.00 1.00 1.00 1.00,"\ "pmat 1 6 1.58 1.30 1.00 0.90 0.79 0.63,"\ "prec 1 6 1.24 1.12 1.00 0.95 0.90 0.81,"\ "resl 1 6 1.41 1.21 1.00 0.92 0.84 0.71,"\ "team 1 6 1.18 1.09 1.00 0.96 0.92 0.86,"\ "acap 1 5 1.11 1.05 1.00 0.95 0.90,"\ "aexp 1 5 1.13 1.07 1.00 0.94 0.88,"\ "cplx 1 6 0.71 0.86 1.00 1.13 1.27 1.41,"\ "data 2 5 0.91 1.00 1.05 1.10,"\ "docu 1 5 1.18 1.09 1.00 0.92 0.85,"\ "ltex 1 5 1.22 1.11 1.00 0.91 0.82,"\ "pcap 1 5 1.32 1.16 1.00 0.88 0.76,"\ "pcon 1 5 1.30 1.15 1.00 0.88 0.77,"\ "plex 1 5 1.16 1.08 1.00 0.94 0.86,"\ "pvol 2 6 0.82 1.00 1.08 1.15 1.22,"\ "rely 1 5 1.45 1.23 1.00 0.85 0.69,"\ "ruse 2 6 0.98 1.00 1.00 1.01 1.02,"\ "sced 1 5 1.19 1.10 1.00 0.92 0.84,"\ "site 1 6 1.18 1.09 1.00 0.95 0.90 0.85,"\ "stor 3 6 1.00 1.05 1.10 1.15,"\ "time 3 6 1.00 1.06 1.13 1.20,"\ "tool 1 5 1.25 1.13 1.00 0.90 0.80") #CoQualMo Defect Removal (Requirements) table2Array(Model,"DefRemoval-Reqs",\ "aa 1 6 0.00 0.00 0.10 0.27 0.34 0.40,"\ "etat 1 6 0.00 0.23 0.40 0.50 0.57 0.60,"\ "pr 1 6 0.00 0.25 0.40 0.50 0.58 0.70") #CoQualMo Defect Removal (Design) table2Array(Model,"DefRemoval-Design",\ "aa 1 6 0.00 0.00 0.13 0.28 0.44 0.50,"\ "etat 1 6 0.00 0.23 0.43 0.54 0.65 0.70,"\ "pr 1 6 0.00 0.28 0.40 0.54 0.70 0.78") #CoQualMo Defect Removal (Coding) table2Array(Model,"DefectRemoval-Coding",\ "aa 1 6 0.00 0.10 0.20 0.30 0.48 0.55,"\ "etat 1 6 0.00 0.38 0.58 0.69 0.78 0.88,"\ "pr 1 6 0.00 0.30 0.48 0.60 0.73 0.83") }