-
Notifications
You must be signed in to change notification settings - Fork 8
/
clingo.html
1480 lines (1325 loc) · 97.8 KB
/
clingo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module clingo</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>clingo</strong></big></big> (version 5.0.0)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">«Potassco</a></font></td></tr></table>
<p><tt>The clingo-5.0.0 module.<br>
<br>
This module provides functions and classes to work with ground terms and to<br>
control the instantiation process. In clingo builts, additional functions to<br>
control and inspect the solving process are available.<br>
<br>
Functions defined in a python script block are callable during the<br>
instantiation process using @-syntax. The default grounding/solving process can<br>
be customized if a main function is provided.<br>
<br>
Note that gringo's precomputed terms (terms without variables and interpreted<br>
functions), called symbols in the following, are wrapped in the <a href="#Symbol">Symbol</a> class.<br>
Furthermore, strings, numbers, and tuples can be passed whereever a symbol is<br>
expected - they are automatically converted into a <a href="#Symbol">Symbol</a> object. Functions<br>
called during the grounding process from the logic program must either return a<br>
symbol or a sequence of symbols. If a sequence is returned, the corresponding<br>
@-term is successively substituted by the values in the sequence.<br>
<br>
Static Objects:<br>
<br>
__version__ -- version of the clingo module (5.0.0)<br>
Infimum -- represents an #inf symbol<br>
Supremum -- represents a #sup symbol<br>
<br>
Functions:<br>
<br>
<a href="#-Function">Function</a>() -- create a function symbol<br>
<a href="#-Number">Number</a>() -- creat a number symbol<br>
<a href="#-parse_program">parse_program</a>() -- parse a logic program<br>
<a href="#-parse_term">parse_term</a>() -- parse ground terms<br>
<a href="#-String">String</a>() -- create a string symbol<br>
<a href="#-Tuple">Tuple</a>() -- create a tuple symbol (shortcut)<br>
<br>
Classes:<br>
<br>
<a href="#Assignment">Assignment</a> -- partial assignment of truth values to solver literals<br>
<a href="#Backend">Backend</a> -- extend the logic program<br>
<a href="#Configuration">Configuration</a> -- modify/inspect the solver configuration<br>
<a href="#Control">Control</a> -- controls the grounding/solving process<br>
<a href="#Model">Model</a> -- provides access to a model during solve call<br>
<a href="#ProgramBuilder">ProgramBuilder</a> -- extend a non-ground logic program<br>
<a href="#PropagateControl">PropagateControl</a> -- controls running search in a custom propagator<br>
<a href="#PropagateInit">PropagateInit</a> -- object to initialize custom propagators<br>
<a href="#SolveControl">SolveControl</a> -- controls running search in a model handler<br>
<a href="#SolveFuture">SolveFuture</a> -- handle for asynchronous solve calls<br>
<a href="#SolveIter">SolveIter</a> -- handle to iterate over models<br>
<a href="#SolveResult">SolveResult</a> -- result of a solve call<br>
<a href="#Symbol">Symbol</a> -- captures precomputed terms<br>
<a href="#SymbolicAtom">SymbolicAtom</a> -- captures information about a symbolic atom<br>
<a href="#SymbolicAtomIter">SymbolicAtomIter</a> -- iterate over symbolic atoms<br>
<a href="#SymbolicAtoms">SymbolicAtoms</a> -- inspection of symbolic atoms<br>
<a href="#SymbolType">SymbolType</a> -- the type of a symbol<br>
<a href="#TheoryAtom">TheoryAtom</a> -- captures theory atoms<br>
<a href="#TheoryAtomIter">TheoryAtomIter</a> -- iterate over theory atoms<br>
<a href="#TheoryElement">TheoryElement</a> -- captures theory elements<br>
<a href="#TheoryTerm">TheoryTerm</a> -- captures theory terms<br>
<a href="#TheoryTermType">TheoryTermType</a> -- the type of a theory term<br>
<br>
Example:<br>
<br>
#script (python)<br>
import clingo<br>
def id(x):<br>
return x<br>
<br>
def seq(x, y):<br>
return [x, y]<br>
<br>
def main(prg):<br>
prg.ground([("base", [])])<br>
prg.solve()<br>
<br>
#end.<br>
<br>
p(@id(10)).<br>
q(@seq(1,2)).</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="clingo.ast.html">clingo.ast</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#22bb33">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#22bb33"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial">object
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="#Assignment">Assignment</a>
</font></dt><dt><font face="helvetica, arial"><a href="#Backend">Backend</a>
</font></dt><dt><font face="helvetica, arial"><a href="#Configuration">Configuration</a>
</font></dt><dt><font face="helvetica, arial"><a href="#Control">Control</a>
</font></dt><dt><font face="helvetica, arial"><a href="#Model">Model</a>
</font></dt><dt><font face="helvetica, arial"><a href="#ProgramBuilder">ProgramBuilder</a>
</font></dt><dt><font face="helvetica, arial"><a href="#PropagateControl">PropagateControl</a>
</font></dt><dt><font face="helvetica, arial"><a href="#PropagateInit">PropagateInit</a>
</font></dt><dt><font face="helvetica, arial"><a href="#SolveControl">SolveControl</a>
</font></dt><dt><font face="helvetica, arial"><a href="#SolveFuture">SolveFuture</a>
</font></dt><dt><font face="helvetica, arial"><a href="#SolveIter">SolveIter</a>
</font></dt><dt><font face="helvetica, arial"><a href="#SolveResult">SolveResult</a>
</font></dt><dt><font face="helvetica, arial"><a href="#Symbol">Symbol</a>
</font></dt><dt><font face="helvetica, arial"><a href="#SymbolType">SymbolType</a>
</font></dt><dt><font face="helvetica, arial"><a href="#SymbolicAtom">SymbolicAtom</a>
</font></dt><dt><font face="helvetica, arial"><a href="#SymbolicAtomIter">SymbolicAtomIter</a>
</font></dt><dt><font face="helvetica, arial"><a href="#SymbolicAtoms">SymbolicAtoms</a>
</font></dt><dt><font face="helvetica, arial"><a href="#TheoryAtom">TheoryAtom</a>
</font></dt><dt><font face="helvetica, arial"><a href="#TheoryAtomIter">TheoryAtomIter</a>
</font></dt><dt><font face="helvetica, arial"><a href="#TheoryElement">TheoryElement</a>
</font></dt><dt><font face="helvetica, arial"><a href="#TheoryTerm">TheoryTerm</a>
</font></dt><dt><font face="helvetica, arial"><a href="#TheoryTermType">TheoryTermType</a>
</font></dt></dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="Assignment">class <strong>Assignment</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Object to inspect the (parital) assignment of an associated solver.<br>
<br>
Assigns truth values to solver literals. Each solver literal is either true,<br>
false, or undefined, represented by the python constants True, False, or None,<br>
respectively.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Assignment-decision"><strong>decision</strong></a>(...)</dt><dd><tt><a href="#Assignment-decision">decision</a>(self, level) -> int<br>
<br>
Return the decision literal of the given level.</tt></dd></dl>
<dl><dt><a name="Assignment-has_literal"><strong>has_literal</strong></a>(...)</dt><dd><tt><a href="#Assignment-has_literal">has_literal</a>(self, lit) -> bool<br>
<br>
Determine if the literal is valid in this solver.</tt></dd></dl>
<dl><dt><a name="Assignment-is_false"><strong>is_false</strong></a>(...)</dt><dd><tt><a href="#Assignment-is_false">is_false</a>(self, lit) -> bool<br>
<br>
Determine if the literal is false.</tt></dd></dl>
<dl><dt><a name="Assignment-is_fixed"><strong>is_fixed</strong></a>(...)</dt><dd><tt><a href="#Assignment-is_fixed">is_fixed</a>(self, lit) -> bool<br>
<br>
Determine if the literal is assigned on the top level.</tt></dd></dl>
<dl><dt><a name="Assignment-is_true"><strong>is_true</strong></a>(...)</dt><dd><tt><a href="#Assignment-is_true">is_true</a>(self, lit) -> bool<br>
<br>
Determine if the literal is true.</tt></dd></dl>
<dl><dt><a name="Assignment-level"><strong>level</strong></a>(...)</dt><dd><tt><a href="#Assignment-level">level</a>(self, lit) -> int<br>
<br>
The decision level of the given literal.<br>
<br>
Note that the returned value is only meaningful if the literal is assigned -<br>
i.e., <a href="#Assignment-value">value</a>(lit) is not None.</tt></dd></dl>
<dl><dt><a name="Assignment-value"><strong>value</strong></a>(...)</dt><dd><tt><a href="#Assignment-value">value</a>(self, lit) -> bool or None<br>
<br>
The truth value of the given literal or None if it has none.</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>decision_level</strong></dt>
<dd><tt>The current decision level.</tt></dd>
</dl>
<dl><dt><strong>has_conflict</strong></dt>
<dd><tt>True if the current assignment is conflicting.</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="Backend">class <strong>Backend</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#Backend">Backend</a> object providing a low level interface to extend a logic program."<br>
<br>
This class provides an interface that allows for adding statements in ASPIF<br>
format.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Backend-add_atom"><strong>add_atom</strong></a>(...)</dt><dd><tt><a href="#Backend-add_atom">add_atom</a>(self) -> Int<br>
<br>
Return a fresh program atom.</tt></dd></dl>
<dl><dt><a name="Backend-add_rule"><strong>add_rule</strong></a>(...)</dt><dd><tt><a href="#Backend-add_rule">add_rule</a>(self, head, body, choice) -> None<br>
<br>
Add a disjuntive or choice rule to the program.<br>
<br>
Arguments:<br>
head -- list of program atoms<br>
<br>
Keyword Arguments:<br>
body -- list of program literals (Default: [])<br>
choice -- whether to add a disjunctive or choice rule (Default: False)<br>
<br>
Integrity constraints and normal rules can be added by using an empty or<br>
singleton head list, respectively.</tt></dd></dl>
<dl><dt><a name="Backend-add_weight_rule"><strong>add_weight_rule</strong></a>(...)</dt><dd><tt><a href="#Backend-add_weight_rule">add_weight_rule</a>(self, head, lower, body, choice) -> None<br>
Add a disjuntive or choice rule with one weight constraint with a lower bound<br>
in the body to the program.<br>
<br>
Arguments:<br>
head -- list of program atoms<br>
lower -- integer for the lower bound<br>
body -- list of pairs of program literals and weights<br>
<br>
Keyword Arguments:<br>
choice -- whether to add a disjunctive or choice rule (Default: False)</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="Configuration">class <strong>Configuration</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Allows for changing the configuration of the underlying solver.<br>
<br>
Options are organized hierarchically. To change and inspect an option use:<br>
<br>
config.group.subgroup.option = "value"<br>
value = config.group.subgroup.option<br>
<br>
There are also arrays of option groups that can be accessed using integer<br>
indices:<br>
<br>
config.group.subgroup[0].option = "value1"<br>
config.group.subgroup[1].option = "value2"<br>
<br>
To list the subgroups of an option group, use the keys member. Array option<br>
groups, like solver, have a non-negative length and can be iterated.<br>
Furthermore, there are meta options having key "configuration". Assigning a<br>
meta option sets a number of related options. To get further information about<br>
an option or option group <opt>, use property __desc_<opt> to retrieve a<br>
description.<br>
<br>
Example:<br>
<br>
#script (python)<br>
import clingo<br>
<br>
def main(prg):<br>
prg.conf.solve.models = 0<br>
prg.ground([("base", [])])<br>
prg.solve()<br>
<br>
#end.<br>
<br>
{a; c}.<br>
<br>
Expected Answer Sets:<br>
<br>
{ {}, {a}, {c}, {a,c} }<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Configuration-__delattr__"><strong>__delattr__</strong></a>(...)</dt><dd><tt>x.<a href="#Configuration-__delattr__">__delattr__</a>('name') <==> del x.name</tt></dd></dl>
<dl><dt><a name="Configuration-__getattribute__"><strong>__getattribute__</strong></a>(...)</dt><dd><tt>x.<a href="#Configuration-__getattribute__">__getattribute__</a>('name') <==> x.name</tt></dd></dl>
<dl><dt><a name="Configuration-__getitem__"><strong>__getitem__</strong></a>(...)</dt><dd><tt>x.<a href="#Configuration-__getitem__">__getitem__</a>(y) <==> x[y]</tt></dd></dl>
<dl><dt><a name="Configuration-__len__"><strong>__len__</strong></a>(...)</dt><dd><tt>x.<a href="#Configuration-__len__">__len__</a>() <==> len(x)</tt></dd></dl>
<dl><dt><a name="Configuration-__setattr__"><strong>__setattr__</strong></a>(...)</dt><dd><tt>x.<a href="#Configuration-__setattr__">__setattr__</a>('name', value) <==> x.name = value</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>keys</strong></dt>
<dd><tt>The list of names of sub-option groups or options.<br>
<br>
The list is None if the current object is not an option group.</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="Control">class <strong>Control</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt><a href="#Control">Control</a>(arguments) -> <a href="#Control">Control</a><br>
<br>
<a href="#Control">Control</a> object for the grounding/solving process.<br>
<br>
Arguments:<br>
arguments -- optional arguments to the grounder and solver (default: []).<br>
<br>
Note that only gringo options (without --text) and clasp's search options are<br>
supported. Furthermore, a <a href="#Control">Control</a> object is blocked while a search call is<br>
active; you must not call any member function during search.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Control-__init__"><strong>__init__</strong></a>(...)</dt><dd><tt>x.<a href="#Control-__init__">__init__</a>(...) initializes x; see help(type(x)) for signature</tt></dd></dl>
<dl><dt><a name="Control-add"><strong>add</strong></a>(...)</dt><dd><tt><a href="#Control-add">add</a>(self, name, params, program) -> None<br>
<br>
Extend the logic program with the given non-ground logic program in string form.<br>
<br>
Arguments:<br>
name -- name of program block to add<br>
params -- parameters of program block<br>
program -- non-ground program as string<br>
<br>
Example:<br>
<br>
#script (python)<br>
import clingo<br>
<br>
def main(prg):<br>
prg.<a href="#Control-add">add</a>("p", ["t"], "q(t).")<br>
prg.<a href="#Control-ground">ground</a>([("p", [2])])<br>
prg.<a href="#Control-solve">solve</a>()<br>
<br>
#end.<br>
<br>
Expected Answer Set:<br>
q(2)</tt></dd></dl>
<dl><dt><a name="Control-assign_external"><strong>assign_external</strong></a>(...)</dt><dd><tt><a href="#Control-assign_external">assign_external</a>(self, external, truth) -> None<br>
<br>
Assign a truth value to an external atom (represented as a function symbol).<br>
<br>
It is possible to assign a Boolean or None. A Boolean fixes the external to the<br>
respective truth value; and None leaves its truth value open.<br>
<br>
The truth value of an external atom can be changed before each solve call. An<br>
atom is treated as external if it has been declared using an #external<br>
directive, and has not been forgotten by calling <a href="#Control-release_external">release_external</a>() or defined<br>
in a logic program with some rule. If the given atom is not external, then the<br>
function has no effect.<br>
<br>
Arguments:<br>
external -- symbol representing the external atom<br>
truth -- bool or None indicating the truth value<br>
<br>
To determine whether an atom a is external, inspect the symbolic_atoms using<br>
<a href="#SolveControl">SolveControl</a>.symbolic_atoms[a].is_external. See <a href="#Control-release_external">release_external</a>() for an<br>
example.</tt></dd></dl>
<dl><dt><a name="Control-builder"><strong>builder</strong></a>(...)</dt><dd><tt><a href="#Control-builder">builder</a>(self) -> <a href="#ProgramBuilder">ProgramBuilder</a><br>
<br>
Return a builder to construct non-ground logic programs.<br>
<br>
Example:<br>
<br>
#script (python)<br>
<br>
import clingo<br>
<br>
def main(prg):<br>
s = "a."<br>
with prg.<a href="#Control-builder">builder</a>() as b:<br>
clingo.<a href="#-parse_program">parse_program</a>(s, lambda stm: b.<a href="#Control-add">add</a>(stm))<br>
prg.<a href="#Control-ground">ground</a>([("base", [])])<br>
prg.<a href="#Control-solve">solve</a>()<br>
<br>
#end.</tt></dd></dl>
<dl><dt><a name="Control-cleanup"><strong>cleanup</strong></a>(...)</dt><dd><tt><a href="#Control-cleanup">cleanup</a>(self) -> None<br>
<br>
Cleanup the domain used for grounding by incorporating information from the<br>
solver.<br>
<br>
This function cleans up the domain used for grounding. This is done by first<br>
simplifying the current program representation (falsifying released external<br>
atoms). Afterwards, the top-level implications are used to either remove atoms<br>
from the domain or mark them as facts.<br>
<br>
Note that any atoms falsified are completely removed from the logic program.<br>
Hence, a definition for such an atom in a successive step introduces a fresh atom.</tt></dd></dl>
<dl><dt><a name="Control-get_const"><strong>get_const</strong></a>(...)</dt><dd><tt><a href="#Control-get_const">get_const</a>(self, name) -> <a href="#Symbol">Symbol</a><br>
<br>
Return the symbol for a constant definition of form: #const name = symbol.</tt></dd></dl>
<dl><dt><a name="Control-ground"><strong>ground</strong></a>(...)</dt><dd><tt><a href="#Control-ground">ground</a>(self, parts, context) -> None<br>
<br>
Ground the given list of program parts specified by tuples of names and arguments.<br>
<br>
Keyword Arguments:<br>
parts -- list of tuples of program names and program arguments to ground<br>
context -- context object whose methods are called during grounding using<br>
the @-syntax (if ommitted methods from the main module are used)<br>
<br>
Note that parts of a logic program without an explicit #program specification<br>
are by default put into a program called base without arguments.<br>
<br>
Example:<br>
<br>
#script (python)<br>
import clingo<br>
<br>
def main(prg):<br>
parts = []<br>
parts.append(("p", [1]))<br>
parts.append(("p", [2]))<br>
prg.<a href="#Control-ground">ground</a>(parts)<br>
prg.<a href="#Control-solve">solve</a>()<br>
<br>
#end.<br>
<br>
#program p(t).<br>
q(t).<br>
<br>
Expected Answer Set:<br>
q(1) q(2)</tt></dd></dl>
<dl><dt><a name="Control-interrupt"><strong>interrupt</strong></a>(...)</dt><dd><tt><a href="#Control-interrupt">interrupt</a>(self) -> None<br>
<br>
Interrupt the active solve call.<br>
<br>
This function is thread-safe and can be called from a signal handler. If no<br>
search is active the subsequent call to <a href="#Control-solve">solve</a>(), <a href="#Control-solve_async">solve_async</a>(), or <a href="#Control-solve_iter">solve_iter</a>()<br>
is interrupted. The <a href="#SolveResult">SolveResult</a> of the above solving methods can be used to<br>
query if the search was interrupted.</tt></dd></dl>
<dl><dt><a name="Control-load"><strong>load</strong></a>(...)</dt><dd><tt><a href="#Control-load">load</a>(self, path) -> None<br>
<br>
Extend the logic program with a (non-ground) logic program in a file.<br>
<br>
Arguments:<br>
path -- path to program</tt></dd></dl>
<dl><dt><a name="Control-register_propagator"><strong>register_propagator</strong></a>(...)</dt><dd><tt><a href="#Control-register_propagator">register_propagator</a>(self, propagator) -> None<br>
<br>
Registers the given propagator with all solvers.<br>
<br>
Arguments:<br>
propagator -- the propagator to register<br>
<br>
A propagator should be a class of the form below. Not all functions have to be<br>
implemented and can be ommited if not needed.<br>
<br>
class Propagator(object)<br>
init(self, init) -> None<br>
This function is called once before each solving step. It is used to<br>
map relevant program literals to solver literals, add watches for<br>
solver literals, and initialize the data structures used during<br>
propagation.<br>
<br>
Arguments:<br>
init -- <a href="#PropagateInit">PropagateInit</a> object<br>
<br>
Note that this is the last point to access theory atoms. Once the<br>
search has started, they are no longer accessible.<br>
<br>
propagate(self, control, changes) -> None<br>
Can be used to propagate solver literals given a partial assignment.<br>
<br>
Arguments:<br>
control -- <a href="#PropagateControl">PropagateControl</a> object<br>
changes -- list of watched solver literals assigned to true<br>
<br>
Usage:<br>
Called during propagation with a non-empty list of watched solver<br>
literals that have been assigned to true since the last call to either<br>
propagate, undo, (or the start of the search) - the change set. Only<br>
watched solver literals are contained in the change set. Each literal<br>
in the change set is true w.r.t. the current <a href="#Assignment">Assignment</a>.<br>
<a href="#PropagateControl">PropagateControl</a>.add_clause can be used to add clauses. If a clause is<br>
unit resulting, it can be propagated using<br>
<a href="#PropagateControl">PropagateControl</a>.propagate(). If either of the two methods returns<br>
False, the propagate function must return immediately.<br>
<br>
c = ...<br>
if not control.add_clause(c) or not control.propagate(c):<br>
return<br>
<br>
Note that this function can be called from different solving threads.<br>
Each thread has its own assignment and id, which can be obtained using<br>
<a href="#PropagateControl">PropagateControl</a>.id().<br>
<br>
undo(self, thread_id, assign, changes) -> None<br>
Called whenever a solver with the given id undos assignments to watched<br>
solver literals.<br>
<br>
Arguments:<br>
thread_id -- the solver thread id<br>
changes -- list of watched solver literals whose assignment is undone<br>
<br>
This function is meant to update assignment dependend state in a<br>
propagator.<br>
<br>
check(self, control) -> None<br>
This function is similar to propagate but is only called on total<br>
assignments without a change set.<br>
<br>
Arguments:<br>
control -- <a href="#PropagateControl">PropagateControl</a> object<br>
<br>
This function is called even if no watches have been added.</tt></dd></dl>
<dl><dt><a name="Control-release_external"><strong>release_external</strong></a>(...)</dt><dd><tt><a href="#Control-release_external">release_external</a>(self, symbol) -> None<br>
<br>
Release an external atom represented by the given symbol.<br>
<br>
This function causes the corresponding atom to become permanently false if<br>
there is no definition for the atom in the program. Otherwise, the function has<br>
no effect.<br>
<br>
Example:<br>
<br>
#script (python)<br>
from clingo import function<br>
<br>
def main(prg):<br>
prg.<a href="#Control-ground">ground</a>([("base", [])])<br>
prg.<a href="#Control-assign_external">assign_external</a>(<a href="#-Function">Function</a>("b"), True)<br>
prg.<a href="#Control-solve">solve</a>()<br>
prg.<a href="#Control-release_external">release_external</a>(<a href="#-Function">Function</a>("b"))<br>
prg.<a href="#Control-solve">solve</a>()<br>
<br>
#end.<br>
<br>
a.<br>
#external b.<br>
<br>
Expected Answer Sets:<br>
a b<br>
a</tt></dd></dl>
<dl><dt><a name="Control-solve"><strong>solve</strong></a>(...)</dt><dd><tt><a href="#Control-solve">solve</a>(self, on_model, assumptions) -> <a href="#SolveResult">SolveResult</a><br>
<br>
Start a search process and return a <a href="#SolveResult">SolveResult</a>.<br>
<br>
Keyword Arguments:<br>
on_model -- optional callback for intercepting models<br>
a <a href="#Model">Model</a> object is passed to the callback<br>
assumptions -- a list of (atom, boolean) tuples that serve as assumptions for<br>
the solve call, e.g. - solving under assumptions [(<a href="#-Function">Function</a>("a"),<br>
True)] only admits answer sets that contain atom a<br>
<br>
Note that in gringo or in clingo with lparse or text output enabled this<br>
function just grounds and returns a <a href="#SolveResult">SolveResult</a> where<br>
<a href="#SolveResult">SolveResult</a>.satisfiability() is None. Furthermore, you might want to start<br>
clingo using the --outf=3 option to disable all output from clingo.<br>
<br>
This function releases the GIL but it is not thread-safe.<br>
<br>
Take a look at <a href="#Control">Control</a>.solve_async for an example on how to use the model<br>
callback.</tt></dd></dl>
<dl><dt><a name="Control-solve_async"><strong>solve_async</strong></a>(...)</dt><dd><tt><a href="#Control-solve_async">solve_async</a>(self, on_model, on_finish, assumptions) -> <a href="#SolveFuture">SolveFuture</a><br>
<br>
Start a search process in the background and return a <a href="#SolveFuture">SolveFuture</a> object.<br>
<br>
Keyword Arguments:<br>
on_model -- optional callback for intercepting models<br>
a <a href="#Model">Model</a> object is passed to the callback<br>
on_finish -- optional callback called once search has finished<br>
a <a href="#SolveResult">SolveResult</a> and a Boolean indicating whether the solve call<br>
has been canceled is passed to the callback<br>
assumptions -- list of (atom, boolean) tuples that serve as assumptions for<br>
the solve call, e.g. - solving under assumptions [(<a href="#-Function">Function</a>("a"),<br>
True)] only admits answer sets that contain atom a<br>
<br>
Note that this function is only available in clingo with thread support<br>
enabled. Both the on_model and the on_finish callbacks are called from another<br>
thread. To ensure that the methods can be called, make sure to not use any<br>
functions that block the GIL indefinitely. Furthermore, you might want to start<br>
clingo using the --outf=3 option to disable all output from clingo.<br>
<br>
Example:<br>
<br>
#script (python)<br>
import clingo<br>
<br>
def on_model(model):<br>
print model<br>
<br>
def on_finish(res, canceled):<br>
print res, canceled<br>
<br>
def main(prg):<br>
prg.<a href="#Control-ground">ground</a>([("base", [])])<br>
f = prg.<a href="#Control-solve_async">solve_async</a>(on_model, on_finish)<br>
f.wait()<br>
<br>
#end.<br>
<br>
q.<br>
<br>
Expected Output:<br>
q<br>
SAT False</tt></dd></dl>
<dl><dt><a name="Control-solve_iter"><strong>solve_iter</strong></a>(...)</dt><dd><tt><a href="#Control-solve_iter">solve_iter</a>(self, assumptions) -> <a href="#SolveIter">SolveIter</a><br>
<br>
Return a <a href="#SolveIter">SolveIter</a> object, which can be used to iterate over models.<br>
<br>
Keyword Arguments:<br>
assumptions -- a list of (atom, boolean) tuples that serve as assumptions for<br>
the solve call, e.g. - solving under assumptions [(<a href="#-Function">Function</a>("a"),<br>
True)] only admits answer sets that contain atom a<br>
<br>
Example:<br>
<br>
#script (python)<br>
import clingo<br>
<br>
def main(prg):<br>
prg.<a href="#Control-add">add</a>("p", "{a;b;c}.")<br>
prg.<a href="#Control-ground">ground</a>([("p", [])])<br>
with prg.<a href="#Control-solve_iter">solve_iter</a>() as it:<br>
for m in it: print m<br>
<br>
#end.</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>backend</strong></dt>
<dd><tt>A Backend object providing a low level interface to extend a logic program.</tt></dd>
</dl>
<dl><dt><strong>configuration</strong></dt>
<dd><tt>Configuration object to change the configuration.</tt></dd>
</dl>
<dl><dt><strong>statistics</strong></dt>
<dd><tt>A dictionary containing solve statistics of the last solve call.<br>
<br>
Contains the statistics of the last solve(), solve_async(), or solve_iter()<br>
call. The statistics correspond to the --stats output of clingo. The detail of<br>
the statistics depends on what level is requested on the command line.<br>
Furthermore, you might want to start clingo using the --outf=3 option to<br>
disable all output from clingo.<br>
<br>
Note that this (read-only) property is only available in clingo.<br>
<br>
Example:<br>
import json<br>
json.dumps(prg.statistics, sort_keys=True, indent=4, separators=(',', ': '))</tt></dd>
</dl>
<dl><dt><strong>symbolic_atoms</strong></dt>
<dd><tt>SymbolicAtoms object to inspect the symbolic atoms.</tt></dd>
</dl>
<dl><dt><strong>theory_atoms</strong></dt>
<dd><tt>A TheoryAtomIter object, which can be used to iterate over the theory atoms.</tt></dd>
</dl>
<dl><dt><strong>use_enumeration_assumption</strong></dt>
<dd><tt>Boolean determining how learnt information from enumeration modes is treated.<br>
<br>
If the enumeration assumption is enabled, then all information learnt from<br>
clasp's various enumeration modes is removed after a solve call. This includes<br>
enumeration of cautious or brave consequences, enumeration of answer sets with<br>
or without projection, or finding optimal models; as well as clauses/nogoods<br>
added with Model.add_clause()/Model.add_nogood().<br>
<br>
Note that initially the enumeration assumption is enabled.</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__new__</strong> = <built-in method __new__ of type object><dd><tt>T.<a href="#Control-__new__">__new__</a>(S, ...) -> a new object with type S, a subtype of T</tt></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="Model">class <strong>Model</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Provides access to a model during a solve call.<br>
<br>
The string representation of a model object is similar to the output of models<br>
by clingo using the default output.<br>
<br>
Note that model objects cannot be constructed from python. Instead they are<br>
passed as argument to a model callback (see <a href="#Control">Control</a>.solve() and<br>
<a href="#Control">Control</a>.solve_async()). Furthermore, the lifetime of a model object is limited<br>
to the scope of the callback. They must not be stored for later use in other<br>
places like - e.g., the main function.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="Model-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#Model-__repr__">__repr__</a>() <==> repr(x)</tt></dd></dl>
<dl><dt><a name="Model-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#Model-__str__">__str__</a>() <==> str(x)</tt></dd></dl>
<dl><dt><a name="Model-contains"><strong>contains</strong></a>(...)</dt><dd><tt><a href="#Model-contains">contains</a>(self, a) -> bool<br>
<br>
Check if an atom a is contained in the model.<br>
<br>
The atom must be represented using a function symbol.</tt></dd></dl>
<dl><dt><a name="Model-symbols"><strong>symbols</strong></a>(...)</dt><dd><tt><a href="#Model-symbols">symbols</a>(self, atoms, terms, shown, csp, extra, complement)<br>
-> list of terms<br>
<br>
Return the list of atoms, terms, or CSP assignments in the model.<br>
<br>
Keyword Arguments:<br>
atoms -- select all atoms in the model (independent of #show statements)<br>
(Default: False)<br>
terms -- select all terms displayed with #show statements in the model<br>
(Default: False)<br>
shown -- select all atoms and terms as outputted by clingo<br>
(Default: False)<br>
csp -- select all csp assignments (independent of #show statements)<br>
(Default: False)<br>
extra -- select terms added by clingo extensions<br>
(Default: False)<br>
complement -- return the complement of the answer set w.r.t. to the Herbrand<br>
base accumulated so far (does not affect csp assignments)<br>
(Default: False)<br>
<br>
Note that atoms are represented using functions (<a href="#Symbol">Symbol</a> objects), and that CSP<br>
assignments are represented using functions with name "$" where the first<br>
argument is the name of the CSP variable and the second its value.</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>context</strong></dt>
<dd><tt>SolveControl object that allows for controlling the running search.</tt></dd>
</dl>
<dl><dt><strong>cost</strong></dt>
<dd><tt>Return the list of integer cost values of the model.<br>
<br>
The return values correspond to clasp's cost output.</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="ProgramBuilder">class <strong>ProgramBuilder</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Object to build non-ground programs.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="ProgramBuilder-__enter__"><strong>__enter__</strong></a>(...)</dt><dd><tt><a href="#ProgramBuilder-__enter__">__enter__</a>(self) -> <a href="#ProgramBuilder">ProgramBuilder</a><br>
<br>
Begin building a program.<br>
<br>
Must be called before adding statements.</tt></dd></dl>
<dl><dt><a name="ProgramBuilder-__exit__"><strong>__exit__</strong></a>(...)</dt><dd><tt><a href="#ProgramBuilder-__exit__">__exit__</a>(self, type, value, traceback) -> bool<br>
<br>
Finish building a program.<br>
<br>
Follows python __exit__ conventions. Does not suppress exceptions.</tt></dd></dl>
<dl><dt><a name="ProgramBuilder-add"><strong>add</strong></a>(...)</dt><dd><tt><a href="#ProgramBuilder-add">add</a>(self, statement) -> None<br>
<br>
Adds a statement in form of an ast.AST node to the program.</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PropagateControl">class <strong>PropagateControl</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>This object can be used to add clauses and propagate literals.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="PropagateControl-add_clause"><strong>add_clause</strong></a>(...)</dt><dd><tt><a href="#PropagateControl-add_clause">add_clause</a>(self, clause, tag, lock) -> bool<br>
<br>
Add the given clause to the solver.<br>
<br>
This method returns False if the current propagation must be stopped.<br>
<br>
Arguments:<br>
clause -- sequence of solver literals<br>
<br>
Keyword Arguments:<br>
tag -- clause applies only in the current solving step<br>
(Default: False)<br>
lock -- exclude clause from the solver's regular clause deletion policy<br>
(Default: False)</tt></dd></dl>
<dl><dt><a name="PropagateControl-add_nogood"><strong>add_nogood</strong></a>(...)</dt><dd><tt><a href="#PropagateControl-add_nogood">add_nogood</a>(self, clause, tag, lock) -> bool<br>
Equivalent to <a href="#PropagateControl-add_clause">add_clause</a>([-lit for lit in clause], tag, lock).</tt></dd></dl>
<dl><dt><a name="PropagateControl-propagate"><strong>propagate</strong></a>(...)</dt><dd><tt><a href="#PropagateControl-propagate">propagate</a>(self) -> bool<br>
<br>
Propagate implied literals.</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>assignment</strong></dt>
<dd><tt>The partial assignment of the current solver thread.</tt></dd>
</dl>
<dl><dt><strong>thread_id</strong></dt>
<dd><tt>The numeric id of the current solver thread.</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="PropagateInit">class <strong>PropagateInit</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Object that is used to initialize a propagator before each solving step.<br>
<br>
Each symbolic or theory atom is uniquely associated with a positive program<br>
atom in form of a positive integer. Program literals additionally have a sign<br>
to represent default negation. Furthermore, there are non-zero integer solver<br>
literals. There is a surjective mapping from program atoms to solver literals.<br>
<br>
All methods called during propagation use solver literals whereas<br>
<a href="#SymbolicAtom">SymbolicAtom</a>.literal() and <a href="#TheoryAtom">TheoryAtom</a>.literal() return program literals. The<br>
function <a href="#PropagateInit">PropagateInit</a>.<a href="#PropagateInit-solver_literal">solver_literal</a>() can be used to map program literals or<br>
condition ids to solver literals.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="PropagateInit-add_watch"><strong>add_watch</strong></a>(...)</dt><dd><tt><a href="#PropagateInit-add_watch">add_watch</a>(self, lit) -> None<br>
<br>
Add a watch for the solver literal in the given phase.</tt></dd></dl>
<dl><dt><a name="PropagateInit-solver_literal"><strong>solver_literal</strong></a>(...)</dt><dd><tt><a href="#PropagateInit-solver_literal">solver_literal</a>(self, lit) -> int<br>
<br>
Map the given program literal or condition id to its solver literal.</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>number_of_threads</strong></dt>
<dd><tt>The number of solver threads used in the corresponding solve call.</tt></dd>
</dl>
<dl><dt><strong>symbolic_atoms</strong></dt>
<dd><tt>The symbolic atoms captured by a SymbolicAtoms object.</tt></dd>
</dl>
<dl><dt><strong>theory_atoms</strong></dt>
<dd><tt>A TheoryAtomIter object to iterate over all theory atoms.</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="SolveControl">class <strong>SolveControl</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Object that allows for controlling a running search.<br>
<br>
Note that <a href="#SolveControl">SolveControl</a> objects cannot be constructed from python. Instead<br>
they are available as properties of <a href="#Model">Model</a> objects.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="SolveControl-add_clause"><strong>add_clause</strong></a>(...)</dt><dd><tt><a href="#SolveControl-add_clause">add_clause</a>(self, lits) -> None<br>
<br>
Add a clause that applies to the current solving step during the search.<br>
<br>
Arguments:<br>
lits -- list of literals represented as pairs of atoms and Booleans<br>
<br>
Note that this function can only be called in the model callback (or while<br>
iterating when using a <a href="#SolveIter">SolveIter</a>).</tt></dd></dl>
<dl><dt><a name="SolveControl-add_nogood"><strong>add_nogood</strong></a>(...)</dt><dd><tt><a href="#SolveControl-add_nogood">add_nogood</a>(self, lits) -> None<br>
<br>
Equivalent to add_clause with the literals inverted.<br>
<br>
Arguments:<br>
lits -- list of pairs of Booleans and atoms representing the nogood</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="SolveFuture">class <strong>SolveFuture</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Handle for asynchronous solve calls.<br>
<br>
<a href="#SolveFuture">SolveFuture</a> objects cannot be created from python. Instead they are returned by<br>
<a href="#Control">Control</a>.solve_async, which performs a search in the background. A <a href="#SolveFuture">SolveFuture</a><br>
object can be used to wait for such a background search or cancel it.<br>
<br>
Functions in this object release the GIL. They are not thread-safe though.<br>
<br>
See <a href="#Control">Control</a>.solve_async for an example.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="SolveFuture-cancel"><strong>cancel</strong></a>(...)</dt><dd><tt><a href="#SolveFuture-cancel">cancel</a>(self) -> None<br>
<br>
Cancel the running search.<br>
<br>
See <a href="#Control">Control</a>.interrupt() for a thread-safe alternative.</tt></dd></dl>
<dl><dt><a name="SolveFuture-get"><strong>get</strong></a>(...)</dt><dd><tt><a href="#SolveFuture-get">get</a>(self) -> <a href="#SolveResult">SolveResult</a><br>
<br>
Get the result of an solve_async call.<br>
<br>
If the search is not completed yet, the function blocks until the result is<br>
ready.</tt></dd></dl>
<dl><dt><a name="SolveFuture-wait"><strong>wait</strong></a>(...)</dt><dd><tt><a href="#SolveFuture-wait">wait</a>(self, timeout) -> None or bool<br>
<br>
Wait for solve_async call to finish with an optional timeout.<br>
<br>
If a timeout is given, the function waits at most timeout seconds and returns a<br>
Boolean indicating whether the search has finished. Otherwise, the function<br>
blocks until the search is finished and returns nothing.<br>
<br>
Arguments:<br>
timeout -- optional timeout in seconds<br>
(permits floating point values)</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="SolveIter">class <strong>SolveIter</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Object to conveniently iterate over all models.<br>
<br>
During solving the GIL is released. The functions in this object are not<br>
thread-safe though.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="SolveIter-__enter__"><strong>__enter__</strong></a>(...)</dt><dd><tt><a href="#SolveIter-__enter__">__enter__</a>(self) -> <a href="#SolveIter">SolveIter</a><br>
<br>
Returns self.</tt></dd></dl>
<dl><dt><a name="SolveIter-__exit__"><strong>__exit__</strong></a>(...)</dt><dd><tt><a href="#SolveIter-__exit__">__exit__</a>(self, type, value, traceback) -> bool<br>
<br>
Follows python __exit__ conventions. Does not suppress exceptions.<br>
<br>
Stops the current search. It is necessary to call this method after each search.</tt></dd></dl>
<dl><dt><a name="SolveIter-__iter__"><strong>__iter__</strong></a>(...)</dt><dd><tt>x.<a href="#SolveIter-__iter__">__iter__</a>() <==> iter(x)</tt></dd></dl>
<dl><dt><a name="SolveIter-get"><strong>get</strong></a>(...)</dt><dd><tt><a href="#SolveIter-get">get</a>(self) -> <a href="#SolveResult">SolveResult</a><br>
<br>
Return the result of the search.<br>
<br>
Note that this function might start a search for the next model and then return<br>
a result accordingly. The function might be called after iteration to check if<br>
the search has been interrupted.</tt></dd></dl>
<dl><dt><a name="SolveIter-next"><strong>next</strong></a>(...)</dt><dd><tt>x.<a href="#SolveIter-next">next</a>() -> the next value, or raise StopIteration</tt></dd></dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="SolveResult">class <strong>SolveResult</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Captures the result of a solve call.<br>
<br>
<a href="#SolveResult">SolveResult</a> objects cannot be constructed from python. Instead they<br>
are returned by the solve methods of the <a href="#Control">Control</a> object.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="SolveResult-__repr__"><strong>__repr__</strong></a>(...)</dt><dd><tt>x.<a href="#SolveResult-__repr__">__repr__</a>() <==> repr(x)</tt></dd></dl>
<dl><dt><a name="SolveResult-__str__"><strong>__str__</strong></a>(...)</dt><dd><tt>x.<a href="#SolveResult-__str__">__str__</a>() <==> str(x)</tt></dd></dl>
<hr>
Data descriptors defined here:<br>
<dl><dt><strong>exhausted</strong></dt>
<dd><tt>True if the search space was exhausted.</tt></dd>
</dl>
<dl><dt><strong>interrupted</strong></dt>
<dd><tt>True if the search was interrupted.</tt></dd>
</dl>
<dl><dt><strong>satisfiable</strong></dt>
<dd><tt>True if the problem is satisfiable, False if the problem is<br>
unsatisfiable, or None if the satisfiablity is not known.</tt></dd>
</dl>
<dl><dt><strong>unknown</strong></dt>
<dd><tt>True if the satisfiablity is not known.<br>
<br>
This is equivalent to satisfiable is None.</tt></dd>
</dl>
<dl><dt><strong>unsatisfiable</strong></dt>
<dd><tt>True if the problem is unsatisfiable, False if the problem is<br>
satisfiable, or None if the satisfiablity is not known.<br>
<br>
This is equivalent to None if satisfiable is None else not satisfiable.</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#88ff99">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="Symbol">class <strong>Symbol</strong></a>(object)</font></td></tr>
<tr bgcolor="#88ff99"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>Represents a gringo symbol.<br>
<br>
This includes numbers, strings, functions (including constants with<br>
len(arguments) == 0 and tuples with len(name) == 0), #inf and #sup. <a href="#Symbol">Symbol</a><br>
objects are ordered like in gringo and their string representation corresponds<br>
to their gringo representation.<br>
<br>
Note that this class does not have a constructor. Instead there are the<br>
functions <a href="#-Number">Number</a>(), <a href="#-String">String</a>(), and <a href="#-Function">Function</a>() to construct symbol objects or the<br>