OptimizationRunnerFactory.cpp
Go to the documentation of this file.
1 
19 
20 #include "../typedef.hpp"
21 #include "TreeValidator.hpp"
22 #include "HeightChecker.hpp"
23 
24 #include "TopologyGenerator.hpp"
27 
28 #include "Evaluator.hpp"
29 #include "Tester.hpp"
30 
31 #include "utility/LogHelper.hpp"
32 //#include "utility/TopologyHelper.hpp"
33 #include "utility/SVGHelper.hpp"
34 
35 #include "OptimizationRunner.hpp"
36 #include "../combinatorial_optimization/HillClimbingAlogrithm.hpp"
37 #include "../combinatorial_optimization/SimulatedAnnealingAlgorithm.hpp"
38 #include "../combinatorial_optimization/ExponentialCoolingSchedule.hpp"
39 
40 namespace ISM {
41 
43  TopologyGeneratorParameters topologyGeneratorParams,
44  OptimizationAlgorithmParameters optimizationAlgorithmParameters,
45  CostFunctionParameters costFunctionParameters,
46  TreeValidatorParameters treeValidatorParams,
47  std::pair<PatternNameToObjectSet, PatternNameToObjectSet> testSets,
48  std::map<std::string, ISM::ObjectRelations> allObjectRelationsPerPattern,
49  DocumentationHelperPtr documentationHelper,
50  bool storeFullyMeshedISM,
51  bool storeStartTopologyISM)
52  {
53  TreeValidatorPtr treeValidator ;
54 
55  switch (treeValidatorParams.treeValidatorId)
56  {
57  case 0:
58  treeValidator = TreeValidatorPtr(new HeightChecker(treeValidatorParams.maxTreeHeight));
59  break;
60  default:
61  std::string errorMessage = std::to_string(treeValidatorParams.treeValidatorId)
62  + " is not a valid treeEvaluatorId!";
63  LogHelper::logMessage(errorMessage, LOG_ERROR);
64  throw std::runtime_error(errorMessage);
65  }
66 
67  EvaluatorPtr evaluator;
68  RecognizerPtr recognizer;
69  ObjectSetValidatorPtr objectSetValidator;
70 
71  switch (evaluatorParams.evaluatorId)
72  {
73  case 0:
74  recognizer = ISM::RecognizerPtr(new ISM::Recognizer("", evaluatorParams.binSize,
75  evaluatorParams.maxAngleDeviation, false));
76  objectSetValidator = ISM::ObjectSetValidatorPtr(new ObjectSetValidator(recognizer,
77  evaluatorParams.confidenceThreshold));
78  evaluator = EvaluatorPtr(new Tester(objectSetValidator, testSets.first, testSets.second,
79  evaluatorParams.testForFalseNegatives));
80  break;
81  default:
82  std::string errorMessage = std::to_string(evaluatorParams.evaluatorId) + " is not a valid evaluatorId!";
83  LogHelper::logMessage(errorMessage, LOG_ERROR);
84  throw std::runtime_error(errorMessage);
85  }
86 
87 
88  TopologyGeneratorPtr topologyGenerator;
89 
90  switch (topologyGeneratorParams.topologyGeneratorId)
91  {
92  case 0 :
93  topologyGenerator = TopologyGeneratorPaperPtr(new TopologyGeneratorPaper(allObjectRelationsPerPattern,
94  topologyGeneratorParams.maxNeighbourCount,
95  topologyGeneratorParams.swapRelations,
96  topologyGeneratorParams.removeRelations));
97  break;
98  case 1:
99  topologyGenerator = TopologyGeneratorNaivePtr(new TopologyGeneratorNaive(allObjectRelationsPerPattern,
100  topologyGeneratorParams.maxNeighbourCount));
101  break;
102  default :
103  std::string errorMessage = std::to_string(topologyGeneratorParams.topologyGeneratorId) +
104  " is not a valid successorGeneratorId!";
105  LogHelper::logMessage(errorMessage, LOG_ERROR);
106  throw std::runtime_error(errorMessage);
107  }
108 
109  TopologyManagerPtr topologyManager = TopologyManagerPtr(new TopologyManager(evaluator, treeValidator,
110  topologyGenerator, documentationHelper));
111 
113  topologyManager, documentationHelper,
114  optimizationAlgorithmParameters, costFunctionParameters,
115  storeFullyMeshedISM, storeStartTopologyISM
116  ));
117 
118  }
119 
120 }
121 
boost::shared_ptr< Recognizer > RecognizerPtr
Definition: Recognizer.hpp:171
boost::shared_ptr< TreeValidator > TreeValidatorPtr
boost::shared_ptr< TopologyGenerator > TopologyGeneratorPtr
static void logMessage(const std::string &message, LogLevel logLevel=LOG_INFO, const char *logColor=LOG_COLOR_DEFAULT)
Definition: LogHelper.cpp:96
boost::shared_ptr< ObjectSetValidator > ObjectSetValidatorPtr
boost::shared_ptr< DocumentationHelper > DocumentationHelperPtr
boost::shared_ptr< OptimizationRunner > OptimizationRunnerPtr
boost::shared_ptr< TopologyGeneratorPaper > TopologyGeneratorPaperPtr
boost::shared_ptr< TopologyGeneratorNaive > TopologyGeneratorNaivePtr
boost::shared_ptr< Evaluator > EvaluatorPtr
Definition: Evaluator.hpp:35
static OptimizationRunnerPtr createOptimizationRunner(EvaluatorParameters evaluatorParams, TopologyGeneratorParameters topologyGeneratorParams, OptimizationAlgorithmParameters optimizationAlgorithmParameters, CostFunctionParameters costFunctionParameters, TreeValidatorParameters treeValidatorParams, std::pair< PatternNameToObjectSet, PatternNameToObjectSet > testSets, std::map< std::string, ISM::ObjectRelations > allObjectRelationsPerPattern, DocumentationHelperPtr documentationHelper, bool storeFullyMeshedISM, bool storeStartTopologyISM)
this namespace contains all generally usable classes.
boost::shared_ptr< TopologyManager > TopologyManagerPtr


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:40