#include "project.h" #include "randomNum.h" double attrange_Normm[2][42]={ {1,1,1,1,1,1,1,1,3,3,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,0.0416,-0.12,0.0904,0.0576,-0.126,0.1056,0.0572,-0.1272,0.1208,-1.518,0.112,-0.1308,2.2,0.85,5,1.5,0.16}, {6,6,6,5,5,5,5,5,6,6,5,5,6,5,5,5,5,5,5,5,5,5,5,6,6,0.0624,-0.08,0.1356,0.0864,-0.084,0.1584,0.0864,-0.0848,0.1812,-1.012,0.168,-0.0872,9.18,1.09,10000,4.5,0.49} }; float tprec,tflex,tresl,tteam,tpmat,ttime,tstor,tdata,tpvol,truse,trely,tcplx,tdocu,tsced,tacap,tpcap,tpcon,tapex,tltex,ttool,tsite,tplex ; randomNum rd; project::project() { initialize(); } project::~project() { } void project::initialize() { //initializations pRSlope=0.052; nRSlope=-0.100; dfrRSlope=0.113; pDSlope=0.072; nDSlope=-0.105; dfrDSlope=0.132; pCSlope=0.072; nCSlope=-0.106; dfrCSlope=0.151; SFSlope=-1.265; posEMSlope=0.140; negEMSlope=-0.109; A=5.97; B=0.96; C=3.67; D=0.28; ksloc=100; for (int i=0; i<25; i++) attributes[i]=0; //defect removal schemes automated_analysis=0; peer_reviews=0; execution_testing_and_tools=0; //scale factors prec=0; flex=0; resl=0; team=0; pmat=0; //effort multipliers time=0; stor=0; data=0; pvol=0; ruse=0; rely=0; docu=0; acap=0; pcap=0; pcon=0; apex=0; plex=0; ltex=0; tool=0; sced=0; cplx=0; site=0; pCoqualRSlope=pRSlope; nCoqualRSlope=nRSlope; dfrCoqualRSlope=dfrRSlope; pCoqualDSlope=pDSlope; nCoqualDSlope=nDSlope; dfrCoqualDSlope=dfrDSlope; pCoqualCSlope=pCSlope; nCoqualCSlope=nCSlope; dfrCoqualCSlope=dfrCSlope; SFCocomoSlope=SFSlope; posEMCocomoSlope=posEMSlope; negEMCocomoSlope=negEMSlope; } //The regulated CocomoII model double project::SFCocomo (int rating) {return (double)(rating-6)*SFCocomoSlope;} double project::posEMCocomo (int rating) {return (double)(rating-3)*posEMCocomoSlope + 1;} double project::negEMCocomo (int rating) {return (double)(rating-3)*negEMCocomoSlope + 1;} //cocomoII stuff double project::fprec () {return SFCocomo(prec);} double project::fflex () {return SFCocomo(flex);} double project::fresl () {return SFCocomo(resl);} double project::fteam () {return SFCocomo(team);} double project::fpmat () {return SFCocomo(pmat);} double project::ftime () {return posEMCocomo(time);} double project::fstor () {return posEMCocomo(stor);} double project::fdata () {return posEMCocomo(data);} double project::fpvol () {return posEMCocomo(pvol);} double project::fruse () {return posEMCocomo(ruse);} double project::frely () {return posEMCocomo(rely);} double project::fcplx () {return posEMCocomo(cplx);} double project::fdocu () {return posEMCocomo(docu);} double project::fsced () {return negEMCocomo(sced);} double project::facap () {return negEMCocomo(acap);} double project::fpcap () {return negEMCocomo(pcap);} double project::fpcon () {return negEMCocomo(pcon);} double project::fapex () {return negEMCocomo(apex);} double project::fltex () {return negEMCocomo(ltex);} double project::ftool () {return negEMCocomo(tool);} double project::fsite () {return negEMCocomo(site);} double project::fplex () {return negEMCocomo(plex);} void project::setattnum(int attnum, double rating) { switch (attnum) { case 0: sautomated_analysis((int)rating); break; case 1: speer_reviews((int)rating); break; case 2: sexecution_testing_and_tools((int)rating); break; case 3: sprec((int)rating); break; case 4: sflex((int)rating); break; case 5: sresl((int)rating); break; case 6: steam((int)rating); break; case 7: spmat((int)rating); break; case 8: stime((int)rating); break; case 9: sstor((int)rating); break; case 10: sdata((int)rating); break; case 11: spvol((int)rating); break; case 12: sruse((int)rating); break; case 13: srely((int)rating); break; case 14: sdocu((int)rating); break; case 15: sacap((int)rating); break; case 16: spcap((int)rating); break; case 17: spcon((int)rating); break; case 18: sapex((int)rating); break; case 19: splex((int)rating); break; case 20: sltex((int)rating); break; case 21: stool((int)rating); break; case 22: ssced((int)rating); break; case 23: scplx((int)rating); break; case 24: ssite((int)rating); break; //Slopes, A, B and Ksloc case 25: spCoqualRSlope (rating); break; case 26: snCoqualRSlope (rating);break; case 27: sdfrCoqualRSlope (rating);break; case 28: spCoqualDSlope (rating);break; case 29: snCoqualDSlope (rating);break; case 30: sdfrCoqualDSlope (rating);break; case 31: spCoqualCSlope (rating);break; case 32: snCoqualCSlope (rating);break; case 33: sdfrCoqualCSlope (rating);break; case 34: sSFCocomoSlope (rating);break; case 35: sposEMCocomoSlope (rating);break; case 36: snegEMCocomoSlope (rating);break; case 37: sA (rating); break; case 38: sB (rating); break; case 39: sKsloc (rating); break; case 40: sC (rating); break; case 41: sD (rating); break; } } int project::setatt(int rating, int min, int max) { if (rating > max) return max; else if (rating < min) return min; else return rating; } void project::sprec (int rating) { int min=1;int max=5; attributes[3]=prec=setatt(rating, min, max); } void project::sflex (int rating) { int min=1;int max=5; attributes[4]=flex=setatt(rating, min, max); } void project::sresl (int rating) { int min=1;int max=5; attributes[5]=resl=setatt(rating, min, max); } void project::steam (int rating) { int min=1;int max=5; attributes[6]=team=setatt(rating, min, max); } void project::spmat (int rating) { int min=1;int max=5; attributes[7]=pmat=setatt(rating, min, max); } void project::stime (int rating) { int min=3;int max=6; attributes[8]=time=setatt(rating, min, max); } void project::sstor (int rating) { int min=3;int max=6; attributes[9]=stor=setatt(rating, min, max); } void project::sdata (int rating) { int min=2;int max=5; attributes[10]=data=setatt(rating, min, max); } void project::spvol (int rating) { int min=2;int max=5; attributes[11]=pvol=setatt(rating, min, max); } void project::sruse (int rating) { int min=2;int max=6; attributes[12]=ruse=setatt(rating, min, max); } void project::srely (int rating) { int min=1;int max=5; attributes[13]=rely=setatt(rating, min, max); } void project::ssced (int rating) { int min=1;int max=5; attributes[22]=sced=setatt(rating, min, max); } void project::scplx (int rating) { int min=1;int max=6; attributes[23]=cplx=setatt(rating, min, max); } void project::sdocu (int rating) { int min=1;int max=5; attributes[14]=docu=setatt(rating, min, max); } void project::sacap (int rating) { int min=1;int max=5; attributes[15]=acap=setatt(rating, min, max); } void project::spcap (int rating) { int min=1;int max=5; attributes[16]=pcap=setatt(rating, min, max); } void project::spcon (int rating) { int min=1;int max=5; attributes[17]=pcon=setatt(rating, min, max); } void project::sapex (int rating) { int min=1;int max=5; attributes[18]=apex=setatt(rating, min, max); } void project::sltex (int rating) { int min=1;int max=5; attributes[20]=ltex=setatt(rating, min, max); } void project::stool (int rating) { int min=1;int max=5; attributes[21]=tool=setatt(rating, min, max); } void project::ssite (int rating) { int min=1;int max=6; attributes[24]=site=setatt(rating, min, max); } void project::splex (int rating) { int min=1;int max=5; attributes[19]=plex=setatt(rating, min, max); } void project::sautomated_analysis (int rating) { int min=1;int max=6; attributes[0]=automated_analysis=setatt(rating, min, max); } void project::speer_reviews (int rating) { int min=1;int max=6; attributes[1]=peer_reviews=setatt(rating, min, max); } void project::sexecution_testing_and_tools (int rating) { int min=1;int max=6; attributes[2]=execution_testing_and_tools=setatt(rating, min, max); } void project::spCoqualRSlope (double val) {attributes[25]=pCoqualRSlope=val;} void project::snCoqualRSlope (double val) {attributes[26]=nCoqualRSlope=val;} void project::sdfrCoqualRSlope (double val) {attributes[27]=dfrCoqualRSlope=val;} void project::spCoqualDSlope (double val) {attributes[28]=pCoqualDSlope=val;} void project::snCoqualDSlope (double val) {attributes[29]=nCoqualDSlope=val;} void project::sdfrCoqualDSlope (double val) {attributes[30]=dfrCoqualDSlope=val;} void project::spCoqualCSlope (double val) {attributes[31]=pCoqualCSlope=val;} void project::snCoqualCSlope (double val) {attributes[32]=nCoqualCSlope=val;} void project::sdfrCoqualCSlope (double val) {attributes[33]=dfrCoqualCSlope=val;} void project::sSFCocomoSlope (double val) {attributes[34]=SFCocomoSlope=val;} void project::sposEMCocomoSlope (double val) {attributes[35]=posEMCocomoSlope=val;} void project::snegEMCocomoSlope (double val) {attributes[36]=negEMCocomoSlope=val;} void project::sA (double val) {attributes[37]=A=val;} void project::sB (double val) {attributes[38]=B=val;} void project::sKsloc (double val) {attributes[39]=ksloc=val;} void project::sC (double val) {attributes[40]=C=val;} void project::sD (double val) {attributes[41]=D=val;} char* project::displayAttName (int attnum) { switch (attnum) { case 0: return "automated_analysis"; break; case 1: return "peer_reviews"; break; case 2: return "execution_testing_and_tools"; break; case 3: return "prec"; break; case 4: return "flex"; break; case 5: return "resl"; break; case 6: return "team"; break; case 7: return "pmat"; break; case 8: return "time"; break; case 9: return "stor"; break; case 10: return "data"; break; case 11: return "pvol"; break; case 12: return "ruse"; break; case 13: return "rely"; break; case 14: return "docu"; break; case 15: return "acap"; break; case 16: return "pcap"; break; case 17: return "pcon"; break; case 18: return "apex"; break; case 19: return "plex"; break; case 20: return "ltex"; break; case 21: return "tool"; break; case 22: return "sced"; break; case 23: return "cplx"; break; case 24: return "site"; break; //Slopes, A, B and Ksloc case 25: return "pCoqualRSlope"; break; case 26: return "nCoqualRSlope"; break; case 27: return "dfrCoqualRSlope"; break; case 28: return "pCoqualDSlope"; break; case 29: return "nCoqualDSlope"; break; case 30: return "dfrCoqualDSlope"; break; case 31: return "pCoqualCSlope"; break; case 32: return "nCoqualCSlope"; break; case 33: return "dfrCoqualCSlope"; break; case 34: return "SFCocomoSlope"; break; case 35: return "posEMCocomoSlope"; break; case 36: return "negEMCocomoSlope"; break; case 37: return "A"; break; case 38: return "B"; break; case 39: return "Ksloc"; break; case 40: return "A"; break; case 41: return "B"; break; default: return ""; break; } } void project::displayAtt (int attnum) { switch (attnum) { case 0: dispautomated_analysis(); break; case 1: disppeer_reviews(); break; case 2: dispexecution_testing_and_tools(); break; case 3: dispprec(); break; case 4: dispflex(); break; case 5: dispresl(); break; case 6: dispteam(); break; case 7: disppmat(); break; case 8: disptime(); break; case 9: dispstor(); break; case 10: dispdata(); break; case 11: disppvol(); break; case 12: dispruse(); break; case 13: disprely(); break; case 14: dispdocu(); break; case 15: dispacap(); break; case 16: disppcap(); break; case 17: disppcon(); break; case 18: dispapex(); break; case 19: dispplex(); break; case 20: displtex(); break; case 21: disptool(); break; case 22: dispsced(); break; case 23: dispcplx(); break; case 24: dispsite(); break; //Slopes, A, B and Ksloc case 25: disppCoqualRSlope (); break; case 26: dispnCoqualRSlope ();break; case 27: dispdfrCoqualRSlope ();break; case 28: disppCoqualDSlope ();break; case 29: dispnCoqualDSlope ();break; case 30: dispdfrCoqualDSlope ();break; case 31: disppCoqualCSlope ();break; case 32: dispnCoqualCSlope ();break; case 33: dispdfrCoqualCSlope ();break; case 34: dispSFCocomoSlope ();break; case 35: dispposEMCocomoSlope ();break; case 36: dispnegEMCocomoSlope ();break; case 37: dispA (); break; case 38: dispB (); break; case 39: dispKsloc (); break; case 40: dispC (); break; case 41: dispD (); break; } } void project::dispprec () {cout << "prec: " << prec << endl;} void project::dispflex () {cout << "flex: " << flex << endl;} void project::dispresl () {cout << "resl: " << resl << endl;} void project::dispteam () {cout << "team: " << team << endl;} void project::disppmat () {cout << "pmat: " << pmat << endl;} void project::disptime () {cout << "time: " << time << endl;} void project::dispstor () {cout << "stor: " << stor << endl;} void project::dispdata () {cout << "data: " << data << endl;} void project::disppvol () {cout << "pvol: " << pvol << endl;} void project::dispruse () {cout << "ruse: " << ruse << endl;} void project::disprely () {cout << "rely: " << rely << endl;} void project::dispdocu () {cout << "docu: " << docu << endl;} void project::dispacap () {cout << "acap: " << acap << endl;} void project::disppcap () {cout << "pcap: " << pcap << endl;} void project::disppcon () {cout << "pcon: " << pcon << endl;} void project::dispapex () {cout << "apex: " << apex << endl;} void project::displtex () {cout << "ltex: " << ltex << endl;} void project::disptool () {cout << "tool: " << tool << endl;} void project::dispsced () {cout << "sced: " << sced << endl;} void project::dispcplx () {cout << "cplx: " << cplx << endl;} void project::dispsite () {cout << "site: " << site << endl;} void project::dispplex () {cout << "plex: " << plex << endl;} void project::dispautomated_analysis () {cout << "automated_analysis: " << automated_analysis << endl;} void project::disppeer_reviews () {cout << "peer_reviews: " << peer_reviews << endl;} void project::dispexecution_testing_and_tools () {cout << "execution_testing_and_tools: " << execution_testing_and_tools << endl;} void project::disppCoqualRSlope () {cout << "pCoqualRSlope: " << pCoqualRSlope << endl;} void project::dispnCoqualRSlope () {cout << "nCoqualRSlope: " << nCoqualRSlope << endl;} void project::dispdfrCoqualRSlope () {cout << "dfrCoqualRSlope: " << dfrCoqualRSlope << endl;} void project::disppCoqualDSlope () {cout << "pCoqualDSlope: " << pCoqualDSlope << endl;} void project::dispnCoqualDSlope () {cout << "nCoqualDSlope: " << nCoqualDSlope << endl;} void project::dispdfrCoqualDSlope () {cout << "dfrCoqualDSlope: " << dfrCoqualDSlope << endl;} void project::disppCoqualCSlope () {cout << "pCoqualCSlope: " << pCoqualCSlope << endl;} void project::dispnCoqualCSlope () {cout << "nCoqualCSlope: " << nCoqualCSlope << endl;} void project::dispdfrCoqualCSlope () {cout << "dfrCoqualCSlope: " << dfrCoqualCSlope << endl;} void project::dispSFCocomoSlope () {cout << "SFCocomoSlope: " << SFCocomoSlope << endl;} void project::dispposEMCocomoSlope () {cout << "posEMCocomoSlope: " << posEMCocomoSlope << endl;} void project::dispnegEMCocomoSlope () {cout << "negEMCocomoSlope: " << negEMCocomoSlope << endl;} void project::dispA () {cout << "A: " << A << endl;} void project::dispB () {cout << "B: " << B << endl;} void project::dispKsloc () {cout << "ksloc: " << ksloc << endl;} void project::dispC () {cout << "C: " << C << endl;} void project::dispD () {cout << "D: " << D << endl;} double project::effort() { float tprec,tflex,tresl,tteam,tpmat,ttime,tstor,tdata,tpvol,truse,trely,tcplx,tdocu,tsced,tacap,tpcap,tpcon,tapex,tltex,ttool,tsite,tplex ; setattnum(34,rd.randomGenerateDouble(attrange_Normm[0][34],attrange_Normm[1][34])); tprec=fprec(); setattnum(34,rd.randomGenerateDouble(attrange_Normm[0][34],attrange_Normm[1][34])); tflex=fflex(); setattnum(34,rd.randomGenerateDouble(attrange_Normm[0][34],attrange_Normm[1][34])); tresl=fresl(); setattnum(34,rd.randomGenerateDouble(attrange_Normm[0][34],attrange_Normm[1][34])); tteam=fteam(); setattnum(34,rd.randomGenerateDouble(attrange_Normm[0][34],attrange_Normm[1][34])); tpmat=fpmat(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); ttime=ftime(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); tstor=fstor(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); tdata=fdata(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); tpvol=fpvol(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); truse=fruse(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); trely=frely(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); tcplx=fcplx(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); tdocu=fdocu(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tsced=fsced(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tacap=facap(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tpcap=fpcap(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tpcon=fpcon(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tapex=fapex(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tltex=fltex(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); ttool=ftool(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tsite=fsite(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tplex=fplex(); return (A*pow(ksloc,(B+0.01*(tprec+tflex+tresl+tteam+tpmat))) *(ttime*tstor*tdata*tpvol*truse*trely*tdocu*tacap*tpcap* tpcon*tapex*tplex*tltex*ttool*tsced*tcplx*tsite)); } //Time to develop Model // double project::pmNs(){ setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); ttime=ftime(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); tstor=fstor(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); tdata=fdata(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); tpvol=fpvol(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); truse=fruse(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); trely=frely(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); tcplx=fcplx(); setattnum(35,rd.randomGenerateDouble(attrange_Normm[0][35],attrange_Normm[1][35])); tdocu=fdocu(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tsced=fsced(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tacap=facap(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tpcap=fpcap(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tpcon=fpcon(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tapex=fapex(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tltex=fltex(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); ttool=ftool(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tsite=fsite(); setattnum(36,rd.randomGenerateDouble(attrange_Normm[0][36],attrange_Normm[1][36])); tplex=fplex(); return (A+pow(ksloc,(B+0.01*(tprec+tflex+tresl+tteam+tpmat))) *(ttime*tstor*tdata*tpvol*truse*trely*tdocu*tacap*tpcap* tpcon*tapex*tplex*tltex*ttool*tcplx*tsite)); } double project::scedpercent(){ switch(sced){ case 1: return(75); case 2: return(85); case 3: return(100); case 4: return(130); case 5: return(160); default : return (0); } } double project::months(){ return ((C*pow(pmNs(),(D+0.2*(B+0.01*(tprec+tflex+tresl+tteam+tpmat)))))*(scedpercent()/100)); } //Threat model //Threat model tables double project::t1[5][5] = {{0,0,0,1,2},{0,0,0,0,1}}; double project::t2[5][6] = {{0,0,0,1,2,4},{0,0,0,0,1,2},{0,0,0,0,0,1}}; double project::t3[5][5] = {{2,1},{1}}; double project::t4[5][5] = {{4,2,1},{2,1},{1}}; double project::t5[5][5] = {{0},{0},{1},{2,1},{4,2,1}}; double project::t6[6][5] = {{0},{0},{0},{1},{2,1},{4,2,1}}; double project::t7[5][5] = {{0},{0},{0},{1},{2,1}}; double project::t8[6][5] = {{0},{0},{0},{0},{1},{2,1}}; double project::threat() { return (double)(sched_threat()+prod_threat()+pers_threat()+proc_threat() +plat_threat()+reuse_threat())/3.73; } double project::sched_threat() { return (t1[sced-1][rely-1]*fsced()*frely()+t2[sced-1][time-1]*fsced()*ftime()+t1[sced-1][pvol-1]*fsced()*fpvol()+t3[sced-1][tool-1]*fsced()*ftool()+t4[sced-1][acap-1]*fsced()*facap() +t4[sced-1][apex-1]*fsced()*fapex()+t4[sced-1][pcap-1]*fsced()*fpcap()+t4[sced-1][plex-1]*fsced()*fplex()+t3[sced-1][ltex-1]*fsced()*fltex()+t3[sced-1][pmat-1]*fsced()*fpmat()); } double project::prod_threat() { return (t5[rely-1][acap-1]*frely()*facap()+t5[rely-1][pcap-1]*frely()*fpcap()+t6[cplx-1][acap-1]*fcplx()*facap()+t6[cplx-1][pcap-1]*fcplx()*fpcap()+t6[cplx-1][tool-1]*fcplx()*ftool() +t5[rely-1][pmat-1]*frely()*fpmat()+t2[sced-1][cplx-1]*fsced()*fcplx()+t1[sced-1][rely-1]*fsced()*frely()+t2[sced-1][time-1]*fsced()*ftime()+t6[ruse-1][apex-1]*fruse()*fapex() +t6[ruse-1][ltex-1])*fruse()*fltex(); } double project::pers_threat() { return (t3[pmat-1][acap-1]*fpmat()*facap()+t6[stor-1][acap-1]*fstor()*facap()+t6[time-1][acap-1]*ftime()*facap()+t3[tool-1][acap-1]*ftool()*facap()+t3[tool-1][pcap-1]*ftool()*fpcap() +t6[ruse-1][apex-1]*fruse()*fapex()+t6[ruse-1][ltex-1]*fruse()*fltex()+t3[pmat-1][pcap-1]*fpmat()*fpcap()+t6[stor-1][pcap-1]*fstor()*fpcap()+t6[time-1][pcap-1]*ftime()*fpcap() +t4[ltex-1][pcap-1]*fltex()*fpcap()+t7[pvol-1][plex-1]*fpvol()*fplex()+t4[sced-1][acap-1]*fsced()*facap()+t4[sced-1][apex-1]*fsced()*fapex()+t4[sced-1][pcap-1]*fsced()*fpcap() +t4[sced-1][plex-1]*fsced()*fplex()+t3[sced-1][ltex-1]*fsced()*fltex()+t5[rely-1][acap-1]*frely()*facap()+t5[rely-1][pcap-1]*frely()*fpcap()+t6[cplx-1][acap-1]*fcplx()*facap() +t6[cplx-1][pcap-1]*fcplx()*fpcap()+t3[team-1][apex-1]*fteam()*fapex()); } double project::proc_threat() { return (t3[tool-1][pmat-1]*ftool()*fpmat()+t8[time-1][tool-1]*ftime()*ftool()+t3[tool-1][pmat-1]*ftool()*fpmat()+t3[team-1][apex-1]*fteam()*fapex()+t3[team-1][sced-1]*fteam()*fsced() +t3[team-1][site-1]*fteam()*fsite()+t3[sced-1][tool-1]*fsced()*ftool()+t3[sced-1][pmat-1]*fsced()*fpmat()+t6[cplx-1][tool-1]*fcplx()*ftool()+t3[pmat-1][acap-1]*fpmat()*facap() +t3[tool-1][acap-1]*ftool()*facap()+t3[tool-1][pcap-1]*ftool()*fpcap()+t3[pmat-1][pcap-1]*fpmat()*fpcap()); } double project::plat_threat() { return (t2[sced-1][time-1]*fsced()*ftime()+t1[sced-1][pvol-1]*fsced()*fpvol()+t6[stor-1][acap-1]*fstor()*facap()+t6[time-1][acap-1]*ftime()*facap()+t6[stor-1][pcap-1]*fstor()*fpcap() +t7[pvol-1][plex-1]*fpvol()*fplex()+t8[time-1][tool-1]*ftime()*ftool()); } double project::reuse_threat() { return (t6[ruse-1][apex-1]*fruse()*fapex()+t6[ruse-1][ltex-1]*fruse()*fltex()); } double project::posCoqualR (int rating) {return (double)(rating-3)*pCoqualRSlope + 1;} double project::negCoqualR (int rating) {return (double)(rating-3)*nCoqualRSlope + 1;} double project::dfrCoqualR (int rating) {return (double)(rating-1)*dfrCoqualRSlope;} double project::posCoqualD (int rating) {return (double)(rating-3)*pCoqualDSlope + 1;} double project::negCoqualD (int rating) {return (double)(rating-3)*nCoqualDSlope + 1;} double project::dfrCoqualD (int rating) {return (double)(rating-1)*dfrCoqualDSlope;} double project::posCoqualC (int rating) {return (double)(rating-3)*pCoqualCSlope + 1;} double project::negCoqualC (int rating) {return (double)(rating-3)*nCoqualCSlope + 1;} double project::dfrCoqualC (int rating) {return (double)(rating-1)*dfrCoqualCSlope;} double project::flexR() {return 1.0;} double project::pcapR() {return 1.0;} double project::ruseR() {return posCoqualR(ruse);} double project::cplxR() {return posCoqualR(cplx);} double project::timeR() {return posCoqualR(time);} double project::storR() {return posCoqualR(stor);} double project::pvolR() {return posCoqualR(pvol);} double project::dataR() {return posCoqualR(data);} double project::acapR() {return negCoqualR(acap);} double project::pconR() {return negCoqualR(pcon);} double project::apexR() {return negCoqualR(apex);} double project::plexR() {return negCoqualR(plex);} double project::ltexR() {return negCoqualR(ltex);} double project::toolR() {return negCoqualR(tool);} double project::siteR() {return negCoqualR(site);} double project::scedR() {return negCoqualR(sced);} double project::relyR() {return negCoqualR(rely);} double project::docuR() {return negCoqualR(docu);} double project::reslR() {return negCoqualR(resl);} double project::teamR() {return negCoqualR(team);} double project::pmatR() {return negCoqualR(pmat);} double project::precR() {return negCoqualR(prec);} double project::flexD() {return 1.0;} double project::ruseD() {return posCoqualD(ruse);} double project::cplxD() {return posCoqualD(cplx);} double project::timeD() {return posCoqualD(time);} double project::storD() {return posCoqualD(stor);} double project::pvolD() {return posCoqualD(pvol);} double project::dataD() {return posCoqualD(data);} double project::acapD() {return negCoqualD(acap);} double project::pconD() {return negCoqualD(pcon);} double project::apexD() {return negCoqualD(apex);} double project::plexD() {return negCoqualD(plex);} double project::ltexD() {return negCoqualD(ltex);} double project::toolD() {return negCoqualD(tool);} double project::siteD() {return negCoqualD(site);} double project::scedD() {return negCoqualD(sced);} double project::relyD() {return negCoqualD(rely);} double project::docuD() {return negCoqualD(docu);} double project::reslD() {return negCoqualD(resl);} double project::teamD() {return negCoqualD(team);} double project::pmatD() {return negCoqualD(pmat);} double project::precD() {return negCoqualD(prec);} double project::pcapD() {return negCoqualD(pcap);} double project::flexC() {return 1.0;} double project::ruseC() {return posCoqualC(ruse);} double project::cplxC() {return posCoqualC(cplx);} double project::timeC() {return posCoqualC(time);} double project::storC() {return posCoqualC(stor);} double project::pvolC() {return posCoqualC(pvol);} double project::dataC() {return posCoqualC(data);} double project::acapC() {return negCoqualC(acap);} double project::pconC() {return negCoqualC(pcon);} double project::apexC() {return negCoqualC(apex);} double project::plexC() {return negCoqualC(plex);} double project::ltexC() {return negCoqualC(ltex);} double project::toolC() {return negCoqualC(tool);} double project::siteC() {return negCoqualC(site);} double project::scedC() {return negCoqualC(sced);} double project::relyC() {return negCoqualC(rely);} double project::docuC() {return negCoqualC(docu);} double project::reslC() {return negCoqualC(resl);} double project::teamC() {return negCoqualC(team);} double project::pmatC() {return negCoqualC(pmat);} double project::precC() {return negCoqualC(prec);} double project::pcapC() {return negCoqualC(pcap);} double project::automated_analysisR() { // switch (automated_analysis) { // case 1: return 0.0; break; // case 2: return 0.0; break; // case 3: return 0.1; break; // case 4: return 0.27; break; // case 5: return 0.34; break; // case 6: return 0.4; break; // default: std::cout << "automated_analysis out of range\n"; return 0.0; break; // } return dfrCoqualR(automated_analysis); } double project::peer_reviewsR() { // switch (peer_reviews) { // case 1: return 0.0; break; // case 2: return 0.25; break; // case 3: return 0.4; break; // case 4: return 0.5; break; // case 5: return 0.58; break; // case 6: return 0.7; break; // default: std::cout << "peer_reviews out of range\n"; return 0.0; break; // } return dfrCoqualR(peer_reviews); } double project::execution_testing_and_toolsR() { return dfrCoqualR(execution_testing_and_tools); } double project::automated_analysisD() { return dfrCoqualD(automated_analysis); } double project::peer_reviewsD() { return dfrCoqualD(peer_reviews); } double project::execution_testing_and_toolsD() { return dfrCoqualD(execution_testing_and_tools); } double project::automated_analysisC() { return dfrCoqualC(automated_analysis); } double project::peer_reviewsC() { return dfrCoqualC(peer_reviews); } double project::execution_testing_and_toolsC() { return dfrCoqualC(execution_testing_and_tools); } double project::defectsIntroR() { return flexR()*pcapR()*ruseR()*cplxR()*timeR()*storR()*pvolR()*dataR() *acapR()*pconR()*apexR()*plexR()*ltexR()*toolR()*siteR()*scedR()*relyR() *docuR()*reslR()*teamR()*pmatR()*precR(); } double project::defectsIntroD() { return flexD()*pcapD()*ruseD()*cplxD()*timeD()*storD()*pvolD()*dataD() *acapD()*pconD()*apexD()*plexD()*ltexD()*toolD()*siteD()*scedD()*relyD() *docuD()*reslD()*teamD()*pmatD()*precD(); } double project::defectsIntroC() { return flexC()*pcapC()*ruseC()*cplxC()*timeC()*storC()*pvolC()*dataC() *acapC()*pconC()*apexC()*plexC()*ltexC()*toolC()*siteC()*scedC()*relyC() *docuC()*reslC()*teamC()*pmatC()*precC(); } double project::defectsRemR() { return (1-automated_analysisR())*(1-peer_reviewsR())*(1-execution_testing_and_toolsR()); } double project::defectsRemD() { return (1-automated_analysisD())*(1-peer_reviewsD())*(1-execution_testing_and_toolsD()); } double project::defectsRemC() { return (1-automated_analysisC())*(1-peer_reviewsC())*(1-execution_testing_and_toolsC()); } double project::defects() { return ksloc*(10*defectsIntroR()*defectsRemR() +20*defectsIntroD()*defectsRemD() +30*defectsIntroC()*defectsRemC()); } double project::threatMutate() { randomNum rdm; double RNum; double tmp1 [5][5]; double tmp2 [5][6]; double tmp3 [5][5]; double tmp4 [5][5]; double tmp5 [5][5]; double tmp6 [6][5]; double tmp7 [5][5]; double tmp8 [6][5]; bool mutate[8] = {false,false,false,false,false,false,false,false}; for (int i=0;i<8;i++) { RNum = rdm.randomGenerateDouble(0,1); if (RNum > 0.5) { mutate[i]=true; } } if (mutate[0]) { RNum = rdm.randomGenerateDouble(0.5,1.5); for (int i=0;i<5;i++) { for (int j=0;j<5;j++) { tmp1[i][j]=t1[i][j]; t1[i][j]*=RNum; } } } if (mutate[1]) { RNum = rdm.randomGenerateDouble(0.5,1); for (int i=0;i<5;i++) { for (int j=0;j<6;j++) { tmp2[i][j]=t2[i][j]; t2[i][j]*=RNum; } } } if (mutate[2]) { RNum = rdm.randomGenerateDouble(0.5,1.5); for (int i=0;i<5;i++) { for (int j=0;j<5;j++) { tmp3[i][j]=t3[i][j]; t3[i][j]*=RNum; } } } if (mutate[3]) { RNum = rdm.randomGenerateDouble(0.5,1); for (int i=0;i<5;i++) { for (int j=0;j<5;j++) { tmp4[i][j]=t4[i][j]; t4[i][j]*=RNum; } } } if (mutate[4]) { RNum = rdm.randomGenerateDouble(0.5,1); for (int i=0;i<5;i++) { for (int j=0;j<5;j++) { tmp5[i][j]=t5[i][j]; t5[i][j]*=RNum; } } } if (mutate[5]) { RNum = rdm.randomGenerateDouble(0.5,1); for (int i=0;i<6;i++) { for (int j=0;j<5;j++) { tmp6[i][j]=t6[i][j]; t6[i][j]*=RNum; } } } if (mutate[6]) { RNum = rdm.randomGenerateDouble(0.5,1.5); for (int i=0;i<5;i++) { for (int j=0;j<5;j++) { tmp7[i][j]=t7[i][j]; t7[i][j]*=RNum; } } } if (mutate[7]) { RNum = rdm.randomGenerateDouble(0.5,1.5); for (int i=0;i<6;i++) { for (int j=0;j<5;j++) { tmp8[i][j]=t8[i][j]; t8[i][j]*=RNum; } } } double TH = threat(); if (mutate[0]) { for (int i=0;i<5;i++) { for (int j=0;j<5;j++) { t1[i][j]=tmp1[i][j]; } } } if (mutate[1]) { for (int i=0;i<5;i++) { for (int j=0;j<6;j++) { t2[i][j]=tmp2[i][j]; } } } if (mutate[2]) { for (int i=0;i<5;i++) { for (int j=0;j<5;j++) { t3[i][j]=tmp3[i][j]; } } } if (mutate[3]) { for (int i=0;i<5;i++) { for (int j=0;j<5;j++) { t4[i][j]=tmp4[i][j]; } } } if (mutate[4]) { for (int i=0;i<5;i++) { for (int j=0;j<5;j++) { t5[i][j]=tmp5[i][j]; } } } if (mutate[5]) { for (int i=0;i<6;i++) { for (int j=0;j<5;j++) { t6[i][j]=tmp6[i][j]; } } } if (mutate[6]) { for (int i=0;i<5;i++) { for (int j=0;j<5;j++) { t7[i][j]=tmp7[i][j]; } } } if (mutate[7]) { for (int i=0;i<6;i++) { for (int j=0;j<5;j++) { t8[i][j]=tmp8[i][j]; } } } return TH; }