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

projectors.cc

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Guido Tack, 2006
00008  *
00009  *  Last modified:
00010  *     $Date: 2008-02-27 18:06:13 +0100 (Wed, 27 Feb 2008) $ by $Author: tack $
00011  *     $Revision: 6332 $
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 #include "gecode/set/projectors/propagator.hh"
00039 
00040 using namespace Gecode::Set;
00041 
00042 namespace Gecode {
00043 
00044   void projector(Space* home, const SetVar& xa, const SetVar& ya,
00045                  ProjectorSet& ps, bool negated) {
00046     if (home->failed()) return;
00047     ViewArray<SetView> x(home, 2);
00048     x[0] = xa; x[1] = ya;
00049     if (negated) {
00050       GECODE_ES_FAIL(home,
00051                      (Projection::NaryProjection<true>::post(home, 
00052                                                              x, ps)));
00053     } else {
00054       GECODE_ES_FAIL(home,
00055                      (Projection::NaryProjection<false>::post(home, 
00056                                                               x, ps)));
00057     }
00058     
00059   }
00060 
00061   void projector(Space* home, const SetVarArgs& xa,
00062                  ProjectorSet& ps, bool negated) {
00063     if (home->failed()) return;
00064     ViewArray<SetView> x(home, xa.size());
00065     for (int i=x.size(); i--;)
00066       x[i] = xa[i];
00067     if (negated) {
00068       GECODE_ES_FAIL(home,
00069                      (Projection::NaryProjection<true>::post(home, 
00070                                                              x, ps)));
00071     } else {
00072       GECODE_ES_FAIL(home,
00073                      (Projection::NaryProjection<false>::post(home, 
00074                                                               x, ps)));
00075     }
00076     
00077   }
00078 
00079   void projector(Space* home, const SetVar& xa, const SetVar& ya,
00080                  const BoolVar& bv, ProjectorSet& ps) {
00081     if (home->failed()) return;
00082     ViewArray<SetView> x(home, 2);
00083     x[0] = xa; x[1] = ya;
00084     Gecode::Int::BoolView b(bv);
00085     GECODE_ES_FAIL(home,
00086                    (Projection::ReNaryProjection::post(home, 
00087                                                        x, b, ps)));
00088   }
00089 
00090   void projector(Space* home,
00091                  const SetVar& xa, const SetVar& ya, const SetVar& za,
00092                  ProjectorSet& ps, bool negated) {
00093     if (home->failed()) return;
00094     ViewArray<SetView> x(home, 3);
00095     x[0] = xa; x[1] = ya; x[2] = za;
00096     if (negated) {
00097       GECODE_ES_FAIL(home,
00098                      (Projection::NaryProjection<true>::post(home, 
00099                                                              x, ps)));
00100     } else {
00101       GECODE_ES_FAIL(home,
00102                      (Projection::NaryProjection<false>::post(home, 
00103                                                               x, ps)));
00104     }
00105     
00106   }
00107 
00108   void projector(Space* home,
00109                  const SetVar& xa, const SetVar& ya, const SetVar& za,
00110                  const BoolVar& bv, ProjectorSet& ps) {
00111     if (home->failed()) return;
00112     ViewArray<SetView> x(home, 3);
00113     x[0] = xa; x[1] = ya; x[2] = za;
00114     Gecode::Int::BoolView b(bv);
00115     GECODE_ES_FAIL(home,
00116                    (Projection::ReNaryProjection::post(home, 
00117                                                           x, b, ps)));
00118   }
00119 
00120   void projector(Space* home, const SetVar& xa, const SetVar& ya,
00121                  const IntVar& i, Projector& p) {
00122     if (home->failed()) return;
00123     ViewArray<SetView> x(home, 2);
00124     x[0] = xa; x[1] = ya;
00125     Gecode::Int::IntView iv(i);
00126     GECODE_ES_FAIL(home,
00127                    (Projection::CardProjection::post(home,x,i,p)));
00128   }
00129 
00130   void projector(Space* home, const SetVar& xa, const SetVar& ya,
00131                  const SetVar& za, const IntVar& i, Projector& p) {
00132     if (home->failed()) return;
00133     ViewArray<SetView> x(home, 3);
00134     x[0] = xa; x[1] = ya; x[2] = za;
00135     Gecode::Int::IntView iv(i);
00136     GECODE_ES_FAIL(home,
00137                    (Projection::CardProjection::post(home,x,i,p)));
00138   }
00139   
00140 
00141 }
00142 
00143 // STATISTICS: set-post