<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>ex/sg-bus-services.txt</filename>
    </added>
    <added>
      <filename>ex/sg-bus-stops.txt</filename>
    </added>
    <added>
      <filename>how_to_run_tsp_sg_bus.txt</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -47,22 +47,6 @@ let path_length pts =
         pts
     |&gt; snd
 
-    
-    (*
-let objective arr =
-    Array.fold_left (fun (i,sum) e -&gt; (i + 1, sum + e * i)) (1, 0) arr
-    |&gt; snd
-    |&gt; float
-
-let _ =
-    let init = [|1;2;3;4;5;6;7;8;9;1;2;3;4;5;6;7;8;9;|] in
-    let cooling = Anneal.kirkpatrick_seq 0.9999 10.0 in
-    let (n, sol, score) = Anneal.optimize init objective reversed_section 500000 cooling in
-    Printf.printf &quot;%d evaluations; score=%f; sol=\n&quot; n score;
-    Array.iter (Printf.printf &quot;%d &quot;) sol;
-    print_newline ()
-    *)
-
 let _ =
     let posfn = ref &quot;coords.txt&quot; in
     let usage = Printf.sprintf &quot;Usage: %s [-help] [-coords filename]&quot; Sys.argv.(0) in
@@ -75,32 +59,44 @@ let _ =
         ]
         ignore
         usage;
+    let doit name path =
+        let d = path_length path in
+        Printf.eprintf &quot;Path %s:&quot; name;
+        Array.iter (Printf.eprintf &quot; %d&quot;) path;
+        Printf.eprintf &quot;: %f\n&quot; d;
+        flush_all ();
+        let cooling = Anneal.kirkpatrick_seq 0.9999 10.0 in
+        let (n, sol, score) = Anneal.optimize path (fun p -&gt; -. path_length p) reversed_section 500000 cooling in
+        Printf.eprintf &quot;  Optimization: %d evaluations; score=%f\n&quot; n score;
+        Printf.printf &quot;%s &quot; name;
+        Array.iter (Printf.printf &quot;%d &quot;) sol;
+        print_newline ()
+    in
+    let read_path () =
+        let line = read_line () in
+        let re = Str.regexp &quot;[ \t]+&quot; in
+        let name::pts = Str.split re line in
+        (name, Array.of_list (List.map int_of_string pts))
+    in
+    let rec loop () =
+        let name, p = read_path () in
+        match Array.length p with
+        | 0 -&gt; ()
+        | n when n &gt; 2 -&gt;
+            (*TODO bug if p = 2 and p.(0)=p.(1) *)
+            doit name p;
+            loop ()
+        | _ -&gt;
+            loop ()
+    in
     try
         let buf = Scanf.Scanning.from_file !posfn in
         let _ = read_positions buf in
-        let doit path =
-            let d = path_length path in
-            Printf.printf &quot;Path:&quot;;
-            Array.iter (Printf.printf &quot; %d&quot;) path;
-            Printf.printf &quot;: %f\n&quot; d;
-            let cooling = Anneal.kirkpatrick_seq 0.9999 10.0 in
-            let (n, sol, score) = Anneal.optimize path (fun p -&gt; -. path_length p) reversed_section 5000 cooling in
-            Printf.printf &quot;  Optimization: %d evaluations; score=%f; sol=&quot; n score;
-            Array.iter (Printf.printf &quot;%d &quot;) sol;
-            print_newline ()
-        in
-        (*
-        let _ = doit [|1; 1;|] in (* TODO something wrong ... infinite loop ... probably in solution generation! *)
-        let _ = doit [|1; 2;|] in
-        let _ = doit [|1; 3;|] in
-        let _ = doit [|2; 3;|] in
-        let _ = doit [|3; 2;|] in
-        *)
-        let _ = doit [|1; 1; 2;|] in
-        let _ = doit [|1; 2; 3;|] in
-        ()
+        loop ()
     with
-        exn -&gt;
-            Printf.printf &quot;ERROR:%s\n%s\n&quot; (Printexc.to_string exn) usage;
+        | End_of_file -&gt;
+            ()
+        | exn -&gt;
+            Printf.printf &quot;ERROR:%s\n%s\n&quot; (Printexc.to_string exn) usage
 
 </diff>
      <filename>ex/tspRun.ml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>88768c8f39323eb34283cba73a53f6db1407907d</id>
    </parent>
  </parents>
  <author>
    <name>Ludovic Coquelle</name>
    <email>lcoquelle@gmail.com</email>
  </author>
  <url>http://github.com/khigia/ocaml-anneal/commit/1e32c07d9b9fc6f878a251e33fe2c5d62ecdba7d</url>
  <id>1e32c07d9b9fc6f878a251e33fe2c5d62ecdba7d</id>
  <committed-date>2008-06-11T08:12:51-07:00</committed-date>
  <authored-date>2008-06-11T08:12:51-07:00</authored-date>
  <message>Completed TSP example to calculate SG bus stop services.</message>
  <tree>8204b3054cb63e397847fd37ca4d8c91f893783d</tree>
  <committer>
    <name>Ludovic Coquelle</name>
    <email>lcoquelle@gmail.com</email>
  </committer>
</commit>
