File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,10 @@ std::vector<GiaOp> GeneticStrategy::RunStrategy(
5656 rsz::Resizer* resizer,
5757 utl::Logger* logger)
5858{
59+ if (pop_size_ <= 0 ) {
60+ logger->error (RMP, 64 , " Population size should be greater than 0" );
61+ }
62+
5963 // Initial solution and slack
6064 debugPrint (logger,
6165 RMP,
@@ -139,10 +143,15 @@ std::vector<GiaOp> GeneticStrategy::RunStrategy(
139143 return absl::Bernoulli (random_, static_cast <double >(tourn_prob_));
140144 });
141145 if (winner != tournament.end ()) {
142- newPopulation.push_back (population[*winner]);
146+ newPopulation.emplace_back (population[*winner]);
143147 }
144148 }
145149 removeDuplicates (newPopulation, logger);
150+
151+ if (newPopulation.empty ()) {
152+ newPopulation.emplace_back (population.front ());
153+ }
154+
146155 population = std::move (newPopulation);
147156
148157 for (const auto & candidate : population) {
You can’t perform that action at this time.
0 commit comments