def write_weights(id, otherid, isouter, isotherouter): if isotherouter and isouter: write_dedgew(id, otherid, outerweight) elif isotherouter and not isouter: write_dedgew(id, otherid, transitionweight) elif not isotherouter and isouter: write_dedgew(id, otherid, transitionweight) elif not isotherouter and not isouter: write_dedgew(id, otherid, innerweight) else: print "PROBLEM"
def write_weights(id, row, col, idother, rowother, colother): if inside_barrier(row, col): if inside_barrier(rowother, colother): write_dedgew(id, idother, 0.0) elif inside_heat(rowother, colother): write_dedgew(id, idother, 0.0) else: write_dedgew(id, idother, 0.0) elif inside_heat(row, col): if inside_barrier(rowother, colother): write_dedgew(id, idother, 0.0) elif inside_heat(rowother, colother): write_dedgew(id, idother, heatsideweight) else: write_dedgew(id, idother, weightother) else: if inside_barrier(rowother, colother): write_dedgew(id, idother, 0.0) elif inside_heat(rowother, colother): write_dedgew(id, idother, weightother) else: write_dedgew(id, idother, weightother)
else: drop_type = 'linear' # if drop is linear, we can calculate the constant and make it 'constant' if drop_type == 'linear': drop_constant = 1.0 / float(nodes) drop_type = 'constant' previous = 0 if drop_type == 'constant': weight = 1.0 for i in range(1, nodes): new = i # from previous to new write_dedgew(previous, new, weight) weight = weight - drop_constant if weight < 0.0: weight = 0.0 # keep it above 0.0 previous = new elif drop_type == 'quadratic': base = float(nodes) * float(nodes) # expression: x^2/base for i in range(1, nodes): new = i # we must compute the inverse node number # if 0 then it must be N # if 1 then it must be N - 1 inverse = nodes - previous weight = float(inverse * inverse) / base write_dedgew(previous, new, weight)