Belle II Software  release-05-02-19
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 31 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 46 of file CellularAutomaton.h.

52  {
53  activeCells = 0;
54 
56  // compare cells with inner neighbours:
57  for (auto* aNode : aNetworkContainer) {
58  auto& currentCell = aNode->getMetaInfo();
59  if (currentCell.isActivated() == false) { continue; }
60  goodNeighbours = 0;
61 
62  for (auto* aNeighbour : aNode->getInnerNodes()) {
63  // skip if neighbour has not the same state (NOTE if one wants to improve the versatility of the code,
64  // this should actually become a member of the cell-class, which then can add some extra
65  // stuff like checking for loops.
66  if (currentCell != aNeighbour->getMetaInfo()) continue;
67 
68  goodNeighbours++;
69  }
70  if (goodNeighbours != 0) {
71  currentCell.setStateUpgrade(true);
72  activeCells++;
73  } else {
74  // WARNING setActivationState does provoke unintended behavior, since sometimes states can not be
75  // upgraded in one round, but can in the next round!
76  /*currentCell.setActivationState(false);*/
77  deadCells++;
78  }
79  }
80 
82  for (auto* aNode : aNetworkContainer) {
83  auto& currentCell = aNode->getMetaInfo();
84  if (currentCell.isActivated() == false or currentCell.isUpgradeAllowed() == false) { continue; }
85 
86  currentCell.setStateUpgrade(false);
87  currentCell.increaseState();
88  if (currentCell.getState() > highestCellState) { highestCellState = currentCell.getState(); }
89  }
90 
92  if (BaseClass::m_validator.isValidRound(caRound) == false) {
93  break;
94  }
95 
96  caRound++;
97  } // CA main-loop
98 
99  return caRound;
100  }
101 
102 
106  unsigned int findSeeds(ContainerType& aNetworkContainer, bool strictSeeding = false) override final
107  {
108  unsigned int nSeeds = 0;

◆ 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 114 of file CellularAutomaton.h.

◆ getValidator()

virtual ValidatorType& getValidator ( )
inlinevirtualinherited

getter

returns the validator of the algorithm

Definition at line 38 of file TrackerAlgorithmBase.h.

40 { return 0; }

◆ setValidator()

virtual void setValidator ( ValidatorType &  aValidator)
inlinevirtualinherited

setter

allows to set some condition for validating the algorithm

Definition at line 45 of file TrackerAlgorithmBase.h.


The documentation for this class was generated from the following file:
Belle2::CellularAutomaton::findSeeds
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,...
Definition: CellularAutomaton.h:114
Belle2::TrackerAlgorithmBase::m_validator
ValidatorType m_validator
something which checks the quality of the test so far (will be applied by the apply-function
Definition: TrackerAlgorithmBase.h:33