1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
type t = int * int
(** agent_id * agent_type *)
type ag = t
let make ~id ~sort = id, sort
let print ?sigs ~with_id f (i, ty) =
match sigs with
| Some sigs ->
Format.fprintf f "%a%t" (Signature.print_agent sigs) ty (fun f ->
if with_id then Format.fprintf f "/*%i*/" i)
| None -> Format.fprintf f "n%i" i
let print_site ?sigs (i, agent) f id =
match sigs with
| Some sigs -> Signature.print_site sigs agent f id
| None -> Format.fprintf f "n%is%i" i id
let print_internal ?sigs (i, agent) site f id =
match sigs with
| Some sigs -> Signature.print_site_internal_state sigs agent site f (Some id)
| None -> Format.fprintf f "n%is%i~%i" i site id
let print_raw_internal ?sigs (i, agent) site f id =
match sigs with
| Some sigs -> Signature.print_internal_state sigs agent site f id
| None -> Format.fprintf f "n%is%i~%i" i site id
let rename ~debug_mode inj (n_id, n_ty) =
Renaming.apply ~debug_mode inj n_id, n_ty
let sort (_, ty) = ty
let id (id, _) = id
let compare (id1, _) (id2, _) = Mods.int_compare id1 id2
let json_dictionnary = "\"agent\":{\"id\":0,\"type\":1}"
let write_json ob a =
JsonUtil.write_compact_pair Yojson.Basic.write_int Yojson.Basic.write_int ob a
let read_json p lb =
JsonUtil.read_compact_pair Yojson.Basic.read_int Yojson.Basic.read_int p lb
let to_json (id, ty) = `List [ `Int id; `Int ty ]
let of_json = function
| `List [ `Int id; `Int ty ] -> id, ty
| x -> raise (Yojson.Basic.Util.Type_error ("Invalid agent", x))
module SetMap = SetMap.Make (struct
type t = ag
let compare = compare
let print = print ?sigs:None ~with_id:true
end)