#!/usr/local/bin/maple # -*- maplev -*- # Nathaniel Shar # HW 27 # Experimental Mathematics # It is okay to link to this assignment on the course webpage. ############# # Problem 1 # ############# with(Optimization): Waldorp := proc(J, R, DelayJ, u, S, Sspec) local y, A, H, i, j, r, s, solns: A := [seq([seq(`if`(incident(j,r), 1, 0), r=R)], j=J)]: H := [seq([seq(`if`(s[1]=r[1] and s[2]=r[-1], 1, 0), r=R)], s=S)]: print(nops(J)): solns := Minimize(add(int(DelayJ[j], u=0..y[j]), j=1..nops(J)), {seq(add(H[i][j]*x[j], j=1..nops(R))=Sspec[i], i=1..nops(Sspec)), seq(add(A[i][j]*x[j], j=1..nops(R))=y[i], i=1..nops(J)), seq(x[j] >= 0, j=1..nops(R))} ): return subs(solns[2], [seq(x[j], j=1..nops(R))]), #subs(solns[2], [seq(subs(u=y[j], DelayJ[j]), j=1..nops(J))]), subs(solns[2], [seq(add(A[j][i]*subs(u=y[j], DelayJ[j]), j=1..nops(J)), i=1..nops(R))]): end: incident := proc(j, r) local i: for i from 1 to nops(r)-1 do: if j[1] = r[i] and j[2] = r[i+1] then: return true: fi: od: return false: end: ############# # Problem 2 # ############# # Waldorp([[1,2],[2,4],[1,3],[3,4]], # [[1,2,4],[1,3,4]],[10*u,u+50,u+50,10*u],u,[[1,4]],[6]); # gives [3,3], [83,83] # and # Waldorp([[1,2],[2,4],[1,3],[3,4],[2,3]], # [[1,2,4],[1,3,4],[1,2,3,4]],[10*u,u+50,u+50,10*u,u+10],u,[[1,4]],[6]); # gives [2,2,2], [92,92,92]. # This corresponds to the claims in the article.