Compiler directives

Overview

Changes the behavior of the code according to the user supplied directives. More…

// macros

#define BRKGA_MULTIPLE_INCLUSIONS
#define MATING_FULL_SPEED
#define MATING_SEED_ONLY
#define MATING_SEQUENTIAL

Detailed Documentation

Changes the behavior of the code according to the user supplied directives. Usually, pass by flag -D (in GCC and Clang). For instance,

$ gcc -DBRKGA_MULTIPLE_INCLUSIONS code.cpp -o code.o

Macros

#define BRKGA_MULTIPLE_INCLUSIONS

Allows inclusion within multiple translation units.

If we need to include this file in multiple translation units (files) that are compiled separately, we have to inline some functions and template definitions to avoid multiple definitions and linking problems. However, such inlining can make the object code grows large. In other cases, the compiler may complain about too many inline functions, if you are already using several inline functions.

#define MATING_FULL_SPEED

Enables full speed parallel mating.

At full speed (MATING_FULL_SPEED), the mating process is done in parallel, using independent RNGs. The results are reproducible if and only if you use the same seed and the same number of threads.

#define MATING_SEED_ONLY

Enables Seed-only parallel mating.

Using MATING_SEED_ONLY, the mating is still parallel, but each RNG is seeded on each mating. This is a little bit slower than full speed, but we depend only on the seed, regardless of the number of threads. I.e., Runs with a different number of threads, but the same seed should result in the same sequence of decisions.

#define MATING_SEQUENTIAL

Enables sequential mating.

Using MATING_SEQUENTIAL, the mating process is completely sequential, as in the original BRKGA. The reproducibility is guaranteed with only the same seed. This option can be very slow for large chromosomes and large populations. But it makes debugging easier.