| 1 |
#ifndef __READERLP_MODEL_HPP__ |
| 2 |
#define __READERLP_MODEL_HPP__ |
| 3 |
|
| 4 |
#include <limits> |
| 5 |
#include <memory> |
| 6 |
#include <string> |
| 7 |
#include <vector> |
| 8 |
|
| 9 |
enum class VariableType { |
| 10 |
CONTINUOUS, |
| 11 |
BINARY, |
| 12 |
GENERAL, |
| 13 |
SEMICONTINUOUS, |
| 14 |
SEMIINTEGER |
| 15 |
}; |
| 16 |
|
| 17 |
enum class ObjectiveSense { MIN, MAX }; |
| 18 |
|
| 19 |
struct Variable { |
| 20 |
VariableType type = VariableType::CONTINUOUS; |
| 21 |
double lowerbound = 0.0; |
| 22 |
double upperbound = std::numeric_limits<double>::infinity(); |
| 23 |
std::string name; |
| 24 |
|
| 25 |
Variable(std::string n = "") : name(n){}; |
| 26 |
}; |
| 27 |
|
| 28 |
struct LinTerm { |
| 29 |
std::shared_ptr<Variable> var; |
| 30 |
double coef = 1.0; |
| 31 |
}; |
| 32 |
|
| 33 |
struct QuadTerm { |
| 34 |
std::shared_ptr<Variable> var1; |
| 35 |
std::shared_ptr<Variable> var2; |
| 36 |
double coef = 1.0; |
| 37 |
}; |
| 38 |
|
| 39 |
struct Expression { |
| 40 |
std::vector<std::shared_ptr<LinTerm>> linterms; |
| 41 |
std::vector<std::shared_ptr<QuadTerm>> quadterms; |
| 42 |
double offset = 0.0; |
| 43 |
std::string name = ""; |
| 44 |
}; |
| 45 |
|
| 46 |
struct Constraint { |
| 47 |
double lowerbound = -std::numeric_limits<double>::infinity(); |
| 48 |
double upperbound = std::numeric_limits<double>::infinity(); |
| 49 |
std::shared_ptr<Expression> expr; |
| 50 |
|
| 51 |
Constraint() : expr(std::shared_ptr<Expression>(new Expression)){}; |
| 52 |
}; |
| 53 |
|
| 54 |
struct SOS { |
| 55 |
std::string name = ""; |
| 56 |
short type = 0; // 1 or 2 |
| 57 |
std::vector<std::pair<std::shared_ptr<Variable>, double>> entries; |
| 58 |
}; |
| 59 |
|
| 60 |
struct Model { |
| 61 |
std::shared_ptr<Expression> objective; |
| 62 |
ObjectiveSense sense; |
| 63 |
std::vector<std::shared_ptr<Constraint>> constraints; |
| 64 |
std::vector<std::shared_ptr<Variable>> variables; |
| 65 |
std::vector<std::shared_ptr<SOS>> soss; |
| 66 |
}; |
| 67 |
|
| 68 |
#endif |