TopologyGeneratorNaive.cpp
Go to the documentation of this file.
1 
19 #include "../utility/MathHelper.hpp"
20 
21 namespace ISM {
22 
23  TopologyGeneratorNaive::TopologyGeneratorNaive(const std::map<std::string, ISM::ObjectRelations> allObjectRelationsPerPattern,
24  int maxNeighbourCount)
25  : TopologyGenerator(allObjectRelationsPerPattern, maxNeighbourCount)
26  {
27  for (std::map<std::string, unsigned int>::iterator it = mNumRelationsPerPattern.begin();
28  it != mNumRelationsPerPattern.end();
29  ++it)
30  {
31  unsigned int numRelations = mNumRelationsPerPattern[it->first];
32  std::vector<unsigned int> keys;
33  for (unsigned int i = 0; i < numRelations; ++i)
34  {
35  keys.push_back(i);
36  }
37  mKeysPerPattern[it->first] = keys;
38  }
39  }
40 
41 
42  std::vector<std::vector<bool>> TopologyGeneratorNaive::calculateNeighbours(const std::string &pattern,
43  std::vector<bool> from)
44  {
45  unsigned int numberRelations = from.size() + 1;
46  std::vector<std::vector<bool>> topologies;
47  unsigned int numAllRelations = mNumRelationsPerPattern[pattern];
48  std::vector<unsigned int> keys = mKeysPerPattern[pattern];
49 
50  do
51  {
52  std::vector<bool> vec(numAllRelations, 0);
53  for (unsigned int i = 0; i < numberRelations; ++i) {
54  vec[keys[i]] = 1;
55  }
56  topologies.push_back(vec);
57  } while (MathHelper::getNextCombination(keys.begin(), keys.begin() + numberRelations, keys.end()));
58 
59  return topologies;
60  }
61 
63  {
64  std::stringstream s;
65  s << "TopologyGenerator is TopologyGeneratorNaive.cpp: " << std::endl
66  << "- Generates all possible relation topologies" << std::endl;
67  return s.str();
68  }
69 }
std::map< std::string, unsigned int > mNumRelationsPerPattern
std::map< std::string, std::vector< unsigned int > > mKeysPerPattern
static bool getNextCombination(const std::vector< unsigned int >::iterator first, std::vector< unsigned int >::iterator k, const std::vector< unsigned int >::iterator last)
Definition: MathHelper.hpp:31
std::vector< std::vector< bool > > calculateNeighbours(const std::string &pattern, std::vector< bool > from)
this namespace contains all generally usable classes.
TopologyGeneratorNaive(const std::map< std::string, ISM::ObjectRelations > allObjectRelationsPerPattern, int maxNeighbourCount)


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:41