Fix CI: random class issue, t-eoRoulette and update the workflow

This commit is contained in:
Jxtopher 2024-04-30 14:08:30 +02:00
commit d72ec5ad2e
4 changed files with 8 additions and 17 deletions

View file

@ -1,10 +1,5 @@
name: Build Debug (Ubuntu)
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push, pull_request]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)

View file

@ -198,7 +198,7 @@ class eoInitPermutation: public eoInit<EOT> // FIXME inherit from eoInitWithDim
}
UF_random_generator<unsigned int> gen(chrom.size());
std::shuffle(chrom.begin(), chrom.end(), gen);
std::random_shuffle(chrom.begin(), chrom.end(), gen);
chrom.invalidate();
}

View file

@ -68,16 +68,12 @@ public:
}
assert(not _pop[0].invalid());
const typename EOT::Fitness min_fit
= std::min_element( std::begin(_pop), std::end(_pop) )
->fitness();
cumulative.clear();
cumulative.push_back(_pop[0].fitness() - min_fit);
cumulative.push_back(_pop[0].fitness() );
for (unsigned i = 1; i < _pop.size(); ++i) {
assert(not _pop[i].invalid());
cumulative.push_back(cumulative.back() + _pop[i].fitness() - min_fit);
cumulative.push_back(cumulative.back() + _pop[i].fitness());
}
assert(cumulative.size() == _pop.size());
}

View file

@ -361,10 +361,10 @@ template<class Chrom> class eoUBitXover: public eoQuadOp<Chrom>
{
if (chrom1[i] != chrom2[i] && eo::rng.flip(preference))
{
// bool tmp = chrom1[i];
// chrom1[i]=chrom2[i];
// chrom2[i] = tmp;
std::swap(chrom1[i], chrom2[i]);
bool tmp = chrom1[i];
chrom1[i]=chrom2[i];
chrom2[i] = tmp;
// std::swap(chrom1[i], chrom2[i]);
changed = true;
}
}