From bea2cf1b30aff00d6062d0df4e4a471c885a9c93 Mon Sep 17 00:00:00 2001
From: Mart Lubbers <mart@martlubbers.net>
Date: Tue, 20 Oct 2015 16:15:53 +0200
Subject: [PATCH] working chip location

---
 ar/assignments/2.tex    | 16 ++++++++--------
 ar/assignments/src/2.py | 39 +++++++++++++++++++++++++--------------
 2 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/ar/assignments/2.tex b/ar/assignments/2.tex
index 5731d97..7bd482d 100644
--- a/ar/assignments/2.tex
+++ b/ar/assignments/2.tex
@@ -38,15 +38,15 @@ specified width and height.
 		\nonumber & \qquad\qquad\qquad \vee c_iy>c_jy+c_jh\\
 		\nonumber & \qquad\qquad\qquad \vee c_iy+c_jh<c_jh\Bigr)\Biggr)\wedge\\
 	\bigwedge_{i\in PC}\bigwedge_{j\in PC}\Biggl( & i=j\\
-		\nonumber & \vee\frac{c_ix+c_iw}{2}-\frac{c_jx+c_jw}{2}>15\\
-		\nonumber & \vee\frac{c_jx+c_jw}{2}-\frac{c_ix+c_iw}{2}>15\\
-		\nonumber & \vee\frac{c_iy+c_ih}{2}-\frac{c_jy+c_jh}{2}>15\\
-		\nonumber & \vee\frac{c_jy+c_jh}{2}-\frac{c_iy+c_ih}{2}>15\Biggr)\wedge\\
-	\bigwedge_{i\in RC}\bigvee_{j\in PC}\Biggl(
-		\nonumber & !(     c_ix-1     >c_jx+c_jw\\
+		\nonumber & \vee c_ix+\frac{c_iw}{2}-c_jx+\frac{c_jw}{2}>15\\
+		\nonumber & \vee c_jx+\frac{c_jw}{2}-c_ix+\frac{c_iw}{2}>15\\
+		\nonumber & \vee c_iy+\frac{c_ih}{2}-c_jy+\frac{c_jh}{2}>15\\
+		\nonumber & \vee c_jy+\frac{c_jh}{2}-c_iy+\frac{c_ih}{2}>15\Biggr)\wedge\\
+	\bigwedge_{i\in RC}\bigvee_{j\in PC}\neg\Biggl(
+		& (c_ix-1>c_jx+c_jw\\
 		\nonumber & \vee c_ix+1+c_jw<c_jx\\
-		\nonumber & \vee c_iy-1     >c_jy+c_jh\\
-		\nonumber & \vee c_iy+1+c_jh<c_jh\Biggr)\\
+		\nonumber & \vee c_iy-1>c_jy+c_jh\\
+		\nonumber & \vee c_iy+1+c_jh<c_jh\Biggr)
 \end{align}
 
 \subsection{SMT format solution}
diff --git a/ar/assignments/src/2.py b/ar/assignments/src/2.py
index bbaabf0..2b5ed99 100644
--- a/ar/assignments/src/2.py
+++ b/ar/assignments/src/2.py
@@ -50,20 +50,31 @@ for i, (w, h) in enumerate(pc+rc, 1):
                 ')').format(i, j))
 
 # Print the PC distance to eachother
-#for i, _ in enumerate(pc, 1):
-#    for j, _ in enumerate(pc, 1):
-#        if i != j:
-#            print((
-#                '\t(or \n'
-#                '\t\t(> (- (/ (+ c{0:02d}x c{0:02d}w) 2) '
-#                '(/ (+ c{1:02d}x c{1:02d}w) 2)) {2})\n'
-#                '\t\t(> (- (/ (+ c{1:02d}x c{1:02d}w) 2) '
-#                '(/ (+ c{0:02d}x c{0:02d}w) 2)) {2})\n'
-#                '\t\t(> (- (/ (+ c{0:02d}y c{0:02d}h) 2) '
-#                '(/ (+ c{1:02d}y c{1:02d}h) 2)) {2})\n'
-#                '\t\t(> (- (/ (+ c{1:02d}y c{1:02d}h) 2) '
-#                '(/ (+ c{0:02d}y c{0:02d}h) 2)) {2})'
-#                ')').format(i, j, pd))
+for i, _ in enumerate(pc, 1):
+    for j, _ in enumerate(pc, 1):
+        if i != j:
+            print((
+                '\t(or \n'
+                '\t\t(> \n'
+                '\t\t\t(- \n'
+                '\t\t\t\t(+ \n'
+                '\t\t\t\t\tc{0:02d}x \n'
+                '\t\t\t\t\t(/ c{0:02d}w 2) \n'
+                '\t\t\t\t) \n'
+                '\t\t\t\t(+ \n'
+                '\t\t\t\t\tc{1:02d}x \n'
+                '\t\t\t\t\t(/ c{1:02d}w 2) \n'
+                '\t\t\t\t) \n'
+                '\t\t\t) \n'
+                '\t\t\t{2} \n'
+                '\t\t)\n'
+                '\t\t(> (- (+ c{1:02d}x (/ c{1:02d}w 2)) '
+                '(+ c{0:02d}x (/ c{0:02d}w 2))) {2})\n'
+                '\t\t(> (- (+ c{0:02d}y (/ c{0:02d}h 2)) '
+                '(+ c{1:02d}y (/ c{1:02d}h 2))) {2})\n'
+                '\t\t(> (- (+ c{1:02d}y (/ c{1:02d}h 2)) '
+                '(+ c{0:02d}y (/ c{0:02d}h 2))) {2})'
+                ')').format(i, j, pd))
 
 # Print the constraint that they have to be connected to a ps
 for i, _ in enumerate(rc, 1+len(pc)):
-- 
2.20.1