fix(moRndVectorVNSelection): use shuffle for modern compilers

This commit is contained in:
Johann Dreo 2024-09-05 14:42:40 +02:00
commit 51be7e324b

View file

@ -52,7 +52,7 @@ public:
/** /**
* Default constructor with first search heuristics * Default constructor with first search heuristics
* *
* @param _firstLS first local search * @param _firstLS first local search
* @param _firstShake first heuristic which perturbs the solution * @param _firstShake first heuristic which perturbs the solution
* @param _cycle when true, the first heuristics follows the last ones. Otherwise the search stop. * @param _cycle when true, the first heuristics follows the last ones. Otherwise the search stop.
*/ */
@ -67,7 +67,7 @@ public:
} }
/** /**
* test if there is still some heuristics * test if there is still some heuristics
* *
* @param _solution the current solution * @param _solution the current solution
* @return true if there is some heuristics * @return true if there is some heuristics
@ -83,11 +83,17 @@ public:
*/ */
virtual void init(EOT& /*_solution*/) { virtual void init(EOT& /*_solution*/) {
if(order.size() == 0) if(order.size() == 0)
for(unsigned int i = 0; i < LSvector.size(); i++) for(unsigned int i = 0; i < LSvector.size(); i++) {
order.push_back(i); order.push_back(i); }
#if __cplusplus >= 201103L
std::random_device rd;
std::mt19937 gen(rd());
std::shuffle(order.begin(), order.end(), gen);
#else
UF_random_generator<unsigned int> gen(order.size()); UF_random_generator<unsigned int> gen(order.size());
std::random_shuffle(order.begin(), order.end(), gen); std::random_shuffle(order.begin(), order.end(), gen);
#endif
currentOrder = 0; currentOrder = 0;
current = order[currentOrder]; current = order[currentOrder];