Skip to content

libcmaes partially not properly seeded -- hence not fully reproducible #257

@berndbischl

Description

@berndbischl

Hi.

There are multiple places where you don't respect the user-provided seed in parameters.seed

bipopcmastrategy.cc

Lines 37 + 54 have this:

 _gen = std::mt19937(rd());
_gen.seed(static_cast<uint64_t>(time(nullptr)));

esostrategy, Line 56 + 71 same problem

std::random_device rd;
_uhgen = std::mt19937(rd());
_uhunif = std::uniform_real_distribution<>(0,1);

I think this is also problematic in cmasolutions.cc
This calls into the RNG of Eigen, which I think uses rand()
and is hence also not seeded

if (p._x0min == p._x0max) {
  if (p._x0min == dVec::Constant(p._dim,-std::numeric_limits<double>::max()))
    _xmean = dVec::Random(p._dim) * 4.0; // initial mean randomly sampled from -4,4 in all dimensions.
  else _xmean = p._x0min;
} else {
  _xmean = 0.5*(dVec::Random(p._dim) + dVec::Constant(p._dim,1.0)); // scale to [0,1].
  _xmean = _xmean.cwiseProduct(p._x0max - p._x0min) + p._x0min; // scale to bounds.
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions