Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sasa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
verimag
synchrone
sasa
Commits
d4752be1
Commit
d4752be1
authored
4 years ago
by
erwan
Browse files
Options
Downloads
Patches
Plain Diff
Doc: some enhancements in the Algo API doc
parent
cdf64a92
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/algo/algo.mli
+59
-37
59 additions, 37 deletions
lib/algo/algo.mli
with
59 additions
and
37 deletions
lib/algo/algo.mli
+
59
−
37
View file @
d4752be1
(* Time-stamp: <modified the 02/09/2020 (at 10:27) by Erwan Jahier> *)
(** {1 The Algorithm programming Interface.} *)
(**
{1 What's need to be provided by users.}
(* Time-stamp: <modified the 16/09/2020 (at 15:42) by Erwan Jahier> *)
(** {1 The Algorithm programming Interface}
A SASA process is an instance of an algorithm defined via this
module.
*)
(**
{2 To be provided by users}
In order to define a SASA algorithm, one need to provide an enable
and a step function:
...
...
@@ -18,15 +20,22 @@ type 's neighbor
type
action
=
string
type
'
s
enable_fun
=
'
s
->
'
s
neighbor
list
->
action
list
type
'
s
step_fun
=
'
s
->
'
s
neighbor
list
->
action
->
'
s
(** The first argument holds the current state of the process. As it is
(** [enable_fun] and [step_fun] have the same arguments in input:
- The first argument holds the current state of the process. As it is
polymorphic (['s]), algorithms designers can put anything they need
into this state (an integer, a structure, etc.). The only constraint
is that all algorithms should use the same type.
The second argument holds the process neighbors. Note that SASA
-
The second argument holds the process neighbors. Note that SASA
processes, that live in graph nodes, can only access to their
immediate neighbors. From each neighbor, a process can access to
various information thanks to the functions below.
various information (cf [state], [reply], and [weight] functions below).
[enable_fun] returns the list of enable actions.
[step_fun], which also takes an action in input, returns the new value
of the local state resulting from the execution of the action.
*)
type
'
s
state_init_fun
=
int
->
string
->
'
s
...
...
@@ -35,14 +44,47 @@ type 's state_init_fun = int -> string -> 's
of node neighbors, and the pid. Anonymous algorithms are not
supposed to use the pid. *)
(** Returns the processes local state *)
(** {2 To be provided optionally} *)
(** {3 Potential function}
Let the user define what the potential of a configuration is.
Used to explore best/worst case daemons (--worst-daemon)
*)
type
pid
=
string
type
'
s
potential_fun
=
pid
list
->
(
pid
->
'
s
*
'
s
neighbor
list
)
->
float
(** {3 Legitimate Configurations} *)
type
'
s
legitimate_fun
=
pid
list
->
(
pid
->
'
s
*
'
s
neighbor
list
)
->
bool
(** By default, legitimate configurations (i.e., global states) are
silent ones. But this is not true for all algorithms. Predicates
of this type are used to redefine what's a legitimate configuration
is. *)
(** {3 Fault Injection } *)
type
'
s
fault_fun
=
int
->
string
->
'
s
->
'
s
(** The fault function is called on each node to update their state
each time a legitimate configuration is reached. It takes 3
arguments: the number of node neighbors, the pid, and the value of
the current state. *)
(** {2 Can be used in algorithms} *)
(** {3 Process (local) Information} *)
(** Returns the neighbor processes local state *)
val
state
:
'
s
neighbor
->
'
s
(** Returns the channel number, that let this neighbor
access
to the
content of the current process, if its neighbor can access
it. The
channel number is the rank,starting at 0, in the
neighbors' list.
Returns -1 if the neighbor can not access to the
process, which may
happen in directed graphs.
(** Returns the
neighbor
channel number, that let this neighbor access
to the
content
of the current process, if its
neighbor can access
it. The
channel
number
is the
rank,starting
at
0,
in the
neighbors' list.
Returns -1 if the
neighbor can not access to the
process, which may
happen in directed graphs.
An algorithm that uses reply, and not the pid, is called
semi-anonymous. It is called anonymous if it can access none. *)
...
...
@@ -53,10 +95,11 @@ val reply : 's neighbor -> int
returned if not weight is set in the graph. *)
val
weight
:
'
s
neighbor
->
int
(** For debugging *)
val
print_neighbor
:
'
s
neighbor
->
unit
val
fmt_print_neighbor
:
Format
.
formatter
->
'
s
neighbor
->
unit
(** {
1 Access to
Topological Information}
(** {
3
Topological Information}
When writing algorithms, one can also have access to topological
information (i.e., information that are relative to the graph) *)
...
...
@@ -79,29 +122,8 @@ val diameter : unit -> int
val
get_graph_attribute
:
string
->
string
(** {1 Potential function }
Let the user define what the potential of a configuration is.
Used to explore best/worst case daemons (--worst-daemon)
*)
type
pid
=
string
type
'
s
potential_fun
=
pid
list
->
(
pid
->
'
s
*
'
s
neighbor
list
)
->
float
(** {1 Legitimate Configurations} *)
type
'
s
legitimate_fun
=
pid
list
->
(
pid
->
'
s
*
'
s
neighbor
list
)
->
bool
(** By default, legitimate configurations (i.e., global states) are
silent ones. But this is not true for all algorithms. Predicates
of this type are used to redefine what's a legitimate configuration
is. *)
(** {1 Fault Injection} *)
type
'
s
fault_fun
=
int
->
string
->
'
s
->
'
s
(** The fault function is called on each node to update their state
each time a legitimate configuration is reached. It takes 3
arguments: the number of node neighbors, the pid, and the value of
the current state. *)
(** {
1
Code Registration}
(** {
2
Code Registration}
The [register: 's to_register -> unit] function must be called once in
the user code. *)
...
...
@@ -135,7 +157,7 @@ type 's to_register = {
(** To be called once *)
val
register
:
'
s
to_register
->
unit
(** {1 Automatic
Generation of
Registration
Code
}
(** {1 Automatic
Code
Registration }
Once enable and step functions are defined, they need to be
registered by calling the register function.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment