examples/netgen.c
changeset 1 c445c931472f
equal deleted inserted replaced
-1:000000000000 0:37153a921d76
       
     1 /* netgen.c */
       
     2 
       
     3 /* This main program generates 50 original NETGEN instances of the
       
     4    minimum cost flow problem and writes them in DIMACS format to the
       
     5    current directory. */
       
     6 
       
     7 #include <stddef.h>
       
     8 #include <stdio.h>
       
     9 #include <stdlib.h>
       
    10 #include <glpk.h>
       
    11 
       
    12 static int parm[50][15] =
       
    13 {    {13502460, 101,
       
    14       5000, 2500, 2500, 25000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
       
    15    },{4281922, 102,
       
    16       5000, 2500, 2500, 25000, 1, 100, 2500000, 0, 0, 0, 100, 1, 1000,
       
    17    },{44820113, 103,
       
    18       5000, 2500, 2500, 25000, 1, 100, 6250000, 0, 0, 0, 100, 1, 1000,
       
    19    },{13450451, 104,
       
    20       5000, 2500, 2500, 25000, -100, -1, 250000, 0, 0, 0, 100, 1, 1000,
       
    21    },{14719436, 105,
       
    22       5000, 2500, 2500, 25000, 101, 200, 250000, 0, 0, 0, 100, 1, 1000,
       
    23    },{17365786, 106,
       
    24       5000, 2500, 2500, 12500, 1, 100, 125000, 0, 0, 0, 100, 1, 1000,
       
    25    },{19540113, 107,
       
    26       5000, 2500, 2500, 37500, 1, 100, 375000, 0, 0, 0, 100, 1, 1000,
       
    27    },{19560313, 108,
       
    28       5000, 2500, 2500, 50000, 1, 100, 500000, 0, 0, 0, 100, 1, 1000,
       
    29    },{2403509, 109,
       
    30       5000, 2500, 2500, 75000, 1, 100, 750000, 0, 0, 0, 100, 1, 1000,
       
    31    },{92480414, 110,
       
    32       5000, 2500, 2500, 12500, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
       
    33    },{4230140, 111,
       
    34       5000, 2500, 2500, 37500, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
       
    35    },{10032490, 112,
       
    36       5000, 2500, 2500, 50000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
       
    37    },{17307474, 113,
       
    38       5000, 2500, 2500, 75000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
       
    39    },{4925114, 114,
       
    40       5000, 500, 4500, 25000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
       
    41    },{19842704, 115,
       
    42       5000, 1500, 3500, 25000, 1, 100, 250000, 0, 0, 0, 100, 1, 1000,
       
    43    },{88392060, 116,
       
    44       5000, 2500, 2500, 25000, 1, 100, 250000, 0, 0, 0, 0, 1, 1000,
       
    45    },{12904407, 117,
       
    46       5000, 2500, 2500, 12500, 1, 100, 125000, 0, 0, 0, 0, 1, 1000,
       
    47    },{11811811, 118,
       
    48       5000, 2500, 2500, 37500, 1, 100, 375000, 0, 0, 0, 0, 1, 1000,
       
    49    },{90023593, 119,
       
    50       5000, 2500, 2500, 50000, 1, 100, 500000, 0, 0, 0, 0, 1, 1000,
       
    51    },{93028922, 120,
       
    52       5000, 2500, 2500, 75000, 1, 100, 750000, 0, 0, 0, 0, 1, 1000,
       
    53    },{72707401, 121,
       
    54       5000, 50, 50, 25000, 1, 100, 250000, 50, 50, 0, 100, 1, 1000,
       
    55    },{93040771, 122,
       
    56       5000, 250, 250, 25000, 1, 100, 250000, 250, 250, 0, 100, 1, 1000,
       
    57    },{70220611, 123,
       
    58       5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
       
    59    },{52774811, 124,
       
    60       5000, 1000, 1000, 25000, 1, 100, 250000, 1000, 1000, 0, 100, 1,
       
    61       1000,
       
    62    },{22492311, 125,
       
    63       5000, 1500, 1500, 25000, 1, 100, 250000, 1500, 1500, 0, 100, 1,
       
    64       1000,
       
    65    },{35269337, 126,
       
    66       5000, 500, 500, 12500, 1, 100, 125000, 500, 500, 0, 100, 1, 1000,
       
    67    },{30140502, 127,
       
    68       5000, 500, 500, 37500, 1, 100, 375000, 500, 500, 0, 100, 1, 1000,
       
    69    },{49205455, 128,
       
    70       5000, 500, 500, 50000, 1, 100, 500000, 500, 500, 0, 100, 1, 1000,
       
    71    },{42958341, 129,
       
    72       5000, 500, 500, 75000, 1, 100, 750000, 500, 500, 0, 100, 1, 1000,
       
    73    },{25440925, 130,
       
    74       5000, 500, 500, 12500, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
       
    75    },{75294924, 131,
       
    76       5000, 500, 500, 37500, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
       
    77    },{4463965, 132,
       
    78       5000, 500, 500, 50000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
       
    79    },{13390427, 133,
       
    80       5000, 500, 500, 75000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
       
    81    },{95250971, 134,
       
    82       1000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
       
    83    },{54830522, 135,
       
    84       2500, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
       
    85    },{520593, 136,
       
    86       7500, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
       
    87    },{52900925, 137,
       
    88       10000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 1000,
       
    89    },{22603395, 138,
       
    90       5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 50,
       
    91    },{55253099, 139,
       
    92       5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 250,
       
    93    },{75357001, 140,
       
    94       5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 500,
       
    95    },{10072459, 141,
       
    96       5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 2500,
       
    97    },{55728492, 142,
       
    98       5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 100, 1, 5000,
       
    99    },{593043, 143,
       
   100       5000, 500, 500, 25000, 1, 100, 250000, 500, 500, 0, 0, 1, 1000,
       
   101    },{94236572, 144,
       
   102       5000, 500, 500, 25000, 1, 10, 250000, 500, 500, 0, 100, 1, 1000,
       
   103    },{94882955, 145,
       
   104       5000, 500, 500, 25000, 1, 1000, 250000, 500, 500, 0, 100, 1, 1000,
       
   105    },{48489922, 146,
       
   106       5000, 500, 500, 25000, 1, 10000, 250000, 500, 500, 0, 100, 1,
       
   107       1000,
       
   108    },{75578374, 147,
       
   109       5000, 500, 500, 25000, -100, -1, 250000, 500, 500, 0, 100, 1,
       
   110       1000,
       
   111    },{44821152, 148,
       
   112       5000, 500, 500, 25000, -50, 49, 250000, 500, 500, 0, 100, 1, 1000,
       
   113    },{45224103, 149,
       
   114       5000, 500, 500, 25000, 101, 200, 250000, 500, 500, 0, 100, 1,
       
   115       1000,
       
   116    },{63491741, 150,
       
   117       5000, 500, 500, 25000, 1001, 1100, 250000, 500, 500, 0, 100, 1,
       
   118       1000,
       
   119    }
       
   120 };
       
   121 
       
   122 typedef struct { double rhs; } v_data;
       
   123 typedef struct { double cap, cost; } a_data;
       
   124 
       
   125 int main(void)
       
   126 {     glp_graph *G;
       
   127       int k;
       
   128       char fname[100+1];
       
   129       G = glp_create_graph(sizeof(v_data), sizeof(a_data));
       
   130       for (k = 1; k <= 50; k++)
       
   131       {  sprintf(fname, "netgn%03d.min", parm[k-1][1]);
       
   132          glp_netgen(G, offsetof(v_data, rhs), offsetof(a_data, cap),
       
   133             offsetof(a_data, cost), &parm[k-1][-1]);
       
   134          glp_write_mincost(G, offsetof(v_data, rhs), -1,
       
   135             offsetof(a_data, cap), offsetof(a_data, cost), fname);
       
   136       }
       
   137       glp_delete_graph(G);
       
   138       return 0;
       
   139 }
       
   140 
       
   141 /* eof */