function readRisks(infile, modelRisks) { while ((getline < infile)) { if ($1 ~ /^[ /t]*#/) { continue } #skip comments if ($0 ~ /^[ /t]*$/) { continue } #skip blank lines setRiskRanges(modelRisks, $1, $2, $3, $4, $6, $7, $8) } close(infile) } #Given a "worst" attribute/value pair weight, interpolate the weight in #the given direction with each step away from the "worst" causing a drop #of weight/(2^distance-from-worst) #eg: # sced 1, cplx 6 has a weight of 4 and decreases in the positive direction # for sced and the negative direction for cplx. # therefore sced 2, cplx 6 has a weight of 2 as it is 1 away from the s1c6 # and 4 / (2^(0 + 1) = 2. For diagonal movement (say sced 2, cplx 5) the distance # is the sum of both the sced and cplx displacements rather than the square # root of this distance, so sced 2, cplx 5 has a weight of 1 as # 4 / (2^(1+1) = 1 # #ex: sced1, cplx6 -> 4 + - # cplx # 1 2 3 4 5 6 #s +----------- #c 1| 1 2 4 #e 2| 1 2 #d 3| 1 function setRiskRanges(modelRisks, attr1, val1, attr2, val2, weight, dir1, dir2, xoffset,yoffset,x,y,falloffDistance) { falloffDistance = ( log(weight) / log(2) ) + 1 xoffset = 0 yoffset = 0 for (x = 0; x <= falloffDistance; x++) { for(y = 0; y < falloffDistance - x; y++) { modelRisks[attr1,xoffset+val1] = \ append(attr2 "@" yoffset+val2 "=" weight/(2^(y+x)),\ modelRisks[attr1,xoffset+val1]) modelRisks[attr2,yoffset+val2] = \ append(attr1 "@" xoffset+val1 "=" weight/(2^(y+x)),\ modelRisks[attr2,yoffset+val2]) if (dir2 == "+") yoffset += 1 else yoffset -= 1 } yoffset = 0 if (dir1 == "+") xoffset += 1 else xoffset -= 1 } }