Main Page | Class Hierarchy | Class List | File List | Class Members

Driver.h

00001 // Driver.h -- The interface to the dynamic selection of decomposition
00002 // algorithms.
00003 
00004 /*
00005  * Copyright (C) 1997, 1998 Tudor Hulubei <tudor@hulubei.net>.
00006  *
00007  * This library is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU Lesser General Public License as
00009  * published by the Free Software Foundation; either version 2, or (at
00010  * your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA,
00020  * 02111-1307, USA.
00021  */
00022 
00023 /*
00024  * NOTE: This is an interal header file.
00025  * You should not attempt to use it directly.
00026  */
00027 
00028 // $Id: Driver_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00029 
00030 #ifndef _CSP_KERNEL_Driver_H
00031 #define _CSP_KERNEL_Driver_H
00032 
00033 
00034 CSP_NAMESPACE_BEGIN(csp);
00035 
00036 
00037 class CSP_API Decomposition;
00038 
00039 
00054 class CSP_API Driver
00055 {
00056   public:
00063     Driver(Problem& problem, Filter& filter) :
00064         m_problem(problem),
00065         m_filter(filter),
00066         m_timeLimitExceeded(false),
00067         m_nodeLimitExceeded(false),
00068         m_yields(0),
00069         m_voluntaryYields(0) {}
00070 
00076     void registerDecomposition(Decomposition& decomposition);
00077 
00083     void unregisterDecomposition(Decomposition& decomposition);
00084 
00086     size_t decompositions() const
00087     {
00088         return m_decompositions.size();
00089     }
00090 
00097     Decomposition& decomposition(size_t n) const
00098     {
00099         assert(n < m_decompositions.size());
00100         return *m_decompositions[n];
00101     }
00102 
00112     const Resources& resources() const
00113     {
00114         assert(m_decompositions.size() > 0);
00115         return m_decompositions[0]->resources();
00116     }
00117 
00119     Resources& resources()
00120     {
00121         assert(m_decompositions.size() > 0);
00122         return m_decompositions[0]->resources();
00123     }
00124 
00129     const timeval& timeLimit() const
00130     {
00131         assert(m_decompositions.size() > 0);
00132         return m_decompositions[0]->m_timeLimit;
00133     }
00134 
00144     timeval setTimeLimit(const timeval& timeLimit);
00145 
00147     bool timeLimitExceeded() const
00148     {
00149         return m_timeLimitExceeded;
00150     }
00151 
00155     const ulonglong nodeLimit() const
00156     {
00157         assert(m_decompositions.size() > 0);
00158         return m_decompositions[0]->m_nodeLimit;
00159     }
00160 
00169     ulonglong setNodeLimit(const ulonglong nodeLimit);
00170 
00173     bool nodeLimitExceeded() const
00174     {
00175         return m_nodeLimitExceeded;
00176     }
00177 
00179     ulonglong solutions() const;
00180 
00192     bool canYield(size_t index) const
00193     {
00194         return index < m_decompositions.size() - 1;
00195     }
00196 
00204     void setSolutionCallback(bool (*solutionCallback)(Decomposition&, bool&));
00205 
00211     ulonglong search();
00212 
00225     void yield(size_t fromIndex, bool voluntary);
00226 
00231     double staticOptimismPercentage() const
00232     {
00233         return m_decompositions[0]->staticOptimismPercentage();
00234     }
00235 
00247     void setStaticOptimismPercentage(double percentage);
00248 
00253     double dynamicOptimismPercentage() const
00254     {
00255         return m_decompositions[0]->dynamicOptimismPercentage();
00256     }
00257 
00268     void setDynamicOptimismPercentage(double percentage);
00269 
00271     ulonglong yields() const { return m_yields; }
00272 
00275     ulonglong voluntaryYields() const { return m_yields; }
00276 
00278     ulonglong totalCCKS() const;
00279 
00281     ulonglong failedCCKS() const;
00282 
00283   private:
00284     // The chain of decomposition algorithms.
00285     vector<Decomposition*> m_decompositions;
00286 
00287     // The problem to be solved.
00288     Problem& m_problem;
00289 
00290     // The filter.
00291     Filter& m_filter;
00292 
00293     // `true' if the search timed out.
00294     bool m_timeLimitExceeded;
00295 
00296     // `true' if the search exceeded the number of nodes allowed.
00297     bool m_nodeLimitExceeded;
00298 
00299     // The total number of times the driver's yield() method was called.
00300     ulonglong m_yields;
00301 
00302     // The number of voluntary yields.
00303     ulonglong m_voluntaryYields;
00304 
00306     Driver(const Driver&);
00307 
00309     Driver& operator=(const Driver&);
00310 };
00311 
00312 
00313 CSP_NAMESPACE_END(csp);
00314 
00315 
00316 #endif // _CSP_KERNEL_Driver_H
00317 
00318 // Local Variables:
00319 // mode: C++
00320 // End:

Generated on Wed May 25 12:21:14 2005 for csp.kdevelop by  doxygen 1.3.9.1