Generated on Fri Oct 19 11:24:59 2018 for Gecode by doxygen 1.6.3

offset.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  *     Vincent Barichard <Vincent.Barichard@univ-angers.fr>
00006  *
00007  *  Copyright:
00008  *     Christian Schulte, 2002
00009  *     Vincent Barichard, 2012
00010  *
00011  *  This file is part of Gecode, the generic constraint
00012  *  development environment:
00013  *     http://www.gecode.org
00014  *
00015  *  Permission is hereby granted, free of charge, to any person obtaining
00016  *  a copy of this software and associated documentation files (the
00017  *  "Software"), to deal in the Software without restriction, including
00018  *  without limitation the rights to use, copy, modify, merge, publish,
00019  *  distribute, sublicense, and/or sell copies of the Software, and to
00020  *  permit persons to whom the Software is furnished to do so, subject to
00021  *  the following conditions:
00022  *
00023  *  The above copyright notice and this permission notice shall be
00024  *  included in all copies or substantial portions of the Software.
00025  *
00026  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00027  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00028  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00029  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00030  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00031  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00032  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00033  *
00034  */
00035 
00036 namespace Gecode { namespace Float {
00037 
00038   /*
00039    * Constructors and initialization
00040    *
00041    */
00042   forceinline
00043   OffsetView::OffsetView(void) {}
00044   forceinline
00045   OffsetView::OffsetView(const FloatView& y, FloatNum d)
00046     : DerivedView<FloatView>(y), c(d) {}
00047 
00048 
00049   /*
00050    * Value access
00051    *
00052    */
00053   forceinline FloatNum
00054   OffsetView::offset(void) const {
00055     return c;
00056   }
00057   forceinline void
00058   OffsetView::offset(FloatNum n) {
00059     c = n;
00060   }
00061   forceinline FloatVal
00062   OffsetView::domain(void) const {
00063     return x.domain()+c;
00064   }
00065   forceinline FloatNum
00066   OffsetView::min(void) const {
00067     return x.min()+c;
00068   }
00069   forceinline FloatNum
00070   OffsetView::max(void) const {
00071     return x.max()+c;
00072   }
00073   forceinline FloatNum
00074   OffsetView::med(void) const {
00075     return x.med()+c;
00076   }
00077   forceinline FloatVal
00078   OffsetView::val(void) const {
00079     return x.val()+c;
00080   }
00081 
00082   forceinline FloatNum
00083   OffsetView::size(void) const {
00084     return x.size();
00085   }
00086 
00087 
00088   /*
00089    * Domain tests
00090    *
00091    */
00092   forceinline bool
00093   OffsetView::zero_in(void) const {
00094     return x.in(-c);
00095   }
00096   forceinline bool
00097   OffsetView::in(FloatNum n) const {
00098     return x.in(n-c);
00099   }
00100   forceinline bool
00101   OffsetView::in(const FloatVal& n) const {
00102     return x.in(n-c);
00103   }
00104 
00105 
00106   /*
00107    * Domain update by value
00108    *
00109    */
00110   forceinline ModEvent
00111   OffsetView::lq(Space& home, int n) {
00112     return x.lq(home,n-c);
00113   }
00114   forceinline ModEvent
00115   OffsetView::lq(Space& home, FloatNum n) {
00116     return x.lq(home,n-c);
00117   }
00118   forceinline ModEvent
00119   OffsetView::lq(Space& home, FloatVal n) {
00120     return x.lq(home,n-c);
00121   }
00122 
00123   forceinline ModEvent
00124   OffsetView::gq(Space& home, int n) {
00125     return x.gq(home,n-c);
00126   }
00127   forceinline ModEvent
00128   OffsetView::gq(Space& home, FloatNum n) {
00129     return x.gq(home,n-c);
00130   }
00131   forceinline ModEvent
00132   OffsetView::gq(Space& home, FloatVal n) {
00133     return x.gq(home,n-c);
00134   }
00135 
00136   forceinline ModEvent
00137   OffsetView::eq(Space& home, int n) {
00138     return x.eq(home,n-c);
00139   }
00140   forceinline ModEvent
00141   OffsetView::eq(Space& home, FloatNum n) {
00142     return x.eq(home,n-c);
00143   }
00144   forceinline ModEvent
00145   OffsetView::eq(Space& home, const FloatVal& n) {
00146     return x.eq(home,n-c);
00147   }
00148 
00149 
00150   /*
00151    * Delta information for advisors
00152    *
00153    */
00154   forceinline FloatNum
00155   OffsetView::min(const Delta& d) const {
00156     return x.min(d)+c;
00157   }
00158   forceinline FloatNum
00159   OffsetView::max(const Delta& d) const {
00160     return x.max(d)+c;
00161   }
00162 
00163   forceinline ModEventDelta
00164   OffsetView::med(ModEvent me) {
00165     return VarImpView<FloatVar>::med(me);
00166   }
00167 
00168 
00169   /*
00170    * Cloning
00171    *
00172    */
00173   forceinline void
00174   OffsetView::update(Space& home, OffsetView& y) {
00175     DerivedView<FloatView>::update(home,y);
00176     c=y.c;
00177   }
00178 
00179   /*
00180    * Ordering
00181    *
00182    */
00183   forceinline bool
00184   OffsetView::operator <(const OffsetView& y) const {
00185     return ((base() < y.base())
00186             || ((base() == y.base()) && (offset() < y.offset())));
00187   }
00188 
00189 
00190   /*
00191    * View comparison
00192    *
00193    */
00194   forceinline bool
00195   operator ==(const OffsetView& x, const OffsetView& y) {
00196     return (x.base() == y.base()) && (x.offset() == y.offset());
00197   }
00198   forceinline bool
00199   operator !=(const OffsetView& x, const OffsetView& y) {
00200     return !(x == y);
00201   }
00202 
00203 }}
00204 
00205 // STATISTICS: float-var
00206