SVGHelper.hpp
Go to the documentation of this file.
1 
18 #pragma once
19 
20 #include "limits"
21 
22 #include <boost/filesystem/path.hpp>
23 #include <boost/shared_ptr.hpp>
24 #include <boost/property_tree/ptree.hpp>
25 #include <boost/property_tree/xml_parser.hpp>
26 
27 #include "../combinatorial_trainer/ObjectRelation.hpp"
28 #include "../combinatorial_trainer/EvaluationResult.hpp"
29 #include "../combinatorial_trainer/Topology.hpp"
30 #include "../combinatorial_trainer/EvaluationResult.hpp"
31 #include "../combinatorial_optimization/CostFunction.hpp"
32 
33 namespace ISM
34 {
35 using boost::filesystem::path;
36 using boost::property_tree::ptree;
37 
38 
39 class SVGHelper
40 {
41  public:
42  SVGHelper(path outputPath) : mOutputPath(outputPath) {}
43 
44  void writeResult();
45 
46  void processHistory(std::vector<std::vector<std::pair<TopologyPtr, unsigned int>>>& history,
47  CostFunctionPtr<TopologyPtr> globalCostFunction, const std::string& patternName);
48 
49  private:
52 
53  std::string identifier;
54  unsigned int index;
55  double cost;
56 
57  int y = 0;
58  int x = 0;
59  };
60 
62  std::vector<TopologyContainer> evaluatedTopologies;
63  int selectedTopologyIndex = -1;
64  unsigned int selectedTopologyType = 0;
65  };
66 
67  struct OptimizationRun {
68  std::vector<OptimizationRound> allRounds;
69 
70  double minCost;
71  double maxCost;
72 
75 
76  int lastSelectedIndex = -1;
77  };
78 
79  const std::string ATR_CHOSEN_INDEX = "chosen_index";
80  const std::string ATR_ROUND_NUMBER = "round_number";
81  const std::string ATR_EVALUATION_RESULT = "evaluation_result";
82  const std::string ATR_PATTERN_NAME = "pattern_name";
83  const std::string ATR_RELATION_IDS = "relation_ids";
84 
85  const std::string NAME_TOPOLOGY = "topology";
86  const std::string NAME_ROUND = "round";
87  const std::string NAME_OPTIMIZATION_RUN = "optimization-run";
88 
89  const std::string COLOR_FIRST_HIGHLIGHT = "aqua";
90  const std::string COLOR_LAST_HIGHLIGHT = "blue";
91  const std::string COLOR_HIGHLIGHT = "cornflowerblue";
92  const std::string COLOR_BEST = "purple";
93 
94  const std::string COLOR_RANDOM_WALK_HIGHLIGHT = "black";
95  const std::string COLOR_RANDOM_RESTART_HIGHLIGHT = "black";
96 
97  const unsigned int MIN_CIRCLE_RADIUS = 100;
98  const unsigned int MAX_CIRCLE_RADIUS = 160;
99  const unsigned int PADDING = 20;
100  const unsigned int FONT_SIZE = 30;
101  const unsigned int HIGHLIGHT_WIDTH = 7;
102  const unsigned int LINE_WIDTH = 6;
103 
104  const unsigned int MAX_TOPOLOGIES_PER_LINE = 12;
105 
107 
110  std::string mCurrentPatternName;
111  std::vector<OptimizationRound> mAllEvaluationRounds;
112  std::map<std::string, std::vector<OptimizationRun>> mPatternNameToOptimizationRuns;
113 
114  std::vector<ptree> createSVG(std::vector<OptimizationRun> optimizationRuns);
115  ptree genCircleSVG(double radius, int x, int y, const std::string& circleColor,
116  bool highlight, const std::string& highlightColor);
117  ptree genPolylineSVG(std::vector<std::string> linePoints);
118  ptree genTextSVG(const std::string& lineOne, const std::string& lineTwo,
119  const std::string& lineThree, int x, int y);
120  ptree genRectSVG(int x, int y, unsigned int width,
121  unsigned int height, const std::string& colorString);
122  ptree genSeparatorLineSVG(int y, int x1, int x2);
123 
124  ptree createXML(const std::string& patternName);
126  ptree genEvaluationRoundXML(unsigned int roundNumber, unsigned int chosenIndex);
127 
128  std::string genRGBString(double cost, double minCost, double maxCost);
129 
130  double calculateCircleRadius(double evaluationDuration,
131  double minEvaluationDuration,
132  double maxEvaluationDuration);
133 
134  std::vector<int> calculateXValues(unsigned int numTopologies, unsigned int imageWidth);
135 
136  void calculatePositions(std::vector<OptimizationRun>& optimizationRuns,
137  std::vector<std::vector<int>>& seperatorLinePositions,
138  unsigned int& imgWidth, unsigned int& imgHeight);
139 
140 }; typedef boost::shared_ptr<SVGHelper> SVGHelperPtr;
141 
142 }
const std::string ATR_CHOSEN_INDEX
Definition: SVGHelper.hpp:79
const unsigned int MIN_CIRCLE_RADIUS
Definition: SVGHelper.hpp:97
double calculateCircleRadius(double evaluationDuration, double minEvaluationDuration, double maxEvaluationDuration)
Definition: SVGHelper.cpp:519
std::string mCurrentPatternName
Definition: SVGHelper.hpp:110
const std::string ATR_PATTERN_NAME
Definition: SVGHelper.hpp:82
boost::shared_ptr< CostFunction< InstanceType >> CostFunctionPtr
const unsigned int MAX_CIRCLE_RADIUS
Definition: SVGHelper.hpp:98
std::map< std::string, std::vector< OptimizationRun > > mPatternNameToOptimizationRuns
Definition: SVGHelper.hpp:112
void calculatePositions(std::vector< OptimizationRun > &optimizationRuns, std::vector< std::vector< int >> &seperatorLinePositions, unsigned int &imgWidth, unsigned int &imgHeight)
Definition: SVGHelper.cpp:141
ptree createXML(const std::string &patternName)
Definition: SVGHelper.cpp:455
ptree genCircleSVG(double radius, int x, int y, const std::string &circleColor, bool highlight, const std::string &highlightColor)
Definition: SVGHelper.cpp:355
std::vector< TopologyContainer > evaluatedTopologies
Definition: SVGHelper.hpp:62
const unsigned int LINE_WIDTH
Definition: SVGHelper.hpp:102
std::string patternName
const std::string ATR_EVALUATION_RESULT
Definition: SVGHelper.hpp:81
const unsigned int FONT_SIZE
Definition: SVGHelper.hpp:100
const std::string NAME_OPTIMIZATION_RUN
Definition: SVGHelper.hpp:87
const unsigned int MAX_TOPOLOGIES_PER_LINE
Definition: SVGHelper.hpp:104
boost::shared_ptr< SVGHelper > SVGHelperPtr
Definition: SVGHelper.hpp:140
const std::string ATR_ROUND_NUMBER
Definition: SVGHelper.hpp:80
void writeResult()
Definition: SVGHelper.cpp:85
const std::string COLOR_BEST
Definition: SVGHelper.hpp:92
ptree genTextSVG(const std::string &lineOne, const std::string &lineTwo, const std::string &lineThree, int x, int y)
Definition: SVGHelper.cpp:371
ptree genTopologyContainerXML(TopologyContainer tc)
Definition: SVGHelper.cpp:476
const std::string COLOR_RANDOM_WALK_HIGHLIGHT
Definition: SVGHelper.hpp:94
const std::string COLOR_HIGHLIGHT
Definition: SVGHelper.hpp:91
std::vector< OptimizationRound > mAllEvaluationRounds
Definition: SVGHelper.hpp:111
std::vector< int > calculateXValues(unsigned int numTopologies, unsigned int imageWidth)
Definition: SVGHelper.cpp:107
const std::string ATR_RELATION_IDS
Definition: SVGHelper.hpp:83
SVGHelper(path outputPath)
Definition: SVGHelper.hpp:42
ptree genRectSVG(int x, int y, unsigned int width, unsigned int height, const std::string &colorString)
Definition: SVGHelper.cpp:441
const std::string COLOR_FIRST_HIGHLIGHT
Definition: SVGHelper.hpp:89
const std::string COLOR_RANDOM_RESTART_HIGHLIGHT
Definition: SVGHelper.hpp:95
std::vector< ptree > createSVG(std::vector< OptimizationRun > optimizationRuns)
Definition: SVGHelper.cpp:229
ptree genSeparatorLineSVG(int y, int x1, int x2)
Definition: SVGHelper.cpp:406
const unsigned int HIGHLIGHT_WIDTH
Definition: SVGHelper.hpp:101
ptree genPolylineSVG(std::vector< std::string > linePoints)
Definition: SVGHelper.cpp:420
ptree genEvaluationRoundXML(unsigned int roundNumber, unsigned int chosenIndex)
Definition: SVGHelper.cpp:484
this namespace contains all generally usable classes.
OptimizationRound mCurrentOptimizationRound
Definition: SVGHelper.hpp:108
OptimizationRun mCurrentOptimizationRun
Definition: SVGHelper.hpp:109
const std::string NAME_ROUND
Definition: SVGHelper.hpp:86
void processHistory(std::vector< std::vector< std::pair< TopologyPtr, unsigned int >>> &history, CostFunctionPtr< TopologyPtr > globalCostFunction, const std::string &patternName)
Definition: SVGHelper.cpp:29
const std::string NAME_TOPOLOGY
Definition: SVGHelper.hpp:85
std::string genRGBString(double cost, double minCost, double maxCost)
Definition: SVGHelper.cpp:493
std::vector< OptimizationRound > allRounds
Definition: SVGHelper.hpp:68
const unsigned int PADDING
Definition: SVGHelper.hpp:99
const std::string COLOR_LAST_HIGHLIGHT
Definition: SVGHelper.hpp:90


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