Generated on Fri Jun 5 2015 21:15:11 for Gecode by doxygen 1.8.9.1
stop.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2006
8  *
9  * Last modified:
10  * $Date: 2015-03-11 15:59:09 +0100 (Wed, 11 Mar 2015) $ by $Author: schulte $
11  * $Revision: 14435 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 namespace Gecode { namespace Search {
39 
40  /*
41  * Base class
42  *
43  */
45  Stop::Stop(void) {}
47  Stop::~Stop(void) {}
48  forceinline void*
49  Stop::operator new(size_t s) {
50  return heap.ralloc(s);
51  }
52  forceinline void
53  Stop::operator delete(void* p) {
54  heap.rfree(p);
55  }
56 
57 
58 
59 
60  /*
61  * Stopping for node limit
62  *
63  */
64 
66  NodeStop::NodeStop(unsigned long int l0) : l(l0) {}
67 
68  forceinline unsigned long int
69  NodeStop::limit(void) const {
70  return l;
71  }
72 
73  forceinline void
74  NodeStop::limit(unsigned long int l0) {
75  l=l0;
76  }
77 
78 
79  /*
80  * Stopping for failure limit
81  *
82  */
83 
85  FailStop::FailStop(unsigned long int l0) : l(l0) {}
86 
87  forceinline unsigned long int
88  FailStop::limit(void) const {
89  return l;
90  }
91 
92  forceinline void
93  FailStop::limit(unsigned long int l0) {
94  l=l0;
95  }
96 
97 
98  /*
99  * Stopping for time limit
100  *
101  */
102 
104  TimeStop::TimeStop(unsigned long int l0)
105  : l(l0) {
106  t.start();
107  }
108 
109  forceinline unsigned long int
110  TimeStop::limit(void) const {
111  return l;
112  }
113 
114  forceinline void
115  TimeStop::limit(unsigned long int l0) {
116  l=l0;
117  }
118 
119  forceinline void
121  t.start();
122  }
123 
124 }}
125 
126 // STATISTICS: search-other
unsigned long int limit(void) const
Return current limit.
Definition: stop.hpp:69
NNF * l
Left subtree.
Definition: bool-expr.cpp:244
void rfree(void *p)
Free memory block starting at p.
Definition: heap.hpp:355
unsigned long int l
Current limit in milliseconds.
Definition: search.hh:578
void * ralloc(size_t s)
Allocate s bytes from heap.
Definition: heap.hpp:341
Support::Timer t
Time when execution should stop.
Definition: search.hh:576
NodeStop(unsigned long int l)
Stop if node limit l is exceeded.
Definition: stop.hpp:66
Heap heap
The single global heap.
Definition: heap.cpp:49
void start(void)
Start timer.
Definition: timer.hpp:70
int p
Number of positive literals for node type.
Definition: bool-expr.cpp:236
FailStop(unsigned long int l)
Stop if failure limit l is exceeded.
Definition: stop.hpp:85
unsigned long int limit(void) const
Return current limit.
Definition: stop.hpp:88
void reset(void)
Reset time to zero.
Definition: stop.hpp:120
Stop(void)
Default constructor.
Definition: stop.hpp:45
unsigned long int l
Node limit.
Definition: search.hh:534
#define forceinline
Definition: config.hpp:132
unsigned long int l
Failure limit.
Definition: search.hh:557
virtual ~Stop(void)
Destructor.
Definition: stop.hpp:47
TimeStop(unsigned long int l)
Stop if search exceeds l milliseconds (from creation of this object)
Definition: stop.hpp:104
Gecode toplevel namespace
unsigned long int limit(void) const
Return current limit in milliseconds.
Definition: stop.hpp:110