################################################################## # Basic model parameters filename = "patch.txt" xmax = 30 xrep = 4 tmax = 20 m = [.01, .05, .02] p = [.2, .5, 0] y = [2, 4, 0] cost = 1 c3 = 4 acap = 60.0 x0 = 0.25*xmax xint = 2 ################################################################## # Utility Functions def printarr(f): """ Print out the f array, used when testing """ for x in range(xmax+1): for t in range(tmax+1): print "%4.1f" % (f[x,t]), print def listmax(lst): """ Find the largest element in the list lst. Return a pair containing its position and value. """ maxval=lst[0] maxpos=0 for i in range(len(lst)): if lst[i]>maxval: maxpos=i maxval=lst[i] return (maxpos,maxval) def chop(x, min, max): """ Return x, pushed into the range [min...max] """ if min<=x and x<=max: return x elif x