main page
modules
namespaces
classes
files
Gecode home
Generated on Fri Aug 24 2012 04:52:13 for Gecode by
doxygen
1.8.1.1
gecode
driver.hh
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, 2009
8
*
9
* Last modified:
10
* $Date: 2010-10-07 07:44:30 +1100 (Thu, 07 Oct 2010) $ by $Author: schulte $
11
* $Revision: 11465 $
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
#ifndef __GECODE_DRIVER_HH__
39
#define __GECODE_DRIVER_HH__
40
41
#include <
gecode/minimodel.hh
>
42
#include <
gecode/search.hh
>
43
#ifdef GECODE_HAS_GIST
44
#include <
gecode/gist.hh
>
45
#endif
46
47
/*
48
* Configure linking
49
*
50
*/
51
#if !defined(GECODE_STATIC_LIBS) && \
52
(defined(__CYGWIN__) || defined(__MINGW32__) || defined(_MSC_VER))
53
54
#ifdef GECODE_BUILD_DRIVER
55
#define GECODE_DRIVER_EXPORT __declspec( dllexport )
56
#else
57
#define GECODE_DRIVER_EXPORT __declspec( dllimport )
58
#endif
59
60
#else
61
62
#ifdef GECODE_GCC_HAS_CLASS_VISIBILITY
63
#define GECODE_DRIVER_EXPORT __attribute__ ((visibility("default")))
64
#else
65
#define GECODE_DRIVER_EXPORT
66
#endif
67
68
#endif
69
70
// Configure auto-linking
71
#ifndef GECODE_BUILD_DRIVER
72
#define GECODE_LIBRARY_NAME "Driver"
73
#include <
gecode/support/auto-link.hpp
>
74
#endif
75
86
namespace
Gecode {
87
88
98
enum
ScriptMode
{
99
SM_SOLUTION
,
100
SM_TIME
,
101
SM_STAT
,
102
SM_GIST
103
};
104
105
class
BaseOptions;
106
107
namespace
Driver {
112
class
GECODE_DRIVER_EXPORT
BaseOption
{
113
friend
class
Gecode::BaseOptions
;
114
protected
:
115
const
char
*
opt
;
116
const
char
*
exp
;
117
BaseOption
*
next
;
118
public
:
120
BaseOption
(
const
char
* o,
const
char
* e);
122
virtual
bool
parse
(
int
& argc,
char
* argv[]) = 0;
124
virtual
void
help
(
void
) = 0;
126
virtual
~
BaseOption
(
void
);
128
static
char
* strdup(
const
char
* s);
130
static
void
strdel(
const
char
* s);
131
};
132
137
class
GECODE_DRIVER_EXPORT
StringValueOption
:
public
BaseOption
{
138
protected
:
139
const
char
*
cur
;
140
public
:
142
StringValueOption
(
const
char
* o,
const
char
* e,
const
char
*
v
=NULL);
144
void
value(
const
char
*
v
);
146
const
char
* value(
void
)
const
;
148
virtual
bool
parse
(
int
& argc,
char
* argv[]);
150
virtual
void
help(
void
);
152
virtual
~
StringValueOption
(
void
);
153
};
154
155
160
class
GECODE_DRIVER_EXPORT
StringOption
:
public
BaseOption
{
161
protected
:
163
class
Value
{
164
public
:
165
int
val
;
166
const
char
*
opt
;
167
const
char
*
help
;
168
Value
*
next
;
169
};
170
int
cur
;
171
Value
*
fst
;
172
Value
*
lst
;
173
public
:
175
StringOption
(
const
char
* o,
const
char
* e,
int
v
=0);
177
void
value(
int
v
);
179
int
value(
void
)
const
;
181
void
add(
int
v
,
const
char
* o,
const
char
* h = NULL);
183
virtual
bool
parse
(
int
& argc,
char
* argv[]);
185
virtual
void
help(
void
);
187
virtual
~
StringOption
(
void
);
188
};
189
190
195
class
GECODE_DRIVER_EXPORT
IntOption
:
public
BaseOption
{
196
protected
:
197
int
cur
;
198
public
:
200
IntOption
(
const
char
* o,
const
char
* e,
int
v
=0);
202
void
value(
int
v
);
204
int
value(
void
)
const
;
206
virtual
bool
parse
(
int
& argc,
char
* argv[]);
208
virtual
void
help(
void
);
209
};
210
215
class
GECODE_DRIVER_EXPORT
UnsignedIntOption
:
public
BaseOption
{
216
protected
:
217
unsigned
int
cur
;
218
public
:
220
UnsignedIntOption
(
const
char
* o,
const
char
* e,
unsigned
int
v
=0);
222
void
value(
unsigned
int
v
);
224
unsigned
int
value(
void
)
const
;
226
virtual
bool
parse
(
int
& argc,
char
* argv[]);
228
virtual
void
help(
void
);
229
};
230
235
class
GECODE_DRIVER_EXPORT
DoubleOption
:
public
BaseOption
{
236
protected
:
237
double
cur
;
238
public
:
240
DoubleOption
(
const
char
* o,
const
char
* e,
unsigned
int
v
=0);
242
void
value(
double
v
);
244
double
value(
void
)
const
;
246
virtual
bool
parse
(
int
& argc,
char
* argv[]);
248
virtual
void
help(
void
);
249
};
250
255
class
GECODE_DRIVER_EXPORT
BoolOption
:
public
BaseOption
{
256
protected
:
257
bool
cur
;
258
public
:
260
BoolOption
(
const
char
* o,
const
char
* e);
262
void
value(
bool
v
);
264
bool
value(
void
)
const
;
266
virtual
bool
parse
(
int
& argc,
char
* argv[]);
268
virtual
void
help(
void
);
269
};
270
271
}
272
277
class
GECODE_DRIVER_EXPORT
BaseOptions
{
278
protected
:
279
Driver::BaseOption
*
fst
;
280
Driver::BaseOption
*
lst
;
281
const
char
*
_name
;
282
public
:
284
BaseOptions
(
const
char
* s);
286
virtual
void
help(
void
);
287
289
void
add(
Driver::BaseOption
& o);
291
void
parse
(
int
& argc,
char
* argv[]);
292
294
const
char
* name(
void
)
const
;
296
void
name(
const
char
*);
297
299
virtual
~
BaseOptions
(
void
);
300
};
301
306
class
GECODE_DRIVER_EXPORT
Options
:
public
BaseOptions
{
307
protected
:
309
310
Driver::StringOption
_model
;
311
Driver::StringOption
_symmetry
;
312
Driver::StringOption
_propagation
;
313
Driver::StringOption
_icl
;
314
Driver::StringOption
_branching
;
315
316
318
319
Driver::StringOption
_search
;
320
Driver::UnsignedIntOption
_solutions
;
321
Driver::DoubleOption
_threads
;
322
Driver::UnsignedIntOption
_c_d
;
323
Driver::UnsignedIntOption
_a_d
;
324
Driver::UnsignedIntOption
_node
;
325
Driver::UnsignedIntOption
_fail
;
326
Driver::UnsignedIntOption
_time
;
327
Driver::StringOption
_interrupt
;
328
329
331
332
Driver::StringOption
_mode
;
333
Driver::UnsignedIntOption
_samples
;
334
Driver::UnsignedIntOption
_iterations
;
335
336
337
public
:
339
Options
(
const
char
* s);
340
342
343
344
void
model(
int
v
);
346
void
model(
int
v
,
const
char
* o,
const
char
* h = NULL);
348
int
model(
void
)
const
;
349
351
void
symmetry(
int
v
);
353
void
symmetry(
int
v
,
const
char
* o,
const
char
* h = NULL);
355
int
symmetry(
void
)
const
;
356
358
void
propagation(
int
v
);
360
void
propagation(
int
v
,
const
char
* o,
const
char
* h = NULL);
362
int
propagation(
void
)
const
;
363
365
void
icl(
IntConLevel
i
);
367
IntConLevel
icl(
void
)
const
;
368
370
void
branching(
int
v
);
372
void
branching(
int
v
,
const
char
* o,
const
char
* h = NULL);
374
int
branching(
void
)
const
;
376
378
379
380
void
search(
int
v
);
382
void
search(
int
v
,
const
char
* o,
const
char
* h = NULL);
384
int
search(
void
)
const
;
385
387
void
solutions
(
unsigned
int
n);
389
unsigned
int
solutions
(
void
)
const
;
390
392
void
threads
(
double
n);
394
double
threads
(
void
)
const
;
395
397
void
c_d
(
unsigned
int
d
);
399
unsigned
int
c_d
(
void
)
const
;
400
402
void
a_d
(
unsigned
int
d
);
404
unsigned
int
a_d
(
void
)
const
;
405
407
void
node(
unsigned
int
n);
409
unsigned
int
node(
void
)
const
;
410
412
void
fail(
unsigned
int
n);
414
unsigned
int
fail(
void
)
const
;
415
417
void
time(
unsigned
int
t);
419
unsigned
int
time(
void
)
const
;
420
422
void
interrupt(
bool
b
);
424
bool
interrupt(
void
)
const
;
426
428
429
430
void
mode(
ScriptMode
em);
432
ScriptMode
mode(
void
)
const
;
433
435
void
iterations(
unsigned
int
i
);
437
unsigned
int
iterations(
void
)
const
;
438
440
void
samples(
unsigned
int
s);
442
unsigned
int
samples(
void
)
const
;
444
445
#ifdef GECODE_HAS_GIST
446
447
class
_I {
448
private
:
450
Support::DynamicArray<Gist::Inspector*,Heap>
_click;
452
unsigned
int
n_click;
454
Support::DynamicArray<Gist::Inspector*,Heap>
_solution;
456
unsigned
int
n_solution;
458
Support::DynamicArray<Gist::Inspector*,Heap>
_move;
460
unsigned
int
n_move;
462
Support::DynamicArray<Gist::Comparator*,Heap>
_compare;
464
unsigned
int
n_compare;
465
public
:
467
_I(
void
);
469
void
click(
Gist::Inspector
*
i
);
471
void
solution(
Gist::Inspector
*
i
);
473
void
move(
Gist::Inspector
*
i
);
475
void
compare
(
Gist::Comparator
*
i
);
476
478
Gist::Inspector
* click(
unsigned
int
i
)
const
;
480
Gist::Inspector
* solution(
unsigned
int
i
)
const
;
482
Gist::Inspector
* move(
unsigned
int
i
)
const
;
484
Gist::Comparator
*
compare
(
unsigned
int
i
)
const
;
485
} inspect;
486
#endif
487
};
488
493
class
GECODE_DRIVER_EXPORT
SizeOptions
:
public
Options
{
494
protected
:
495
unsigned
int
_size
;
496
public
:
498
SizeOptions
(
const
char
* s);
500
virtual
void
help(
void
);
502
void
parse
(
int
& argc,
char
* argv[]);
503
505
void
size
(
unsigned
int
s);
507
unsigned
int
size
(
void
)
const
;
508
};
509
514
class
GECODE_DRIVER_EXPORT
InstanceOptions
:
public
Options
{
515
protected
:
516
const
char
*
_inst
;
517
public
:
519
InstanceOptions
(
const
char
* s);
521
virtual
void
help(
void
);
523
void
parse
(
int
& argc,
char
* argv[]);
524
526
void
instance(
const
char
* s);
528
const
char
* instance(
void
)
const
;
530
~
InstanceOptions
(
void
);
531
};
532
533
}
534
535
#include <
gecode/driver/options.hpp
>
536
537
namespace
Gecode {
538
539
namespace
Driver {
547
template
<
class
BaseSpace>
548
class
ScriptBase
:
public
BaseSpace {
549
public
:
551
ScriptBase
(
void
) {}
553
ScriptBase
(
bool
share,
ScriptBase
& e) : BaseSpace(share,e) {}
555
virtual
void
print
(std::ostream& os)
const
{ (void) os; }
557
virtual
void
compare
(
const
Space
&, std::ostream& os)
const
{
558
(void) os;
559
}
567
template
<
class
Script,
template
<
class
>
class
Engine,
class
Options
>
568
static
void
run
(
const
Options
&
opt
);
569
private
:
571
explicit
ScriptBase
(
ScriptBase
& e);
572
};
573
}
574
584
typedef
Driver::ScriptBase<Space>
Script
;
589
typedef
Driver::ScriptBase<MinimizeSpace>
MinimizeScript
;
594
typedef
Driver::ScriptBase<MaximizeSpace>
MaximizeScript
;
595
596
}
597
598
#include <
gecode/driver/script.hpp
>
599
600
#endif
601
602
// STATISTICS: driver-any