19 #include "SolverConfig.h"
25 constexpr
double BOOL_TOL = 0.001;
33 throw_with_nested(
SolverException(caller(),
"Mapping keys are not unique!"));
39 for (
Robot* r : l.robots())
42 for (
Robot* r : l.robots()) {
49 throw_with_nested(
SolverException(caller(),
"Activity identifications are not unique!"));
54 uint32_t varCount = VariableMappingLP::numberOfVariables();
55 varCount +=
x.size()+
z.size()+
y.size()+
w.size();
56 for (
const auto& p :
c)
57 varCount += p.second.size();
64 for (
Activity* a : r->activities()) {
67 for (
Location* l : sa->locations()) {
69 varDesc.emplace_back(
"x_{"+to_string(sa->aid())+
"}#{"+to_string(l->point())+
"}");
70 setValue(
x, {sa->aid(), l->point()}, idx++, caller());
75 varDesc.emplace_back(
"z_{"+to_string(sa->aid())+
"}#{"+to_string(pm->pid())+
"}");
76 setValue(
z, {sa->aid(), pm->pid()}, idx++, caller());
82 for (
Movement* mv : da->movements()) {
84 varDesc.emplace_back(
"y_{"+to_string(da->aid())+
"}#{"+to_string(mv->mid())+
"}");
85 setValue(
y, {da->aid(), mv->mid()}, idx++, caller());
93 for (
Activity* a : r->activities()) {
95 if (da !=
nullptr && da->
optional()) {
98 varDesc.emplace_back(
"w_{"+to_string(da->aid())+
"}#{"+to_string(da->successor()->aid())+
"}");
99 setValue(
w, {da->aid(), da->successor()->aid()}, idx++, caller());
106 for (
const pair<ActivityMode*, ActivityMode*>& col : l.collisions()) {
107 int32_t numberOfRobots = l.robots().size();
109 assert(am1->baseParent() !=
nullptr && am2->baseParent() !=
nullptr &&
"Unexpected null pointers!");
110 const Activity *act1 = am1->baseParent(), *act2 = am2->baseParent();
111 for (int32_t r = -numberOfRobots; r <= numberOfRobots; ++r) {
112 uint32_t m1 = am1->id(), m2 = am2->id();
113 uint32_t a1 = act1->aid(), a2 = act2->aid();
116 varDesc.emplace_back(
"c_{"+to_string(a1)+
","+to_string(m1)+
"}#{"+to_string(a2)+
","+to_string(m2)+
"}#{" +to_string(r)+
"}");
117 c[{
pack(a1,m1),
pack(a2,m2)}].push_back(idx++);
123 map<uint32_t, uint32_t> m;
124 for (
const auto& p : mapping) {
125 if (abs(solution[p.second]-1.0) < BOOL_TOL)
126 setValue(m, p.first.first, p.first.second, caller());
The instance of the class corresponds to a robot movement between two coordinates.
The base class incorporating common properties of robot operations and movements. ...
Instance of this class includes all the data structures and methods related to a robot.
void addActivities(const std::vector< Activity * > &activities, bool mandatory, bool mapW=true)
It adds the mapping for extra activities.
virtual bool optional() const
It returns whether this dynamic activity is optional, i.e. may or may not be performed.
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.
void addActivityBinaryVariables(Robot *r)
It creates the mapping for x, z, and y variables.
Collection of movements between two static activities.
void addActivityOrderBinaryVariables(Robot *r)
It constructs the mapping for w variables.
A general exception of the program.
Mapping of continuous variables occurring in the energy optimization problem.
std::vector< std::string > varDesc
Description of the continuous variables.
Various auxiliary functions used across the program.
void addCollisionBinaryVariables(const RoboticLine &l)
Mapping of c variables is created.
uint64_t pack(const uint32_t &v1, const uint32_t &v2)
It packs two uint32_t numbers to uint64_t data type.
Collection of locations in which a robot operation (or waiting) can be performed. ...
VariableMappingILP(Robot *r)
Constructs the mapping of all the variables related to robot r.
It represents the power saving mode of the robot.
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.
Either a movement or location.
Location of the robot used either during work (welding) or waiting.
The robotic cell corresponds to an instance of this class.
Mapping of integer, to be more precise binary, variables of the energy optimization problem...
Structure containing information about the variable.
std::map< std::pair< uint32_t, uint32_t >, uint32_t > map2to1
Mapping of variables indexed by two numbers.