$ondollar title Tinyco Cash Flow (GNF) Example 10.7 of Rardin (1998) $offsymxref offsymlist offuelxref offuellist offupper option limrow = 0, limcol = 0; set i "nodes" /1*10/; alias (i,j); alias (i,k); set arc(i,j) "arc set of the digraph" /1.2, 2.1, 1.6, 6.1, 2.3, 3.2, 2.7, 7.2, 3.4, 4.3, 3.8, 8.3, 4.5, 5.4, 4.9, 9.4, 6.7, 7.8, 8.9, 9.10, 10.5/; parameter a(i,j) "gain/loss multiplier on arc (i,j)" /1.2 1.005, 2.1 .9901, 1.6 .998, 6.1 .998, 2.3 1.005, 3.2 .9901, 2.7 .998, 7.2 .998, 3.4 1.005, 4.3 .9901, 3.8 .998, 8.3 .998, 4.5 1.005, 5.4 .9901, 4.9 .998, 9.4 .998, 6.7 1.009, 7.8 1.009, 8.9 1.009, 9.10 1.009, 10.5 .998/; parameter u(i,j) "capacity on arc (i,j)" /2.1 100, 3.2 100, 4.3 100, 5.4 100/; parameter b(k) "net demand at node k" /1 -100, 2 300, 3 -500, 4 -10, 5 30, 6 -200/; free variable retn "ending return"; positive variables x(i,j) "flow on arc (i,j)"; x.up(i,j)$(u(i,j) gt 0) = u(i,j); equations bal(k) "balance of flow at node k ne 5", bal5 "balance of flow at node 5"; bal(k)$(ord(k) ne 5).. sum(i$arc(i,k), a(i,k)*x(i,k)) - sum(j$arc(k,j), x(k,j)) =e= b(k); bal5.. sum(i$arc(i,'5'), a(i,'5')*x(i,'5')) - sum(j$arc('5',j), x('5',j)) - retn =e= b('5'); model tinyco /all/; solve tinyco using lp maximizing retn;