21 #include "SolverConfig.h"
39 solStatus = INFEASIBLE;
49 vector<string> toPrint;
51 toPrint.emplace_back(
"Solution is "+
string(s.
status == OPTIMAL ?
"optimal" :
"feasible")+
".");
52 toPrint.emplace_back(
"Total energy consumed: "+to_string(s.
totalEnergy)+
" J");
54 toPrint.emplace_back(
"Lower bound on energy: "+to_string(s.
lowerBound)+
" J\n");
56 toPrint.emplace_back(
"");
59 string line =
"activity "+to_string(mit.first)+
": ";
60 line += to_string(mit.second.first)+
"+"+to_string(mit.second.second);
63 line +=
" (point="+to_string(sit->second.first)+
", mode="+to_string(sit->second.second)+
")";
64 toPrint.push_back(move(line));
68 toPrint.push_back(
"");
70 toPrint.push_back(
"Run time: "+to_string(s.
runTime)+
" s");
72 toPrint.push_back(
"Memory usage: "+to_string(s.
memUsage)+
" Bytes");
75 if (s.
status == INFEASIBLE)
76 toPrint.push_back(
"No feasible solution exists!");
78 toPrint.push_back(
"Solution not found!");
81 for (uint64_t l = 0; l < toPrint.size(); ++l) {
82 if (l+1 < toPrint.size())
83 out<<toPrint[l]<<endl;
110 ofstream out(file.c_str(), ofstream::out | ofstream::trunc);
112 throw SolverException(caller(),
"Cannot write to "+file+
" file! Please check permissions.");
115 out<<
"activity id, start time, duration, type, point, power saving mode, movement, energy"<<endl;
117 uint32_t aid = mit.first;
119 double start = mit.second.first, duration = mit.second.second;
121 out<<aid<<
", "<<start<<
", "<<duration<<
", ";
126 uint32_t point, powerMode;
129 point = p.first; powerMode = p.second;
132 string msg =
"Incomplete solution - cannot find selected point and power saving mode for activity "+to_string(aid)+
"!";
136 out<<
"STATIC, "<<point<<
", "<<powerMode<<
", NA, "<<sa->
energyConsumption(duration, loc->lid(), powerMode)<<endl;
142 out<<
"DYNAMIC, NA, NA, "<<mv->mid()<<
", "<<mv->
energyConsumption(duration)<<endl;
146 out<<(s.
status == INFEASIBLE ?
"No feasible solution exists!" :
"Solution not found!")<<endl;
166 ofstream resFile(pathToFile.c_str(), ofstream::app);
167 if (resFile.good()) {
169 resFile<<
"instance name, status, lower bound on energy, total energy, runtime [s]"<<endl;
171 resFile<<instanceName<<
", "<<s.
status<<
", ";
179 cerr<<
"Warning: Cannot open '"<<pathToFile<<
"' file for writing of results!"<<endl;
The instance of the class corresponds to a robot movement between two coordinates.
double totalEnergy
The amount of energy required per robot cycle.
The base class incorporating common properties of robot operations and movements. ...
The structure representing a solution found by an algorithm.
Collection of movements between two static activities.
double runTime
Run time (seconds) of the optimization algorithm required for obtaining this solution.
std::map< uint32_t, Location * > pointToLocation
Unique coordinate, i.e. a point, to the related location.
State convert(const Status &ilpStatus)
Conversion between the ILP solver status and the solution state.
A general exception of the program.
The structures and methods suitable for fast searching in the data structure of the robotic cell...
bool fileExists(const std::string &pathToFile)
It checks the existence of the file.
ostream & operator<<(ostream &out, const Solution &s)
It prints the solution to the output stream.
Various auxiliary functions used across the program.
The file defines extended exceptions for the better error handling in the program.
std::map< uint32_t, std::pair< uint32_t, uint32_t > > pointAndPowerMode
It maps the identification of a static activity to its assigned coordinate and used power saving mode...
Collection of locations in which a robot operation (or waiting) can be performed. ...
State status
Enum specifying whether the solution is optimal, feasible, or infeasible...
void writeBriefResultToCsvFile(const std::string &instanceName, const std::string &pathToFile, const Solution &s)
It writes the solution to the file in the same format as writeBriefResultToStream function...
Status
Constants specifying whether a solution is optimal, feasible, infeasible, unbounded, or undefined, respectively.
double memUsage
Memory usage (bytes) of the optimization algorithm, currently not used due to implementation issues...
double energyConsumption(double duration, const uint32_t &lid, const uint32_t &pid) const
Movement * getSelectedMovement(const Solution &s, const PrecalculatedMapping &m, DynamicActivity *da)
It extracts the selected movement of the given dynamic activity from the solution.
void writeSolutionToCsvFile(const string &file, const Solution &s, const PrecalculatedMapping &mapper)
It writes the solution to a csv file, the header is 'activity id, start time, duration, type, point, power saving mode, movement, energy'.
State
Enum declares constants specifying whether a found solution is optimal, feasible, infeasible...
double energyConsumption(const double &duration) const
A representation of the solution that is algorithm independent.
double lowerBound
Lower bound on energy, i.e. there is not a solution consuming less energy than this number...
void writeBriefResultToStream(std::ostream &OUT, const string &instanceName, const Solution &s)
It prints the solution as follows: 'instance name (state, runtime s): energy'.
Location of the robot used either during work (welding) or waiting.
The structure contains the maps for fast searching in the robotic cell.
std::map< uint32_t, Activity * > aidToActivity
Activity identification to its pointer.
std::map< uint32_t, std::pair< double, double > > startTimeAndDuration
Mapping of the activity identification to its start time and duration.