GAMS Rev 133 Linux/Intel 09/25/02 11:30:54 Page 1 Large Random Min Cost Flow example 2 4 option limrow=0, limcol=0, solprint=off; 5 6 set 7 nodes /1*5000/ 8 sources(nodes) 9 sinks(nodes); 10 11 alias (nodes,i,j,k); 12 13 set arcs(i,j); 14 parameter cost(i,j), supply(nodes), randomVector(nodes); 15 16 variables f(i,j), totalcost; 17 positive variable f; 18 19 scalar counter; 20 21 * first define a random set of arcs of a given density. 22 * (If density is too low, the problem may not have a solution - 23 * there may not be a path from sources to sinks.) 24 option seed=25671; 25 arcs(i,j) = yes$(uniform(0,1) < .025); 26 * no self-directed arcs 27 arcs(i,i) = no; 28 29 * now define costs on these arcs 30 cost(i,j) = uniform(0,50) $ arcs(i,j); 31 32 * determine eligible source nodes (those with outflowing arcs) 33 * and sinks (those with inflowing arcs); 34 sources(nodes) = no; sinks(nodes) = no; 35 loop(arcs(i,j), 36 sources(i) = yes; 37 sinks(j) = yes; 38 ); 39 40 supply(nodes) = 0; 41 * pick two sources to have positive supplies 42 counter = 0; 43 loop(nodes$(sources(nodes) and counter<2), 44 supply(nodes) = 10; 45 counter = counter+1; 46 ); 47 * and five sinks to have balancing negative supplies 48 counter = 0; 49 loop(nodes$(sinks(nodes) and counter<5 and supply(nodes)=0), 50 supply(nodes) = -4; 51 counter = counter+1; 52 ); 53 54 * display sources, sinks, supply; 55 56 equations balance(i), objective; GAMS Rev 133 Linux/Intel 09/25/02 11:30:54 Page 2 Large Random Min Cost Flow example 57 58 balance(i).. 59 sum(arcs(i,k), f(arcs)) - sum(arcs(j,i), f(arcs)) =e= supply(i); 60 objective.. 61 totalcost =e= sum(arcs, cost(arcs)*f(arcs)); 62 63 model mcf/balance, objective/; 64 65 * choose the cplex lp solver 66 option lp=cplex; 67 68 * tell GAMS to look for an options file cplex.opt 69 mcf.optfile = 1; 70 71 solve mcf using lp minimizing totalcost; 72 73 option f:0:0:2; display f.l; 74 75 76 77 COMPILATION TIME = 0.010 SECONDS 0.8 Mb LNX207-133 GAMS Rev 133 Linux/Intel 09/25/02 11:30:54 Page 3 Large Random Min Cost Flow example Model Statistics SOLVE mcf Using LP From line 71 MODEL STATISTICS BLOCKS OF EQUATIONS 2 SINGLE EQUATIONS 5001 BLOCKS OF VARIABLES 2 SINGLE VARIABLES 625004 NON ZERO ELEMENTS 1875010 GENERATION TIME = 51.660 SECONDS 117.2 Mb LNX207-133 EXECUTION TIME = 93.850 SECONDS 117.2 Mb LNX207-133 GAMS Rev 133 Linux/Intel 09/25/02 11:30:54 Page 4 Large Random Min Cost Flow example Solution Report SOLVE mcf Using LP From line 71 S O L V E S U M M A R Y MODEL mcf OBJECTIVE totalcost TYPE LP DIRECTION MINIMIZE SOLVER CPLEX FROM LINE 71 **** SOLVER STATUS 1 NORMAL COMPLETION **** MODEL STATUS 1 OPTIMAL **** OBJECTIVE VALUE 78.7738 RESOURCE USAGE, LIMIT 71.830 1000.000 ITERATION COUNT, LIMIT 49201 10000 GAMS/Cplex Jun 14, 2002 LNX.CP.CL 20.7 022.024.040.LNX For Cplex 7.5 Using environment variable ILOG_LICENSE_FILE to look for a Cplex license. Cplex 7.5.0, GAMS Link 22 User supplied options: lpmethod 1 itlim 1000000 Optimal solution found. Objective : 78.773790 **** REPORT SUMMARY : 0 NONOPT 0 INFEASIBLE 0 UNBOUNDED GAMS Rev 133 Linux/Intel 09/25/02 11:30:54 Page 5 Large Random Min Cost Flow example E x e c u t i o n ---- 73 VARIABLE f.L 1 .343 6, 1 .540 4 2 .593 10, 64 .1152 6 323 .3945 2, 324 .323 2 343 .64 6, 540 .896 4 593 .4950 10, 635 .4751 4 896 .635 4, 957 .1303 4 1076.3087 2, 1125.4 2 1152.2346 4, 1152.3755 2 1303.3368 4, 1649.6 4 1738.2779 4, 1746.957 4 1746.3683 4, 1957.1125 2 2314.2997 4, 2346.4181 4 2779.3536 4, 2997.7 4 3087.324 2, 3231.4128 4 3368.3 4, 3536.2314 4 3683.1738 4, 3755.4900 2 3945.4653 2, 4066.4 2 4128.5 4, 4181.3231 4 4346.1649 4, 4653.1957 2 4751.4346 4, 4900.4066 2 4950.1076 2, 4950.1746 8 EXECUTION TIME = 0.640 SECONDS 72.1 Mb LNX207-133 USER: Computer Sciences Dept. G010628:1627AS-LNX University of Wisconsin-Madison DC2621 **** FILE SUMMARY INPUT /afs/cs.wisc.edu/u/s/w/swright/public/html/635/examples/largenet2.gms OUTPUT /afs/cs.wisc.edu/u/s/w/swright/public/html/635/examples/largenet2.lst