/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Christian Schulte * * Copyright: * Christian Schulte, 2002 * * Last modified: * $Date: 2007-11-08 15:53:26 +0100 (Thu, 08 Nov 2007) $ by $Author: tack $ * $Revision: 5219 $ * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #include "gecode/int/linear.hh" namespace Gecode { using namespace Int; void linear(Space* home, const IntVarArgs& x, IntRelType r, int c, IntConLevel icl, PropKind) { if (home->failed()) return; GECODE_AUTOARRAY(Linear::Term, t, x.size()); for (int i = x.size(); i--; ) { t[i].a=1; t[i].x=x[i]; } Linear::post(home,t,x.size(),r,c,icl); } void linear(Space* home, const IntVarArgs& x, IntRelType r, int c, BoolVar b, IntConLevel, PropKind) { if (home->failed()) return; GECODE_AUTOARRAY(Linear::Term, t, x.size()); for (int i = x.size(); i--; ) { t[i].a=1; t[i].x=x[i]; } Linear::post(home,t,x.size(),r,c,b); } void linear(Space* home, const IntArgs& a, const IntVarArgs& x, IntRelType r, int c, IntConLevel icl, PropKind) { if (a.size() != x.size()) throw ArgumentSizeMismatch("Int::linear"); if (home->failed()) return; GECODE_AUTOARRAY(Linear::Term, t, x.size()); for (int i = x.size(); i--; ) { t[i].a=a[i]; t[i].x=x[i]; } Linear::post(home,t,x.size(),r,c,icl); } void linear(Space* home, const IntArgs& a, const IntVarArgs& x, IntRelType r, int c, BoolVar b, IntConLevel, PropKind) { if (a.size() != x.size()) throw ArgumentSizeMismatch("Int::linear"); if (home->failed()) return; GECODE_AUTOARRAY(Linear::Term, t, x.size()); for (int i = x.size(); i--; ) { t[i].a=a[i]; t[i].x=x[i]; } Linear::post(home,t,x.size(),r,c,b); } void linear(Space* home, const IntVarArgs& x, IntRelType r, IntVar y, IntConLevel icl, PropKind) { if (home->failed()) return; GECODE_AUTOARRAY(Linear::Term, t, x.size()+1); for (int i = x.size(); i--; ) { t[i].a=1; t[i].x=x[i]; } t[x.size()].a=-1; t[x.size()].x=y; Linear::post(home,t,x.size()+1,r,0,icl); } void linear(Space* home, const IntVarArgs& x, IntRelType r, IntVar y, BoolVar b, IntConLevel, PropKind) { if (home->failed()) return; GECODE_AUTOARRAY(Linear::Term, t, x.size()+1); for (int i = x.size(); i--; ) { t[i].a=1; t[i].x=x[i]; } t[x.size()].a=-1; t[x.size()].x=y; Linear::post(home,t,x.size()+1,r,0,b); } void linear(Space* home, const IntArgs& a, const IntVarArgs& x, IntRelType r, IntVar y, IntConLevel icl, PropKind) { if (a.size() != x.size()) throw ArgumentSizeMismatch("Int::linear"); if (home->failed()) return; GECODE_AUTOARRAY(Linear::Term, t, x.size()+1); for (int i = x.size(); i--; ) { t[i].a=a[i]; t[i].x=x[i]; } t[x.size()].a=-1; t[x.size()].x=y; Linear::post(home,t,x.size()+1,r,0,icl); } void linear(Space* home, const IntArgs& a, const IntVarArgs& x, IntRelType r, IntVar y, BoolVar b, IntConLevel, PropKind) { if (a.size() != x.size()) throw ArgumentSizeMismatch("Int::linear"); if (home->failed()) return; GECODE_AUTOARRAY(Linear::Term, t, x.size()+1); for (int i = x.size(); i--; ) { t[i].a=a[i]; t[i].x=x[i]; } t[x.size()].a=-1; t[x.size()].x=y; Linear::post(home,t,x.size()+1,r,0,b); } namespace { using namespace Int; GECODE_REGISTER3(Linear::DomEq >); GECODE_REGISTER3(Linear::DomEq >); GECODE_REGISTER3(Linear::Eq); GECODE_REGISTER4(Linear::Eq,Linear::NoView>); GECODE_REGISTER5(Linear::Eq,ScaleView >); GECODE_REGISTER3(Linear::Eq); GECODE_REGISTER3(Linear::Eq); GECODE_REGISTER3(Linear::Eq); GECODE_REGISTER4(Linear::Eq,Linear::NoView>); GECODE_REGISTER5(Linear::Eq,ScaleView >); GECODE_REGISTER3(Linear::EqBin); GECODE_REGISTER3(Linear::EqBin); GECODE_REGISTER3(Linear::EqBin); GECODE_REGISTER4(Linear::EqTer); GECODE_REGISTER4(Linear::EqTer); GECODE_REGISTER4(Linear::EqTer); GECODE_REGISTER4(Linear::EqTer); GECODE_REGISTER3(Linear::GqBin); GECODE_REGISTER3(Linear::GqBin); GECODE_REGISTER3(Linear::GqBin); GECODE_REGISTER3(Linear::Lq); GECODE_REGISTER4(Linear::Lq >); GECODE_REGISTER4(Linear::Lq,Linear::NoView>); GECODE_REGISTER5(Linear::Lq,ScaleView >); GECODE_REGISTER3(Linear::Lq); GECODE_REGISTER3(Linear::Lq); GECODE_REGISTER3(Linear::Lq); GECODE_REGISTER3(Linear::Lq); GECODE_REGISTER4(Linear::Lq >); GECODE_REGISTER4(Linear::Lq,Linear::NoView>); GECODE_REGISTER5(Linear::Lq,ScaleView >); GECODE_REGISTER3(Linear::LqBin); GECODE_REGISTER3(Linear::LqBin); GECODE_REGISTER3(Linear::LqBin); GECODE_REGISTER4(Linear::LqTer); GECODE_REGISTER4(Linear::LqTer); GECODE_REGISTER4(Linear::LqTer); GECODE_REGISTER4(Linear::LqTer); GECODE_REGISTER3(Linear::Nq); GECODE_REGISTER4(Linear::Nq,Linear::NoView>); GECODE_REGISTER5(Linear::Nq,ScaleView >); GECODE_REGISTER3(Linear::Nq); GECODE_REGISTER3(Linear::Nq); GECODE_REGISTER3(Linear::Nq); GECODE_REGISTER4(Linear::Nq,Linear::NoView>); GECODE_REGISTER5(Linear::Nq,ScaleView >); GECODE_REGISTER3(Linear::NqBin); GECODE_REGISTER3(Linear::NqBin); GECODE_REGISTER3(Linear::NqBin); GECODE_REGISTER4(Linear::NqTer); GECODE_REGISTER4(Linear::NqTer); GECODE_REGISTER4(Linear::NqTer); GECODE_REGISTER4(Linear::NqTer); GECODE_REGISTER5(Linear::ReEq,Linear::NoView,BoolView>); GECODE_REGISTER5(Linear::ReEq,Linear::NoView,NegBoolView>); GECODE_REGISTER6(Linear::ReEq,ScaleView,BoolView>); GECODE_REGISTER6(Linear::ReEq,ScaleView,NegBoolView>); GECODE_REGISTER4(Linear::ReEq); GECODE_REGISTER4(Linear::ReEq); GECODE_REGISTER4(Linear::ReEq); GECODE_REGISTER4(Linear::ReEq); GECODE_REGISTER5(Linear::ReEq,Linear::NoView,BoolView>); GECODE_REGISTER5(Linear::ReEq,Linear::NoView,NegBoolView>); GECODE_REGISTER6(Linear::ReEq,ScaleView,BoolView>); GECODE_REGISTER6(Linear::ReEq,ScaleView,NegBoolView>); GECODE_REGISTER4(Linear::ReEqBin); GECODE_REGISTER4(Linear::ReEqBin); GECODE_REGISTER4(Linear::ReEqBin); GECODE_REGISTER4(Linear::ReEqBin); GECODE_REGISTER4(Linear::ReLq >); GECODE_REGISTER4(Linear::ReLq,Linear::NoView>); GECODE_REGISTER5(Linear::ReLq,ScaleView >); GECODE_REGISTER3(Linear::ReLq); GECODE_REGISTER3(Linear::ReLq); GECODE_REGISTER3(Linear::ReLq); GECODE_REGISTER4(Linear::ReLq >); GECODE_REGISTER4(Linear::ReLq,Linear::NoView>); GECODE_REGISTER5(Linear::ReLq,ScaleView >); GECODE_REGISTER3(Linear::ReLqBin); GECODE_REGISTER3(Linear::ReLqBin); GECODE_REGISTER3(Linear::ReLqBin); } } // STATISTICS: int-post