42 #ifndef GECODE_THREADS_WINDOWS
46 namespace Gecode {
namespace Driver {
60 Cutoff(
unsigned int node,
unsigned int fail,
unsigned int time)
78 ((ns != NULL) && ns->
stop(s,o)) ||
79 ((fs != NULL) && fs->
stop(s,o)) ||
80 ((ts != NULL) && ts->
stop(s,o));
92 create(
unsigned int node,
unsigned int fail,
unsigned int time,
94 if ( (!intr) && (node == 0) && (fail == 0) && (time == 0))
97 return new Cutoff(node,fail,time);
99 #ifdef GECODE_THREADS_WINDOWS
102 if (t == CTRL_C_EVENT) {
119 if (force || !sigint) {
120 #ifdef GECODE_THREADS_WINDOWS
121 SetConsoleCtrlHandler( (PHANDLER_ROUTINE)
interrupt, install);
123 std::signal(SIGINT, install ? interrupt : SIG_DFL);
129 delete ns;
delete fs;
delete ts;
144 am(
double t[],
int n);
150 dev(
double t[],
int n);
152 #ifdef GECODE_HAS_GIST
157 template<
class Engine>
163 class GistEngine<DFS<S> > {
165 static void explore(S* root,
const Gist::Options&
opt) {
172 class GistEngine<BAB<S> > {
174 static void explore(S* root,
const Gist::Options&
opt) {
181 class GistEngine<Restart<S> > {
183 static void explore(S* root,
const Gist::Options&
opt) {
190 template<
class Space>
191 template<
class Script,
template<
class>
class Engine,
class Options>
198 #ifdef GECODE_HAS_GIST
208 for (
int i=0; o.inspect.click(
i) != NULL;
i++)
209 opt.
inspect.click(o.inspect.click(
i));
210 for (
int i=0; o.inspect.solution(
i) != NULL;
i++)
211 opt.
inspect.solution(o.inspect.solution(
i));
212 for (
int i=0; o.inspect.move(
i) != NULL;
i++)
213 opt.
inspect.move(o.inspect.move(
i));
214 for (
int i=0; o.inspect.compare(
i) != NULL;
i++)
215 opt.
inspect.compare(o.inspect.compare(
i));
217 (void) GistEngine<Engine<Script> >::
explore(s, opt);
224 cout << o.
name() << endl;
229 unsigned int n_p = s->propagators();
230 unsigned int n_b = s->branchers();
240 Engine<Script> e(s,so);
245 ex->
print(std::cout);
253 cout <<
"Search engine stopped..." << endl
255 int r =
static_cast<Cutoff*
>(so.
stop)->reason(stat,so);
257 cout <<
"user interrupt " << endl;
265 cout <<
"limit reached" << endl << endl;
268 cout <<
"Initial" << endl
269 <<
"\tpropagators: " << n_p << endl
270 <<
"\tbranchers: " << n_b << endl
278 <<
"\tpropagations: " << stat.
propagate << endl
279 <<
"\tnodes: " << stat.
node << endl
280 <<
"\tfailures: " << stat.
fail << endl
281 <<
"\tpeak depth: " << stat.
depth << endl
283 <<
static_cast<int>((stat.
memory+1023) / 1024) <<
" KB"
290 cout << o.
name() << endl;
295 unsigned int n_p = s->propagators();
296 unsigned int n_b = s->branchers();
306 Engine<Script> e(s,so);
317 <<
"\tpropagators: " << n_p << endl
318 <<
"\tbranchers: " << n_b << endl
324 <<
"\tpropagations: " << stat.
propagate << endl
325 <<
"\tnodes: " << stat.
node << endl
326 <<
"\tfailures: " << stat.
fail << endl
327 <<
"\tpeak depth: " << stat.
depth << endl
329 <<
static_cast<int>((stat.
memory+1023) / 1024) <<
" KB"
335 cout << o.
name() << endl;
337 double* ts =
new double[o.
samples()];
338 bool stopped =
false;
339 for (
unsigned int s = o.
samples(); !stopped && s--; ) {
341 for (
unsigned int k = o.
iterations(); !stopped && k--; ) {
350 Engine<Script> e(s,so);
364 cout <<
"\tSTOPPED" << endl;
368 cout <<
"\tRuntime: "
370 << showpoint << fixed
371 << setprecision(6) << m <<
"ms"
372 << setprecision(2) <<
" (" << d <<
"% deviation)"
380 cerr <<
"Exception: " << e.
what() <<
"." << endl
381 <<
"Stopping..." << endl;