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