25 #include "SolverConfig.h"
41 construct(generator, l.robots().size() > 1);
51 high_resolution_clock::time_point start = high_resolution_clock::now();
53 s.
runTime = duration_cast<duration<double>>(high_resolution_clock::now()-start).count();
56 if (sILP.
status == ILP_OPTIMAL || sILP.
status == ILP_FEASIBLE) {
62 set<uint32_t> selectedActivities;
69 if (idToStart.size() != idToDuration.size() && idToPoint.size() != idToPowerMode.size())
72 double minStartTime = F64_MAX;
73 for (
const auto& p : idToPoint) {
74 uint32_t aid = p.first, point = p.second;
75 uint32_t pwrm = getValue(idToPowerMode, aid, caller());
77 minStartTime = min(minStartTime, getValue(idToStart, aid, caller()));
78 selectedActivities.insert(aid);
81 for (
const auto& p : idToMovement) {
82 minStartTime = min(minStartTime, getValue(idToStart, p.first, caller()));
83 selectedActivities.insert(p.first);
86 for (
const uint32_t& aid : selectedActivities) {
87 double start = getValue(idToStart, aid, caller())-minStartTime;
88 double duration = getValue(idToDuration, aid, caller());
92 throw_with_nested(
SolverException(caller(),
"Cannot map ILP solution to the problem solution!\nCheck validity of the model..."));
95 }
else if (sILP.
status != ILP_UNKNOWN) {
103 double lowerBound = 0.0;
104 for (
Robot* r : robots) {
121 if (addGlobalConstraints)
129 string msg =
"Cannot add constraints to the ILP model!\nEither variable mapping or RoboticLine data-structure is corrupted!";
void initializeLocalEnvironments(int numberOfThreads)
It enables the solver to initialize all the data structures (e.g. expensive to construct) required fo...
void printStatistics() const
It prints various statistics like density of A matrix and number of constraints to the standard outpu...
double totalEnergy
The amount of energy required per robot cycle.
Generation of the (I)LP constraints.
The structure representing a solution found by an algorithm.
Instance of this class includes all the data structures and methods related to a robot.
std::vector< Variable > variables
Continuous variables of the problem with the well-specified domains.
uint32_t numberOfVariables() const
Total number of variables including both continuous and binary ones.
map4toN c
Binary variables used for collisions resolution.
RoboticLineSolverILP(Robot *r, const PrecalculatedMapping &m)
Integer Linear Programming problem is built from the robot.
VariableMappingILP mMapper
Mapping of both the continuous and binary variables.
double runTime
Run time (seconds) of the optimization algorithm required for obtaining this solution.
void addUniqueModeSelection(const map2to1 &x, map2to1 &z)
It calls addUniquePointSelection and addUniquePowerModeSelection methods.
State convert(const Status &ilpStatus)
Conversion between the ILP solver status and the solution state.
A general exception of the program.
std::vector< std::string > varDesc
Description of the continuous variables.
double RUNTIME_OF_LOWER_BOUND
Time limit for the tight lower bound.
Solution solve(double relGap=Settings::ILP_RELATIVE_GAP, double timLim=Settings::MAX_RUNTIME) const
ILP solver optimizes the energy consumption of the robotic cell until a stop criterion is reached...
std::vector< double > solution
The best found solution.
Various auxiliary functions used across the program.
bool VERBOSE
Boolean flag determining verbosity of the program.
Structure storing a solution of an Integer Linear Programming problem.
uint32_t NUMBER_OF_THREADS
Maximal number of threads to be used.
void addEnergyFunctions(const map1to1 &d, const map1to1 &W, const map2to1 &x, const map2to1 &z, const map2to1 &y)
It adds the energy functions of both the static and dynamic activities.
The file defines extended exceptions for the better error handling in the program.
std::vector< std::string > varDesc
Optional description of the variables.
An exact solver for the energy optimization problem.
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...
Solver-independent interface for solving Integer Linear Programming problems.
map1to1 s
Maps activity identification to the index of variable corresponding to the start time of this activit...
State status
Enum specifying whether the solution is optimal, feasible, or infeasible...
double criterion
The criterion value of the solution.
void addFlowConstraints(const map2to1 &x, const map2to1 &y)
Add flow preservation constraints ensuring that robot leaves the same location as it enters...
static double lowerBoundOnEnergy(const std::vector< Robot * > &robots, const PrecalculatedMapping &m)
A tight lower bound on the energy consumption.
double bound
The best known lower or upper bound.
It declares the namespace for program settings.
std::map< uint32_t, uint32_t > inverseMapping(const std::vector< double > &solution, const map2to1 &mapping)
It extracts the variables set to true and returns the ,,selected" indices.
void construct(ConstraintsGenerator &generator, bool addGlobalConstraints=true)
It builds the Integer Linear Programming problem corresponding to the energy optimization problem of ...
std::vector< double > c
Vector of the criterion coefficients.
void addAllPrecedences(const map1to1 &s, const map1to1 &d, const map2to1 &y, const map2to1 &w)
It calls all the methods related to the order of activities.
map1to1 W
Maps activity identification to the index of variable corresponding to the energy consumption of this...
void addGlobalConstraints(const map1to1 &s, const map1to1 &d, const map2to1 &x, const map2to1 &y, const map4toN &c)
Adds all the global constraints, i.e. time lags, spatial compatibility, and collision resolution...
map1to1 d
Maps activity identification to the index of variable corresponding to the duration of this activity...
Status status
Solution status, see Status enum.
std::vector< Variable > x
Variables of the problem.
void addDurationConstraints(const map1to1 &d, const map2to1 &z, const map2to1 &y)
It constructs all the constraints that limit the duration of activities.
double lowerBound
Lower bound on energy, i.e. there is not a solution consuming less energy than this number...
ILPModel mModel
The energy optimization of the robotic cell formulated as an Integer Linear Programming problem...
SolutionILP solveILP(const ILPModel &m, bool verbose, double gap=0.0, double timeLimit=0.0, int numberOfThreads=1, int threadId=0)
Integer Linear Programming solver is called to solve the problem and the solution is returned...
void checkFormulation() const
It checks that sizes of vectors and the matrix are valid.
The robotic cell corresponds to an instance of this class.
The structure contains the maps for fast searching in the robotic cell.
RoboticLineSolverILP class, declared in this file, addresses the energy optimization problem of robot...
uint64_t moveConstraintsToModel(ILPModel &m)
It efficiently moves all the generated constraints to the given model.
std::map< uint32_t, std::pair< double, double > > startTimeAndDuration
Mapping of the activity identification to its start time and duration.