generators/netgen/netgen.h
author Alpar Juttner <alpar@cs.elte.hu>
Sun, 11 Dec 2011 07:33:29 +0100
changeset 10 d7ce0311ece2
permissions -rw-r--r--
Some common benchmarking tools added
     1 /*** netgen.h
     2  *** Prototype code for inclusion into network generation routines
     3  ***/
     4 
     5 /*** Constant definitions */
     6 
     7 #ifndef NULL
     8 #define NULL 0
     9 #endif
    10 
    11 #define BAD_SEED  -1			/* error indicators */
    12 #define TOO_BIG   -2
    13 #define BAD_PARMS -3
    14 #define ALLOCATION_FAILURE -4
    15 
    16 
    17 /*** Type definitions */
    18 
    19 typedef unsigned long NODE;		/* node number */
    20 typedef unsigned long ARC;		/* arc number */
    21 typedef long CAPACITY;			/* arc capacity */
    22 typedef long COST;			/* arc cost */
    23 typedef unsigned long INDEX;		/* index element */
    24 typedef int INDEX_LIST;			/* index list handle */
    25 
    26 
    27 /*** Function prototypes */
    28 
    29 #ifdef __STDC__
    30 
    31 #include <stdlib.h>
    32 #include <string.h>
    33 
    34 void netgen_(long*, long[], long*, long*);	/* Fortran external interface */
    35 ARC netgen(long, long*);	    		/* C external interface */
    36 
    37 INDEX_LIST make_index_list(INDEX, INDEX); /* allocates a new index list */
    38 void free_index_list(INDEX_LIST);	/* frees an existing list */
    39 INDEX choose_index(INDEX_LIST, INDEX);	/* chooses index at specified position */
    40 void remove_index(INDEX_LIST, INDEX);	/* removes specified index from list */
    41 INDEX index_size(INDEX_LIST); 		/* number of indices remaining */
    42 INDEX pseudo_size(INDEX_LIST);		/* "modified" index size */
    43 
    44 void set_random(long);	    		/* initialize random seed */
    45 long ng_random(long, long);    		/* generate random integer in interval */
    46 
    47 #else
    48 
    49 void *malloc();				/* some standard header should define this */
    50 void *realloc();			/* ditto */
    51 void free();				/* ditto */
    52 void *memset();				/* ditto */
    53 void exit();				/* ditto */
    54 
    55 void netgen_();				/* Fortran external interface */
    56 ARC netgen();		    		/* C external interface */
    57 
    58 INDEX_LIST make_index_list();		/* allocates a new index list */
    59 void free_index_list();			/* frees an existing list */
    60 INDEX choose_index();			/* chooses index at specified position */
    61 void remove_index();			/* removes specified index from list */
    62 INDEX index_size(); 			/* number of indices remaining */
    63 INDEX pseudo_size();			/* "modified" index size */
    64 
    65 void set_random();	    		/* initialize random seed */
    66 long ng_random();    			/* generate random integer in interval */
    67 
    68 #endif
    69 
    70 /*** To maintain compatibility with the old Fortran network generator,
    71  *** the following are defined.  This allows linking the generator code
    72  *** with the solver, with the generated network passed to the solver
    73  *** through arrays in memory.
    74  ***/
    75 
    76 #define MAXNODES   10000000  		/* maximum problem sizes */
    77 #define MAXARCS    40000000
    78 
    79 #define FROM arrays_	    		/* aliases for network storage */
    80 #define TO   arraye_
    81 #define U    arrayu_
    82 #define C    arrayc_
    83 #define B    arrayb_
    84 
    85 #ifdef ALLOCATE_NETWORK	    		/* storage definitions */
    86 #define EXTERN 
    87 #else
    88 #define EXTERN extern
    89 #endif
    90 
    91 EXTERN NODE     FROM[MAXARCS];	/* origin of each arc */
    92 EXTERN NODE     TO  [MAXARCS];	/* destination */
    93 EXTERN CAPACITY U   [MAXARCS];	/* capacity */
    94 EXTERN COST     C   [MAXARCS];	/* cost */
    95 EXTERN CAPACITY B   [MAXNODES];	/* supply (demand) at each node */