Generated on Tue Apr 18 10:21:45 2017 for Gecode by doxygen 1.6.3

scale.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   ScaleView::ScaleView(void) {}
00048   forceinline
00049   ScaleView::ScaleView(FloatVal d, const FloatView& y)
00050     : DerivedView<FloatView>(y), a(d) {}
00051 
00052 
00053   /*
00054    * Value access
00055    *
00056    */
00057   forceinline FloatVal
00058   ScaleView::scale(void) const {
00059     return a;
00060   }
00061   forceinline FloatVal
00062   ScaleView::domain(void) const {
00063     return x.domain()*a;
00064   }
00065   forceinline FloatNum
00066   ScaleView::min(void) const {
00067     FloatVal c = x.min(); c *= a; return c.min();
00068   }
00069   forceinline FloatNum
00070   ScaleView::max(void) const {
00071     FloatVal c = x.max(); c *= a; return c.max();
00072   }
00073   forceinline FloatNum
00074   ScaleView::med(void) const {
00075     FloatVal c = x.med(); c *= a; return (c.min()+c.max())/2;
00076   }
00077   forceinline FloatVal
00078   ScaleView::val(void) const {
00079     FloatVal c = x.val(); c *= a; return c;
00080   }
00081 
00082   forceinline FloatNum
00083   ScaleView::size(void) const {
00084     FloatVal c = x.size(); c *= a; return c.max();
00085   }
00086 
00087 
00088   /*
00089    * Domain tests
00090    *
00091    */
00092   forceinline bool
00093   ScaleView::zero_in(void) const {
00094     return x.zero_in();
00095   }
00096   forceinline bool
00097   ScaleView::in(FloatNum n) const {
00098     return x.in(n/a);
00099   }
00100   forceinline bool
00101   ScaleView::in(const FloatVal& n) const {
00102     return x.in(n/a);
00103   }
00104 
00105 
00106   /*
00107    * Domain update by value
00108    *
00109    */
00110   forceinline ModEvent
00111   ScaleView::lq(Space& home, int n) {
00112     FloatVal c = n; c /= a;
00113     return x.lq(home,c.max());
00114   }
00115   forceinline ModEvent
00116   ScaleView::lq(Space& home, FloatNum n) {
00117     FloatVal c = n; c /= a;
00118     return x.lq(home,c.max());
00119   }
00120   forceinline ModEvent
00121   ScaleView::lq(Space& home, FloatVal n) {
00122     FloatVal c = n; c /= a;
00123     return x.lq(home,c.max());
00124   }
00125 
00126   forceinline ModEvent
00127   ScaleView::gq(Space& home, int n) {
00128     FloatVal c = n; c /= a;
00129     return x.gq(home,c.min());
00130   }
00131   forceinline ModEvent
00132   ScaleView::gq(Space& home, FloatNum n) {
00133     FloatVal c = n; c /= a;
00134     return x.gq(home,c.min());
00135   }
00136   forceinline ModEvent
00137   ScaleView::gq(Space& home, FloatVal n) {
00138     FloatVal c = n; c /= a;
00139     return x.gq(home,c.min());
00140   }
00141 
00142   forceinline ModEvent
00143   ScaleView::eq(Space& home, int n) {
00144     FloatVal c = n; c /= a;
00145     return x.eq(home,c);
00146   }
00147   forceinline ModEvent
00148   ScaleView::eq(Space& home, FloatNum n) {
00149     FloatVal c = n; c /= a;
00150     return x.eq(home,c);
00151   }
00152   forceinline ModEvent
00153   ScaleView::eq(Space& home, const FloatVal& n) {
00154     FloatVal c = n; c /= a;
00155     return x.eq(home,c);
00156   }
00157 
00158 
00159   /*
00160    * Delta information for advisors
00161    *
00162    */
00163   forceinline FloatNum
00164   ScaleView::min(const Delta& d) const {
00165     FloatVal c = x.min(d); c *= a; return c.min();
00166   }
00167   forceinline FloatNum
00168   ScaleView::max(const Delta& d) const {
00169     FloatVal c = x.max(d); c *= a; return c.max();
00170   }
00171 
00172   forceinline ModEventDelta
00173   ScaleView::med(ModEvent me) {
00174     return VarImpView<FloatVar>::med(me);
00175   }
00176 
00177 
00178   /*
00179    * Cloning
00180    *
00181    */
00182   forceinline void
00183   ScaleView::update(Space& home, bool share, ScaleView& y) {
00184     DerivedView<FloatView>::update(home,share,y);
00185     a=y.a;
00186   }
00187 
00188 }}
00189 
00190 // STATISTICS: float-var
00191