-
Notifications
You must be signed in to change notification settings - Fork 0
/
persuader.asl
71 lines (66 loc) · 3.01 KB
/
persuader.asl
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
64
65
66
67
68
69
70
71
// initial beliefs
revenue(3, "Show vodka ad").
revenue(2, "Show steak ad").
revenue(1, "Show university ad").
revenue(0.1, "Show community college ad").
acceptable("Show university ad", "Show community college ad").
acceptable("Show community college ad", "Show university ad").
// Rule - acceptability check
is_acceptable(PersuaderAction, MitigatorAction) :-
.findall(_, acceptable(PersuaderAction, MitigatorAction), Res)
& .length(Res, Length)
& Length > 0.
// initial goal
!start.
/***Plans***/
// announce utility mapping
+!start <- .findall(revenue(X, Y), revenue(X, Y), Utility)
.broadcast(tell, announce(utility, Utility)).
// receive mitigator's utility mapping; determine and propose compromise
+respond(Utility) <- .print("Received utility mapping: ", Utility)
for (.member(Benefit, Utility)) {
+Benefit
}
.findall(revenue(X, Y), revenue(X, Y), OwnUtility)
.max(OwnUtility, revenue(OwnMaxUtility, OwnAction))
.findall(benefit(X, Y), benefit(X, Y), OtherUtility)
.max(OtherUtility, benefit(OtherMaxUtility, OtherAction))
.print("Own best action: ", OwnAction)
.print("Other's best action: ", OtherAction)
if (OwnAction == OtherAction) {
.print("Propose executing: ", OwnAction)
.broadcast(tell, propose(action, OwnAction))
} else {
if(is_acceptable(OwnAction, OtherAction)) {
.print("Own best action acceptable")
.print("Propose executing: ", OwnAction)
.broadcast(tell, propose(action, OwnAction))
} else {
.print("Own best action not acceptable")
.findall(Name, revenue(Value, Name), Actions)
for(.member(Action, Actions)){
.findall(Value, revenue(Value, Action), OwnValues)
.nth(0, OwnValues, OwnValue)
.findall(Value, benefit(Value, Action), OtherValues)
.nth(0, OtherValues, OtherValue)
if(OtherValue < 0 & OwnValue > 0) {
+combinedUtility(OtherValue / OwnValue, Action)
} elif(OtherValue > 0 & OwnValue < 0) {
+combinedUtility(OwnValue / OtherValue, Action)
} elif(OtherValue < 0 & OwnValue < 0) {
+combinedUtility(OwnValue * OtherValue * -1, Action)
} else {
+combinedUtility(OwnValue * OtherValue, Action)
}
}
.findall(combinedUtility(X, Y), combinedUtility(X, Y), CombinedUtility)
.max(CombinedUtility, combinedUtility(CombinedMaxUtility, CombinedAction))
.print("Action with combined maximum utility: ", CombinedAction)
.print("Propose executing: ", CombinedAction)
.broadcast(tell, propose(action, CombinedAction))
}
}.
// receive approval and execte action
+approve(Action) <- .print("Execute: ", Action).
// or receive disapproval and stop service offering
+disapprove(Action) <- .print("Must not execute: ", Action, ". Shutting down service offering.").