6 #include "../../core/Variable.h"
12 #include <poly/poly.h>
13 #include <poly/polynomial_context.h>
23 std::vector<Variable> variable_order;
25 lp_variable_order_t* lp_var_order;
26 lp_polynomial_context_t* lp_context;
28 Data(
const std::vector<Variable>& v);
32 std::shared_ptr<Data> m_data;
40 LPContext(
const LPContext& rhs) {
44 LPContext& operator=(
const LPContext& rhs) {
49 std::optional<carl::Variable> carl_variable(lp_variable_t var)
const {
50 return LPVariables::getInstance().carl_variable(var);
54 return LPVariables::getInstance().lp_variable(var);
57 std::optional<lp_variable_t> lp_variable_opt(
carl::Variable var)
const {
58 return LPVariables::getInstance().lp_variable_opt(var);
65 LPContext(
const std::vector<Variable>& carl_var_order) : m_data(std::make_shared<Data>(carl_var_order)) {
67 for (
size_t i = 0; i < carl_var_order.size(); i++) {
68 lp_variable_t poly_var = LPVariables::getInstance().lp_variable(carl_var_order[i]);
69 lp_variable_order_push(m_data->lp_var_order, poly_var);
73 lp_polynomial_context_t* lp_context() {
74 return m_data->lp_context;
77 const lp_polynomial_context_t* lp_context()
const {
78 return m_data->lp_context;
81 const std::vector<Variable>& variable_ordering()
const {
82 return m_data->variable_order;
85 bool has(
const Variable& var)
const {
86 return std::find(variable_ordering().begin(), variable_ordering().end(), var) != variable_ordering().end();
92 inline bool operator==(
const LPContext& rhs)
const {
93 return m_data == rhs.m_data;
96 bool is_extension_of(
const LPContext& other)
const {
97 auto it_a = variable_ordering().begin();
98 auto it_b = other.variable_ordering().begin();
99 while (it_a != variable_ordering().end() && it_b != other.variable_ordering().end() && *it_a == *it_b) {
103 return it_b == other.variable_ordering().end();
107 inline std::ostream&
operator<<(std::ostream& os,
const LPContext& ctx) {
108 os << ctx.variable_ordering();
#define CARL_LOG_FUNC(channel, args)
carl is the main namespace for the library.
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
bool operator==(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
A Variable represents an algebraic variable that can be used throughout carl.