checkpoint
authoradam <adam@megacz.com>
Sun, 16 Dec 2007 03:37:23 +0000 (19:37 -0800)
committeradam <adam@megacz.com>
Sun, 16 Dec 2007 03:37:23 +0000 (19:37 -0800)
darcs-hash:20071216033723-5007d-7645249fd4bb5fd37fdb17e62b97f939b1d28265.gz

src/edu/berkeley/qfat/Main.java
src/edu/berkeley/qfat/Mesh.java

index 44a8312..9d5c4fc 100644 (file)
@@ -264,8 +264,8 @@ public class Main extends MeshViewer {
         System.out.println("tile volume: " + tile.volume());
         System.out.println("goal volume: " + goal.volume());
 
-        tile.score_against = goal;
-        goal.score_against = tile;
+        tile.error_against = goal;
+        goal.error_against = tile;
     }
 
     public synchronized void breakit() {
@@ -290,8 +290,8 @@ public class Main extends MeshViewer {
 
         //p.reComputeError();
         p.reComputeErrorAround();
-        double tile_score = tile.score();
-        double goal_score = goal.score();
+        double tile_error = tile.error();
+        double goal_error = goal.error();
 
         Vec v;
         /*
@@ -311,19 +311,19 @@ public class Main extends MeshViewer {
 
         p.reComputeErrorAround();
 
-        double new_tile_score = tile.score();
-        double new_goal_score = goal.score();
-        double tile_delta = (new_tile_score - tile_score) / tile_score;
-        double goal_delta = (new_goal_score - goal_score) / goal_score;
+        double new_tile_error = tile.error();
+        double new_goal_error = goal.error();
+        double tile_delta = (new_tile_error - tile_error) / tile_error;
+        double goal_delta = (new_goal_error - goal_error) / goal_error;
         double delta = tile_delta + goal_delta;
         double swapProbability = Math.exp((-1 * delta) / temp);
         boolean doSwap = good && (Math.random() < swapProbability);
         //boolean doSwap = good && (tile_delta <= 0 && goal_delta <= 0);
         //boolean doSwap = good && (tile_delta + goal_delta <= 0);
         if (doSwap) {
-            tile_score = new_tile_score;
-            goal_score = new_goal_score;
-            //System.out.println("score: " + tile_score + " / " + goal_score);
+            tile_error = new_tile_error;
+            goal_error = new_goal_error;
+            //System.out.println("error: " + tile_error + " / " + goal_error);
             hits++;
         } else {
             p.move(v.times(-1));
@@ -337,6 +337,7 @@ public class Main extends MeshViewer {
         float hightemp = 10;
         float temp = hightemp;
         float last = 10;
+        float lastbreak = 10;
         while(true) {
             synchronized(this) {
                 double ratio = (hits+misses==0) ? 1 : (hits / (hits+misses));
@@ -351,7 +352,10 @@ public class Main extends MeshViewer {
                         breaks--;
                         breakit();
                         //gamma = 1;
+                        float t = temp;
+                        temp = lastbreak;
                         gamma = 1;
+                        lastbreak = t;
                         //temp = last * 0.8f;
                         //last = temp;
                         //temp = hightemp;
@@ -369,8 +373,12 @@ public class Main extends MeshViewer {
                             gamma = 0.98f;
                         } else {
                             breakit();
+                        float t = temp;
+                        temp = lastbreak;
+                        gamma = 1;
+                        lastbreak = t;
                             //gamma = 1;
-                            gamma = 0.99f;
+                        //gamma = 0.99f;
                             //gamma = 1;
                             //temp = last * 0.8f;
                             //last = temp;
index f63bd1d..b4f282a 100644 (file)
@@ -20,13 +20,13 @@ public class Mesh implements Iterable<Mesh.T> {
 
     public boolean immutableVertices;
     public boolean ignorecollision    = false;
-    public Mesh    score_against      = null;
-    public double  score              = 0;
+    public Mesh    error_against      = null;
+    public double  error              = 0;
 
     public Mesh(boolean immutableVertices) { this.immutableVertices = immutableVertices; }
 
     public void makeVerticesImmutable() { this.immutableVertices = true; }
-    public float score() { return (float)score; }
+    public float error() { return (float)error; }
 
     public int size() { return vertices.size(); }
     public Iterable<Vertex> vertices() { return vertices; }
@@ -83,7 +83,7 @@ public class Mesh implements Iterable<Mesh.T> {
         Vertex bound_to = this;
 
         public Point getPoint() { return p; }
-        public float score() { return oldscore; }
+        public float error() { return olderror; }
 
         private Vertex(Point p) {
             this.p = p;
@@ -91,11 +91,11 @@ public class Mesh implements Iterable<Mesh.T> {
             vertices.add(this);
         }
 
-        public float oldscore = 0;
-        public void setScore(float nscore) {
-            score -= oldscore;
-            oldscore = nscore;
-            score += oldscore;
+        public float olderror = 0;
+        public void setError(float nerror) {
+            error -= olderror;
+            olderror = nerror;
+            error += olderror;
         }
 
         public Matrix _recomputeFundamentalQuadric() {
@@ -109,26 +109,26 @@ public class Mesh implements Iterable<Mesh.T> {
         }
 
         public HasQuadric nearest() {
-            if (score_against==null) return null;
-            return score_against.vertices.nearest(p, this);
+            if (error_against==null) return null;
+            return error_against.vertices.nearest(p, this);
         }
-        public void unComputeError() { setScore(0); }
+        public void unComputeError() { setError(0); }
         public void computeError() {
-            float nscore =
+            float nerror =
                 quadric_count != 0
                 ? (quadric.preAndPostMultiply(p) * 100) / quadric_count
                 : nearest_in_other_mesh != null
                 ? nearest_in_other_mesh.fundamentalQuadric().preAndPostMultiply(p) * 100 * 10
-                : score_against != null
+                : error_against != null
                 ? nearest().fundamentalQuadric().preAndPostMultiply(p) * 100 * 10
                 : 0;
             for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next) {
                 double ang = Math.abs(e.crossAngle());
                 if (ang > Math.PI) throw new Error();
                 float minangle = (float)(Math.PI * 0.8);
-                if (ang > minangle) nscore += (ang - minangle);
+                if (ang > minangle) nerror += (ang - minangle);
             }
-            setScore(nscore);
+            setError(nerror);
         }
 
         private void removeTrianglesFromRTree() {
@@ -326,7 +326,7 @@ public class Mesh implements Iterable<Mesh.T> {
 
         public boolean intersects(T t) { return t.intersects(p1.p, p2.p); }
         public float comparator() {
-            Vertex nearest = score_against.nearest(midpoint());
+            Vertex nearest = error_against.nearest(midpoint());
             return (float)Math.max(length(), midpoint().distance(nearest.p));
         }
         public int compareTo(E e) {