solver  1.0
Classes | Typedefs | Functions
VariableMappingILP.h File Reference

Mapping of integer, to be more precise binary, variables of the energy optimization problem. More...

#include <vector>
#include <utility>
#include "ILPSolver/VariableMappingLP.h"
+ Include dependency graph for VariableMappingILP.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  VariableMappingILP
 Mapping of continuous and binary variables. More...
 

Typedefs

using map2to1 = std::map< std::pair< uint32_t, uint32_t >, uint32_t >
 Mapping of variables indexed by two numbers.
 
using map4toN = std::map< std::pair< uint64_t, uint64_t >, std::vector< uint32_t > >
 Mapping of variables indexed by four numbers.
 

Functions

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. More...
 

Detailed Description

Mapping of integer, to be more precise binary, variables of the energy optimization problem.

Author
Libor Bukata

Definition in file VariableMappingILP.h.

Function Documentation

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.

Parameters
solutionA solution of the ILP problem.
mappingA mapping of some binary variables.
Returns
A map containing the indices (keys of mapping) of binary variables set to true.
1 // Solution of an ILP problem.
2 vector<double> sol = { 0.0, 0.0, 1.0, 0.0, 1.0, 0.0 };
3 // Mapping of variables, e.g. {{activity id, location id}, index}*.
4 map2to1 mapping = { {{0,0},0}, {{0,1},1}, {{0,2},2}, {{1,3},3}, {{1,4},4}, {{1,5},5} };
5 // It returns {{0,2}, {1,4}}, for our example above it means that locations
6 // with id 2 and 4 were selected for activities 0 and 1, respectively.
7 const auto& ret = inverseMapping(sol, mapping);