chiark / gitweb /
best interpolation so far
authorIan Jackson <ian@davenant.greenend.org.uk>
Sat, 19 Jan 2008 01:15:32 +0000 (01:15 +0000)
committerIan Jackson <ian@davenant.greenend.org.uk>
Sat, 19 Jan 2008 01:15:32 +0000 (01:15 +0000)
Makefile
energy.c
interpolate.c

index dd4b218ed001f0eb33ec5f901a29e70c2679efef..ecccd72524fcd94b895bfd509ddc5e4ccd7da876 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -40,8 +40,8 @@ lumpy.cfm: oldmoebius-converter prime.data ../moebius/ins-new ../moebius/a.out
 ring.cfm: oldmoebius-converter prime.data /dev/null ../moebius/a.out
                ./$^ -o$@
 
-best.CFM:      minimise sgtatham.cfm
-               ./$^ -iwip.cfm -o$@
+best.CFM:
+               ./minimise sgtatham.cfm -iwip.cfm -o$@
 
 view-%:                view+%.o mgraph+%.o common.o
                $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL) -L/usr/X11R6/lib -lX11
@@ -49,6 +49,14 @@ view-%:              view+%.o mgraph+%.o common.o
 interpolate-%: interpolate+%.o mgraph+%.o common.o
                $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL)
 
+define interpolate
+dense-$1.cfm:  interpolate-$1 $2
+               ./$$< <$2 $$o
+endef
+
+$(eval $(call interpolate,64, best.CFM))
+$(eval $(call interpolate,125, dense-64.cfm, dense-64.cfm))
+
 # this ridiculous repetition is due to make being too lame
 
 view+%.o: view.c
index 478969824cc6b324fe760048c92f336721eb9a4e..dd9206f4b7a5cb80c3178cfc9f35ae603982158f 100644 (file)
--- a/energy.c
+++ b/energy.c
@@ -32,11 +32,10 @@ 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));
+  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));
 
   if (printing) printf("| total %# e |", energy);
 
index b705bcff861c4dcc2c01faba9e554be202ef65aa..778e37ceaefc6b3d8ed117a823e7e093ebc00055 100644 (file)
@@ -94,6 +94,8 @@ static void traverse_next(Traverse *t) {
   t->v= v2;
 }
 
+#if 0
+
 static void interpolate(void) {
   /* four points P Q R S, although P and S may be missing
    * interpolate in QR finding M. */
@@ -139,10 +141,12 @@ static void interpolate(void) {
          K srtarg[k]= all.a[vq][k];
 
        K {
+         const double alpha= 3.0;
          all.a[vm][k]= 0.5 * (all.a[vq][k] + all.a[vr][k]);
-//       pqtarg[k]= 0.5 * (pqtarg[k] + all.a[vm][k]);
-//       srtarg[k]= 0.5 * (srtarg[k] + all.a[vm][k]);
-//       all.a[vm][k]= 0.5 * (pqtarg[k] + srtarg[k]);
+         pqtarg[k]= 0.5 * (pqtarg[k] + all.a[vm][k]);
+         srtarg[k]= 0.5 * (srtarg[k] + all.a[vm][k]);
+         all.a[vm][k]= (pqtarg[k] + srtarg[k] + alpha * all.a[vm][k])
+           / (2 + alpha);
          note_computed(vm,k);
        }
       }
@@ -151,7 +155,9 @@ static void interpolate(void) {
   }
 }
 
-#if 0
+#endif
+
+#if 1
 
 static void interpolate_line(int startvertex,
                             int direction /* edge number */,
@@ -222,7 +228,7 @@ static void interpolate(void) {
   int x,y;
   
   for (y=0; y<(Y+1)/2; y+=INC) {
-    interpolate_line(y<<YSHIFT, 0, OX*2+1);
+    interpolate_line(y<<YSHIFT | ((y>>1)&1), 0, OX*2+1);
   }
   for (x=0; x<X; x+=INC) {
     interpolate_line(                x, 5, OY);