18 #ifndef HLIDAC_PES_PARALLEL_SOLVER_H
19 #define HLIDAC_PES_PARALLEL_SOLVER_H
113 const std::vector<Location*>& fixed,
bool writeCircuit =
true);
128 static double penaltyFunction(
const double& minCycle,
const double& demandedCycleTime);
136 uint32_t
selectAlternative(
const std::vector<CircuitRecord>& alternatives)
const;
147 double calculateNewCycleTime(
const uint32_t& threadId,
const double& currentCycleTime, std::vector<StaticActivity*>& alternative,
157 std::vector<std::vector<CircuitRecord>>& initialCircuits,
PrecalculatedCircuits& precalculatedCircuits);
207 std::vector<std::vector<std::vector<double>>>
mDist;
209 std::vector<std::vector<std::vector<int64_t>>>
mPreds;
211 std::vector<std::vector<std::vector<Location*>>>
mLocs;
std::vector< SpatialCmpTuple > mSortedSptCmp
The vector of spatial compatibility pairs heuristically sorted in decreasing order of difficulty...
RoboticLine mLine
Robotic cell to be optimized.
The structure representing a solution found by an algorithm.
void addRandomTuplesToKB(const uint32_t &threadId, const uint32_t &numOfTuples, std::vector< std::vector< CircuitRecord >> &initialCircuits, PrecalculatedCircuits &precalculatedCircuits)
It generates and adds a requested number of tuples to the KnowledgeBase.
ParallelHeuristicSolver(const RoboticLine &l, const PrecalculatedMapping &m)
It initializes the heuristic, i.e. preallocates some arrays, calculates the length of the tabu list...
Instance of this class includes all the data structures and methods related to a robot.
std::unordered_map< ShortestCircuit, HamiltonianCircuit< Location >> PrecalculatedCircuits
Mapping of ShortestCircuit to the related shortest closed path through locations. ...
std::vector< std::vector< CircuitRecord > > generateShortestCircuits(PrecalculatedCircuits &precalculatedCircuits)
It finds random alternatives for each robot and calculates their shortest closed paths through locati...
void workerThread(uint32_t threadId, std::vector< std::vector< CircuitRecord >> initialCircuits, PrecalculatedCircuits precalculatedCircuits)
The worker thread generates initial tuples, and optimizes them by local modifications proposed by sub...
double changeRobotPaths(uint32_t threadId, const CircuitTuple &t, PartialSolution &ps, const std::vector< std::vector< Location * >> &fixed)
It randomly modifies the robot paths to enable the heuristic to search otherwise unreachable parts of...
std::atomic< bool > mFeasible
Used to stop other OpenMP threads if the instance infeasibility is detected by a thread.
PrecalculatedMapping mMapping
Fast searching in the data structure of the robotic cell.
static double penaltyFunction(const double &minCycle, const double &demandedCycleTime)
The function expressing the risk of exceeding the robot cycle time depending on its lower estimation...
Declares LP solver which deals with partially fixed energy optimization problems created by the paral...
Solution solve()
It optimizes the robotic cell and returns the best found solution.
std::vector< CircuitRecord > generateRandomAlternatives(const uint32_t &threadId, const Graph &g, const DistanceMatrix< double > &m)
Generates some random alternatives, i.e. candidates for a feasible order, from a distance graph and d...
uint32_t selectAlternative(const std::vector< CircuitRecord > &alternatives) const
It randomly selects a robot alternative according to a distribution function that slightly prefers th...
void controlThread()
Generates various alternatives, launches worker threads, prints progress info, joins the workers...
std::atomic< bool > mStopCondition
The control thread sets this flag to true to stop all the worker threads.
Protected access to the shared data of the threads of the parallel heuristic.
Various data structures used by the heuristic.
uint32_t mTabuListSize
The number of tabu list elements calculated in the constructor.
The optimization sub-heuristics and Linear Programming solver for partially fixed problems...
std::vector< std::vector< std::vector< Location * > > > mLocs
Preallocated 2-D array of locations for getShortestCircuit method, indexed by thread.
double mRuntime
The runtime of this heuristic, updated from time to time.
Defines the optimization part of the parallel heuristic, i.e. sub-heuristics and the evaluation of tu...
A partially fixed problem, i.e. tuple.
double calculateNewCycleTime(const uint32_t &threadId, const double ¤tCycleTime, std::vector< StaticActivity * > &alternative, std::vector< Location * > &fixed, Location *toFix, PrecalculatedCircuits &precalculatedCircuits)
A highly optimized function calculates a lower estimation on the robot cycle time if toFix location i...
std::vector< std::vector< std::vector< double > > > mDist
Preallocated 2-D array of distances for getShortestCircuit method, indexed by thread.
Fixed locations, power saving modes, and movements.
Graph constructMinimalDurationGraph(Robot *r) const
Generates a distance graph for the given robot.
DistanceMatrix< double > createInitialDistanceMatrix(const Graph &g) const
It creates an initial matrix of distances based on edge lengths.
KnowledgeBase mKB
Various data of the heuristic, e.g. generated tuples, performance statistics, etc.
void generatePromisingTuples(const uint32_t &threadId)
It generates promising tuples and adds them to the KnowledgeBase.
A parallel heuristic for the energy optimization of robotic cells.
Universal algorithms like Floyd-Warshall, Golden Search, etc.
A graph in which random alternatives will be searched for.
Declares the class storing the best found solutions, tuples, and information about the heuristic perf...
void writePerformanceRecordToLogFile(const double &initializationTime, const double &finalRuntime)
It writes various statistics about the heuristic performance to a CSV file.
HamiltonianCircuit< Location > getShortestCircuit(const uint32_t &threadId, const std::vector< StaticActivity * > &circuit, const std::vector< Location * > &fixed, bool writeCircuit=true)
It calculates the shortest circuit through locations that visits each static activity in the same ord...
std::vector< std::vector< std::vector< int64_t > > > mPreds
Preallocated 2-D array of predecessors for getShortestCircuit method, indexed by thread.
void printProgressInfo(const double ¤tRuntime)
Prints various information about the performance of the sub-heuristics, generation of tuples...
std::vector< std::vector< T >> DistanceMatrix
Definition of the matrix data type.
Location of the robot used either during work (welding) or waiting.
The robotic cell corresponds to an instance of this class.
The structure contains the maps for fast searching in the robotic cell.
HeuristicAlgorithms algo
Optimization sub-heuristics and the related Linear Programming solver for partially fixed problems...