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