Belle II Software  release-06-02-00
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  deadCells = 0,
45  caRound = 1,
46  goodNeighbours = 0,
47  highestCellState = 0;
48 
49  // each iteration of following while loop is one CA-time-step
50  while (activeCells != 0 and caRound < stopInRound) {
51  activeCells = 0;
52 
54  // compare cells with inner neighbours:
55  for (auto* aNode : aNetworkContainer) {
56  auto& currentCell = aNode->getMetaInfo();
57  if (currentCell.isActivated() == false) { continue; }
58  goodNeighbours = 0;
59 
60  for (auto* aNeighbour : aNode->getInnerNodes()) {
61  // skip if neighbour has not the same state (NOTE if one wants to improve the versatility of the code,
62  // this should actually become a member of the cell-class, which then can add some extra
63  // stuff like checking for loops.
64  if (currentCell != aNeighbour->getMetaInfo()) continue;
65 
66  goodNeighbours++;
67  }
68  if (goodNeighbours != 0) {
69  currentCell.setStateUpgrade(true);
70  activeCells++;
71  } else {
72  // WARNING setActivationState does provoke unintended behavior, since sometimes states can not be
73  // upgraded in one round, but can in the next round!
74  /*currentCell.setActivationState(false);*/
75  deadCells++;
76  }
77  }
78 
80  for (auto* aNode : aNetworkContainer) {
81  auto& currentCell = aNode->getMetaInfo();
82  if (currentCell.isActivated() == false or currentCell.isUpgradeAllowed() == false) { continue; }
83 
84  currentCell.setStateUpgrade(false);
85  currentCell.increaseState();
86  if (currentCell.getState() > highestCellState) { highestCellState = currentCell.getState(); }
87  }
88 
90  if (BaseClass::m_validator.isValidRound(caRound) == false) {
91  break;
92  }
93 
94  caRound++;
95  } // CA main-loop
96 
97  return caRound;
98  }
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 104 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: