Generated on Fri Mar 20 15:56:19 2015 for Gecode by doxygen 1.6.3

rbs.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  *     Guido Tack <tack@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Christian Schulte, 2014
00009  *     Guido Tack, 2012
00010  *
00011  *  Last modified:
00012  *     $Date: 2015-03-19 14:02:56 +0100 (Thu, 19 Mar 2015) $ by $Author: schulte $
00013  *     $Revision: 14468 $
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 #include <gecode/search/support.hh>
00041 #include <gecode/search/meta/rbs.hh>
00042 
00043 namespace Gecode {
00044 
00045   template<template<class> class E, class T>
00046   forceinline
00047   RBS<E,T>::RBS(T* s, const Search::Options& m_opt) {
00048     if (m_opt.cutoff == NULL)
00049       throw Search::UninitializedCutoff("RBS::RBS");
00050     Search::Options e_opt(m_opt.expand());
00051     e_opt.clone = false;
00052     Search::Meta::RestartStop* rs = new Search::Meta::RestartStop(m_opt.stop);
00053     e_opt.stop = rs;
00054     Space* master;
00055     Space* slave;
00056     if (s->status(rs->m_stat) == SS_FAILED) {
00057       rs->m_stat.fail++;
00058       master = NULL;
00059       slave  = NULL;
00060     } else {
00061       if (m_opt.clone)
00062         master = s->clone();
00063       else
00064         master = s;
00065       slave = master->clone();
00066       CRI cri(0,0,0,NULL,NoGoods::eng);
00067       slave->slave(cri);
00068     }
00069     E<T> engine(dynamic_cast<T*>(slave),e_opt);
00070     Search::EngineBase<T>* eb = &engine;
00071     Search::Engine* ee = eb->e;
00072     eb->e = NULL;
00073     e = new Search::Meta::RBS(master,rs,ee,m_opt);
00074   }
00075 
00076 
00077   template<template<class> class E, class T>
00078   forceinline T*
00079   rbs(T* s, const Search::Options& o) {
00080     RBS<E,T> r(s,o);
00081     return r.next();
00082   }
00083 
00084 }
00085 
00086 // STATISTICS: search-meta