solver  1.0
PrecalculatedMapping.h
Go to the documentation of this file.
1 /*
2  This file is part of the EnergyOptimizatorOfRoboticCells program.
3 
4  EnergyOptimizatorOfRoboticCells is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  EnergyOptimizatorOfRoboticCells is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with EnergyOptimizatorOfRoboticCells. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef HLIDAC_PES_PRECALCULATED_MAPPING_H
19 #define HLIDAC_PES_PRECALCULATED_MAPPING_H
20 
27 #include <map>
28 #include <set>
29 #include <vector>
30 #include <utility>
31 #include <unordered_map>
32 #include "RoboticLine.h"
33 #include "Shared/Utils.h"
34 #include "Solution/Solution.h"
35 
44 namespace std {
46  template <>
47  struct hash<pair<uint32_t, uint32_t>> {
48  size_t operator() (const pair<uint32_t, uint32_t>& p) const {
49  hash<uint64_t> h;
50  uint64_t v64 = pack(p.first, p.second);
51  return h(v64);
52  }
53  };
54 
56  template <>
57  struct hash<pair<Location*, Location*>> {
58  size_t operator() (const pair<Location*, Location*>& p) const {
59  hash<uint64_t> h;
60  uint64_t v64 = pack(p.first->point(), p.second->point());
61  return h(v64);
62  }
63  };
64 }
66 
68 using SpatialCmpTuple = std::tuple<uint32_t, uint32_t, StaticActivity*, StaticActivity*, std::vector<std::pair<Location*, Location*>>>;
69 
78  std::map<uint32_t, Activity*> aidToActivity;
80  std::map<uint32_t, Location*> pointToLocation;
82  std::unordered_map<std::pair<uint32_t, uint32_t>, Movement*> pointsToMovement;
84  std::unordered_map<std::pair<Location*, Location*>, Movement*> locationsToMovement;
86  std::map<uint32_t, std::vector<uint32_t> > pointToPredecessorPoints;
88  std::map<uint32_t, std::vector<uint32_t> > pointToSuccessorPoints;
90  std::map<StaticActivity*, std::map<StaticActivity*, std::vector<std::pair<Location*, Location*>>>> sptComp;
92  std::vector<SpatialCmpTuple> sptCompVec;
94  std::map<Movement*, std::tuple<std::vector<double>, std::vector<double>>> mvToEnergyFunc;
96  std::map<std::pair<Location*, RobotPowerMode*>, std::tuple<std::vector<double>, std::vector<double>>> locToEnergyFunc;
98  std::map<ActivityMode*, std::set<ActivityMode*>> collisionSearch;
100  std::map<Activity*, std::vector<TimeLag>> timeLagsFromAct;
102  std::map<Activity*, std::vector<TimeLag>> timeLagsToAct;
103 };
104 
113 
121 template <class X, class Y>
122 extern std::vector<Movement*> findMovements(X from, Y to);
123 
124 #endif
The instance of the class corresponds to a robot movement between two coordinates.
Definition: RoboticLine.h:133
The structure representing a solution found by an algorithm.
Definition: Solution.h:50
std::map< std::pair< Location *, RobotPowerMode * >, std::tuple< std::vector< double >, std::vector< double > > > locToEnergyFunc
Location and the selected power saving mode are mapped to the linear energy function, i.e. the size of each vector in the tuple is 2.
Collection of movements between two static activities.
Definition: RoboticLine.h:261
std::map< Activity *, std::vector< TimeLag > > timeLagsFromAct
It searches for all the time lags starting from the given activity.
std::map< uint32_t, Location * > pointToLocation
Unique coordinate, i.e. a point, to the related location.
STL namespace.
std::vector< SpatialCmpTuple > sptCompVec
Enables to fast iterate through spatial compatibility elements.
std::vector< Movement * > findMovements(X from, Y to)
It finds all the movements located between from and to and returns them in the vector.
std::map< StaticActivity *, std::map< StaticActivity *, std::vector< std::pair< Location *, Location * > > > > sptComp
Two-step mapping taking two static activities and returning a list of compatible pairs of locations...
Various auxiliary functions used across the program.
uint64_t pack(const uint32_t &v1, const uint32_t &v2)
It packs two uint32_t numbers to uint64_t data type.
Definition: Utils.cpp:26
std::map< ActivityMode *, std::set< ActivityMode * > > collisionSearch
It finds colliding movements and locations for a given location or movement.
Movement * getSelectedMovement(const Solution &s, const PrecalculatedMapping &m, DynamicActivity *da)
It extracts the selected movement of the given dynamic activity from the solution.
std::map< Movement *, std::tuple< std::vector< double >, std::vector< double > > > mvToEnergyFunc
It takes a pointer to a movement and returns the vector of precalculated coordinates corresponding to...
std::map< uint32_t, std::vector< uint32_t > > pointToPredecessorPoints
It finds all the starting coordinates of the movements entering the given coordinate, i.e. the point.
std::map< uint32_t, std::vector< uint32_t > > pointToSuccessorPoints
It finds all the ending coordinates of the movements leaving the given coordinate, i.e. the point.
std::map< Activity *, std::vector< TimeLag > > timeLagsToAct
It searches for all the time lags ending in the given activity.
A representation of the solution that is algorithm independent.
Location of the robot used either during work (welding) or waiting.
Definition: RoboticLine.h:192
The structure contains the maps for fast searching in the robotic cell.
std::unordered_map< std::pair< uint32_t, uint32_t >, Movement * > pointsToMovement
Two coordinates are mapped to the movement starting/ending at the first/second coordinate, respectively.
The file contains various classes devoted to abstract representation of the robotic cell...
std::unordered_map< std::pair< Location *, Location * >, Movement * > locationsToMovement
It finds the movement between two locations if exists.
std::map< uint32_t, Activity * > aidToActivity
Activity identification to its pointer.
std::tuple< uint32_t, uint32_t, StaticActivity *, StaticActivity *, std::vector< std::pair< Location *, Location * >>> SpatialCmpTuple
Defines the data type for an element of the spatial compatibility, i.e. (rob1 idx, rob2 idx, act1, act2, {{loc1, loc2}*}).