From c16fd6316436adc10017564d352c6b872f50a4ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= <edu@thorsten-wissmann.de>
Date: Wed, 29 Jan 2014 00:40:14 +0100
Subject: [PATCH] Many benchmark bugfixes and optimizations

---
 CoAlgFormula.ml | 12 ++++++++++--
 coalgcompare.ml | 12 ++++++------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/CoAlgFormula.ml b/CoAlgFormula.ml
index 489c217..54a19c4 100644
--- a/CoAlgFormula.ml
+++ b/CoAlgFormula.ml
@@ -156,12 +156,20 @@ let rec exportFormula_buffer sb f =
       prio 4 f1
   | ALLOWS (s, f1) ->
       Buffer.add_string sb "<{";
-      Buffer.add_string sb (Str.concat " " (L.map string_of_int s));
+      Buffer.add_string sb (
+          match s with
+          | [] -> " "
+          | _ ->(Str.concat " " (L.map string_of_int s))
+      );
       Buffer.add_string sb "}>";
       prio 4 f1
   | ENFORCES (s, f1) ->
       Buffer.add_string sb "[{";
-      Buffer.add_string sb (Str.concat " " (L.map string_of_int s));
+      Buffer.add_string sb (
+          match s with
+          | [] -> " "
+          | _ ->(Str.concat " " (L.map string_of_int s))
+      );
       Buffer.add_string sb "}]";
       prio 4 f1
   | MIN (n, s, f1) ->
diff --git a/coalgcompare.ml b/coalgcompare.ml
index 7c36205..7a830ef 100644
--- a/coalgcompare.ml
+++ b/coalgcompare.ml
@@ -26,7 +26,7 @@ type testresults =
         list))
 
 let debugMsg str =
-    print_endline (":: " ^ str)
+    prerr_endline (":: " ^ str)
 
 (* generates the int range from i to j (including) *)
 let (--) i j = 
@@ -161,9 +161,9 @@ let doTestK () : testresults =
     lPPP A list of pairs (p->p->p, n), e.g. (.+., 1).
   *)
   let timeout = 300 in (* 5 minutes *)
-  let lF = List.map (fun p -> (C.AP (string_of_int p), 1)) (0--10) in
+  let lF = List.map (fun p -> (C.AP ("p"^(string_of_int p)), 1)) (0--3) in
   let lFF = [(C.const_not,1)] in
-  let lFFF = [(C.const_and,1); (C.const_or, 1)] in
+  let lFFF = [(C.const_and,1)] in (* Warning: This forbids disjunctions! *)
   let lPFF = [(C.const_ex,1); (C.const_ax, 1)] in
   (* role names *)
   let lP : (string *int) list = List.map (fun p -> (string_of_int p, 1)) (0--10) in
@@ -215,9 +215,9 @@ let doGenCL aglist sizelist : unit =
     lFP A list of pairs (f->p, n), e.g. (?., 1).
     lPPP A list of pairs (p->p->p, n), e.g. (.+., 1).
   *)
-  let lF = List.map (fun p -> (C.AP (string_of_int p), 1)) (0--10) in
+  let lF = List.map (fun p -> (C.AP ("p"^(string_of_int p)), 1)) (1--3) in
   let lFF = [(C.const_not,1)] in
-  let lFFF = [(C.const_and,1); (C.const_or, 1)] in
+  let lFFF = [(C.const_and,1)] in (* Warning: This forbids disjunctions! *)
   let lPFF = [(C.const_enforces,1); (C.const_allows, 1)] in
   (* role names *)
   let lP = List.map (fun p -> (p, 1)) (TList.powerset aglist) in
@@ -234,7 +234,7 @@ let _ =
     let argidx = ref (1) in
     let fail str = (prerr_endline str ; printUsage ()) in
     let getarg () =
-        if !argidx >= Array.length Sys.argv then (fail "Error: Missing argument") else ();
+        if !argidx >= Array.length Sys.argv then (fail "Error: Missing argument ") else ();
         let str = Sys.argv.(!argidx) in
         argidx := 1 + !argidx;
         str
-- 
GitLab