Skip to content

Commit

Permalink
Creating instrumental branch to safely merge the dev-bbob-noisy branc…
Browse files Browse the repository at this point in the history
…h with the development branch

First Commit working on the bbob-noisy suite

Added the f_sphere_gaussian.c file, which implements the sphere function with gaussian noise (and customable noise variance, for either moderate level or strong level of noise). The file contains the implementations of f_sphere_gaussian_raw, f_sphere_gaussian_evaluate, f_sphere_gaussian_evaluate_gradient,f_sphere_gaussian_allocate and f_sphere_gaussian_bbob_problem_allocate. In order to implement these functions, we slightly modified the coco_problem_s structure and added three new attributes: random_seed (uint_32, the random seed for generating samples from given distributions), distribution_theta (*double, the parameters of the distributions from which the noise is sampled) and last_noise_value(double, the noise value obtained from the last function evaluation. Used to compute the gradient at a given point with the same noise as the function evaluation it follows. The correct functioning of this is based on the assumption that the gradient is computed after each function evaluation). We also added the coco_noisy_problem_allocate_from_scalars function in the coco_problem.c file, which is basically a wrapper around the coco_problem_allocate_from_scalars function, which also allocates the random_seed and distribution_theta arguments mentioned before.

First Commit working on the bbob-noisy suite

Added the f_sphere_gaussian.c file, which implements the sphere function with gaussian noise (and customable noise variance, for either moderate level or strong level of noise). The file contains the implementations of f_sphere_gaussian_raw, f_sphere_gaussian_evaluate, f_sphere_gaussian_evaluate_gradient,f_sphere_gaussian_allocate and f_sphere_gaussian_bbob_problem_allocate. In order to implement these functions, we slightly modified the coco_problem_s structure and added three new attributes: random_seed (uint_32, the random seed for generating samples from given distributions), distribution_theta (*double, the parameters of the distributions from which the noise is sampled) and last_noise_value(double, the noise value obtained from the last function evaluation. Used to compute the gradient at a given point with the same noise as the function evaluation it follows. The correct functioning of this is based on the assumption that the gradient is computed after each function evaluation). We also added the coco_noisy_problem_allocate_from_scalars function in the coco_problem.c file, which is basically a wrapper around the coco_problem_allocate_from_scalars function, which also allocates the random_seed and distribution_theta arguments mentioned before. EDIT: Added some missing semi-columns that I forgot around...

Writing getter functions for random_seed, distribution_theta and last_noise_value and added coco_problem_sample_gaussian function to generate normal noises.

* ```/coco/code-experiments/src/coco.h```
* ```/coco/code-experiments/src/coco_problem.c```
* ```/coco/code-experiments/src/f_sphere_gaussian.c```

Added all the new getters for the new `coco_problem_s` members (more specifically `coco_problem_get_random_seed`, `coco_problem_get_distribution_theta`, `coco_problem_get_last_noise_value`). Their signat>

Defining the functions for the uniform noise model and implementing the sphere with uniform noise

Implementing the functions for sampling following the cauchy noise model

Changing approach

The approach previously undertaken is highly unpractical and unfeasible. So I decided to change the approach
and create a wrap around the standard problems and use it to implement the bbob-noisy test suite.
  • Loading branch information
lorenzo-consoli committed Nov 22, 2023
1 parent 8afc184 commit 2e605fa
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
36 changes: 36 additions & 0 deletions code-experiments/build/c/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Makefile to build C example programs included with the COCO distribution
##
## NOTE: We have tried to make this Makefile as generic and portable
## as possible. However, there are many (incompatible) versions of
## make floating around. We regularly test using GNU make and BSD make
## from FreeBSD. If you have trouble compiling the examples, please
## try to use GNU make.
##
## On Windows it is best to use either the included NMakefile by running
##
## nmake -f NMakefile
##
## or installing Cygwin and running GNU make from within Cygwin.

LDFLAGS += -lm
CCFLAGS ?= -g -ggdb -std=c99 -pedantic -Wall -Wextra -Wstrict-prototypes -Wshadow -Wno-sign-compare -Wconversion

########################################################################
## Toplevel targets
all: example_experiment

clean:
rm -f coco.o
rm -f example_experiment.o example_experiment

########################################################################
## Programs
example_experiment: example_experiment.o coco.o
${CC} ${CCFLAGS} -o example_experiment coco.o example_experiment.o ${LDFLAGS}

########################################################################
## Additional dependencies
coco.o: coco.h coco.c
${CC} -c ${CCFLAGS} -o coco.o coco.c
example_experiment.o: coco.h coco.c example_experiment.c
${CC} -c ${CCFLAGS} -o example_experiment.o example_experiment.c
18 changes: 18 additions & 0 deletions code-experiments/src/coco.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,24 @@ struct coco_suite_s;
* See coco_suite_s for more information on its fields. */
typedef struct coco_suite_s coco_suite_t;

/** @brief Structure containing a COCO noisy problem. */
struct coco_noisy_problem_s;

/**
* @brief The COCO noisy problem type.
*
* See coco_noisy_problem_s for more information on its fields. */
typedef struct coco_noisy_problem_s coco_noisy_problem_t;

/** @brief Structure containing a COCO model. */
struct coco_noise_model_s;

/**
* @brief The COCO noise model type.
*
* See coco_noise_model for more information on its fields. */
typedef struct coco_noise_model_s coco_noise_model_t;

/** @brief Structure containing a COCO observer. */
struct coco_observer_s;

Expand Down
2 changes: 2 additions & 0 deletions code-experiments/src/coco_problem.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,10 @@ static coco_problem_t *coco_problem_transformed_allocate(coco_problem_t *inner_p

return inner_copy;
}

/**@}*/


/***********************************************************************************************************/

/**
Expand Down

0 comments on commit 2e605fa

Please sign in to comment.