Index: nodes/channelea.ml
===================================================================
--- nodes/channelea.ml	(revision 1997)
+++ nodes/channelea.ml	(revision 1998)
@@ -64,14 +64,14 @@
 	wi_name: string;
 	wi_nodename: string;
-	wi_essid: string;
-};;
+	wi_essid: string
+}
 type group = {
 	group_essid: string;
-	mutable group_wis: wi list;
-};;
+	mutable group_wis: wi list
+}
 type node = {
 	node_name: string;
-	node_wis: wi list;
-};;
+	node_wis: wi list
+}
 (** A configuration is an assignment of groups, identified by essid, to a
     channel, plus a score. The code should be careful not to use the score
@@ -79,7 +79,7 @@
 type configuration = {
 	mutable score: int;
-	conf: (string, int) Hashtbl.t;
-};;
-type 'a maybe = Nothing | Just of 'a;;
+	conf: (string, int) Hashtbl.t
+}
+type 'a maybe = Nothing | Just of 'a
 
 (** The global nodes hash, mapping from node name to node struct. *)
@@ -152,9 +152,9 @@
 	else if (in_list nointerference wi1.wi_name) &&
 		(in_list nointerference wi2.wi_name) then 1
-	else runtable scoretable diff;;
-
-(** Given a configuration and a node, return the score. this is simply the sum of
-   the scores of all the combinations of interfaces, written down as a fold for
-   efficiency *)
+	else runtable scoretable diff
+
+(** Given a configuration and a node, return the score. this is simply the sum
+    of the scores of all the combinations of interfaces, written down as a fold
+    for efficiency *)
 let node_score c n =
 	let nointerference_ = try Hashtbl.find nointerference n.node_name
@@ -162,6 +162,6 @@
 	let unusable_ = try Hashtbl.find unusable n.node_name
 			with Not_found -> [] in
-	let foldfunc acc (wi1, wi2) = acc + (wi_score c unusable_ nointerference_ wi1 wi2) in
-	let base_score = List.fold_left foldfunc 0 (combinations n.node_wis) in
+	let f a (wi1, wi2) = a + (wi_score c unusable_ nointerference_ wi1 wi2) in
+	let base_score = List.fold_left f 0 (combinations n.node_wis) in
 	base_score * (List.length n.node_wis)
 
@@ -169,6 +169,9 @@
     configuration *)
 let score_interference c (nodename1, winame1, nodename2, winame2) = 
-	let wi1 = List.find (fun wi -> (compare wi.wi_name winame1) == 0) (Hashtbl.find nodes nodename1).node_wis in
-	let wi2 = List.find (fun wi -> (compare wi.wi_name winame2) == 0) (Hashtbl.find nodes nodename2).node_wis in
+	let node1 = Hashtbl.find nodes nodename1 in
+	let node2 = Hashtbl.find nodes nodename2 in
+	let f winame = fun wi -> (compare wi.wi_name winame) == 0 in
+	let wi1 = List.find (f winame1) node1.node_wis in
+	let wi2 = List.find (f winame2) node2.node_wis in
 	let channel1 = c wi1.wi_essid in
 	let channel2 = c wi2.wi_essid in
@@ -182,8 +185,9 @@
 let score_configuration ns c =
 	let mapper = Hashtbl.find c in
-	let foldfunc acc n = acc + (node_score mapper n) in
-	let nodescores = List.fold_left foldfunc 0 ns in
-	let interference_score = List.fold_left (fun a i -> a + score_interference mapper i) 0 !interference in
-	nodescores + interference_score;;
+	let f1 a n = a + (node_score mapper n) in
+	let nodescores = List.fold_left f1 0 ns in
+	let f2 a i = a + (score_interference mapper i) in
+	let interference_score = List.fold_left f2 0 !interference in
+	nodescores + interference_score
 
 (** Return a random configuration. For some reason, if this function accesses
@@ -196,8 +200,12 @@
 
 let print_conf conf = 
-	let print_wi wi = wi.wi_name ^ ": " ^ (string_of_int (Hashtbl.find conf wi.wi_essid)) in
-	let wis node = List.fold_left (fun acc wi -> acc ^ " " ^ (print_wi wi)) "" node.node_wis in
-	let sorted_nodes = List.sort (fun a b -> compare (a.node_name) (b.node_name)) (values nodes) in
-	List.iter (fun n -> print_string (n.node_name ^ ":" ^ (wis n) ^ "\n")) sorted_nodes
+	let channel wi = string_of_int (Hashtbl.find conf wi.wi_essid) in
+	let print_wi wi = wi.wi_name ^ ": " ^ (channel wi) in
+	let wis node = List.fold_left (fun a wi -> a ^ " " ^ (print_wi wi))
+				      "" node.node_wis in
+	let cmpnode a b = compare (a.node_name) (b.node_name) in
+	let sorted_nodes = List.sort cmpnode (values nodes) in
+	let print_node n = print_string (n.node_name ^ ": " ^ (wis n) ^ "\n") in
+	List.iter print_node sorted_nodes
 
 (** Generalized evolutionary algorithm driver. 
@@ -215,6 +223,7 @@
 	let generation = ref 0 in
 	let all_nodes = values nodes in
-	let _ = while !iterations_since_new_high_score < max_stagnant_iterations do
-		let newpop = (recombine $ mutate $ evaluate $ select) population in
+	let iterate = recombine $ mutate $ evaluate $ select in
+	while !iterations_since_new_high_score < max_stagnant_iterations do
+		let newpop = iterate population in
 		Array.sort (fun a b -> compare b.score a.score) newpop;
 		copyarray newpop population;
@@ -233,6 +242,6 @@
 		incr iterations_since_new_high_score;
 		incr generation
-	done in
-	population.(0);;
+	done;
+	population.(0)
 
 (** BEGIN PARSING CODE *)
@@ -253,27 +262,31 @@
 let parse_file fname =
 	let spacere = Str.regexp " " in
-	(** Given the name of the node currently being parsed, parse the given tuple
-	    that consists of a wi name and an essid. *)
+	(** Given the name of the node currently being parsed, parse the given
+	    tuple that consists of a wi name and an essid. *)
 	let parse_pair nodename (wname, essid) = 
-		let new_wi = { wi_name = wname; wi_nodename = nodename; wi_essid = essid} in
-		let foo = try
+		let new_wi = { wi_name = wname;
+			       wi_nodename = nodename;
+			       wi_essid = essid} in
+		let _ = try
 				let group = Hashtbl.find groups essid in
 				group.group_wis <- new_wi::group.group_wis;
-			  with Not_found ->
-				let group = { group_essid = essid; group_wis = [ new_wi ] } in
+			with Not_found ->
+				let group = { group_essid = essid;
+					      group_wis = [ new_wi ] } in
 				Hashtbl.add groups essid group in
 		new_wi in
 	let parse_fields fields = 
 		let nodename = head fields in
-		let rec makepairs l = match l with
-					[]		-> []
-				      | x::[]		-> assert false
-				      | a::b::xs	-> (a, b)::(makepairs xs) in
-		let wis = List.map (parse_pair nodename) (makepairs (tail fields)) in
+		let rec makepairs l =
+			match l with
+			  []		-> []
+			| x::[]		-> assert false
+			| a::b::xs	-> (a, b)::(makepairs xs) in
+		let wis = List.map (parse_pair nodename)
+				   (makepairs (tail fields)) in
 		let sorted_wis = List.sort compare wis in
 		let node = { node_name = nodename; node_wis = sorted_wis } in
 		Hashtbl.add nodes nodename node in
 	List.iter (parse_fields $ (Str.split spacere)) (snarf_lines fname)
-	;;
 
 (* the parsers for the special case components *)
@@ -325,18 +338,23 @@
 	let initialize () = Array.init population_size (fun _ -> random_configuration groups evaluate_hash) in
 	let recombine x = x in
+	let maxchannel essid =
+		let group = Hashtbl.find groups essid in
+		if (List.length group.group_wis) == 1 then 11
+		else 13 in
 	let mutate_conf conf =
-		Hashtbl.iter (fun essid _ -> let f = Random.float 1.0 in
-					     let group = Hashtbl.find groups essid in
-					     let maxchannel = if (List.length group.group_wis) == 1 then 11
-							      else 13 in
-					     if (f < mutation_rate) then
-						     Hashtbl.replace conf essid (1 + (Random.int maxchannel))) conf in
-	let mutate population = let mutants = Array.map (fun c -> let hash = Hashtbl.copy c.conf in
-								  mutate_conf hash;
-								  { score = evaluate_hash hash;
-								    conf = hash}) population in
-				Array.append population mutants in
-	let evaluate population = Array.iter (fun c -> c.score <- evaluate_hash c.conf) population;
-				  population in
+		Hashtbl.iter (fun essid _ ->
+				let f = Random.float 1.0 in
+				if (f < mutation_rate) then
+					let channel = 1 + (Random.int (maxchannel essid)) in
+					Hashtbl.replace conf essid channel) conf in
+	let mutate population =
+		let mutants = Array.map (fun c -> let hash = Hashtbl.copy c.conf in
+						  mutate_conf hash;
+						  { score = evaluate_hash hash;
+						    conf = hash}) population in
+		Array.append population mutants in
+	let evaluate population =
+		Array.iter (fun c -> c.score <- evaluate_hash c.conf) population;
+		population in
 	let select p = Array.sub p 0 ((Array.length p) / 2) in
 	let best = evolutionary_algorithm initialize recombine mutate evaluate select in
Index: nodes/special.conf
===================================================================
--- nodes/special.conf	(revision 1997)
+++ nodes/special.conf	(revision 1998)
@@ -3,2 +3,4 @@
 supernode jorg jorg jorg2
 supernode jacob jacob jacob2
+supernode unigor unigor unigorn
+supernode kaag kaag kaag2
