solver  1.0
ILPModel.h
Go to the documentation of this file.
1 /*
2  This file is part of the EnergyOptimizatorOfRoboticCells program.
3 
4  EnergyOptimizatorOfRoboticCells is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  EnergyOptimizatorOfRoboticCells is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with EnergyOptimizatorOfRoboticCells. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef HLIDAC_PES_ILP_MODEL_H
19 #define HLIDAC_PES_ILP_MODEL_H
20 
27 #include <string>
28 #include <vector>
29 #include "SparseMatrix.h"
31 
33 enum Objective {
34  MINIMIZE, MAXIMIZE
35 };
36 
39  FLT, BIN, INT
40 };
41 
43 enum Operator {
44  LESS_EQUAL, EQUAL, GREATER_EQUAL
45 };
46 
48 struct Variable {
49  Variable(VariableType t = FLT, double lb = F64_MIN, double ub = F64_MAX) : type(t), lowerBound(lb), upperBound(ub) { }
50 
54  double lowerBound;
56  double upperBound;
57 };
58 
69 struct ILPModel {
70  ILPModel(Objective obj = MINIMIZE) : obj(obj) { }
71  size_t numberOfConstraints() const { return A.numberOfRows(); }
72  size_t numberOfVariables() const { return x.size(); }
74  void checkFormulation() const;
76  void printStatistics() const;
77 
83  std::vector<double> c;
85  std::vector<const std::tuple<std::vector<double>, std::vector<double>>*> gurobiC;
87  std::vector<double> b;
89  std::vector<Operator> ops;
91  std::vector<Variable> x;
93  std::vector<std::string> varDesc;
95  std::vector<std::string> conDesc;
96 };
97 
98 #endif
void printStatistics() const
It prints various statistics like density of A matrix and number of constraints to the standard outpu...
Definition: ILPModel.cpp:46
std::vector< double > b
Constants in the constraints, i.e. the right-hand side vector of .
Definition: ILPModel.h:87
VariableType
Constants for floats, binary variables, and integers, respectively.
Definition: ILPModel.h:38
SparseMatrix< double > A
Constraint matrix of the problem.
Definition: ILPModel.h:81
Integer Linear Programming problem is stored in this data structure.
Definition: ILPModel.h:69
Memory efficient storage for a constraint matrix of Integer Linear Programming problem.
std::vector< std::string > varDesc
Optional description of the variables.
Definition: ILPModel.h:93
std::vector< const std::tuple< std::vector< double >, std::vector< double > > * > gurobiC
Convex functions in the criterion in the format suitable for Gurobi solver.
Definition: ILPModel.h:85
std::vector< Operator > ops
Operators of the constraints, see Operator enum.
Definition: ILPModel.h:89
std::vector< double > c
Vector of the criterion coefficients.
Definition: ILPModel.h:83
double upperBound
The maximal value of the variable.
Definition: ILPModel.h:56
Objective
Specifies the sense of the objective function.
Definition: ILPModel.h:33
Objective obj
Sense of the objective function (minimization/maximization).
Definition: ILPModel.h:79
std::vector< Variable > x
Variables of the problem.
Definition: ILPModel.h:91
The file defines allowed inaccuracies in a solution and constants for floats.
void checkFormulation() const
It checks that sizes of vectors and the matrix are valid.
Definition: ILPModel.cpp:27
std::vector< std::string > conDesc
Optional description of the constraints.
Definition: ILPModel.h:95
double lowerBound
The minimal value of the variable.
Definition: ILPModel.h:54
Structure containing information about the variable.
Definition: ILPModel.h:48
Operator
Constants for operators '<=', '=', and '>=', respectively.
Definition: ILPModel.h:43
VariableType type
Type of the variable, see VariableType.
Definition: ILPModel.h:52