coco.h
Go to the documentation of this file.
1 
9 #ifndef __COCO_H__
10 #define __COCO_H__
11 
12 #include <stddef.h>
13 
14 /* Definitions of some 32 and 64-bit types (used by the random number generator) */
15 #ifdef _MSC_VER
16 typedef __int32 int32_t;
17 typedef unsigned __int32 uint32_t;
18 typedef __int64 int64_t;
19 typedef unsigned __int64 uint64_t;
20 #else
21 #include <stdint.h>
22 #endif
23 
24 /* Include definition for NAN among other things */
25 #include <math.h>
26 #include <float.h>
27 #ifndef NAN
28 
29 #define NAN 8.8888e88
30 #endif
31 #ifndef isnan
32 
33 #define isnan(x) (0)
34 #endif
35 #ifndef INFINITY
36 
37 #define INFINITY 1e22
38 /* why not using 1e99? */
39 #endif
40 #ifndef isinf
41 
42 #define isinf(x) (0)
43 #endif
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
55 static const char coco_version[32] = "$COCO_VERSION";
58 /***********************************************************************************************************/
63 static const double coco_pi = 3.14159265358979323846;
64 static const double coco_two_pi = 2.0 * 3.14159265358979323846;
67 /***********************************************************************************************************/
68 
70 typedef enum {
76 
77 /***********************************************************************************************************/
78 
80 struct coco_problem_s;
81 
87 
89 struct coco_suite_s;
90 
95 typedef struct coco_suite_s coco_suite_t;
96 
98 struct coco_observer_s;
99 
105 
107 struct coco_archive_s;
108 
114 
116 struct coco_random_state_s;
117 
123 
124 /***********************************************************************************************************/
125 
134 coco_suite_t *coco_suite(const char *suite_name, const char *suite_instance, const char *suite_options);
135 
139 void coco_suite_free(coco_suite_t *suite);
140 
145 
149 coco_problem_t *coco_suite_get_problem(coco_suite_t *suite, const size_t problem_index);
150 
155  const size_t function,
156  const size_t dimension,
157  const size_t instance);
158 
163 
167 size_t coco_suite_get_function_from_function_index(const coco_suite_t *suite, const size_t function_idx);
168 
172 size_t coco_suite_get_dimension_from_dimension_index(const coco_suite_t *suite, const size_t dimension_idx);
173 
177 size_t coco_suite_get_instance_from_instance_index(const coco_suite_t *suite, const size_t instance_idx);
244  const size_t function_idx,
245  const size_t dimension_idx,
246  const size_t instance_idx);
247 
253  const size_t problem_index,
254  size_t *function_idx,
255  size_t *dimension_idx,
256  size_t *instance_idx);
259 /***********************************************************************************************************/
260 
268 coco_observer_t *coco_observer(const char *observer_name, const char *options);
269 
273 void coco_observer_free(coco_observer_t *observer);
274 
279 
284 
288 const char *coco_observer_get_result_folder(const coco_observer_t *observer);
289 
292 /***********************************************************************************************************/
293 
301 void coco_evaluate_function(coco_problem_t *problem, const double *x, double *y);
302 
306 void coco_evaluate_constraint(coco_problem_t *problem, const double *x, double *y);
307 
311 void coco_recommend_solution(coco_problem_t *problem, const double *x);
312 
316 void coco_problem_free(coco_problem_t *problem);
317 
321 const char *coco_problem_get_name(const coco_problem_t *problem);
322 
326 const char *coco_problem_get_id(const coco_problem_t *problem);
327 
331 const char *coco_problem_get_type(const coco_problem_t *problem);
332 
336 size_t coco_problem_get_dimension(const coco_problem_t *problem);
337 
342 
347 
351 size_t coco_problem_get_evaluations(const coco_problem_t *problem);
352 
357 
362 
367 
372 
378 
383 const double *coco_problem_get_largest_values_of_interest(const coco_problem_t *problem);
384 
390 
396 
400 size_t coco_problem_get_suite_dep_index(const coco_problem_t *problem);
401 
405 void coco_problem_get_initial_solution(const coco_problem_t *problem, double *initial_solution);
408 /***********************************************************************************************************/
409 
418 coco_random_state_t *coco_random_new(uint32_t seed);
419 
424 
430 
437 /***********************************************************************************************************/
438 
446 void *coco_allocate_memory(const size_t size);
447 
451 double *coco_allocate_vector(const size_t size);
452 
456 void coco_free_memory(void *data);
459 /***********************************************************************************************************/
460 
468 void coco_error(const char *message, ...);
469 
473 void coco_warning(const char *message, ...);
474 
478 void coco_info(const char *message, ...);
479 
488 void coco_info_partial(const char *message, ...);
489 
493 void coco_debug(const char *message, ...);
494 
498 const char *coco_set_log_level(const char *level);
501 /***********************************************************************************************************/
502 
511 coco_archive_t *coco_archive(const char *suite_name,
512  const size_t function,
513  const size_t dimension,
514  const size_t instance);
520 int coco_archive_add_solution(coco_archive_t *archive, const double y1, const double y2, const char *text);
521 
526 
531 
537 
541 void coco_archive_free(coco_archive_t *archive);
542 
546 int coco_logger_biobj_feed_solution(coco_problem_t *problem, const size_t evaluation, const double *y);
549 /***********************************************************************************************************/
550 
558 int coco_remove_directory(const char *path);
559 
563 char *coco_strdupf(const char *str, ...);
566 /***********************************************************************************************************/
567 
568 #ifdef __cplusplus
569 }
570 #endif
571 #endif
size_t coco_problem_get_evaluations_constraints(const coco_problem_t *problem)
Returns the number of constraint function evaluations done on the problem.
Definition: coco_problem.c:410
const double * coco_problem_get_largest_fvalues_of_interest(const coco_problem_t *problem)
For multi-objective problems, returns a vector of largest values of interest in each objective...
Definition: coco_problem.c:538
size_t coco_suite_get_number_of_problems(const coco_suite_t *suite)
Returns the number of problems in the given suite.
Definition: coco_suite.c:449
double coco_random_uniform(coco_random_state_t *state)
Returns one uniform [0, 1) random value from the random number generator associated with the given st...
Definition: coco_random.c:70
void coco_archive_free(coco_archive_t *archive)
Frees the archive.
Definition: coco_archive.c:345
size_t coco_problem_get_number_of_integer_variables(const coco_problem_t *problem)
Returns the number of integer variables. If > 0, all integer variables come before any continuous one...
Definition: coco_problem.c:533
size_t coco_problem_get_number_of_constraints(const coco_problem_t *problem)
Returns the number of constraints of the problem.
Definition: coco_problem.c:516
size_t coco_problem_get_dimension(const coco_problem_t *problem)
Returns the number of variables i.e. the dimension of the problem.
Definition: coco_problem.c:505
double x[COCO_LONG_LAG]
Definition: coco_random.c:23
double * coco_allocate_vector(const size_t size)
Safe memory allocation for a vector of doubles that either succeeds or triggers a coco_error...
Definition: coco_utilities.c:451
const char * coco_archive_get_next_solution_text(coco_archive_t *archive)
Returns the text of the next (non-dominated) solution in the archive and "" when there are no solutio...
Definition: coco_archive.c:292
void * coco_allocate_memory(const size_t size)
Safe memory allocation that either succeeds or triggers a coco_error.
Definition: coco_runtime_c.c:80
coco_observer_t * coco_observer(const char *observer_name, const char *options)
Constructs a COCO observer.
Definition: coco_observer.c:403
only error messages are output
Definition: coco.h:71
A structure containing the state of the COCO random generator.
Definition: coco_random.c:22
void coco_info_partial(const char *message,...)
Prints only the given message without any prefix and new line.
Definition: coco_runtime_c.c:56
void coco_observer_free(coco_observer_t *observer)
Frees the given observer.
Definition: coco_observer.c:324
int coco_logger_biobj_feed_solution(coco_problem_t *problem, const size_t evaluation, const double *y)
Feeds the solution to the bi-objective logger for logger output reconstruction purposes.
Definition: logger_biobj.c:751
coco_log_level_type_e
Logging level type.
Definition: coco.h:70
coco_problem_t * coco_suite_get_next_problem(coco_suite_t *suite, coco_observer_t *observer)
Returns the next (observed) problem of the suite or NULL if there is no next problem left...
Definition: coco_suite.c:812
const char * coco_observer_get_result_folder(const coco_observer_t *observer)
Returns result folder name, where logger output is written.
Definition: coco_observer.c:640
void coco_suite_free(coco_suite_t *suite)
Frees the given suite.
Definition: coco_suite.c:380
const double * coco_problem_get_largest_values_of_interest(const coco_problem_t *problem)
Returns a vector of size &#39;dimension&#39; with upper bounds of the region of interest in the decision spac...
Definition: coco_problem.c:527
double coco_random_normal(coco_random_state_t *state)
Generates an approximately normal random number.
Definition: coco_random.c:83
void coco_evaluate_function(coco_problem_t *problem, const double *x, double *y)
Evaluates the problem function in point x and save the result in y.
Definition: coco_problem.c:29
error, warning, info and debug messages are output
Definition: coco.h:74
The COCO observer structure.
Definition: coco_internal.h:179
coco_problem_t * coco_suite_get_problem_by_function_dimension_instance(coco_suite_t *suite, const size_t function, const size_t dimension, const size_t instance)
Returns the first problem of the suite defined by function, dimension and instance numbers...
Definition: coco_suite.c:158
static const double coco_pi
COCO&#39;s own pi constant. Simplifies the case, when the value of pi changes.
Definition: coco.h:63
const char * coco_problem_get_name(const coco_problem_t *problem)
Returns the name of the problem.
Definition: coco_problem.c:478
error, warning and info messages are output
Definition: coco.h:73
coco_random_state_t * coco_random_new(uint32_t seed)
Creates and returns a new random number state using the given seed.
Definition: coco_random.c:50
void coco_recommend_solution(coco_problem_t *problem, const double *x)
Recommends a solution as the current best guesses to the problem. Not implemented yet...
Definition: coco_problem.c:137
The COCO suite structure.
Definition: coco_internal.h:212
void coco_info(const char *message,...)
Outputs some information.
Definition: coco_runtime_c.c:39
coco_problem_t * coco_problem_remove_observer(coco_problem_t *problem, coco_observer_t *observer)
Removes an observer from the given problem.
Definition: coco_observer.c:602
const char * coco_set_log_level(const char *level)
Sets the COCO log level to the given value and returns the previous value of the log level...
Definition: coco_utilities.c:48
char * coco_strdupf(const char *str,...)
Formatted string duplication.
Definition: coco_string.c:73
size_t coco_archive_get_number_of_solutions(coco_archive_t *archive)
Returns the number of (non-dominated) solutions in the archive (computed first, if needed)...
Definition: coco_archive.c:335
size_t coco_problem_get_evaluations(const coco_problem_t *problem)
Returns the number of objective function evaluations done on the problem.
Definition: coco_problem.c:405
The COCO problem structure.
Definition: coco_internal.h:122
void coco_suite_decode_problem_index(const coco_suite_t *suite, const size_t problem_index, size_t *function_idx, size_t *dimension_idx, size_t *instance_idx)
Computes the function, dimension and instance indexes of the problem with problem_index in the given ...
Definition: coco_suite.c:907
size_t coco_suite_encode_problem_index(const coco_suite_t *suite, const size_t function_idx, const size_t dimension_idx, const size_t instance_idx)
Computes the index of the problem in the suite that corresponds to the given function, dimension and instance indices.
Definition: coco_suite.c:890
int coco_remove_directory(const char *path)
Removes the given directory and all its contents.
Definition: coco_utilities.c:322
void coco_problem_get_initial_solution(const coco_problem_t *problem, double *initial_solution)
Returns an initial solution, i.e. a feasible variable setting, to the problem.
Definition: coco_problem.c:555
const char * coco_problem_get_type(const coco_problem_t *problem)
Returns the type of the problem.
Definition: coco_problem.c:499
const char * coco_problem_get_id(const coco_problem_t *problem)
Returns the ID of the problem.
Definition: coco_problem.c:493
void coco_free_memory(void *data)
Frees the allocated memory.
Definition: coco_runtime_c.c:92
size_t coco_problem_get_suite_dep_index(const coco_problem_t *problem)
Returns the problem_index of the problem in its current suite.
Definition: coco_problem.c:587
double coco_problem_get_best_observed_fvalue1(const coco_problem_t *problem)
Returns the best observed value for the first objective.
Definition: coco_problem.c:449
coco_problem_t * coco_problem_add_observer(coco_problem_t *problem, coco_observer_t *observer)
Adds an observer to the given problem.
Definition: coco_observer.c:578
void coco_problem_free(coco_problem_t *problem)
Frees the given problem.
Definition: coco_problem.c:286
coco_archive_t * coco_archive(const char *suite_name, const size_t function, const size_t dimension, const size_t instance)
Constructs a COCO archive.
Definition: coco_archive.c:123
void coco_warning(const char *message,...)
Warns about error conditions.
Definition: coco_runtime_c.c:27
coco_suite_t * coco_suite(const char *suite_name, const char *suite_instance, const char *suite_options)
Constructs a COCO suite.
Definition: coco_suite.c:634
int coco_problem_final_target_hit(const coco_problem_t *problem)
Returns 1 if the final target was hit, 0 otherwise.
Definition: coco_problem.c:436
void coco_evaluate_constraint(coco_problem_t *problem, const double *x, double *y)
Evaluates the problem constraints in point x and save the result in y.
Definition: coco_problem.c:81
error and warning messages are output
Definition: coco.h:72
void coco_debug(const char *message,...)
Outputs detailed information usually used for debugging.
Definition: coco_runtime_c.c:67
const double * coco_problem_get_smallest_values_of_interest(const coco_problem_t *problem)
Returns a vector of size &#39;dimension&#39; with lower bounds of the region of interest in the decision spac...
Definition: coco_problem.c:521
The COCO archive structure.
Definition: coco_archive.c:19
int coco_archive_add_solution(coco_archive_t *archive, const double y1, const double y2, const char *text)
Adds a solution with objectives (y1, y2) to the archive if none of the existing solutions in the arch...
Definition: coco_archive.c:178
size_t coco_suite_get_instance_from_instance_index(const coco_suite_t *suite, const size_t instance_idx)
Returns the instance number in the suite in position instance_idx (counting from 0).
Definition: coco_suite.c:370
static const double coco_two_pi
COCO&#39;s own pi constant. Simplifies the case, when the value of pi changes.
Definition: coco.h:64
static const char coco_version[32]
COCO&#39;s version.
Definition: coco.h:55
double coco_archive_get_hypervolume(coco_archive_t *archive)
Returns the hypervolume of the archive (computed first, if needed).
Definition: coco_archive.c:340
void coco_random_free(coco_random_state_t *state)
Frees all memory associated with the random state.
Definition: coco_random.c:66
size_t coco_problem_get_number_of_objectives(const coco_problem_t *problem)
Returns the number of objectives of the problem.
Definition: coco_problem.c:511
double depreciated_coco_problem_get_final_target_fvalue1(const coco_problem_t *problem)
Returns the target value for the first objective.
size_t coco_suite_get_function_from_function_index(const coco_suite_t *suite, const size_t function_idx)
Returns the function number in the suite in position function_idx (counting from 0).
Definition: coco_suite.c:336
size_t coco_suite_get_dimension_from_dimension_index(const coco_suite_t *suite, const size_t dimension_idx)
Returns the dimension number in the suite in position dimension_idx (counting from 0)...
Definition: coco_suite.c:353
coco_problem_t * coco_suite_get_problem(coco_suite_t *suite, const size_t problem_index)
Returns the problem of the suite defined by problem_index.
Definition: coco_suite.c:432
void coco_error(const char *message,...)
Signals a fatal error.
Definition: coco_runtime_c.c:16