idol
A C++ Framework for Optimization
Loading...
Searching...
No Matches
TempCtr.h
1//
2// Created by henri on 08/09/22.
3//
4
5#ifndef OPTIMIZE_TEMPCTR_H
6#define OPTIMIZE_TEMPCTR_H
7
8#include <ostream>
9#include <idol/mixed-integer/modeling/expressions/LinExpr.h>
10#include <idol/mixed-integer/modeling/Types.h>
11#include <idol/mixed-integer/modeling/variables/Var.h>
12
13namespace idol {
14
15 class TempCtr;
16
17 template<class, class> class AffExpr;
18}
19
42 LinExpr<Var> m_lhs;
43 CtrType m_type = LessOrEqual;
44 double m_rhs = 0.;
45public:
51 TempCtr() = default;
52
60 TempCtr(LinExpr<Var>&& t_lhs, CtrType t_type, double t_rhs) : m_lhs(std::move(t_lhs)), m_rhs(t_rhs), m_type(t_type) {}
61
66 TempCtr(const TempCtr& t_src) = default;
67
72 TempCtr(TempCtr&& t_src) noexcept = default;
73
78 TempCtr& operator=(const TempCtr& t_src) = default;
79
84 TempCtr& operator=(TempCtr&& t_src) noexcept = default;
85
86 LinExpr<Var>& lhs() { return m_lhs; }
87
88 const LinExpr<Var>& lhs() const { return m_lhs; }
89
90 void set_lhs(LinExpr<Var>&& t_lhs) { m_lhs = std::move(t_lhs); }
91
96 [[nodiscard]] CtrType type() const { return m_type; }
97
98 double rhs() const { return m_rhs; }
99
100 double& rhs() { return m_rhs; }
101
102 void set_rhs(double t_rhs) { m_rhs = t_rhs; }
103
108 void set_type(CtrType t_type) {
109 if (t_type < 0 || t_type > 2) {
110 throw Exception("Constraint type out of bounds.");
111 }
112 m_type = t_type;
113 }
114
115};
116
120
121namespace idol {
122 std::ostream &operator<<(std::ostream &t_os, const TempCtr &t_temp_ctr);
123}
124
125#endif //OPTIMIZE_TEMPCTR_H
CtrType type() const
Definition TempCtr.h:96
TempCtr & operator=(TempCtr &&t_src) noexcept=default
TempCtr(TempCtr &&t_src) noexcept=default
TempCtr(LinExpr< Var > &&t_lhs, CtrType t_type, double t_rhs)
Definition TempCtr.h:60
TempCtr()=default
void set_type(CtrType t_type)
Definition TempCtr.h:108
TempCtr & operator=(const TempCtr &t_src)=default
TempCtr(const TempCtr &t_src)=default