/* $Id: user.h,v 7.3 1993/02/04 18:33:49 ingber Exp ingber $ */ /* user.h for Very Fast Simulated Reannealing */ #include #include #include #include /* misc defs on most machines */ #define TRUE 1 #define FALSE 0 #define INTEGER_TYPE 1 #define REAL_TYPE 0 /* print the time every PRINT_FREQUENCY function evaluations Define PRINT_FREQUENCY to 0 to not print out the time. */ #define PRINT_FREQUENCY 1000 /* pointer to array storage for vfsr arguments */ double *parameter_lower_bound, *parameter_upper_bound, *cost_parameters, cost_value, *cost_tangents, *cost_curvature; /* flag to perform cost_curvature calculations */ int cost_curvature_flag; /* the number of parameters to optimize */ int parameter_dimension; /* pointer to array storage for parameter type flags */ int *parameter_int_real; FILE *ptr_out; /* DEFAULT PARAMETERS SETTINGS */ #ifndef HAVE_ANSI #define HAVE_ANSI TRUE #endif #ifndef IO_PROTOTYPES #define IO_PROTOTYPES TRUE #endif #ifndef TIME_CALC #define TIME_CALC TRUE #endif #if TIME_CALC #include #include #endif /* You can define SMALL_FLOAT to better correlate to your machine's precision, i.e., as used in vfsr */ #ifndef SMALL_FLOAT #define SMALL_FLOAT 1.0E-18 #endif #ifndef ADAPTIVE_OPTIONS #define ADAPTIVE_OPTIONS FALSE #endif /* This can be changed to OPTIONS_FILE=TRUE in the Makefile, _or_ by uncommenting the next line. */ /* #define OPTIONS_FILE TRUE */ #ifndef OPTIONS_FILE #define OPTIONS_FILE FALSE #endif #if ADAPTIVE_OPTIONS #if OPTIONS_FILE FILE *ptr_options; char read_option[80]; int read_int; double read_double; #endif #endif #if ADAPTIVE_OPTIONS typedef struct { double COST_PRECISION; int USER_INITIAL_PARAMETERS; double ACCEPTED_TO_GENERATED_RATIO; int LIMIT_ACCEPTANCES; double TEMPERATURE_RATIO_SCALE; double TEMPERATURE_ANNEAL_SCALE; double COST_PARAMETER_SCALE; int TESTING_FREQUENCY_MODULUS; int MAXIMUM_REANNEAL_INDEX; double REANNEAL_RESCALE; double INITIAL_PARAMETER_TEMPERATURE; int USER_INITIAL_PARAMETERS_TEMPS; int USER_INITIAL_COST_TEMP; int NUMBER_COST_SAMPLES; int MAXIMUM_COST_REPEAT; double DELTA_X; int INCLUDE_INTEGER_PARAMETERS; int ACTIVATE_REANNEAL; int LIMIT_INVALID_GENERATED_STATES; } USER_DEFINES; #else typedef int USER_DEFINES; #endif USER_DEFINES *USER_OPTIONS; /* system function prototypes */ #if HAVE_ANSI #if 0 /* This block gives trouble under some Ultrix */ int fprintf(FILE * fp, char *string,...); #if OPTIONS_FILE int fscanf(FILE * fp, char *string,...); #endif int fflush(FILE * fp); int fclose(FILE * fp); void exit(int code); #endif #if IO_PROTOTYPES int fprintf(); #if OPTIONS_FILE int fscanf(); #endif int fflush(); int fclose(); void exit(); #endif /* user-defined */ double cost_function(double *cost_parameters, double *parameter_lower_bound, double *parameter_upper_bound, int *cost_flag, USER_DEFINES * USER_OPTIONS); int main(int argc, char **argv); void initialize_parameters(void); /* possibly with accompanying data file */ #if TIME_CALC void print_time(char *message); void aux_print_time(struct timeval *time, char *message); #endif double myrand(void); double randflt(void); void initialize_rng(void); /* vfsr function prototypes */ double vfsr(double (*cost_function) (), double (*random_generator) (), int parameter_dimension, int *parameter_int_real, double *cost_parameters, double *parameter_lower_bound, double *parameter_upper_bound, double *cost_tangents, double *cost_curvature, int *exit_code, USER_DEFINES * USER_OPTIONS); #else /* HAVE_ANSI */ #if IO_PROTOTYPES int fprintf(); #if OPTIONS_FILE int fscanf(); #endif int fflush(); int fclose(); #endif /* user-defined */ double cost_function(); int main(); void initialize_parameters(); /* possibly with accompanying data file */ #if TIME_CALC void print_time(); void aux_print_time(); #endif double myrand(); double randflt(); void initialize_rng(); /* vfsr function prototypes */ double vfsr(); #endif /* HAVE_ANSI */