examples/netgen.c
changeset 1 c445c931472f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/examples/netgen.c	Mon Dec 06 13:09:21 2010 +0100
     1.3 @@ -0,0 +1,141 @@
     1.4 +/* netgen.c */
     1.5 +
     1.6 +/* This main program generates 50 original NETGEN instances of the
     1.7 +   minimum cost flow problem and writes them in DIMACS format to the
     1.8 +   current directory. */
     1.9 +
    1.10 +#include <stddef.h>
    1.11 +#include <stdio.h>
    1.12 +#include <stdlib.h>
    1.13 +#include <glpk.h>
    1.14 +
    1.15 +static int parm[50][15] =
    1.16 +{    {13502460, 101,
    1.17 +      5000, 2500, 2500, 25000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
    1.18 +   },{4281922, 102,
    1.19 +      5000, 2500, 2500, 25000, 1, 100, 2500000, 0, 0, 0, 100, 1, 1000,
    1.20 +   },{44820113, 103,
    1.21 +      5000, 2500, 2500, 25000, 1, 100, 6250000, 0, 0, 0, 100, 1, 1000,
    1.22 +   },{13450451, 104,
    1.23 +      5000, 2500, 2500, 25000, -100, -1, 250000, 0, 0, 0, 100, 1, 1000,
    1.24 +   },{14719436, 105,
    1.25 +      5000, 2500, 2500, 25000, 101, 200, 250000, 0, 0, 0, 100, 1, 1000,
    1.26 +   },{17365786, 106,
    1.27 +      5000, 2500, 2500, 12500, 1, 100, 125000, 0, 0, 0, 100, 1, 1000,
    1.28 +   },{19540113, 107,
    1.29 +      5000, 2500, 2500, 37500, 1, 100, 375000, 0, 0, 0, 100, 1, 1000,
    1.30 +   },{19560313, 108,
    1.31 +      5000, 2500, 2500, 50000, 1, 100, 500000, 0, 0, 0, 100, 1, 1000,
    1.32 +   },{2403509, 109,
    1.33 +      5000, 2500, 2500, 75000, 1, 100, 750000, 0, 0, 0, 100, 1, 1000,
    1.34 +   },{92480414, 110,
    1.35 +      5000, 2500, 2500, 12500, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
    1.36 +   },{4230140, 111,
    1.37 +      5000, 2500, 2500, 37500, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
    1.38 +   },{10032490, 112,
    1.39 +      5000, 2500, 2500, 50000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
    1.40 +   },{17307474, 113,
    1.41 +      5000, 2500, 2500, 75000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
    1.42 +   },{4925114, 114,
    1.43 +      5000, 500, 4500, 25000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
    1.44 +   },{19842704, 115,
    1.45 +      5000, 1500, 3500, 25000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
    1.46 +   },{88392060, 116,
    1.47 +      5000, 2500, 2500, 25000, 1, 100, 250000, 0, 0, 0, 0, 1, 1000,
    1.48 +   },{12904407, 117,
    1.49 +      5000, 2500, 2500, 12500, 1, 100, 125000, 0, 0, 0, 0, 1, 1000,
    1.50 +   },{11811811, 118,
    1.51 +      5000, 2500, 2500, 37500, 1, 100, 375000, 0, 0, 0, 0, 1, 1000,
    1.52 +   },{90023593, 119,
    1.53 +      5000, 2500, 2500, 50000, 1, 100, 500000, 0, 0, 0, 0, 1, 1000,
    1.54 +   },{93028922, 120,
    1.55 +      5000, 2500, 2500, 75000, 1, 100, 750000, 0, 0, 0, 0, 1, 1000,
    1.56 +   },{72707401, 121,
    1.57 +      5000, 50, 50, 25000, 1, 100, 250000, 50, 50, 0, 100, 1, 1000,
    1.58 +   },{93040771, 122,
    1.59 +      5000, 250, 250, 25000, 1, 100, 250000, 250, 250, 0, 100, 1, 1000,
    1.60 +   },{70220611, 123,
    1.61 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
    1.62 +   },{52774811, 124,
    1.63 +      5000, 1000, 1000, 25000, 1, 100, 250000, 1000, 1000, 0, 100, 1,
    1.64 +      1000,
    1.65 +   },{22492311, 125,
    1.66 +      5000, 1500, 1500, 25000, 1, 100, 250000, 1500, 1500, 0, 100, 1,
    1.67 +      1000,
    1.68 +   },{35269337, 126,
    1.69 +      5000, 500, 500, 12500, 1, 100, 125000, 500, 500, 0, 100, 1, 1000,
    1.70 +   },{30140502, 127,
    1.71 +      5000, 500, 500, 37500, 1, 100, 375000, 500, 500, 0, 100, 1, 1000,
    1.72 +   },{49205455, 128,
    1.73 +      5000, 500, 500, 50000, 1, 100, 500000, 500, 500, 0, 100, 1, 1000,
    1.74 +   },{42958341, 129,
    1.75 +      5000, 500, 500, 75000, 1, 100, 750000, 500, 500, 0, 100, 1, 1000,
    1.76 +   },{25440925, 130,
    1.77 +      5000, 500, 500, 12500, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
    1.78 +   },{75294924, 131,
    1.79 +      5000, 500, 500, 37500, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
    1.80 +   },{4463965, 132,
    1.81 +      5000, 500, 500, 50000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
    1.82 +   },{13390427, 133,
    1.83 +      5000, 500, 500, 75000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
    1.84 +   },{95250971, 134,
    1.85 +      1000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
    1.86 +   },{54830522, 135,
    1.87 +      2500, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
    1.88 +   },{520593, 136,
    1.89 +      7500, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
    1.90 +   },{52900925, 137,
    1.91 +      10000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
    1.92 +   },{22603395, 138,
    1.93 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 50,
    1.94 +   },{55253099, 139,
    1.95 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 250,
    1.96 +   },{75357001, 140,
    1.97 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 500,
    1.98 +   },{10072459, 141,
    1.99 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 2500,
   1.100 +   },{55728492, 142,
   1.101 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 5000,
   1.102 +   },{593043, 143,
   1.103 +      5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 0, 1, 1000,
   1.104 +   },{94236572, 144,
   1.105 +      5000, 500, 500, 25000, 1, 10, 250000, 500, 500, 0, 100, 1, 1000,
   1.106 +   },{94882955, 145,
   1.107 +      5000, 500, 500, 25000, 1, 1000, 250000, 500, 500, 0, 100, 1, 1000,
   1.108 +   },{48489922, 146,
   1.109 +      5000, 500, 500, 25000, 1, 10000, 250000, 500, 500, 0, 100, 1,
   1.110 +      1000,
   1.111 +   },{75578374, 147,
   1.112 +      5000, 500, 500, 25000, -100, -1, 250000, 500, 500, 0, 100, 1,
   1.113 +      1000,
   1.114 +   },{44821152, 148,
   1.115 +      5000, 500, 500, 25000, -50, 49, 250000, 500, 500, 0, 100, 1, 1000,
   1.116 +   },{45224103, 149,
   1.117 +      5000, 500, 500, 25000, 101, 200, 250000, 500, 500, 0, 100, 1,
   1.118 +      1000,
   1.119 +   },{63491741, 150,
   1.120 +      5000, 500, 500, 25000, 1001, 1100, 250000, 500, 500, 0, 100, 1,
   1.121 +      1000,
   1.122 +   }
   1.123 +};
   1.124 +
   1.125 +typedef struct { double rhs; } v_data;
   1.126 +typedef struct { double cap, cost; } a_data;
   1.127 +
   1.128 +int main(void)
   1.129 +{     glp_graph *G;
   1.130 +      int k;
   1.131 +      char fname[100+1];
   1.132 +      G = glp_create_graph(sizeof(v_data), sizeof(a_data));
   1.133 +      for (k = 1; k <= 50; k++)
   1.134 +      {  sprintf(fname, "netgn%03d.min", parm[k-1][1]);
   1.135 +         glp_netgen(G, offsetof(v_data, rhs), offsetof(a_data, cap),
   1.136 +            offsetof(a_data, cost), &parm[k-1][-1]);
   1.137 +         glp_write_mincost(G, offsetof(v_data, rhs), -1,
   1.138 +            offsetof(a_data, cap), offsetof(a_data, cost), fname);
   1.139 +      }
   1.140 +      glp_delete_graph(G);
   1.141 +      return 0;
   1.142 +}
   1.143 +
   1.144 +/* eof */