diff --git a/guides/users/README.md b/guides/users/README.md index a0a92493bfb1637aa380fcc80575ddae10df2dda..02d61f7e10049ecab89752fe8ee905814b17bb93 100644 --- a/guides/users/README.md +++ b/guides/users/README.md @@ -1,35 +1,36 @@ -- [TL;DR](#orgef41afd) -- [Topology](#orge00b9e3) -- [Algorithms](#org071792f) -- [Examples](#orgbbc4152) -- [Batch mode](#orga33ff1d) - - [Running batch simulations with Built-in daemons](#orgc40751d) - - [Running batch simulations with manual daemons](#org73043fc) - - [Running batch simulations with `lurette`](#org3a04cd8) - - [Viewing Results](#orgbe12b82) - - [The `sasa` CLI](#orgfc29f34) -- [Interactive mode](#orgedfef71) - - [Example: use `rdbg` from the `test/alea-coloring/` directory](#org3bcfba2) - - [The exemples of test directory](#org9eb401a) - - [Running interactive sessions with `rdbg`](#org4b24649) - - [Getting `rdbg` on-line help](#orgefcea98) - - [Useful Modules](#orga333c16) -- [Install](#orgb9efe7a) - - [Via opam (version >= 2.\*)](#orgac398ab) - - [Via docker](#orga039e2a) - - [From source](#org50fe9d4) -- [More](#org19a92d2) -- [FAQ](#org31b04e5) - - [Is there a FAQ?](#orgd1a7a10) - - [I have a compilation error that I don't understand](#orgfd30ea8) - - - -<a id="orgef41afd"></a> +- [TL;DR](#org9e79972) +- [Topology](#org5acf069) +- [Algorithms](#org633aad7) +- [Examples](#orgf3a71cb) +- [Batch mode](#orgcf0c55e) + - [Running batch simulations with Built-in daemons](#org8a1d24b) + - [Running batch simulations with manual daemons](#orgb210f36) + - [Running batch simulations with `lurette`](#org3054f33) + - [Viewing Results](#org5dd2887) + - [The `sasa` CLI](#orgf675f37) +- [Interactive mode](#org8faa1ed) + - [Example: use `rdbg` from the `test/alea-coloring/` directory](#org3059bee) + - [The exemples of test directory](#orgae03a82) + - [Running interactive sessions with `rdbg`](#orga8a36c0) + - [Getting `rdbg` on-line help](#org364f2f1) + - [Useful Modules](#orga121e4d) +- [Install](#org4f267cb) + - [Via opam (version >= 2.\*)](#org5050542) + - [Via docker](#org8ac8d84) + - [From source](#org2ca00f9) +- [More](#org08e4f38) +- [FAQ](#org92180aa) + - [Is there a FAQ?](#org6a39565) + - [I have a compilation error that I don't understand](#org98a195b) + - [I have the error `Invalid_argument("compare: functional value")`](#org270d83f) + + + +<a id="org9e79972"></a> # TL;DR -<a id="org1c06b13"></a> SASA is a **Self-stabilizing Algorithms SimulAtor**, based on the so-called **Atomic State model** (ASM) introduced by <span class="underline">Dijkstra</span> in its seminal article on [Self-stabilizing distributed algorithms](http://www.cs.utexas.edu/~EWD/ewd04xx/EWD426.PDF). +<a id="org36389ee"></a> SASA is a **Self-stabilizing Algorithms SimulAtor**, based on the so-called **Atomic State model** (ASM) introduced by <span class="underline">Dijkstra</span> in its seminal article on [Self-stabilizing distributed algorithms](http://www.cs.utexas.edu/~EWD/ewd04xx/EWD426.PDF). Basically, one needs to provide: @@ -53,11 +54,11 @@ Some Tutorials: <https://verimag.gricad-pages.univ-grenoble-alpes.fr/vtt/tags/sa [](http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/sasa/poster.pdf) -<a id="orge00b9e3"></a> +<a id="org5acf069"></a> # Topology -<a id="org3bb17f7"></a> <a id="orge609c67"></a> The topology is given via `.dot` files, that should +<a id="org88651ee"></a> <a id="orgc302762"></a> The topology is given via `.dot` files, that should 1. follow the [graphviz/dot format](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) 2. have nodes **labelled** by the `algo` field @@ -115,14 +116,14 @@ Such parameters can be retrieved in Algorithms using the `Algo.get_graph_attribu nb: a `Algo.diameter: unit -> int` function is provided, but it can be expensive to use. -Some tools are provided in the `sasa` [7](#org7428ef7) to generate such kinds of `dot` graphs: <https://verimag.gricad-pages.univ-grenoble-alpes.fr/vtt/articles/sasa-gg/> +Some tools are provided in the `sasa` [7](#org528f4e8) to generate such kinds of `dot` graphs: <https://verimag.gricad-pages.univ-grenoble-alpes.fr/vtt/articles/sasa-gg/> -<a id="org071792f"></a> +<a id="org633aad7"></a> # Algorithms -<a id="orgae87cad"></a> +<a id="org45ccdff"></a> The following has been generated from [algo.mli](https://gricad-gitlab.univ-grenoble-alpes.fr/verimag/synchrone/sasa/blob/master/lib/algo/algo.mli) @@ -132,7 +133,7 @@ The following has been generated from [algo.mli](https://gricad-gitlab.univ-gren </div> -<a id="orgbbc4152"></a> +<a id="orgf3a71cb"></a> # Examples @@ -166,14 +167,14 @@ The `test` directory also contains sub-directories which gathers programs shared - `test/*/my-rdbg-tuning.ml`: includes `test/my-rdbg-tuning.ml` and defines commands specific to the example of the directory. Indeed, `rdbg`, once launched, first tries to read the content of the file name `my-rdbg-tuning.ml` (if it exists). -<a id="orga33ff1d"></a> +<a id="orgcf0c55e"></a> # Batch mode  -<a id="orgc40751d"></a> +<a id="org8a1d24b"></a> ## Running batch simulations with Built-in daemons @@ -198,7 +199,7 @@ sasa -h | grep "\-daemon" --custom-daemon, -custd -<a id="org73043fc"></a> +<a id="orgb210f36"></a> ## Running batch simulations with manual daemons @@ -225,7 +226,7 @@ It can also by simulated by [`lutin`](http://www-verimag.imag.fr/DIST-TOOLS/SYNC Built-in daemons can of course be programmed in Lutin. One can generate such daemons using the `--gen-lutin-daemon` option: `sasa --gen-lutin-daemon a_graph.dot`. It can be handy at least to get the daemons variables names in the good order if one to write its own daemon. -<a id="org3a04cd8"></a> +<a id="org3054f33"></a> ## Running batch simulations with `lurette` @@ -248,14 +249,14 @@ lurette \ ``` -<a id="orgbe12b82"></a> +<a id="org5dd2887"></a> ## Viewing Results `sasa -rif` and `lurette` generates `.rif` files that can be viewed with `gnuplot-rif` or `sim2chro`; cf <http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/reactive-toolbox/> -<a id="orgfc29f34"></a> +<a id="orgf675f37"></a> ## The `sasa` CLI @@ -318,14 +319,14 @@ sasa --more Display the version ocaml version sasa was compiled with and exit. -<a id="orgedfef71"></a> +<a id="org8faa1ed"></a> # Interactive mode -<a id="org6cb9523"></a> If you want to perform interactive session, you can launch `sasa` under the control of [rdbg](http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/rdbg/). Before reading this section, please read at least the [Basic usage Section if the rdbg documentation](http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/rdbg/README.html#Level0). +<a id="orgfa04b7c"></a> If you want to perform interactive session, you can launch `sasa` under the control of [rdbg](http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/rdbg/). Before reading this section, please read at least the [Basic usage Section if the rdbg documentation](http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/rdbg/README.html#Level0). -<a id="org3bcfba2"></a> +<a id="org3059bee"></a> ## Example: use `rdbg` from the `test/alea-coloring/` directory @@ -378,7 +379,7 @@ $ rdbg Typing `[Enter]` will therefore also load the `rdbg_session.ml` file we have just been using. -<a id="org9eb401a"></a> +<a id="orgae03a82"></a> ## The exemples of test directory @@ -389,7 +390,7 @@ The [test](https://gricad-gitlab.univ-grenoble-alpes.fr/verimag/synchrone/sasa/t - `test/*/my-rdbg-tuning.ml`: includes `test/my-rdbg-tuning.ml` and defines commands specific to the example of the directory. Indeed, `rdbg`, once launched, first tries to read the content of the file name `my-rdbg-tuning.ml` (it it exists). -<a id="org4b24649"></a> +<a id="orga8a36c0"></a> ## Running interactive sessions with `rdbg` @@ -406,7 +407,7 @@ The [test](https://gricad-gitlab.univ-grenoble-alpes.fr/verimag/synchrone/sasa/t All those commands are defined in (the common) [test/my-rdbg-tuning.ml](https://gricad-gitlab.univ-grenoble-alpes.fr/verimag/synchrone/sasa/tree/master/test/my-rdbg-tuning.ml) that is included in (locals) `test/*/my-rdbg-tuning.ml` that are included in (generated) `test/*/rdbg-session.ml` files. `my-rdbg-tuning.ml` contains straigthforward `ocaml` code that defines various `rdbg` shortcuts to ease the simulation of `sasa` systems. Feel free to tailor those command to yours needs by modyfying the local `my-rdbg-tuning.ml`! -<a id="orgefcea98"></a> +<a id="org364f2f1"></a> ## Getting `rdbg` on-line help @@ -419,10 +420,10 @@ Here are 2 useful entry-points to rdbg on-line help: (rdbg) l ``` - 63bbc0a858cb6a06367cf23ad154f086 + 82c2e944ce320891a508ab2190c82cf3 -<a id="orga333c16"></a> +<a id="orga121e4d"></a> ## Useful Modules @@ -449,14 +450,14 @@ Some modules, used by the sasa core engine, can be useful from `rdbg`. </div> -<a id="orgb9efe7a"></a> +<a id="org4f267cb"></a> # Install -<a id="org7428ef7"></a> <a id="org8e0ff64"></a> In any case, you need to install the [graphviz](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) tools suite and a pdf viewer that is able to auto-refresh (for instance `zathura`). +<a id="org528f4e8"></a> <a id="org572cc9c"></a> In any case, you need to install the [graphviz](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) tools suite and a pdf viewer that is able to auto-refresh (for instance `zathura`). -<a id="orgac398ab"></a> +<a id="org5050542"></a> ## Via opam (version >= 2.\*) @@ -491,14 +492,14 @@ opam upgrade In order to be able to use `luciole` and `sim2chro`, you also need to install the Lustre V4 distribution: <http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/lustre-v4/distrib/index.html> -<a id="orga039e2a"></a> +<a id="org8ac8d84"></a> ## Via docker cf the Docker Install section of the [Synchrone Reactive Tool Box](http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/lustre-v6/#docker). -<a id="org50fe9d4"></a> +<a id="org2ca00f9"></a> ## From source @@ -518,7 +519,7 @@ opam install dune ocamlgraph rdbg lutin One can mimick the content of the `test` job in the project [.gitlab-ci.yml Gitlab CI script](https://gricad-gitlab.univ-grenoble-alpes.fr/verimag/synchrone/sasa/tree/master/.gitlab-ci.yml). -<a id="org19a92d2"></a> +<a id="org08e4f38"></a> # More @@ -527,12 +528,12 @@ One can mimick the content of the `test` job in the project [.gitlab-ci.yml Gitl - Tutorials: <https://verimag.gricad-pages.univ-grenoble-alpes.fr/vtt//categories/sasa/> -<a id="org31b04e5"></a> +<a id="org92180aa"></a> # FAQ -<a id="orgd1a7a10"></a> +<a id="org6a39565"></a> ## Is there a FAQ? @@ -541,7 +542,7 @@ Yes. Beside, some tutorials are also available here: <https://verimag.gricad-pages.univ-grenoble-alpes.fr/vtt/tags/sasa/> -<a id="orgfd30ea8"></a> +<a id="org98a195b"></a> ## I have a compilation error that I don't understand @@ -549,3 +550,10 @@ Beside, some tutorials are also available here: <https://verimag.gricad-pages.un - Do a `make clean` - Read carefully the error message. Sometimes it helps. - If the message is totally useless, please feel free to add an issue here <https://gricad-gitlab.univ-grenoble-alpes.fr/verimag/synchrone/sasa/issues> + + +<a id="org270d83f"></a> + +## I have the error `Invalid_argument("compare: functional value")` + +Most probably you a try to compare 2 `'s Algo.neighbor`. It's an abstract type, hence you cannot compare them, i.e., you cannot use `Stdlib.compare`, nor its twins (`<>`, `>`, `<`, etc.), nor functions that use them (`min`, `max`, `List.sort`, etc.). You should compare their `pid` instead (if the network is not anonymous). diff --git a/guides/users/README.org b/guides/users/README.org index be85f6e07687a6d0999004e17ef378f7aec87c20..4ce721f0f60f41b68a2b75a475b5d16e75702c93 100644 --- a/guides/users/README.org +++ b/guides/users/README.org @@ -565,3 +565,11 @@ Beside, some tutorials are also available here: - If the message is totally useless, please feel free to add an issue here https://gricad-gitlab.univ-grenoble-alpes.fr/verimag/synchrone/sasa/issues + +** I have the error =Invalid_argument("compare: functional value")= + +Most probably you a try to compare 2 ='s Algo.neighbor=. It's an +abstract type, hence you cannot compare them, i.e., you cannot use +=Stdlib.compare=, nor its twins (=<>=, =>=, =<=, etc.), nor functions that +use them (=min=, =max=, =List.sort=, etc.). You should compare their +=pid= instead (if the network is not anonymous). diff --git a/lib/algo/algo.ml b/lib/algo/algo.ml index f77c00ff1024a303d98506abbfacd66d6ee198d0..c7cccb6959e412ecf2561b5558f6631bc0eb7611 100644 --- a/lib/algo/algo.ml +++ b/lib/algo/algo.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 26/02/2020 (at 17:16) by Erwan Jahier> *) +(* Time-stamp: <modified the 05/03/2020 (at 17:15) by Erwan Jahier> *) open Sasacore (* Process programmer API *) @@ -19,7 +19,7 @@ let (fmt_print_neighbor: Format.formatter -> 's neighbor -> unit) = fun fmt n -> Format.pp_print_string fmt (n.pid ()) -exception Not_available +exception Not_available of string (** processes local state (user defined) *) let (state : 's neighbor -> 's) = fun s -> s.state @@ -68,9 +68,7 @@ let (to_reg_neigbor : 's Register.neighbor -> 's neighbor) = pid = n.Register.pid; spid = n.Register.spid; reply = n.Register.reply; - weight = fun () -> match n.Register.weight () with - None -> raise Not_available - | Some w -> w; + weight = n.Register.weight; } let (to_reg_enable_fun : 's enable_fun -> diff --git a/lib/algo/algo.mli b/lib/algo/algo.mli index c05092ab357496832d4a31da37cb2c4222b1ce21..a4bc624582969ce3b966559fb2c29774fa974d2a 100644 --- a/lib/algo/algo.mli +++ b/lib/algo/algo.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 19/02/2020 (at 09:46) by Erwan Jahier> *) +(* Time-stamp: <modified the 05/03/2020 (at 14:47) by Erwan Jahier> *) (** {1 The Algorithm programming Interface.} *) (** {1 What's need to be provided by users.} @@ -34,9 +34,9 @@ type 's state_init_fun = int -> 's initialization function that takes as unique argument the number of neighbors of the node. *) -(** When a neighbor information can not be accessed (e.g., the pid - anonymous networks) the Not_available exception is raised. *) -exception Not_available +(** When an information can not be accessed (e.g., the pid anonymous + networks) the Not_available exception is raised. *) +exception Not_available of string (** Returns the processes local state *) val state : 's neighbor -> 's @@ -53,24 +53,25 @@ val pid : 's neighbor -> string *) val spid : 's neighbor -> string -(** Returns the channel number that let this neighbor access to the - content of the process, if it neighbor can access it. Returns -1 if - the neigbor can not access to the process, which may happen in - directed graphs only. This info is not available in all simulation - modes. - *) +(** Returns the channel number that let this neighbor access to the + content of the process, if its neighbor can access it. Returns -1 + if the neighbor can not access to the process, which may happen in + directed graphs only. This info is not available in all simulation + modes. An algorithm that can access to the reply, and not the spid is + called semi-anonymous. It is called anonymous if it can access none. *) val reply : 's neighbor -> int -(** Returns the weight decoration the current node and it neighbor - (which makes sense in directed graphs only) *) -val weight : 's neighbor -> int +(** Returns the weight of the edge between the current node and its neighbor. + Note that "weight" is an edge (dot) attribute. + *) +val weight : 's neighbor -> int val print_neighbor: 's neighbor -> unit val fmt_print_neighbor: Format.formatter -> 's neighbor -> unit (** {1 Access to Topological Information} - When writing algorithms, one can also have acces to topological + When writing algorithms, one can also have access to topological information (i.e., information that are relative to the graph) *) val card : unit -> int @@ -127,7 +128,7 @@ val register : 's to_register -> unit (** {1 Automatic Generation of Registration Code} Once enable and step functions are defined, they need to be - registred by calling the register function. + registered by calling the register function. An alternative to writing this registration code is to let sasa generate it with the "--gen-register" (or "-reg") option. @@ -149,12 +150,12 @@ val register : 's to_register -> unit in the dot file. Defining a copy that is not the identity is necessary if the state is not - functionnal (e.g., if it contains an array or an Hashtbl). + functional (e.g., if it contains an array or an Hashtbl). In the file "state.ml" does not exist in the current directory, a skeleton is generated. - (2) All the algos mentionned in the dot file should define the + (2) All the algos mentioned in the dot file should define the following functions: {[ let (init_state: int -> State.t) = xxx diff --git a/lib/sasacore/register.ml b/lib/sasacore/register.ml index c9d34f766d89d4c3507a7f62ca9282c75b0603a4..f6f4da66b4838cdd13f15b7d0feca0724cc50df4 100644 --- a/lib/sasacore/register.ml +++ b/lib/sasacore/register.ml @@ -1,11 +1,11 @@ -(* Time-stamp: <modified the 19/02/2020 (at 09:33) by Erwan Jahier> *) +(* Time-stamp: <modified the 05/03/2020 (at 17:15) by Erwan Jahier> *) type 's neighbor = { state: 's ; pid: unit -> string; spid: unit -> string; reply: unit -> int; - weight: unit -> int option; + weight: unit -> int; } type algo_id = string diff --git a/lib/sasacore/register.mli b/lib/sasacore/register.mli index b5a4f667ee1d487ad45eb3abd89dc3c6e70c77da..7c5c541f5337973d444a55d2343600f21ba443b0 100644 --- a/lib/sasacore/register.mli +++ b/lib/sasacore/register.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 19/02/2020 (at 09:33) by Erwan Jahier> *) +(* Time-stamp: <modified the 05/03/2020 (at 17:15) by Erwan Jahier> *) (** This module duplicates and extends the Algo module with get_* functions. @@ -13,7 +13,7 @@ type 's neighbor = { pid: unit -> string; spid: unit -> string; reply: unit -> int; - weight: unit -> int option; + weight: unit -> int; } type algo_id = string diff --git a/lib/sasacore/topology.ml b/lib/sasacore/topology.ml index 6573dce9da55466da12d01083df2ad9207169ac1..4195e591b12eb24d9a0589b4ffbea4be688f2e73 100644 --- a/lib/sasacore/topology.ml +++ b/lib/sasacore/topology.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 07/02/2020 (at 13:29) by Erwan Jahier> *) +(* Time-stamp: <modified the 05/03/2020 (at 17:14) by Erwan Jahier> *) open Graph open Graph.Dot_ast @@ -13,7 +13,7 @@ type node = { type t = { nodes: node list; - succ: node_id -> (int option * node_id) list; + succ: node_id -> (int * node_id) list; of_id: node_id -> node; directed:bool } @@ -21,7 +21,7 @@ type t = { type node_info_t = (string, node) Hashtbl.t let node_info:node_info_t = Hashtbl.create 100 -type node_succ_t = (string, (int option * node_id) list) Hashtbl.t +type node_succ_t = (string, (int * node_id) list) Hashtbl.t let node_succ:node_succ_t = Hashtbl.create 100 let (of_id:Dot_ast.id -> string) = @@ -59,11 +59,12 @@ let (get_init: Dot_ast.attr list -> string) = in init_list -let rec (get_weight: Dot_ast.attr -> int option ) = +let rec (get_weight: Dot_ast.attr -> int) = function - | (Ident "weight", Some Number n)::_ -> (try Some (int_of_string n) with _ -> None) + | (Ident "weight", Some Number n)::_ + | (Ident "weight", Some String n)::_ -> (try (int_of_string n) with _ -> 1) | _::tail -> get_weight tail - | [] -> None + | [] -> 1 let (do_graph_attr : (Dot_ast.id * Dot_ast.id option) list -> unit) = fun l -> @@ -96,7 +97,7 @@ let (do_stmt: bool -> node list -> Dot_ast.stmt -> node list) = The code below add the missing edges: *) let attrs = List.flatten attrs in (* XXX why a list of list ? *) - let weight = if directed then get_weight attrs else None in + let weight = get_weight attrs in let add_edge n1 n2 = if n1 = n2 then failwith (Printf.sprintf @@ -105,13 +106,13 @@ let (do_stmt: bool -> node list -> Dot_ast.stmt -> node list) = let pn2 = try Hashtbl.find node_succ n2 with Not_found -> [] in if not (List.mem (weight,n2) pn1) then Hashtbl.replace node_succ n1 ((weight,n2)::pn1); - if not directed && not (List.mem (None,n1) pn2) then - Hashtbl.replace node_succ n2 ((None,n1)::pn2); + if not directed && not (List.mem (weight,n1) pn2) then + Hashtbl.replace node_succ n2 ((weight,n1)::pn2); n2 in ignore (List.fold_left add_edge node nodes); n - | Attr_graph attrs -> do_graph_attr (List.flatten attrs); n + | Attr_graph attrs -> do_graph_attr (List.flatten attrs); n | Attr_node _attrs -> n | Attr_edge _attrs -> n | Equal (_id1, _id2) -> assert false diff --git a/lib/sasacore/topology.mli b/lib/sasacore/topology.mli index 10ce065381665374582f048709800318c8b7466d..b41b5c2ba45fd73904fe3d1c7b776cd0501d975f 100644 --- a/lib/sasacore/topology.mli +++ b/lib/sasacore/topology.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 07/02/2020 (at 13:27) by Erwan Jahier> *) +(* Time-stamp: <modified the 05/03/2020 (at 17:14) by Erwan Jahier> *) (** {1 Topology: internal representation of Graphs } *) @@ -12,7 +12,7 @@ type node = { type t = { nodes: node list; (** *) - succ: node_id -> (int option * node_id) list; (** get neighbors, with weigth if any *) + succ: node_id -> (int * node_id) list; (** get neighbors, with weigth *) of_id: node_id -> node; (** *) directed:bool (** true if the graph is directed *) } diff --git a/sasa.opam b/sasa.opam index f90580d070e2cfe5c306bb3029e0f3dfd5774b3c..da9c738fcf86000c4bce9df07b72dafdb71cb0d9 100644 --- a/sasa.opam +++ b/sasa.opam @@ -25,4 +25,4 @@ depends: [ "rdbg" { >= "1.184" } ] available: [ ocaml-version >= "4.02" ] -post-messages: ["The last version can be obtained via (opam repo add) http://www-verimag.imag.fr/DIST-TOOLS/SYNCHRONE/opam-repository/ "] +post-messages: ["The last version can be obtained via (opam repo add) http://www-verimag.mag.fr/DIST-TOOLS/SYNCHRONE/opam-repository/ "] diff --git a/test/my-rdbg-tuning.ml b/test/my-rdbg-tuning.ml index 67557c8672c8d90b53d63f588921cc9c4a3c9fe6..332cf6c89cca61057acdf93d6d3c04a743789a5a 100644 --- a/test/my-rdbg-tuning.ml +++ b/test/my-rdbg-tuning.ml @@ -251,6 +251,12 @@ Here is the list of rdbg Level 0 commands (i.e., defined in my-rdbg-tuning.ml) : q: "^(RdbgMain.doc_msg "q")^" ");; +let man () = man(); + output_string stdout " + l (* List of Level 0 (sasa specific) commands *) +"; + flush stdout + ;; + (* The code above was (probably) generated by rdbg when no my-rdbg-tuning.ml file was present in this directory *) (**********************************************************************) diff --git a/tools/ggDeco/ggDeco.ml b/tools/ggDeco/ggDeco.ml index 893988da671d7a2ab29885db4e3fd8eaf8306384..d1a5841575d70a8b8cf37e25e11099ef03d057ad 100644 --- a/tools/ggDeco/ggDeco.ml +++ b/tools/ggDeco/ggDeco.ml @@ -71,12 +71,12 @@ let to_dot_string : (t -> string -> string) = List.map (fun (w,neighbour) -> (match w with - | None -> + | 1 -> if n.id < neighbour then Printf.sprintf (" %s -- %s") n.id neighbour else Printf.sprintf (" %s -- %s") neighbour n.id - | Some x -> + | x -> Printf.sprintf (" %s -- %s [weight=%d]") n.id neighbour x ) ) diff --git a/tools/graphgen/classicGraph.ml b/tools/graphgen/classicGraph.ml index 8ed75fe0e5f95659db38ec23abcd083795fad525..792160b7fe6e6ae08877e23e3c86dc5865d63c25 100644 --- a/tools/graphgen/classicGraph.ml +++ b/tools/graphgen/classicGraph.ml @@ -3,10 +3,11 @@ open Topology open Ggcore open List -type node_succ_t = (string, (int option * string) list) Hashtbl.t +type node_succ_t = (string, (int * string) list) Hashtbl.t -let nid_list_remove : (node_id list -> node_id -> (int option*node_id) list) = - fun l e -> rev (fold_left (fun acc elem -> if(elem <> e) then (None,elem)::acc else acc ) [] l) +let nid_list_remove : (node_id list -> node_id -> (int*node_id) list) = + fun l e -> + rev (fold_left (fun acc elem -> if(elem <> e) then (1,elem)::acc else acc ) [] l) let (gen_clique: bool -> int -> Topology.t) = @@ -30,7 +31,10 @@ let (gen_star: bool -> int -> Topology.t) = fun directed nb -> let (node_succ:node_succ_t) = Hashtbl.create nb and nodes = "root"::(create_nodes "p" (1,nb)) in let first = hd nodes in - List.iter (fun node -> Hashtbl.replace node_succ node (if node = first then nid_list_remove nodes node else [(None,first)])) nodes; + List.iter + (fun node -> + Hashtbl.replace node_succ node + (if node = first then nid_list_remove nodes node else [(1,first)])) nodes; let nl = id_to_empty_nodes nodes in { nodes = nl; @@ -39,9 +43,9 @@ let (gen_star: bool -> int -> Topology.t) = directed = directed } -let add_weight (li : node_id list) : (int option * node_id) list = map (fun elem -> (None,elem)) li +let add_weight (li : node_id list) : (int * node_id) list = map (fun elem -> (1,elem)) li -let neighbours_ring : (node_id list -> (node_id -> (int option * node_id) list)) = +let neighbours_ring : (node_id list -> (node_id -> (int * node_id) list)) = fun li -> let node_succ:node_succ_t = Hashtbl.create (length li) in let ((_,last),ret) = fold_left (fun ((first,prev),accu) elem -> @@ -89,7 +93,7 @@ let (gen_grid: bool -> int -> int -> Topology.t) = for jp=bup to bdown do if not ((ip=0 && jp=0) || (ip=jp) || (ip = -jp)) then (Hashtbl.replace table n_id - ((None,(List.nth nodes ((j+jp)*length + i+ip)))::( + ((1,(List.nth nodes ((j+jp)*length + i+ip)))::( try Hashtbl.find table n_id with Not_found -> [])); ) else () done; done; @@ -113,12 +117,12 @@ let rec link_hypercube_nodes : (node_id array -> node_succ_t -> unit) = link_hypercube_nodes n2 n_s; Array.iter2 (fun node1 node2 -> Hashtbl.replace n_s node1 - ((None,node2)::(try Hashtbl.find n_s node1 with Not_found -> [])); + (( 1,node2)::(try Hashtbl.find n_s node1 with Not_found -> [])); Hashtbl.replace n_s node2 - ((None,node1)::(try Hashtbl.find n_s node2 with Not_found -> [])) + ((1,node1)::(try Hashtbl.find n_s node2 with Not_found -> [])) ) n1 n2 -let neighbours_hyper_cube : (node_id list -> (node_id -> (int option * node_id) list)) = +let neighbours_hyper_cube : (node_id list -> (node_id -> (int * node_id) list)) = fun nl -> let na = Array.of_list nl in let (node_succ:node_succ_t) = Hashtbl.create (Array.length na) in diff --git a/tools/graphgen/graphGen.ml b/tools/graphgen/graphGen.ml index 61cb65728376b49645c7b77334b791ae10de89a1..c509ba113be22a13cb5ac84a7f25930917f867b3 100644 --- a/tools/graphgen/graphGen.ml +++ b/tools/graphgen/graphGen.ml @@ -156,12 +156,12 @@ let to_dot_string : (t -> string -> (string * string) list -> string) = List.map (fun (w,neighbour) -> (match w with - | None -> + | 1 -> if n.id < neighbour then Printf.sprintf (" %s -- %s") n.id neighbour else Printf.sprintf (" %s -- %s") neighbour n.id - | Some x -> + | x -> Printf.sprintf (" %s -- %s [weight=%d]") n.id neighbour x ) ) diff --git a/tools/graphgen/randomGraph.ml b/tools/graphgen/randomGraph.ml index b87fa292bb35b5a2054c67f246644880637ea6a5..df1c7600cc004e5a5215d88602efe9ab30e2a7b6 100644 --- a/tools/graphgen/randomGraph.ml +++ b/tools/graphgen/randomGraph.ml @@ -3,7 +3,7 @@ open Topology open Ggcore open List -type node_succ_t = (node_id, (int option * node_id) list) Hashtbl.t +type node_succ_t = (node_id, (int * node_id) list) Hashtbl.t type probability = float (*between 0 and 1*) let gen_ER : (bool -> int -> probability -> Topology.t) = @@ -13,9 +13,9 @@ let gen_ER : (bool -> int -> probability -> Topology.t) = iteri (fun j m -> if (i < j) && (Random.float 1.) < p then (Hashtbl.replace node_succ n - ((None,m)::(try Hashtbl.find node_succ n with Not_found -> [])); + ((1,m)::(try Hashtbl.find node_succ n with Not_found -> [])); Hashtbl.replace node_succ m - ((None,n)::(try Hashtbl.find node_succ m with Not_found -> []))) + ((1,n)::(try Hashtbl.find node_succ m with Not_found -> []))) ) nodes ) nodes; let nl = id_to_empty_nodes nodes in @@ -37,13 +37,16 @@ let rec init_m_nodes : (int -> node_succ_t -> node_id list -> node_id list) = else node::tail | _ -> assert false -let neighbours_BA : (node_id list -> int -> node_succ_t -> (node_id -> (int option * node_id) list)) = +let neighbours_BA : (node_id list -> int -> node_succ_t -> (node_id -> (int * node_id) list)) = fun nodes m node_succ -> let d_tot = 2 * m and nodes = init_m_nodes m node_succ nodes in match nodes with | [] -> assert false | head::nodes -> Hashtbl.replace node_succ head ( - Hashtbl.fold (fun n _ succ -> Hashtbl.replace node_succ n [(None,head)]; (None,n)::succ) node_succ [] + Hashtbl.fold + (fun n _ succ -> + Hashtbl.replace node_succ n [(1,head)]; + (1,n)::succ) node_succ [] ); (*init terminée. On a un graph connexe pour les m+1 premiers points, nl ne contient que les points non ajoutés*) ignore (fold_left (fun deg_tot node -> @@ -54,12 +57,12 @@ let neighbours_BA : (node_id list -> int -> node_succ_t -> (node_id -> (int opti for _ = 0 to m-1 do (*for each edge to create*) let ran = Random.int !deg_temp in ignore (Hashtbl.fold (fun n_id n_succ r -> - if r >= 0 && not (List.mem (None,n_id) !succ) then + if r >= 0 && not (List.mem (1,n_id) !succ) then let r = r - (length n_succ) in ( if r < 0 then - (succ := (None,n_id)::!succ; + (succ := (1,n_id)::!succ; Hashtbl.replace node_succ n_id - ((None,node)::n_succ); + ((1,node)::n_succ); deg_temp := !deg_temp - length n_succ) ); r else r @@ -93,15 +96,15 @@ let gen_BA : (bool -> int -> int -> Topology.t) = directed = directed } -let pre_rand_tree : (node_succ_t -> node_id list -> (node_id -> (int option * node_id) list)) = +let pre_rand_tree : (node_succ_t -> node_id list -> (node_id -> (int * node_id) list)) = fun node_succ -> function | [] -> failwith "Tree Error : You need at least one nodes in your tree" | h::t -> ignore (List.fold_left (fun acc elem -> let no = (List.nth acc (Random.int (List.length acc))) in - (Hashtbl.replace node_succ no ((None,elem)::(try Hashtbl.find node_succ no with Not_found -> [])); - Hashtbl.replace node_succ elem ((None,no)::(try Hashtbl.find node_succ elem with Not_found -> [])) + (Hashtbl.replace node_succ no ((1,elem)::(try Hashtbl.find node_succ no with Not_found -> [])); + Hashtbl.replace node_succ elem ((1,no)::(try Hashtbl.find node_succ elem with Not_found -> [])) ); (elem::acc) ) [h] (t)); @@ -146,7 +149,7 @@ let gen_qudg : (bool -> int -> float -> float -> float -> float -> float -> or : (within the radius r1, with a brobability of p) *) then ( Hashtbl.replace node_succ node - ((None,n)::(try Hashtbl.find node_succ node with Not_found -> [])) + ((1,n)::(try Hashtbl.find node_succ node with Not_found -> [])) ) ) pl ) pl; diff --git a/tools/graphgen/udgUtils.ml b/tools/graphgen/udgUtils.ml index 2e32dcec215bf3f3677379e8073b101762bb5ec3..cb8be27ec3e2f3635b83fac3a45fd60826848dad 100644 --- a/tools/graphgen/udgUtils.ml +++ b/tools/graphgen/udgUtils.ml @@ -56,12 +56,12 @@ let make_links_dot g = List.map (fun (w,neighbour) -> (match w with - | None -> + | 1 -> if n.id < neighbour then Printf.sprintf (" %s -- %s") n.id neighbour else Printf.sprintf (" %s -- %s") neighbour n.id - | Some x -> + | x -> Printf.sprintf (" %s -- %s [weight=%d]") n.id neighbour x ) )