44 #ifndef GECODE_THREADS_WINDOWS
48 namespace Gecode {
namespace Driver {
61 CombinedStop(
unsigned int node,
unsigned int fail,
unsigned int time)
80 ((ns != NULL) && ns->
stop(s,o)) ||
81 ((fs != NULL) && fs->
stop(s,o)) ||
82 ((ts != NULL) && ts->
stop(s,o));
94 create(
unsigned int node,
unsigned int fail,
unsigned int time,
96 if ( (!intr) && (node == 0) && (fail == 0) && (time == 0))
101 #ifdef GECODE_THREADS_WINDOWS
104 if (t == CTRL_C_EVENT) {
121 if (force || !sigint) {
122 #ifdef GECODE_THREADS_WINDOWS
123 SetConsoleCtrlHandler( (PHANDLER_ROUTINE)
interrupt, install);
125 std::signal(SIGINT, install ?
interrupt : SIG_DFL);
131 delete ns;
delete fs;
delete ts;
146 am(
double t[],
int n);
152 dev(
double t[],
int n);
155 template<
class Options>
175 #ifdef GECODE_HAS_GIST
180 template<
class Engine>
190 class GistEngine<DFS<S> > {
192 static void explore(S* root,
const Gist::Options&
opt) {
199 class GistEngine<BAB<S> > {
201 static void explore(S* root,
const Gist::Options&
opt) {
209 template<
class Space>
212 if (strcmp(name,
"stdout") == 0) {
214 }
else if (strcmp(name,
"stdlog") == 0) {
216 }
else if (strcmp(name,
"stderr") == 0) {
227 template<
template<
class>
class E,
class T>
233 template<
class Space>
234 template<
class Script,
template<
class>
class Engine,
class Options>
238 runMeta<Script,Engine,Options,EngineToMeta>(o,s);
240 runMeta<Script,Engine,Options,RBS>(o,s);
244 template<
class Space>
245 template<
class Script,
template<
class>
class Engine,
class Options,
246 template<
template<
class>
class,
class>
class Meta>
251 ofstream sol_file, log_file;
253 ostream& s_out = select_ostream(o.out_file(), sol_file);
254 ostream& l_out = select_ostream(o.log_file(), log_file);
259 #ifdef GECODE_HAS_GIST
269 for (
int i=0; o.inspect.click(
i) != NULL;
i++)
270 opt.
inspect.click(o.inspect.click(
i));
271 for (
int i=0; o.inspect.solution(
i) != NULL;
i++)
272 opt.
inspect.solution(o.inspect.solution(
i));
273 for (
int i=0; o.inspect.move(
i) != NULL;
i++)
274 opt.
inspect.move(o.inspect.move(
i));
275 for (
int i=0; o.inspect.compare(
i) != NULL;
i++)
276 opt.
inspect.compare(o.inspect.compare(
i));
279 (void) GistEngine<Engine<Script> >::
explore(s, opt);
286 l_out << o.name() << endl;
288 int i = o.solutions();
292 unsigned int n_p = s->propagators();
293 unsigned int n_b = s->branchers();
306 Meta<Engine,Script> e(s,so);
307 if (o.print_last()) {
336 l_out <<
"Search engine stopped..." << endl
340 l_out <<
"user interrupt " << endl;
348 l_out <<
"limit reached" << endl << endl;
351 l_out <<
"Initial" << endl
352 <<
"\tpropagators: " << n_p << endl
353 <<
"\tbranchers: " << n_b << endl
360 <<
::abs(static_cast<int>(o.solutions()) - i) << endl
361 <<
"\tpropagations: " << stat.
propagate << endl
362 <<
"\tnodes: " << stat.
node << endl
363 <<
"\tfailures: " << stat.
fail << endl
364 <<
"\trestarts: " << stat.
restart << endl
365 <<
"\tno-goods: " << stat.
nogood << endl
366 <<
"\tpeak depth: " << stat.
depth << endl
367 #ifdef GECODE_PEAKHEAP
369 <<
static_cast<int>((
heap.peak()+1023) / 1024) <<
" KB"
379 l_out << o.name() << endl;
381 int i = o.solutions();
385 unsigned int n_p = s->propagators();
386 unsigned int n_b = s->branchers();
399 Meta<Engine,Script> e(s,so);
410 <<
"\tpropagators: " << n_p << endl
411 <<
"\tbranchers: " << n_b << endl
416 <<
::abs(static_cast<int>(o.solutions()) - i) << endl
417 <<
"\tpropagations: " << stat.
propagate << endl
418 <<
"\tnodes: " << stat.
node << endl
419 <<
"\tfailures: " << stat.
fail << endl
420 <<
"\trestarts: " << stat.
restart << endl
421 <<
"\tno-goods: " << stat.
nogood << endl
422 <<
"\tpeak depth: " << stat.
depth << endl
423 #ifdef GECODE_PEAKHEAP
425 <<
static_cast<int>((
heap.peak()+1023) / 1024) <<
" KB"
435 l_out << o.name() << endl;
437 double* ts =
new double[o.samples()];
438 bool stopped =
false;
439 for (
unsigned int s = o.samples(); !stopped && s--; ) {
441 for (
unsigned int k = o.iterations(); !stopped && k--; ) {
442 unsigned int i = o.solutions();
454 Meta<Engine,Script> e(s,so);
466 ts[s] = t.
stop() / o.iterations();
469 l_out <<
"\tSTOPPED" << endl;
471 double m =
am(ts,o.samples());
472 double d =
dev(ts,o.samples()) * 100.0;
473 l_out <<
"\truntime: "
475 << showpoint << fixed
476 << setprecision(6) << m <<
"ms"
477 << setprecision(2) <<
" (" << d <<
"% deviation)"
485 cerr <<
"Exception: " << e.
what() <<
"." << endl
486 <<
"Stopping..." << endl;
487 if (sol_file.is_open())
489 if (log_file.is_open())
493 if (sol_file.is_open())
495 if (log_file.is_open())