mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Hadrons: size fix for module graph with one vertex
This commit is contained in:
parent
84fa2bdce6
commit
78198d1b04
@ -274,6 +274,7 @@ Graph<unsigned int> Environment::makeModuleGraph(void) const
|
||||
|
||||
for (unsigned int i = 0; i < module_.size(); ++i)
|
||||
{
|
||||
moduleGraph.addVertex(i);
|
||||
for (auto &j: moduleInput_[i])
|
||||
{
|
||||
moduleGraph.addEdge(objectModule_[j], i);
|
||||
|
@ -183,7 +183,7 @@ template <typename T>
|
||||
void GeneticScheduler<T>::crossover(const std::vector<T> &p1,
|
||||
const std::vector<T> &p2)
|
||||
{
|
||||
std::uniform_int_distribution<unsigned int> dis(1, p1.size() - 2);
|
||||
std::uniform_int_distribution<unsigned int> dis(0, p1.size() - 1);
|
||||
unsigned int cut = dis(gen_);
|
||||
std::vector<T> c1, c2, buf;
|
||||
|
||||
@ -211,7 +211,7 @@ void GeneticScheduler<T>::crossover(const std::vector<T> &p1,
|
||||
template <typename T>
|
||||
void GeneticScheduler<T>::mutation(std::vector<T> &c)
|
||||
{
|
||||
std::uniform_int_distribution<unsigned int> dis(1, c.size() - 2);
|
||||
std::uniform_int_distribution<unsigned int> dis(0, c.size() - 1);
|
||||
unsigned int cut = dis(gen_);
|
||||
Graph<T> g = graph_;
|
||||
std::vector<T> buf;
|
||||
@ -220,7 +220,10 @@ void GeneticScheduler<T>::mutation(std::vector<T> &c)
|
||||
{
|
||||
g.removeVertex(c[i]);
|
||||
}
|
||||
buf = g.topoSort(gen_);
|
||||
if (g.size() > 0)
|
||||
{
|
||||
buf = g.topoSort(gen_);
|
||||
}
|
||||
for (unsigned int i = cut; i < c.size(); ++i)
|
||||
{
|
||||
buf.push_back(c[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user