2 pc
= [(4, 2), (4, 2), (4, 2)]
3 rc
= [(9, 7), (12, 6), (10, 7), (18, 5), (20, 4), (10, 6), (8, 6), (10, 8)]
9 print("(benchmark a4.smt")
10 print(":logic QF_UFLIA")
14 for i
, (w
, h
) in enumerate(pc
+rc
, 1):
15 print("(c{:02d}x Int)".format(i
), end
=' ')
16 print("(c{:02d}y Int)".format(i
), end
=' ')
17 print("(c{:02d}w Int)".format(i
), end
=' ')
18 print("(c{:02d}h Int)".format(i
))
24 # Print the PC and RC subformulas
25 for i
, (w
, h
) in enumerate(pc
+rc
, 1):
26 # Print the width and height
29 '(and (= c{0:02d}w {1}) (= c{0:02d}h {2})) '
30 '(and (= c{0:02d}w {2}) (= c{0:02d}h {1})))').format(i
, w
-1, h
-1))
32 # Print the bounds of the coordinates
34 '(> c{0:02d}x 0) (> c{0:02d}y 0)'
35 '(<= (+ c{0:02d}x c{0:02d}w) {1}) (<= (+ c{0:02d}y c{0:02d}h) {2})'
38 # Print the non overlap with others
39 for j
in range(1, 1+len(pc
+rc
)):
43 '(> c{0:02d}x (+ c{1:02d}x c{1:02d}w)) (< (+ c{0:02d}x c{0:02d}w) c{1:02d}x) '
44 '(> c{0:02d}y (+ c{1:02d}y c{1:02d}h)) (< (+ c{0:02d}y c{0:02d}h) c{1:02d}y)'
47 # Print the PC distance to eachother
48 for i
, _
in enumerate(pc
, 1):
49 for j
, _
in enumerate(pc
, 1):
53 '(> (- (+ c{0:02d}x (/ c{0:02d}w 2) ) (+ c{1:02d}x (/ c{1:02d}w 2) ) ) {2} ) '
54 '(> (- (+ c{1:02d}x (/ c{1:02d}w 2)) (+ c{0:02d}x (/ c{0:02d}w 2))) {2}) '
55 '(> (- (+ c{0:02d}y (/ c{0:02d}h 2)) (+ c{1:02d}y (/ c{1:02d}h 2))) {2}) '
56 '(> (- (+ c{1:02d}y (/ c{1:02d}h 2)) (+ c{0:02d}y (/ c{0:02d}h 2))) {2})'
57 ')').format(i
, j
, pd
))
59 # Print the constraint that they have to be connected to a ps
60 for i
, _
in enumerate(rc
, 1+len(pc
)):
62 for j
, _
in enumerate(pc
, 1):
65 '(> c{0:02d}x (+ c{1:02d}x 1 c{1:02d}w)) (< (+ c{0:02d}x c{0:02d}w) (- c{1:02d}x 1)) '
66 '(> c{0:02d}y (+ c{1:02d}y 1 c{1:02d}h)) (< (+ c{0:02d}y c{0:02d}h) (- c{1:02d}y 1))'
70 # Close the and,benchmark parenthesis