6 std::vector<TermT> positiveTerms;
7 std::vector<TermT> negativeTerms;
9 for (
const auto& term : constraint.lhs()) {
10 if (term.is_constant())
continue;
12 if (term.coeff() > 0) {
13 positiveTerms.push_back(term);
15 negativeTerms.push_back(term);
21 for (
const auto& term : positiveTerms) {
25 for (
const auto& term : negativeTerms) {
29 if (constraint.relation() == carl::Relation::LEQ) {
44 for (
const auto& sum : subsetsums) {
45 ConstraintT lhsImplication(lhs - sum, carl::Relation::GEQ);
46 ConstraintT rhsImplication(rhs - sum - constraint.lhs().constant_part(), carl::Relation::GEQ);
52 conjunction.push_back(
FormulaT(carl::FormulaType::IMPLIES, chosenLhsEncoding, chosenRhsEncoding));
73 for (
const auto& sum : subsetsumsPositive) {
80 conjunction.push_back(
FormulaT(carl::FormulaType::IMPLIES, chosenLhsEncoding, chosenRhsEncoding));
83 for (
const auto& sum : subsetsumsNegative) {
90 conjunction.push_back(
FormulaT(carl::FormulaType::IMPLIES, chosenRhsEncoding, chosenLhsEncoding));
100 bool positiveSign =
false;
101 bool negativeSign =
false;
103 for (
const auto& term: constraint.lhs()) {
104 if (term.is_constant())
continue;
106 if (term.coeff() > 0) {
110 if (term.coeff() < 0) {
115 return positiveSign && negativeSign;
121 std::vector<TermT> positiveTerms;
122 std::vector<TermT> negativeTerms;
123 for (
const auto& term: constraint.lhs()) {
124 if (term.is_constant())
continue;
126 if (term.coeff() > 0) {
127 positiveTerms.push_back(term);
129 negativeTerms.push_back(term);
133 std::set<Rational> sums;
147 std::set<Rational> sums;
151 return std::vector<Rational>(sums.begin(), sums.end());
155 if (leftIndex >= terms.size()) {
167 bool hasEncoded =
false;
172 chosenEncoding = *shortEncoding;
177 if (cardinalityEncoding) {
178 chosenEncoding = *cardinalityEncoding;
184 chosenEncoding = *longEncoding;
190 chosenEncoding =
FormulaT(constraint);
193 return chosenEncoding;
bool canEncode(const ConstraintT &constraint)
CardinalityEncoder mCardinalityEncoder
std::optional< FormulaT > doEncode(const ConstraintT &constraint)
Rational encodingSize(const ConstraintT &constraint)
PseudoBoolNormalizer mNormalizer
FormulaT findSubEncoding(const ConstraintT &constraint)
ShortFormulaEncoder mShortFormulaEncoder
std::vector< Rational > calculateSubsetsums(const std::vector< TermT > &terms)
bool canEncode(const ConstraintT &constraint)
LongFormulaEncoder mLongFormulaEncoder
virtual Rational encodingSize(const ConstraintT &constraint)
std::optional< FormulaT > encode(const ConstraintT &constraint)
Encodes an arbitrary constraint.
ConstraintT trim(const ConstraintT &constraint)
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
carl::MultivariatePolynomial< Rational > Poly
carl::Constraint< Poly > ConstraintT
carl::Formulas< Poly > FormulasT