- HashSet<Mesh.Vert> hs = new HashSet<Mesh.Vert>();
- for(Mesh.Vert p : tile.vertices()) hs.add(p);
- for(int i=0; i<10; i++) {
- repaint();
- for(Mesh.Vert v : hs) rand(10,v);
+ synchronized(this) {
+ double ratio = (hits+misses==0) ? 1 : (hits / (hits+misses));
+ hits = 0;
+ misses = 0;
+ float gamma = 1;
+ acceptance = (ratio+acceptance)/2;
+ accepts = (int)(Math.ceil(ratio*100));
+ temps = (int)(Math.ceil(temp*1000));
+ vertss = tile.size();
+ if (breaks > 0) {
+ while (breaks>0) {
+ breaks--;
+ breakit();
+ }
+ seek_upward = true;
+ } else if (acceptance > 0.96) gamma = 0.4f;
+ else if (acceptance > 0.9) gamma = 0.5f;
+ else if (acceptance > 0.8) gamma = 0.65f;
+ else if (acceptance > 0.6) gamma = 0.7f;
+ else if (acceptance > 0.3) gamma = 0.9f;
+ else if (acceptance > 0.15) gamma = 0.95f;
+ else if (acceptance > 0.10) gamma = 0.98f;
+ else breaks++;
+
+ if (seek_upward) {
+ if (acceptance > 0.3) seek_upward = false;
+ else gamma = 2-gamma;
+ }
+
+ temp = temp * gamma;
+
+
+ HashSet<Mesh.Vertex> hs = new HashSet<Mesh.Vertex>();
+ for(Mesh.Vertex p : tile.vertices()) hs.add(p);
+ Mesh.Vertex[] pts = (Mesh.Vertex[])hs.toArray(new Mesh.Vertex[0]);
+
+ int count = 0;
+ long then = System.currentTimeMillis();
+ for(int i=0; i<40; i++) {
+ if (anneal) {
+ count++;
+ Mesh.Vertex v = pts[Math.abs(random.nextInt()) % pts.length];
+ rand(temp,v);
+ v.recomputeFundamentalQuadricIfStale();
+ v.recomputeFundamentalQuadricIfNeighborChanged();
+ }
+ Thread.yield();
+ repaint();
+ }
+ System.out.println("temp="+temp + " ratio="+(Math.ceil(acceptance*100)) + " " +
+ "points_per_second=" +
+ (count*1000)/((double)(System.currentTimeMillis()-then)));
+
+ for(Mesh.Vertex p : goal.vertices()) p.recomputeFundamentalQuadricIfNeighborChanged();
+
+ synchronized(safeTriangles) {
+ safeTriangles.clear();
+ for(Mesh.T t : tile) if (t.shouldBeDrawn()) safeTriangles.add(t);
+ }