examples/netgen.c
author Alpar Juttner <alpar@cs.elte.hu>
Mon, 06 Dec 2010 13:09:21 +0100
changeset 1 c445c931472f
permissions -rw-r--r--
Import glpk-4.45

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