constraint.cpp
Go to the documentation of this file.
00001 // 
00002 // Copyright (c) 2006-2012, Benjamin Kaufmann
00003 // 
00004 // This file is part of Clasp. See http://www.cs.uni-potsdam.de/clasp/ 
00005 // 
00006 // Clasp is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 2 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // Clasp is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with Clasp; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 
00021 #include <clasp/constraint.h>
00022 #include <string>
00023 namespace Clasp {
00025 // (Learnt)Constraint
00027 Constraint::Constraint()                  {}
00028 Constraint::~Constraint()                 {}
00029 void Constraint::destroy(Solver*, bool)   { delete this; }
00030 ConstraintType Constraint::type() const   { return Constraint_t::static_constraint; }
00031 bool Constraint::simplify(Solver&, bool)  { return false; }
00032 void Constraint::undoLevel(Solver&)       {}
00033 uint32 Constraint::estimateComplexity(const Solver&) const { return 1;  }
00034 bool Constraint::valid(Solver&)           { return true; }
00035 ClauseHead* Constraint::clause()          { return 0; } 
00036 LearntConstraint::~LearntConstraint()     {}
00037 LearntConstraint::LearntConstraint()      {}
00038 Activity LearntConstraint::activity() const{ return Activity(0,  (1u<<7)-1); }
00039 void LearntConstraint::decreaseActivity() {}
00040 void LearntConstraint::resetActivity(Activity) {}
00041 ConstraintType LearntConstraint::type() const { return Constraint_t::learnt_conflict; }
00043 // PostPropagator
00045 PostPropagator::PostPropagator() : next(0)           {}
00046 PostPropagator::~PostPropagator()                    {}
00047 bool PostPropagator::init(Solver&)                   { return true; }
00048 void PostPropagator::reset()                         {}
00049 bool PostPropagator::isModel(Solver& s)              { return valid(s); }
00050 void PostPropagator::reason(Solver&, Literal, LitVec&) {}
00051 Constraint::PropResult PostPropagator::propagate(Solver&, Literal, uint32&) { 
00052         return PropResult(true, false); 
00053 }
00054 MessageHandler::MessageHandler() {}
00056 // Antecedent
00058 PlatformError::PlatformError(const char* msg) : ClaspError(std::string("Platform Error: ")+msg) {}
00059 bool Antecedent::checkPlatformAssumptions() {
00060         int32* i = new int32(22);
00061         uint64 p = (uint64)(uintp)i;
00062         bool convOk = ((int32*)(uintp)p) == i;
00063         bool alignmentOk = (p & 3) == 0;
00064         delete i;
00065         if ( !alignmentOk ) {
00066                 throw PlatformError("Unsupported Pointer-Alignment!");
00067         }
00068         if ( !convOk ) {
00069                 throw PlatformError("Can't convert between Pointer and Integer!");
00070         }
00071         p = ~uintp(1);
00072         store_set_bit(p, 0);
00073         if (!test_bit(p, 0)) {
00074                 throw PlatformError("Can't set LSB in pointer!");
00075         }
00076         store_clear_bit(p, 0);
00077         if (p != (~uintp(1))) {
00078                 throw PlatformError("Can't restore LSB in pointer!");
00079         }
00080         Literal max = posLit(varMax-1);
00081         Antecedent a(max);
00082         if (a.type() != Antecedent::binary_constraint || a.firstLiteral() != max) {
00083                 throw PlatformError("Cast between 64- and 32-bit integer does not work as expected!");
00084         }
00085         Antecedent b(max, ~max);
00086         if (b.type() != Antecedent::ternary_constraint || b.firstLiteral() != max || b.secondLiteral() != ~max) {
00087                 throw PlatformError("Cast between 64- and 32-bit integer does not work as expected!");
00088         }
00089         return true;
00090 }
00091 
00092 }


clasp
Author(s): Benjamin Kaufmann
autogenerated on Thu Aug 27 2015 12:41:39