Belle II Software  release-08-01-10
CellularAutomaton< ContainerType, ValidatorType > Class Template Referencefinal

The CellularAutomaton class This class serves as a functor for the algorithm itself. More...

#include <CellularAutomaton.h>

Inheritance diagram for CellularAutomaton< ContainerType, ValidatorType >:
Collaboration diagram for CellularAutomaton< ContainerType, ValidatorType >:

Public Types

using BaseClass = TrackerAlgorithmBase< ContainerType, ValidatorType >
 typedef for the baseClass to get rid of the template arguments
 

Public Member Functions

 CellularAutomaton ()
 constructor
 
int apply (ContainerType &aNetworkContainer) override final
 actual algorithm of Cellular Automaton, returns number of rounds needed to finish or -1 if CA was aborted More...
 
unsigned int findSeeds (ContainerType &aNetworkContainer, bool strictSeeding=false) override final
 checks network given for seeds, returns number of seeds found (if strictSeeding is set to true, no subset of paths are stored, only unique ones). More...
 
virtual ValidatorType & getValidator ()
 getter More...
 
virtual std::string printStatistics ()
 returns current logging info of the algorithm (some stuff one wants to log about that algorithm
 
virtual void setValidator (ValidatorType &aValidator)
 setter More...
 

Public Attributes

unsigned int stopInRound = BaseClass::m_validator.nMaxIterations + 2
 aborts CA after stopInRound iterations - mainly for debugging purposes:
 

Protected Attributes

ValidatorType m_validator
 something which checks the quality of the test so far (will be applied by the apply-function
 

Detailed Description

template<class ContainerType, class ValidatorType>
class Belle2::CellularAutomaton< ContainerType, ValidatorType >

The CellularAutomaton class This class serves as a functor for the algorithm itself.

Definition at line 21 of file CellularAutomaton.h.

Member Function Documentation

◆ apply()

int apply ( ContainerType &  aNetworkContainer)
inlinefinaloverridevirtual

actual algorithm of Cellular Automaton, returns number of rounds needed to finish or -1 if CA was aborted

REDESIGNCOMMENT CELLULARAUTOMATON: optimization tip:

  • at the moment for each round the number of active cells is reduced, but the loop runs over all nodes/cells. TODO: Test Jakob's idea: Maybe its faster to recreate/refill an ActiveCell-List each round.

CAstep:

Updatestep:

catch bad case

Reimplemented from TrackerAlgorithmBase< ContainerType, ValidatorType >.

Definition at line 36 of file CellularAutomaton.h.

37  {
43  unsigned int activeCells = 1, // is set 1 because of following while loop.
44  caRound = 1,
45  goodNeighbours = 0,
46  highestCellState = 0;
47 
48  // each iteration of following while loop is one CA-time-step
49  while (activeCells != 0 and caRound < stopInRound) {
50  activeCells = 0;
51 
53  // compare cells with inner neighbours:
54  for (auto* aNode : aNetworkContainer) {
55  auto& currentCell = aNode->getMetaInfo();
56  if (currentCell.isActivated() == false) { continue; }
57  goodNeighbours = 0;
58 
59  for (auto* aNeighbour : aNode->getInnerNodes()) {
60  // skip if neighbour has not the same state (NOTE if one wants to improve the versatility of the code,
61  // this should actually become a member of the cell-class, which then can add some extra
62  // stuff like checking for loops.
63  if (currentCell != aNeighbour->getMetaInfo()) continue;
64 
65  goodNeighbours++;
66  }
67  if (goodNeighbours != 0) {
68  currentCell.setStateUpgrade(true);
69  activeCells++;
70  }
71  }
72 
74  for (auto* aNode : aNetworkContainer) {
75  auto& currentCell = aNode->getMetaInfo();
76  if (currentCell.isActivated() == false or currentCell.isUpgradeAllowed() == false) { continue; }
77 
78  currentCell.setStateUpgrade(false);
79  currentCell.increaseState();
80  if (currentCell.getState() > highestCellState) { highestCellState = currentCell.getState(); }
81  }
82 
84  if (BaseClass::m_validator.isValidRound(caRound) == false) {
85  break;
86  }
87 
88  caRound++;
89  } // CA main-loop
90 
91  return caRound;
92  }
unsigned int stopInRound
aborts CA after stopInRound iterations - mainly for debugging purposes:
ValidatorType m_validator
something which checks the quality of the test so far (will be applied by the apply-function

◆ findSeeds()

unsigned int findSeeds ( ContainerType &  aNetworkContainer,
bool  strictSeeding = false 
)
inlinefinaloverridevirtual

checks network given for seeds, returns number of seeds found (if strictSeeding is set to true, no subset of paths are stored, only unique ones).

WARNING: requires outerNodes to be set! (bidirectional network, not only directed to inner!).

Reimplemented from TrackerAlgorithmBase< ContainerType, ValidatorType >.

Definition at line 98 of file CellularAutomaton.h.

◆ getValidator()

virtual ValidatorType& getValidator ( )
inlinevirtualinherited

getter

returns the validator of the algorithm

Definition at line 28 of file TrackerAlgorithmBase.h.

28 { return m_validator; }

◆ setValidator()

virtual void setValidator ( ValidatorType &  aValidator)
inlinevirtualinherited

setter

allows to set some condition for validating the algorithm

Definition at line 35 of file TrackerAlgorithmBase.h.


The documentation for this class was generated from the following file: