Commit f7dc8780 authored by erwan's avatar erwan
Browse files

New: make the number of nodes accessible from processes (via Algo.card: unit -> int)

parent b5770fd6
(* Time-stamp: <modified the 07/05/2019 (at 17:50) by Erwan Jahier> *)
(* Time-stamp: <modified the 27/05/2019 (at 15:55) by Erwan Jahier> *)
(** Process programmer API *)
type varT = It | Ft | Bt | Et of int | St | Nt | At of varT * int
......@@ -24,6 +24,7 @@ type internal_tables = {
enable : (string, enable_fun) Hashtbl.t;
step : (string, step_fun) Hashtbl.t;
actions : (string, action list) Hashtbl.t;
mutable card : int
}
let tbls = {
......@@ -32,6 +33,7 @@ let tbls = {
enable = Hashtbl.create 1;
step = Hashtbl.create 1;
actions = Hashtbl.create 1;
card = (-1)
}
let verbose_level = ref 0
......@@ -180,3 +182,14 @@ let (get_actions : algo_id -> action list) = fun algo_id ->
with Not_found ->
print_table "actions" tbls.actions;
raise (Unregistred ("actions", algo_id))
(* exported *)
let (card : unit -> int) =
fun () -> tbls.card
let (set_card : int -> unit) =
fun i ->
tbls.card <- i
(* Time-stamp: <modified the 19/05/2019 (at 21:43) by Erwan Jahier> *)
(* Time-stamp: <modified the 27/05/2019 (at 16:01) by Erwan Jahier> *)
(** Process programmer API *)
type varT = It | Ft | Bt | Et of int | St | Nt | At of varT * int
......@@ -46,13 +46,21 @@ val reg_actions : algo_id -> action list -> unit
(** util(s) *)
val value_to_string : value -> string
(** Global infos *)
val card : unit -> int
(* val degree : unit -> int *)
(* val diameter : unit -> int *)
(**/**)
(** functions below are not part of the API *)
val vart_to_rif_decl: varT -> string -> (string * string) list
val vart_to_rif_string: varT -> string -> string
val verbose_level: int ref
val set_card : int -> unit
(* val set_degree : int -> unit *)
(* val set_diameter : int -> unit *)
(** the following functions are used by sasa *)
val get_vars : algo_id -> vars
......
(* Time-stamp: <modified the 19/05/2019 (at 21:34) by Erwan Jahier> *)
(* Time-stamp: <modified the 27/05/2019 (at 15:58) by Erwan Jahier> *)
open Algo
open Sasacore
......@@ -178,6 +178,7 @@ let (make : bool -> string array -> t) =
let nl = g.nodes in
let nstrl = List.map (fun n -> n.Topology.id) nl in
let nstr = String.concat "," nstrl in
Algo.set_card (List.length nl);
Algo.verbose_level := args.verbose;
Random.init args.seed;
if !Algo.verbose_level > 0 then Printf.eprintf "nodes: %s\nedges:\n" nstr;
......
(* Time-stamp: <modified the 22/03/2019 (at 17:48) by Erwan Jahier> *)
(* Time-stamp: <modified the 27/05/2019 (at 16:15) by Erwan Jahier> *)
(* This is algo 5.4 in the book *)
open Algo
let vars = ["d",It; "par",Nt ]
let d=10
let d=10 (* degree() *)
let actions = ["CD";"CP"]
let (init_vars: neighbor list -> local_env) =
......
(* Time-stamp: <modified the 09/05/2019 (at 21:59) by Erwan Jahier> *)
(* Time-stamp: <modified the 27/05/2019 (at 16:16) by Erwan Jahier> *)
(* cf Collin-Dolex-94 *)
open Algo
let delta=10
let delta=10 (* diameter() *)
Please register or sign in to reply
let vars = ["path",(At (It,delta)); "par",Nt]
let actions = ["update_path";"compute_parent"]
......
(* Time-stamp: <modified the 20/03/2019 (at 13:09) by Erwan Jahier> *)
(* Time-stamp: <modified the 27/05/2019 (at 16:22) by Erwan Jahier> *)
open Algo
let vars = ["v",It]
let k=42
let k= (card() - 1)
let (init_vars: neighbor list -> local_env) =
fun _nl ->
......
(* Time-stamp: <modified the 20/03/2019 (at 15:02) by Erwan Jahier> *)
(* Time-stamp: <modified the 27/05/2019 (at 16:13) by Erwan Jahier> *)
open Algo
let vars = ["clock",It]
let m=10
let m=10 (* max 2 (1+2*diameter ()) *)
let (init_vars: neighbor list -> local_env) =
fun _nl ->
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment