/* $Id: user.h,v 2.3 1993/12/22 04:47:37 ingber Exp ingber $ */ /* user.h for Adaptive Simulated Annealing */ #include #include #include #include /* misc defs on most machines */ #define TRUE 1 #define FALSE 0 /* DEFAULT PARAMETERS SETTINGS */ #ifndef ASA_TEST #define ASA_TEST FALSE #endif #ifndef ASA_TEMPLATE #define ASA_TEMPLATE FALSE #endif #ifndef HAVE_ANSI #define HAVE_ANSI TRUE #endif #ifndef IO_PROTOTYPES #define IO_PROTOTYPES TRUE #endif #ifndef TIME_CALC #define TIME_CALC FALSE #endif #ifndef TIME_STD #define TIME_STD FALSE #endif #if TIME_CALC #if TIME_STD #include #endif #include #include #endif #ifndef INT_LONG #define INT_LONG TRUE #endif #if INT_LONG #define LONG_INT long int #else #define LONG_INT int #endif #ifndef INT_ALLOC #define INT_ALLOC FALSE #endif #if INT_ALLOC #define ALLOC_INT int #else #define ALLOC_INT LONG_INT #endif #ifndef OPTIONAL_DATA #define OPTIONAL_DATA FALSE #endif #ifndef USER_ASA_OUT #define USER_ASA_OUT FALSE #endif /* print the time every PRINT_FREQUENCY function evaluations Define PRINT_FREQUENCY to 0 to not print out the time. */ #define PRINT_FREQUENCY ((LONG_INT) 1000) FILE *ptr_out; #define INTEGER_TYPE ((int) 1) #define REAL_TYPE ((int) -1) #define INTEGER_NO_REANNEAL ((int) 2) #define REAL_NO_REANNEAL ((int) -2) /* You can define SMALL_FLOAT to better correlate to your machine's precision, i.e., as used in asa */ #ifndef SMALL_FLOAT #define SMALL_FLOAT 1.0E-18 #endif #ifndef EPS_DOUBLE #define EPS_DOUBLE SMALL_FLOAT #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 typedef struct { int LIMIT_ACCEPTANCES; int LIMIT_INVALID_GENERATED_STATES; double ACCEPTED_TO_GENERATED_RATIO; double COST_PRECISION; int MAXIMUM_COST_REPEAT; int NUMBER_COST_SAMPLES; double TEMPERATURE_RATIO_SCALE; double COST_PARAMETER_SCALE; double TEMPERATURE_ANNEAL_SCALE; int USER_INITIAL_COST_TEMP; double *user_cost_temperature; int INCLUDE_INTEGER_PARAMETERS; int USER_INITIAL_PARAMETERS; double INITIAL_PARAMETER_TEMPERATURE; int RATIO_TEMPERATURE_SCALES; double *user_temperature_ratio; int USER_INITIAL_PARAMETERS_TEMPS; double *user_parameter_temperature; int TESTING_FREQUENCY_MODULUS; int ACTIVATE_REANNEAL; double REANNEAL_RESCALE; LONG_INT MAXIMUM_REANNEAL_INDEX; double DELTA_X; int DELTA_PARAMETERS; double *user_delta_parameter; int CURVATURE_0; int QUENCH_PARAMETERS; double *user_quench_param_scale; int QUENCH_COST; double *user_quench_cost_scale; #if OPTIONAL_DATA double *asa_data; #endif #if USER_ASA_OUT char *asa_out_file; #endif } USER_DEFINES; /* system function prototypes */ #if HAVE_ANSI /* This block gives trouble under some Ultrix */ #if 0 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, double *cost_tangents, double *cost_curvature, ALLOC_INT * parameter_dimension, int *parameter_int_real, int *cost_flag, int *exit_code, USER_DEFINES * USER_OPTIONS); int main(int argc, char **argv); /* possibly with accompanying data file */ void initialize_parameters(double *cost_parameters, double *parameter_lower_bound, double *parameter_upper_bound, double *cost_tangents, double *cost_curvature, ALLOC_INT * parameter_dimension, int *parameter_int_real, int *cost_curvature_0, int *user_parameter_temp_flag, int *user_cost_temp_flag, int *user_delta_flag, int *user_ratio_temp_flag, int *user_quench_param_flag, int *user_quench_cost_flag, USER_DEFINES * USER_OPTIONS); #if TIME_CALC void print_time(char *message); void aux_print_time(struct timeval *time, char *message); #if TIME_STD int syscall(int sys_option, int who, struct rusage *usage); #else int getrusage(int who, struct rusage *usage); #endif #endif double myrand(void); double randflt(void); void initialize_rng(void); /* asa function prototypes */ double asa(double (*cost_function) (), double (*random_generator) (), double *cost_parameters, double *parameter_lower_bound, double *parameter_upper_bound, double *cost_tangents, double *cost_curvature, ALLOC_INT * parameter_dimension, int *parameter_int_real, int *cost_flag, 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(); #if TIME_STD int syscall(); #else int getrusage(); #endif #endif double myrand(); double randflt(); void initialize_rng(); /* asa function prototypes */ double asa(); #endif /* HAVE_ANSI */ #ifndef SELF_OPTIMIZE #define SELF_OPTIMIZE FALSE #endif #if SELF_OPTIMIZE static LONG_INT funevals = 0; #define RECUR_PRINT_FREQUENCY ((LONG_INT) 1) #if HAVE_ANSI double recur_cost_function(double *recur_cost_parameters, double *recur_parameter_lower_bound, double *recur_parameter_upper_bound, double *recur_cost_tangents, double *recur_cost_curvature, ALLOC_INT * recur_parameter_dimension, int *recur_parameter_int_real, int *recur_cost_flag, int *recur_exit_code, USER_DEFINES * RECUR_USER_OPTIONS); void recur_initialize_parameters(double *recur_cost_parameters, double *recur_parameter_lower_bound, double *recur_parameter_upper_bound, double *recur_cost_tangents, double *recur_cost_curvature, ALLOC_INT * recur_parameter_dimension, int *recur_parameter_int_real, int *recur_cost_curvature_0, int *recur_user_parameter_temp_flag, int *recur_user_cost_temp_flag, int *recur_user_delta_flag, int *recur_user_ratio_temp_flag, int *recur_user_quench_param_flag, int *recur_user_quench_cost_flag, USER_DEFINES * RECUR_USER_OPTIONS); #else double recur_cost_function(); int main(); void recur_initialize_parameters(); #endif #endif #ifndef __GNUC__ /* this can be useful when using gcc */ #define __GNUC__ FALSE #endif