SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
utils.cpp
Go to the documentation of this file.
1 /*
2  * File: utils.cpp
3  * Author: stefan
4  *
5  * Created on June 19, 2013, 4:06 PM
6  */
7 
8 #include <cmath>
9 #include <map>
10 
11 #include "utils.h"
12 
13 namespace smtrat
14 {
15  namespace icp
16  {
17  std::vector<Poly> getNonlinearMonomials( const Poly& _expr )
18  {
19  std::vector<Poly> result;
20  for( auto termIt = _expr.polynomial().begin(); termIt != _expr.polynomial().end(); ++termIt )
21  {
22  if( termIt->monomial() )
23  {
24  if( !termIt->monomial()->is_linear() )
25  {
26 #ifdef __VS
27  result.emplace_back(Poly(Poly::PolyType(termIt->monomial()))*_expr.coefficient());
28 #else
29  result.emplace_back(Poly(typename Poly::PolyType(termIt->monomial()))*_expr.coefficient() );
30 #endif
31  }
32  }
33  }
34  return result;
35  }
36 
37  std::pair<ConstraintT, ConstraintT> intervalToConstraint( const Poly& _lhs, const smtrat::DoubleInterval _interval )
38  {
39  // left:
40  ConstraintT leftTmp;
41 
42  if (!std::isinf(_interval.lower())) {
43  Rational bound = carl::rationalize<Rational>( _interval.lower() );
44  Poly leftEx = _lhs - bound;
45 
46  switch( _interval.lower_bound_type() )
47  {
48  case carl::BoundType::STRICT:
49  leftTmp = ConstraintT(leftEx, carl::Relation::GREATER);
50  break;
51  case carl::BoundType::WEAK:
52  leftTmp = ConstraintT(leftEx, carl::Relation::GEQ);
53  break;
54  default:
55  leftTmp = ConstraintT();
56  }
57  }
58 
59  // right:
60  ConstraintT rightTmp;
61 
62  if (!std::isinf(_interval.upper())) {
63  Rational bound = carl::rationalize<Rational>( _interval.upper() );
64  Poly rightEx = _lhs - bound;
65 
66  switch( _interval.upper_bound_type() )
67  {
68  case carl::BoundType::STRICT:
69  rightTmp = ConstraintT(rightEx, carl::Relation::LESS);
70  break;
71  case carl::BoundType::WEAK:
72  rightTmp = ConstraintT(rightEx, carl::Relation::LEQ);
73  break;
74  default:
75  rightTmp = ConstraintT();
76  }
77  }
78 
79  return std::make_pair( leftTmp, rightTmp );
80  }
81 
83  {
84  for ( auto intervalIt = _intervals.begin(); intervalIt != _intervals.end(); ++intervalIt )
85  {
86  if ( (*intervalIt).second.is_empty() )
87  return true;
88  }
89  return false;
90  }
91 
92  const LRAModule<LRASettings1>::LRAVariable* getOriginalLraVar( carl::Variable::Arg _var, const LRAModule<LRASettings1>& _lra )
93  {
94 #ifdef __VS
96 #else
98 #endif
99  if( target != _lra.originalVariables().end() )
100  {
101  return (*target).second;
102  }
103  return NULL;
104  }
105  }
106 }
A module which performs the Simplex method on the linear part of it's received formula.
Definition: LRAModule.h:30
const VarVariableMap & originalVariables() const
Definition: LRAModule.h:281
std::vector< Poly > getNonlinearMonomials(const Poly &_expr)
Obtains the non-linear monomials of the given polynomial.
Definition: utils.cpp:17
std::pair< ConstraintT, ConstraintT > intervalToConstraint(const Poly &_lhs, const smtrat::DoubleInterval _interval)
Creates a new constraint from an existing interval.
Definition: utils.cpp:37
const LRAModule< LRASettings1 >::LRAVariable * getOriginalLraVar(carl::Variable::Arg _var, const LRAModule< LRASettings1 > &_lra)
Definition: utils.cpp:92
bool intervalBoxContainsEmptyInterval(const EvalDoubleIntervalMap &_intervals)
Checks mIntervals if it contains an empty interval.
Definition: utils.cpp:82
Class to create the formulas for axioms.
carl::Interval< double > DoubleInterval
Definition: model.h:26
carl::MultivariatePolynomial< Rational > Poly
Definition: types.h:25
carl::Constraint< Poly > ConstraintT
Definition: types.h:29
mpq_class Rational
Definition: types.h:19
std::map< carl::Variable, DoubleInterval > EvalDoubleIntervalMap
Definition: model.h:29