coco_archive.c File Reference

Definitions of functions regarding COCO archives. More...

#include "coco.h"
#include "coco_utilities.c"
#include "mo_utilities.c"
#include "mo_avl_tree.c"

Data Structures

struct  coco_archive_s
 The COCO archive structure. More...
 
struct  coco_archive_avl_item_t
 The type for the node's item in the AVL tree used by the archive. More...
 

Functions

static coco_archive_avl_item_tcoco_archive_node_item_create (const double *y, const double *ideal, const double *nadir, const size_t num_obj, const char *text)
 Creates and returns the information on the solution in the form of a node's item in the AVL tree. More...
 
static void coco_archive_node_item_free (coco_archive_avl_item_t *item, void *userdata)
 Frees the data of the given coco_archive_avl_item_t. More...
 
static int coco_archive_compare_by_last_objective (const coco_archive_avl_item_t *item1, const coco_archive_avl_item_t *item2, void *userdata)
 Defines the ordering of AVL tree nodes based on the value of the last objective. More...
 
static coco_archive_tcoco_archive_allocate (void)
 Allocates memory for the archive and initializes its fields. More...
 
coco_archive_tcoco_archive (const char *suite_name, const size_t function, const size_t dimension, const size_t instance)
 Constructs a COCO archive. More...
 
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 archive dominates it. In this case, returns 1, otherwise the archive is not updated and the method returns 0. More...
 
static void coco_archive_update (coco_archive_t *archive)
 Updates the archive fields returned by the getters. More...
 
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 solutions left. The first two solutions are always the extreme ones. More...
 
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). More...
 
double coco_archive_get_hypervolume (coco_archive_t *archive)
 Returns the hypervolume of the archive (computed first, if needed). More...
 
void coco_archive_free (coco_archive_t *archive)
 Frees the archive. More...
 

Detailed Description

Definitions of functions regarding COCO archives.

COCO archives are used to do some pre-processing on the bi-objective archive files. Namely, through a wrapper written in Python, these functions are used to merge archives and compute their hypervolumes.

Function Documentation

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.

The archive always contains the two extreme solutions

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 archive dominates it. In this case, returns 1, otherwise the archive is not updated and the method returns 0.

static coco_archive_t* coco_archive_allocate ( void  )
static

Allocates memory for the archive and initializes its fields.

static int coco_archive_compare_by_last_objective ( const coco_archive_avl_item_t item1,
const coco_archive_avl_item_t item2,
void *  userdata 
)
static

Defines the ordering of AVL tree nodes based on the value of the last objective.

void coco_archive_free ( coco_archive_t archive)

Frees the archive.

double coco_archive_get_hypervolume ( coco_archive_t archive)

Returns the hypervolume of the archive (computed first, if needed).

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 solutions left. The first two solutions are always the extreme ones.

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).

static coco_archive_avl_item_t* coco_archive_node_item_create ( const double *  y,
const double *  ideal,
const double *  nadir,
const size_t  num_obj,
const char *  text 
)
static

Creates and returns the information on the solution in the form of a node's item in the AVL tree.

static void coco_archive_node_item_free ( coco_archive_avl_item_t item,
void *  userdata 
)
static

Frees the data of the given coco_archive_avl_item_t.

static void coco_archive_update ( coco_archive_t archive)
static

Updates the archive fields returned by the getters.