3 * @author Florian Corzilius <corzilius@cs.rwth-aachen.de>
16 template<typename T1, typename T2>
18 Bound<T1, T2>::Bound(const Value<T1>* const _limit, Variable<T1, T2>* const _var, Type _type, const FormulaT& _constraint, Info* _boundInfo, bool _deduced) :
20 Bound<T1, T2>::Bound(const Value<T1>* const _limit, Variable<T1, T2>* const _var, Type _type, const FormulaT& _constraint, Bound<T1, T2>::Info* _boundInfo, bool _deduced) :
23 mMarkedAsDeleted( false ),
27 mAsConstraint( _constraint ),
30 mpOrigins = std::shared_ptr<std::vector<FormulaT>>(new std::vector<FormulaT>());
33 mpOrigins->push_back( FormulaT( carl::FormulaType::TRUE ) );
37 template<typename T1, typename T2>
38 Bound<T1, T2>::~Bound()
44 template<typename T1, typename T2>
45 bool Bound<T1, T2>::operator <( const Bound& _bound ) const
47 assert( mType == EQUAL || _bound.type() == EQUAL || mType == _bound.type() );
48 if( mLimit == NULL && _bound.pLimit() == NULL )
52 else if( mLimit == NULL && _bound.pLimit() != NULL )
54 return mType == LOWER;
56 else if( mLimit != NULL && _bound.pLimit() == NULL )
58 return _bound.type() == UPPER;
62 if( (*mLimit) < _bound.limit() )
66 else if( (*mLimit) == _bound.limit() )
68 if( mType == LOWER && _bound.type() == EQUAL ) return true;
69 if( mType == EQUAL && _bound.type() == UPPER ) return true;
75 template<typename T1, typename T2>
76 bool Bound<T1, T2>::operator >( const Bound& _bound ) const
78 if( mLimit == NULL && _bound.pLimit() == NULL )
80 return (mType == UPPER && _bound.type() == LOWER);
82 else if( mLimit == NULL && _bound.pLimit() != NULL )
84 return mType == UPPER;
86 else if( mLimit != NULL && _bound.pLimit() == NULL )
88 return _bound.type() == LOWER;
92 if( (*mLimit) > _bound.limit() )
96 else if( (*mLimit) == _bound.limit() )
98 if( mType != EQUAL && _bound.type() == EQUAL ) return true;
104 template<typename T1, typename T2>
105 bool Bound<T1, T2>::operator <( const Value<T1>& _value ) const
107 if( mLimit == NULL && mType == UPPER )
111 else if( mLimit == NULL && mType == LOWER )
117 return (*mLimit) < _value;
121 template<typename T1, typename T2>
122 bool Bound<T1, T2>::operator >( const Value<T1>& _value ) const
124 if( mLimit == NULL && mType == UPPER )
128 else if( mLimit == NULL && mType == LOWER )
134 return (*mLimit) > _value;
138 template<typename T1, typename T2>
139 bool Bound<T1, T2>::operator ==( const Value<T1>& _value ) const
145 return (*mLimit) == _value;
148 template<typename T1, typename T2>
149 bool Bound<T1, T2>::operator ==( const T1& _a ) const
151 return mLimit != NULL && (*mLimit) == _a;
154 template<typename T1, typename T2>
155 bool Bound<T1, T2>::operator >( const T1& _a ) const
158 return mType == UPPER;
159 return (*mLimit) > _a;
162 template<typename T1, typename T2>
163 bool Bound<T1, T2>::operator <( const T1& _a ) const
166 return mType == LOWER;
167 return (*mLimit) < _a;
170 template<typename T1, typename T2>
171 bool Bound<T1, T2>::operator >=( const T1& _a ) const
174 return mType == UPPER;
175 return (*mLimit) >= _a;
178 template<typename T1, typename T2>
179 bool Bound<T1, T2>::operator <=( const T1& _a ) const
182 return mType == LOWER;
183 return (*mLimit) <= _a;
186 template<typename T1, typename T2>
187 const std::string Bound<T1, T2>::toString() const
189 if( mLimit == NULL && mType == UPPER )
193 else if( mLimit == NULL && mType == LOWER )
199 return limit().toString();
203 template<typename T3, typename T4>
204 std::ostream& operator <<( std::ostream& _ostream, const Bound<T3, T4>& _bound )
206 _bound.print( false, _ostream, false );
210 template<typename T1, typename T2>
211 void Bound<T1, T2>::print( bool _withOrigins, std::ostream& _out, bool _printType ) const
219 else if( mType == LOWER )
228 if( mLimit == NULL && mType == UPPER )
232 else if( mLimit == NULL && mType == LOWER )
240 _out << " from " << mAsConstraint;
242 _out << " [" << mpInfo->neqRepresentation << "]";
244 if( mDeduced ) _out << " (deduced) ";
248 for( auto origin = origins().begin(); origin != origins().end(); ++origin )
250 _out << *origin << " ";
256 } // end namspace lra
257 } // end namspace smtrat