chiark / gitweb /
add nprocessors utility
[moebius2.git] / energy.c
index 478969824cc6b324fe760048c92f336721eb9a4e..80ac7e885f989e627b2c01edf3f0ba02a6bf5c73 100644 (file)
--- a/energy.c
+++ b/energy.c
@@ -32,11 +32,24 @@ double compute_energy(const struct Vertices *vs) {
 
   if (printing) printf("%15lld c>e |", evaluations);
 
-  COST(3e2, line_bending_cost(vs->a));
-  COST(1e3, edge_length_variation_cost(vs->a));
-  COST(0.2e3, rim_proximity_cost(vs->a));
-//  COST(1e2, graph_layout_cost(vs->a));
-  COST(1e8, noncircular_rim_cost(vs->a));
+  if (XBITS==3) {
+    COST(  3e2,   line_bending_cost(vs->a));
+    COST(  1e3,   edge_length_variation_cost(vs->a));
+    COST( 0.2e3,  rim_proximity_cost(vs->a));
+    COST(  1e8,   noncircular_rim_cost(vs->a));
+    stop_epsilon= 1e-6;
+  } else if (XBITS==4) {
+    COST(  3e2,   line_bending_cost(vs->a));
+    COST(  3e3,   edge_length_variation_cost(vs->a));
+    COST( 3.8e1,  rim_proximity_cost(vs->a)); // 5e1 is too much
+                                                // 2.5e1 is too little
+    // 0.2e1 grows compared to previous ?
+    // 0.6e0 shrinks compared to previous ?
+    COST(  1e12,   noncircular_rim_cost(vs->a));
+    stop_epsilon= 1e-5;
+  } else {
+    abort();
+  }
 
   if (printing) printf("| total %# e |", energy);
 
@@ -168,7 +181,7 @@ double line_bending_cost(const Vertices vertices) {
     double delta= atan2(magnD(axb) + axb_epsilon, dotprod(a,b));
     double cost= pow(delta,exponent_r);
 
-    if (!e && !(qi & YMASK))
+    if (!e && !(qi & ~XMASK))
       cost *= 10;
 
     total_cost += cost;