Generated on Mon Aug 25 11:35:39 2008 for Gecode by doxygen 1.5.6

minus.icc

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  *  Copyright:
00007  *     Christian Schulte, 2003
00008  *
00009  *  Last modified:
00010  *     $Date: 2008-01-31 18:29:16 +0100 (Thu, 31 Jan 2008) $ by $Author: tack $
00011  *     $Revision: 6017 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 namespace Gecode {
00039 
00040   namespace Int {
00041 
00042     /*
00043      * Constructors and initialization
00044      *
00045      */
00046     forceinline
00047     MinusView::MinusView(void) {}
00048     forceinline
00049     MinusView::MinusView(const IntView& x)
00050       : DerivedViewBase<IntView>(x) {}
00051     forceinline void
00052     MinusView::init(const IntView& x) {
00053       view = x;
00054     }
00055     forceinline
00056     MinusView::MinusView(Space* home, const Reflection::VarMap& vars,
00057                          Reflection::Arg* arg)
00058     : DerivedViewBase<IntView>(IntView(home, vars, arg)) {}
00059 
00060 
00061 
00062     /*
00063      * Value access
00064      *
00065      */
00066     forceinline int
00067     MinusView::min(void) const {
00068       return -view.max();
00069     }
00070     forceinline int
00071     MinusView::max(void) const {
00072       return -view.min();
00073     }
00074     forceinline int
00075     MinusView::med(void) const {
00076       return -view.med();
00077     }
00078     forceinline int
00079     MinusView::val(void) const {
00080       return -view.val();
00081     }
00082 
00083     forceinline unsigned int
00084     MinusView::width(void) const {
00085       return view.width();
00086     }
00087     forceinline unsigned int
00088     MinusView::size(void) const {
00089       return view.size();
00090     }
00091     forceinline unsigned int
00092     MinusView::regret_min(void) const {
00093       return view.regret_max();
00094     }
00095     forceinline unsigned int
00096     MinusView::regret_max(void) const {
00097       return view.regret_min();
00098     }
00099 
00100 
00101     /*
00102      * Domain tests
00103      *
00104      */
00105     forceinline bool
00106     MinusView::range(void) const {
00107       return view.range();
00108     }
00109     forceinline bool
00110     MinusView::assigned(void) const {
00111       return view.assigned();
00112     }
00113     forceinline bool
00114     MinusView::in(int n) const {
00115       return view.in(-n);
00116     }
00117     forceinline bool
00118     MinusView::in(double n) const {
00119       return view.in(-n);
00120     }
00121 
00122 
00123     /*
00124      * Domain update by value
00125      *
00126      */
00127     forceinline ModEvent
00128     MinusView::lq(Space* home, int n) {
00129       return view.gq(home,-n);
00130     }
00131     forceinline ModEvent
00132     MinusView::lq(Space* home, double n) {
00133       return view.gq(home,-n);
00134     }
00135     forceinline ModEvent
00136     MinusView::le(Space* home, int n) {
00137       return view.gr(home,-n);
00138     }
00139     forceinline ModEvent
00140     MinusView::le(Space* home, double n) {
00141       return view.gr(home,-n);
00142     }
00143     forceinline ModEvent
00144     MinusView::gq(Space* home, int n) {
00145       return view.lq(home,-n);
00146     }
00147     forceinline ModEvent
00148     MinusView::gq(Space* home, double n) {
00149       return view.lq(home,-n);
00150     }
00151     forceinline ModEvent
00152     MinusView::gr(Space* home, int n) {
00153       return view.le(home,-n);
00154     }
00155     forceinline ModEvent
00156     MinusView::gr(Space* home, double n) {
00157       return view.le(home,-n);
00158     }
00159     forceinline ModEvent
00160     MinusView::nq(Space* home, int n) {
00161       return view.nq(home,-n);
00162     }
00163     forceinline ModEvent
00164     MinusView::nq(Space* home, double n) {
00165       return view.nq(home,-n);
00166     }
00167     forceinline ModEvent
00168     MinusView::eq(Space* home, int n) {
00169       return view.eq(home,-n);
00170     }
00171     forceinline ModEvent
00172     MinusView::eq(Space* home, double n) {
00173       return view.eq(home,-n);
00174     }
00175 
00176 
00177     /*
00178      * Iterator-based domain update
00179      *
00180      */
00181     template <class I>
00182     forceinline ModEvent
00183     MinusView::narrow_r(Space* home, I& i, bool) {
00184       Iter::Ranges::Minus<I> mi(i); 
00185       return view.narrow_r(home,mi,false);
00186     }
00187     template <class I>
00188     forceinline ModEvent
00189     MinusView::inter_r(Space* home, I& i, bool) {
00190       Iter::Ranges::Minus<I> mi(i); 
00191       return view.inter_r(home,mi,false);
00192     }
00193     template <class I>
00194     forceinline ModEvent
00195     MinusView::minus_r(Space* home, I& i, bool) {
00196       Iter::Ranges::Minus<I> mi(i); 
00197       return view.minus_r(home,mi,false);
00198     }
00199     template <class I>
00200     forceinline ModEvent
00201     MinusView::narrow_v(Space* home, I& i, bool) {
00202       Iter::Values::Minus<I> mi(i); 
00203       return view.narrow_v(home,mi,false);
00204     }
00205     template <class I>
00206     forceinline ModEvent
00207     MinusView::inter_v(Space* home, I& i, bool) {
00208       Iter::Values::Minus<I> mi(i); 
00209       return view.inter_v(home,mi,false);
00210     }
00211     template <class I>
00212     forceinline ModEvent
00213     MinusView::minus_v(Space* home, I& i, bool) {
00214       Iter::Values::Minus<I> mi(i); 
00215       return view.minus_v(home,mi,false);
00216     }
00217 
00218 
00219     /*
00220      * Propagator modification events
00221      *
00222      */
00223     forceinline void
00224     MinusView::schedule(Space* home, Propagator* p, ModEvent me) {
00225       return IntView::schedule(home,p,me);
00226     }
00227     forceinline ModEvent
00228     MinusView::me(ModEventDelta med) {
00229       return IntView::me(med);
00230     }
00231     forceinline ModEventDelta
00232     MinusView::med(ModEvent me) {
00233       return IntView::med(me);
00234     }
00235 
00236 
00237     /*
00238      * Dependencies
00239      *
00240      */
00241     forceinline void
00242     MinusView::subscribe(Space* home, Propagator* p, PropCond pc, 
00243                          bool process) {
00244       view.subscribe(home,p,pc,process);
00245     }
00246     forceinline void
00247     MinusView::cancel(Space* home, Propagator* p, PropCond pc) {
00248       view.cancel(home,p,pc);
00249     }
00250     forceinline void
00251     MinusView::subscribe(Space* home, Advisor* a) {
00252       view.subscribe(home,a);
00253     }
00254     forceinline void
00255     MinusView::cancel(Space* home, Advisor* a) {
00256       view.cancel(home,a);
00257     }
00258 
00259 
00260     /*
00261      * Delta information for advisors
00262      *
00263      */
00264     forceinline ModEvent
00265     MinusView::modevent(const Delta* d) {
00266       return IntView::modevent(d);
00267     }
00268     forceinline int
00269     MinusView::min(const Delta* d) const {
00270       return -view.max(d);
00271     }
00272     forceinline int
00273     MinusView::max(const Delta* d) const {
00274       return -view.min(d);
00275     }
00276     forceinline bool
00277     MinusView::any(const Delta* d) const {
00278       return view.any(d);
00279     }
00280 
00281 
00282 
00283     /*
00284      * Cloning
00285      *
00286      */
00287 
00288     forceinline void
00289     MinusView::update(Space* home, bool share, MinusView& x) {
00290       view.update(home,share,x.view);
00291     }
00292 
00293     /*
00294      * Serialization
00295      *
00296      */
00297     forceinline Reflection::Arg*
00298     MinusView::spec(const Space* home, Reflection::VarMap& m) const {
00299       return view.spec(home, m);
00300     }
00301     inline Support::Symbol
00302     MinusView::type(void) {
00303       return Support::Symbol("Gecode::Int::MinusView");
00304     }
00305 
00310     template <>
00311     class ViewRanges<MinusView> : public IntVarImpBwd {
00312     public:
00314 
00315 
00316       ViewRanges(void);
00318       ViewRanges(const MinusView& x);
00320       void init(const MinusView& x);
00322 
00324 
00325 
00326       int min(void) const;
00328       int max(void) const;
00330     };
00331 
00332     forceinline
00333     ViewRanges<MinusView>::ViewRanges(void) {}
00334 
00335     forceinline
00336     ViewRanges<MinusView>::ViewRanges(const MinusView& x)
00337       : IntVarImpBwd(x.base().var()) {}
00338 
00339     forceinline void
00340     ViewRanges<MinusView>::init(const MinusView& x) {
00341       IntVarImpBwd::init(x.base().var());
00342     }
00343 
00344     forceinline int
00345     ViewRanges<MinusView>::min(void) const {
00346       return -IntVarImpBwd::max();
00347     }
00348     forceinline int
00349     ViewRanges<MinusView>::max(void) const {
00350       return -IntVarImpBwd::min();
00351     }
00352 
00353   }
00354 
00355 
00356   /*
00357    * View comparison
00358    *
00359    */
00360   forceinline bool
00361   same(const Int::MinusView& x, const Int::MinusView& y) {
00362     return same(x.base(),y.base());
00363   }
00364   forceinline bool
00365   before(const Int::MinusView& x, const Int::MinusView& y) {
00366     return before(x.base(),y.base());
00367   }
00368 
00369 }
00370 
00371 // STATISTICS: int-var
00372