val-commit.hpp
Go to the documentation of this file.00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 00002 /* 00003 * Main authors: 00004 * Christian Schulte <schulte@gecode.org> 00005 * 00006 * Contributing authors: 00007 * Vincent Barichard <Vincent.Barichard@univ-angers.fr> 00008 * 00009 * Copyright: 00010 * Christian Schulte, 2012 00011 * Vincent Barichard, 2012 00012 * 00013 * Last modified: 00014 * $Date: 2017-02-16 12:11:51 +0100 (Thu, 16 Feb 2017) $ by $Author: schulte $ 00015 * $Revision: 15434 $ 00016 * 00017 * This file is part of Gecode, the generic constraint 00018 * development environment: 00019 * http://www.gecode.org 00020 * 00021 * Permission is hereby granted, free of charge, to any person obtaining 00022 * a copy of this software and associated documentation files (the 00023 * "Software"), to deal in the Software without restriction, including 00024 * without limitation the rights to use, copy, modify, merge, publish, 00025 * distribute, sublicense, and/or sell copies of the Software, and to 00026 * permit persons to whom the Software is furnished to do so, subject to 00027 * the following conditions: 00028 * 00029 * The above copyright notice and this permission notice shall be 00030 * included in all copies or substantial portions of the Software. 00031 * 00032 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00033 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00034 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00035 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 00036 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 00037 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 00038 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00039 * 00040 */ 00041 00042 namespace Gecode { namespace Float { namespace Branch { 00043 00044 forceinline 00045 ValCommitLqGq::ValCommitLqGq(Space& home, const ValBranch<Var>& vb) 00046 : ValCommit<FloatView,FloatVal>(home,vb) {} 00047 forceinline 00048 ValCommitLqGq::ValCommitLqGq(Space& home, bool shared, ValCommitLqGq& vc) 00049 : ValCommit<FloatView,FloatVal>(home,shared,vc) {} 00050 forceinline ModEvent 00051 ValCommitLqGq::commit(Space& home, unsigned int a, FloatView x, int, 00052 FloatNumBranch nl) { 00053 // Should we try the smaller half first? 00054 if ((a == 0) == nl.l) { 00055 if ((x.min() == nl.n) || (x.max() == nl.n)) 00056 return x.eq(home,x.min()); 00057 else 00058 return x.lq(home,nl.n); 00059 } else { 00060 if ((x.min() == nl.n) || (x.max() == nl.n)) 00061 return x.eq(home,x.max()); 00062 else 00063 return x.gq(home,nl.n); 00064 } 00065 } 00066 forceinline NGL* 00067 ValCommitLqGq::ngl(Space&, unsigned int, FloatView, FloatNumBranch) const { 00068 return NULL; 00069 } 00070 forceinline void 00071 ValCommitLqGq::print(const Space&, unsigned int a, FloatView, int i, 00072 FloatNumBranch nl, 00073 std::ostream& o) const { 00074 o << "var[" << i << "] " 00075 << (((a == 0) == nl.l) ? "<=" : ">=") << "(" << nl.n << ")"; 00076 } 00077 00078 }}} 00079 00080 // STATISTICS: float-branch 00081