Skip to content

Commit

Permalink
Implementing the bbob noisy wrappers around the existing functions
Browse files Browse the repository at this point in the history
The present commit implements the wrappers around the f_<function_name>_evaluate, f_<function_name>__allocate and f_<function_name>_bbob_problem_allocate functions,
needed to implement a noisy version of the given problem.

In particular, this is handled by the three functions:

* coco_problem_f_evaluate_wrap_noisy
* coco_problem_allocate_f_wrap_noisy
* coco_problem_allocate_bbob_wrap_noisy

The definition of the just mentioned functions is written in the suite_bbob_noisy_uitilities file, while their declaration is in the coco.h header file.

In order to make this idea of wrapping work, we defined the following structures

* coco_noise_model_s
* coco_noisy_problem_s

The coco_noise_model_s is used to evaluate the noise model according to the paper <paper_name>.

The coco_noisy_problem_s is a structure used as a wrapper around coco_problem_t (which is one of its member attributes, inner_problem), and is (should be) able to
implement the noisy version of a given problem in the bbob test suite.

The preceding approach of defining the noisy version of each function is, as we mentioned in the previous commit message, unfeasible.

On the other hand, for respecting the project structure in terms of protection and isolation of certain files, we found the need to define, finally, the three functions
used to allocate the noisy version of the problems in the bbob datasuite, according to the three aforementioned noise models. These functions are:

* coco_problem_allocate_bbob_wrap_noisy_gaussian
* coco_problem_allocate_bbob_wrap_noisy_uniform
* coco_problem_allocate_bbob_wrap_noisy_cauchy

Corrected a few bugs I noticed from the previous commit and added the bbob_noisy.c file containing the definition of the functions needed to create and allocate the bbob-noisy test suite

Testing the c code build and running the first (unsuccessfull) regression test.

Array initialization was wrong

Need to handle the schaffers and gallagher functions in a particular way

This is due to the fact that the functions f_schaffers_bbob_problem_allocate
and f_gallagher_bbob_problem_allocate have a different signature than the other
f_<function_name>_bbob_problem_allocate ones.
For how I was thinking of implementing the noisy suite, as a wrap around the existing bbob suite,
this fact created the need to define specific wrappers (and function types) for these two mentioned
functions.
In addition, we added some other function type in coco_internal.h for minimizing the number of
unused parameters in the overall project

Generating data for regression test for the bbob-noisy suite

Apparently it kinda works now, it's time to do the needed tests

Preparing code for regression testing

Done the necessary modifications needed to be able to test the new implementation of the bbob-noisy
test suite against the old code.

Running now the full checks. I already checked if the fopt and the xopt are the same across the two implementations,
and this seems to be the case. Writing now the scripts to be able to reproduce the results.

One thing I observed regarding the fact that these tests were not passing at all, is that I realized that the
function id needs to exactly match across the two implementations for the xopt and yopt to be computed in the same way.

This is what I did and, as expected, it corrected this behaviour.

Proceeding with the regression test

I am currently proceeding with the regression tests.
I tested the new implementation (in the noise free version), against the legacy code (by taking the ftrue values instead of the fval ones, noise free again)
The test consisted in randomly sampling a set of x coordinates from the legacy code and evaluate it both on the old and the new implementation.

Before doing so I tested all the optimal values, which worked (the values are the same as for the previous implementation).

For what concerns the results of the regression tests (still on the noise free version), all the tests passed except for F116 F117 F118 (ellipsoid) and F126 F127 F128 (griewank-rosenborg).

This is probably due to some differences in the inner implementation of the functions across the two versions of the coco platform, but I am still trying to figure it out...

The next step (once all test will pass for the noise-free versions), will be to check if the noisy version of the suite yields the same results as well, but now Im currently facing some problems, as the
distributions parameters for sampling the noise are not correctly allocated (or correctly passed to the sampling function), but I dont know for sure yet.

Having problems with Ellipsoid

Maybe I should use the rotated version, as the legACY code computes a rotation on it

Solved issue with Griewank-Rosenbrock and Ellipsoid function

Basically there were some parameters of the objective functions that were passed as variables or literals
and were supposed to be different across the noisy and the noise free implementation, according to the
legacy code

Example.: Default conditioning for ellipsoid was 1.0e6, which is correct for the noise free functions
but not for the noisy version, since for the legacy code the conditioning of noisy problem was just 1.0e4.
There was a similar issue with the Griewank-Rosenbrock function.

This modifications required slightly ones also in the other suites calling the allocators for those functions (to be able to pass them the correct value of the argument).
Hopefully, these modifications should not alterate the already existing behaviour of the other suites, but we'll see when the tests done at commit time are done.

Regression test completed

Cleaning the code

Regression test passed (Hopefully)

Passed the regression test against the legacy code and generated regression test data

1) Cleaning the code further.

1.1) Removed all the declarations that didn't need to be public from the `coco.h` file
1.2) Now the random seed is handles as a global variable (as in the legacy code), so there's no need to pass it as argument for the bbob_noisy problem allocator or as attribute of the noise model
1.3) Passing the noise model as argument to the constructor so that we'll only have one for the three different noise models

2) Modifying the test.

The randomness of the bbob noisy test suite implied the necessity to think about some sort of reproducibility between the runs.
Currently, the structure of the code emulates the legacy code-base, with the random seed defined as a global variable that is increased each time a noise term is sampled.
Thus, in order to obtain the same results over different runs, the order of evaluation must remain unaltered. As the regression data didn't previously store any
information about the order of evaluation (only for the functions, not for the x datapoints), this created the need to modify the way the regression data was created,
in order to store information about the order of eevaluation of the datapoints.
I then uploaded, in the modified format, the generated data (only for the bbob-noisy test suite) to the regression-data github repository of the numbbo organization.
This required some modifications for the script actually running the test, but, if I didn't make any mistake, it should work as well for the older format.

Minor mistake in commit

Still some minor fixes to the commit

Problem with the python interface.

I added the interface for getting the last noise value for debugging, but removed such function from the source code once not needed, but forgot to remove it from the inetrface

Still some minor fixes to the commit (python interface)

Cleaning the code

Error in the file testing the bbob-noisy suite against the legacy code

Updating comments to the code

Started to play around with the pycma package and cleaned a bit the src code by writing functions for allocating the distributon theta array for each distribution

Fixing issue with indexing of problems, function and other stuff

Adding best_decision_vector to the python interface

Cleaning up before PR, Removing unnecessary files

This should be the "final" commit, in the sense that it is the first commit where the results obtained
are exactly the same as the one for the legacy code.
Before I forgot to implement the boundary handling method that were adding a penalty on the decision vector.

Hopefully this is the right time, but I guess we'll have to see the results of the tests done at commit time

Removing printf statemets after debugging

Passing structures as void *

Changing the allocation of the noisy problems

removing python interface to best values/parameters

The signature of the coco_suite_allocate function changed, need to update it on the suite_bbob_noisy.c file as well, I hope this is the only reason why the tests have not passed in the first commit after the merge, but I guess that only time will tell us
  • Loading branch information
lorenzo-consoli committed Nov 22, 2023
1 parent 2e605fa commit 23333cd
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 21 deletions.
18 changes: 0 additions & 18 deletions code-experiments/src/coco.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,6 @@ 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: 0 additions & 2 deletions code-experiments/src/coco_problem.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,10 +819,8 @@ static coco_problem_t *coco_problem_transformed_allocate(coco_problem_t *inner_p

return inner_copy;
}

/**@}*/


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

/**
Expand Down
2 changes: 1 addition & 1 deletion code-experiments/src/suite_largescale.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static coco_problem_t *coco_get_largescale_problem(const size_t function,
problem_id_template, problem_name_template);
} else if (function == 10) {
problem = f_ellipsoid_permblockdiag_bbob_problem_allocate(function, dimension, instance, rseed,
problem_id_template, problem_name_template);
problem_id_template, problem_name_template);
} else if (function == 11) {
problem = f_discus_generalized_permblockdiag_bbob_problem_allocate(function, dimension, instance, rseed,
problem_id_template, problem_name_template);
Expand Down

0 comments on commit 23333cd

Please sign in to comment.