Skip to content
Snippets Groups Projects
Commit 56208143 authored by Thorsten Wißmann's avatar Thorsten Wißmann
Browse files

Implement rule for CL

parent 5e185dd3
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ module TArray = struct ...@@ -14,6 +14,7 @@ module TArray = struct
let all f = any (fun x -> not (f x)) let all f = any (fun x -> not (f x))
let elem (x: 'a) (arr: 'a array) = let elem (x: 'a) (arr: 'a array) =
any (fun y -> x == y) arr any (fun y -> x == y) arr
let included sub sup = all (fun x -> elem x sup) sub
end end
let disjointAgents sort a b = let disjointAgents sort a b =
......
...@@ -10,6 +10,7 @@ module TArray : sig ...@@ -10,6 +10,7 @@ module TArray : sig
val all : ('a -> bool) -> 'a array -> bool val all : ('a -> bool) -> 'a array -> bool
val any : ('a -> bool) -> 'a array -> bool val any : ('a -> bool) -> 'a array -> bool
val elem : 'a -> 'a array -> bool val elem : 'a -> 'a array -> bool
val included : 'a array -> 'a array -> bool
end end
val disjointAgents : sort -> localFormula -> localFormula -> bool val disjointAgents : sort -> localFormula -> localFormula -> bool
......
...@@ -210,6 +210,45 @@ let mkRule_CL sort bs sl = ...@@ -210,6 +210,45 @@ let mkRule_CL sort bs sl =
in in
(* Candidates for D in Rule 2 *) (* Candidates for D in Rule 2 *)
let dCands = bsetFilter diamonds (fun f -> not (hasFullAgentList f)) in let dCands = bsetFilter diamonds (fun f -> not (hasFullAgentList f)) in
let c_j : localFormula list =
bsetFold (fun f a -> (lfGetDest1 sort f)::a) nCands []
in
let getRule2 diamDb acc = (* diamDb = <D> b *)
let d = lfGetDestAg sort diamDb in (* the agent list *)
let b = lfGetDest1 sort diamDb in
let hasAppropriateAglist f =
let aglist = lfGetDestAg sort f in
TArray.included aglist d
in
let maxdisj = maxDisjoints sort (bsetFilter boxes hasAppropriateAglist) in
let createSingleRule acc coalitions =
let a_i : localFormula list =
bsetFold (fun f a -> (lfGetDest1 sort f)::a) coalitions []
in
(* now do rule 2:
coalitions /\ <d> b /\ nCands
————————————————————————————————
a_i /\ b /\ c_j
*)
let children = bsetMake () in
List.iter (bsetAdd children) (b::c_j) ;
List.iter (bsetAdd children) (a_i) ;
((fun bs1 -> bs), [(s1, children)])::acc
in
List.fold_left createSingleRule acc maxdisj
in
let rules = bsetFold getRule2 dCands [] in
let getRule1 acc coalitions =
(* do rule 1:
coalitions
————————————
a_i
*)
let a_i : bset = bsetMake () in
bsetIter (fun f -> bsetAdd a_i (lfGetDest1 sort f)) coalitions ;
((fun bs1 -> bs), [(s1, a_i)])::acc
in
let rules = List.fold_left getRule1 rules disjoints in
(* (*
mkRule_CL sort bs [s1] mkRule_CL sort bs [s1]
= { (λ[bs1]. bs, [(s1, { a_i | i∈I })]) = { (λ[bs1]. bs, [(s1, { a_i | i∈I })])
...@@ -217,8 +256,14 @@ let mkRule_CL sort bs sl = ...@@ -217,8 +256,14 @@ let mkRule_CL sort bs sl =
C_i pairwise disjoint and I maximal C_i pairwise disjoint and I maximal
} }
*) *)
(* just do this to let it compile... *) (* standard return procedure *)
mkRule_MultiModalK sort bs sl let res = ref (Some rules) in
fun () ->
match !res with
| None -> NoMoreRules
| Some rules ->
res := None;
AllInOne rules
let mkRule_Choice sort bs sl = let mkRule_Choice sort bs sl =
assert (List.length sl = 2); assert (List.length sl = 2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment