Actors for Behavioural Simulation
-
Upload
clarktony -
Category
Technology
-
view
63 -
download
1
Transcript of Actors for Behavioural Simulation
Actors for Behavioural Simulation
Tony ClarkSheffield Hallam University, UK
Work in collaboration with:
Vinay Kulkarni, Souvik BaratTata Consultancy Services Research, India
[email protected], [email protected]
Balbir Barn, Middlesex University, [email protected]
March 9, 2017
System Models
I Goals g : (M1, . . . ,Mk)→ {true, false}Example: Profit is increasing.
I Goals can be decomposed: g1 & g2 ⇒ gExample: Decreasing costs and increasing sales produceincreasing profit.
I Measures m : ([V1], . . . , [Vn])→ MExample: Profit is calculated in terms of costs and sales overtime.
I Properties p : N → VExample: Costs at a given time.
I System structures: ({g1, . . .}, {m1, . . .}, {p1 . . .})Problem: How to construct these structures?
System Models
I Goals g : (M1, . . . ,Mk)→ {true, false}Example: Profit is increasing.
I Goals can be decomposed: g1 & g2 ⇒ gExample: Decreasing costs and increasing sales produceincreasing profit.
I Measures m : ([V1], . . . , [Vn])→ MExample: Profit is calculated in terms of costs and sales overtime.
I Properties p : N → VExample: Costs at a given time.
I System structures: ({g1, . . .}, {m1, . . .}, {p1 . . .})Problem: How to construct these structures?
System Models
I Goals g : (M1, . . . ,Mk)→ {true, false}Example: Profit is increasing.
I Goals can be decomposed: g1 & g2 ⇒ gExample: Decreasing costs and increasing sales produceincreasing profit.
I Measures m : ([V1], . . . , [Vn])→ MExample: Profit is calculated in terms of costs and sales overtime.
I Properties p : N → VExample: Costs at a given time.
I System structures: ({g1, . . .}, {m1, . . .}, {p1 . . .})Problem: How to construct these structures?
System Models
I Goals g : (M1, . . . ,Mk)→ {true, false}Example: Profit is increasing.
I Goals can be decomposed: g1 & g2 ⇒ gExample: Decreasing costs and increasing sales produceincreasing profit.
I Measures m : ([V1], . . . , [Vn])→ MExample: Profit is calculated in terms of costs and sales overtime.
I Properties p : N → VExample: Costs at a given time.
I System structures: ({g1, . . .}, {m1, . . .}, {p1 . . .})Problem: How to construct these structures?
System Models
I Goals g : (M1, . . . ,Mk)→ {true, false}Example: Profit is increasing.
I Goals can be decomposed: g1 & g2 ⇒ gExample: Decreasing costs and increasing sales produceincreasing profit.
I Measures m : ([V1], . . . , [Vn])→ MExample: Profit is calculated in terms of costs and sales overtime.
I Properties p : N → VExample: Costs at a given time.
I System structures: ({g1, . . .}, {m1, . . .}, {p1 . . .})Problem: How to construct these structures?
Simulations and Decision Support
System Dynamics
https://commons.wikimedia.org/w/index.php?curid=7240226(Patrhoue)
Incremental Decision Making: A Requirement for Search
Carnegie: Incompleteness and Sense Making
Simulation Approaches
Simulation Method
A Computational Basis for Simulation
ESL Architecture
The ESL Language: Factorial
type Customer = Act { Value( I n t ) };type Fact = Act{ Get( Int ,Customer) };
act fact ::Fact {Get(0,c ::Customer) → c ← Value (1);Get(n :: Int ,c ::Customer) →
l e t cc ::Customer = new cust(n,c)i n s e l f ← Get(n-1,cc)
}
act cust(n :: Int ,c ::Customer) ::Customer {Value(m :: I n t ) c ← Value(n*m)
}
act main ::Customer {f ::Fact = new fact;computeFact(n :: I n t ) ::Void = f ← Get(n, s e l f );→ {
computeFact (6);computeFact (6);computeFact (6)
}Value(n :: I n t ) → print[ I n t ](n)
}
Visualization
The ESL Language: Dining Philosophers
eat() ::Void = f o r x :: I n t i n 0.. random(eatTime) do {}think() ::Void = f o r x :: I n t i n 0.. random(thinkTime) do {}
act philosopher(i :: Int ,left ,right ::Chopstick) ::Philosopher {Time(n :: I n t ) when n < timeLimit → {
think();grab (left.active ,right.active) {
eat()}
}}act chop ::Chopstick {
expor t active;active ::Bool = false
}
chops ::[Chopstick] = [ new chop | i :: I n t ← 0..(max -1) ];
philosophers ::[Philosopher] =[ new philosopher(i,nth(chops ,i),nth(chops ,(i+1)%max)) |
i :: I n t ← 0..(max -1) ];
act main ::Main {Time(n :: I n t ) when n > timeLimit → {
edb ← Filmstrip(’Philosophers ’,getFilmstrip ());stopAll ()
}}
Philosopher Histories
Traffic and Adaptive Behaviour
Nils Bulling, Mehdi Dastani, and Max Knobbout. Monitoring Norm
Violations in Multi-Agent Systems. International Foundation for
Autonomous Agents and Multiagent Systems, 2013.
The ESL Language: Traffic Monitors
act light(colour ::Str ) ::TrafficLight {expor t colour , change;change () ::Void =
case colour {’RED ’ → colour := ’GREEN ’;’GREEN ’ → colour := ’RED ’
}}
act approach(id ::Str ,light ::TrafficLight ,isCar :: I n t ) ::Approach {cars :: I n t = 0;Move →
i f light.colour=’GREEN ’ and cars >0 then s e l f ← DeQueue;DeQueue →
cars := cars - 1;Queue →
cars := cars + 1Time(n :: I n t ) →
probab ly (isCar) s e l f ← Queue e l s e s e l f ← Move};
l1 ::TrafficLight = new light(’RED ’);l2 ::TrafficLight = new light(’GREEN ’);left ::Approach = new approach(’left ’,l1 ,10);right ::Approach = new approach(’right ’,l2 ,20);
westEast ()= i f l2.colour=’RED ’ then {l2.change ();l1.change ()}eastWest ()= i f l1.colour=’RED ’ then {l1.change ();l2.change ()}
Traffic Filmstrip
Prioritise East West
Traffic Filmstrip
West East If Nothing Waiting
Traffic Filmstrip
West East Must Not Build Up
Traffic Filmstrip
Back to Equilibrium
Monitor Actors
Monitor Actors
Monitor Actors
Monitor Actors
Monitor Language
p,q ::= monitors.n a named monitor.
| ε holds for any history.| 2(p) holds when p holds at all times.| µ(λ(n)p) recursive definitions: [µ(λ(n)p)/n]p| p;q holds when p and q both hold now.| p|q holds when p or q (or both) holds now.| p ⊕ q holds when p or q (not both) holds now.| p ⇒ q if p holds then q must hold now.| N(p) holds when p holds for time now + 1.| P(p) holds when p holds for time now - 1.| ?(c) holds when the condition c is true now.| ! (a) always holds and performs action a.| p ↑ q splits two merged histories.| p ↓ q (re)merges two split histories.
Actors controlled by monitor rules: p ⇒ !(a)
Tony Clark, Vinay Kulkarni, Souvik Barat, Balbir Barn. Actor Monitors
for Adaptive Behaviour. ISEC 2017. pp. 85--95
Traffic Monitor
1P0(p) = p2Pn(p) = p;P(Pn-1(p))3
42(PmaxQDuration(?(gre(maxQSize))) ↑ ε ⇒ ! (westEast) ⊕5
6ε ↑ ?(gre(0)) ⇒ ! (eastWest) ⊕7
8?(gre(0)) ↑ ε ⇒ ! (westEast) ⊕9
10ε)
ESL Monitor Types
type Mtd[T] = Act {export history ::[T];Time( I n t )
}
data Tree[T] = Leaf(T) | Pair(Tree[T],Tree[T])
data MTree[T] = Tree(Mtd[T])
history[T](t ::MTree[T]) ::Tree[[T]] =case t {
Leaf(a ::Mtd[T]) → Leaf(a.history);Pair(left ::MTree[T],right ::MTree[T]) →
Pair(history[T](left),history[T](right))}
type Fail = () → Void
type Mtr[T] = rec M. Act {Check(Mtd[T], Int ,M,Fail);Time( I n t )
}
ESL Monitor Definitions
act ε [T] ::Mtr[T] {
Check(a ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) →s ← Check(a,c, s e l f ,f)
}
idle[T] ::Mtr[T] = new nothing[T]()
ESL Monitor Definitions
act ! [T]( command ::() → Void) ::Mtr[T] {
Check(a ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) →{
command ();
s ← Check(a,c,idle[T],f)
}
}
ESL Monitor Definitions
act (_;_)[T](p ::Mtr[T],q ::Mtr[T]) ::Mtr[T] {Check(a ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) →
p ← Check(a,c,new (q;s),f)}
act (_⊕_)[T](p ::Mtr[T],q ::Mtr[T]) ::Mtr[T] {Check(a ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) →
p ← Check(a,c,s,λ() ::Void q ← Check(a,c,s,f))}
act (_|_)[T](p ::Mtr[T],q ::Mtr[T]) ::Mtr[T] {Check(a ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) → {
p ← Check(a,c,s,f);q ← Check(a,c,s,f)
}}
ESL Monitor Definitions
minLength[T](t ::Tree[T]) :: I n t =case t {
Leaf(l ::[T]) → length[T](l);Pair(left ::Tree[T],right ::Tree[T]) →
min(minLength[T](left),minLength[T]( right))}
treeNth[T](t ::Tree[T],n :: I n t ) ::Tree[T] =case t {
Leaf(l ::[T]) → nth[T](l,n);Pair(left ::Tree[T],right ::Tree[T]) →
Pair(treeNth[T](left ,n),treeNth[T](right ,n))}
act ?[T](pred ::(Tree[T]) → Bool) ::Mtr[T] {Check(t ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) →
i f minLength[T]( history(t)) > cthen {
i f pred(treeNth[T]( history(t),c))then s ← Check(t,c,idle[T],f)e l s e f()
} e l s e s e l f ← Check(t,c,s,f)}
ESL Monitor Definitions
act µ[T](g ::(Mtr[T]) → Mtr[T]) ::Mtr[T] {Check(a ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) →
g(new rec [T](g)) ← Check(a,c,s,f)}
2[T](p ::Mtr[T]) ::Mtr[T] =new µ[T](λ(q ::Mtr[T]) ::Mtr[T]
new seq[T](p,new N[T](q)))
act N[T](p ::Mtr[T]) ::Mtr[T] {Check(a ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) →
p ← Check(a,c+1,s,f)}
act P[T](p ::Mtr[T]) ::Mtr[T] {Check(a ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) →
p ← Check(a,c-1,s,f)}
act (_ ⇒ _)[T](p ::Mtr[T],q ::Mtr[T]) ::Mtr[T] =Check(a ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) →
p ← Check(a,c,new (q;s),λ() ::Void s ← Check(a,c,idle[T],f)
}
ESL Monitor Definitions
act (_↑_)[T](p ::Mtr[T],q ::Mtr[T]) ::Mtr[T] {Check(t ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) →
case t {Pair[T](t1 ::MTree[T],t2 ::MTree[T]) →
l e t j ::Mtr[T] = new (t1 ↓ t2)i n {
p ← Check(t1,c,j,f);q ← Check(t2,c,j,f)
}}
}
act (_↓_)[T](t1 ::MTree[T],t2 ::MTree[T]) ::Mtr[T]{done ::Bool = falseCheck(a ::MTree[T],c :: Int ,s ::Mtr[T],f ::Fail) →
i f not(done)then done := truee l s e s ← Check(Pair(t1,t2),c,s,f)
}
Traffic Sequence Diagram
Shopping Simulation
Peer-Olaf Siebers and Uwe Aickelin. A first approach on modelling staff
proactiveness in retail simulation models. J. Artificial Societies and
Social Simulation, 14(2), 2011.
Actor Structure Models: Shop Simulation
Actor Behaviour Models: Customer
Visualisation of Results
Simulation execution produces a history.
History Query Language
rule ::= fact ← element , . . .element ::=
fact
| acto r (id,behaviour ,time)| send(source ,target ,message ,time)| s t a t e (id,name ,value ,time)| next [element]| prev [element]| always [element]| e v en t ua l l y [element]| past [element]| s t a r t| end| f o r a l l [element ](value ,value)
Query Language: Typed Relational Programming
append[T] :: ([T],[T],[T]);
append[T]([],l,l) ← !;
append[T]([x|l1],l2 ,[x|l3]) ←append[T](l1,l2 ,l3);
length[T] :: ([T], I n t );
length[T]([] ,0);
length[T]([_ | l],n) ←length[T](l,m),
n := m + 1;
Query Language: Processing Histories
allActors :: ([Actor( Int ,Str )]);
allActors ([]) ← end, !;
allActors(actors) ←f o r a l l [ acto r (id,beh ,_)](Actor(id ,beh),actors ’),next [allActors(actors ’’)],append[Actor( Int ,Str )](actors ’,actors ’’,actors);
customers :: ([ I n t ]);
customers(cs) ←f o r a l l [ e v en t ua l l y [ acto r (a,’customer ’,_)]](a,cs);
Query Language: Customers With No Sales
noSales :: ([ I n t ]);noSales(cs ’’) ←
customers(cs),makesPurchase(cs ,cs ’),removeAll[ I n t ](cs’,cs,cs ’’);
makesPurchase :: ([ I n t ],[ I n t ]);makesPurchase ([] ,[]);
makesPurchase ([c | cs],[c | cs ’]) ←makePurchase(c), !,makesPurchase(cs ,cs ’);
makesPurchase ([_ | cs],cs ’) ←makesPurchase(cs ,cs ’);
makePurchase :: ( I n t );makePurchase(c) ←
e v en t ua l l y [ send(_,c,SaleConcluded ,_)];
Query Language: Detecting Raids
raid :: ([ I n t ],union { NoRaid (), Raid([ I n t ])});
raid(assistants ,Raid(times ’)) ←f o r a l l [ // get the assistant actors . . .
e v en t ua l l y [ acto r (a,’assistant ’,_)]](a,assistants),f o r a l l [ // times when they are all occupied . . .
e v en t ua l l y [allHelping(assistants ,time)]](time ,times), !;
raid([], NoRaid);
allHelping ::([ I n t ],[ I n t ]);
allHelping ([],_);
allHelping ([a|as],t) ←s t a t e (a,’advising ’,Ref(_),t),allHelping(as,_);
Selected Publications
I Tony Clark, Vinay Kulkarni, Souvik Barat, Balbir Barn: Actor Monitors for Adaptive
Behaviour. Proceedings of the 10th Innovations in Software Engineering Conference, ISEC
2017: 85-95
I Souvik Barat, Vinay Kulkarni, Tony Clark, and Balbir Barn. A Simulation-based Aid for
Organisational Decision-making.In Proceedings of the 11th International Joint Conference
on Software Technologies. 2016.
I Souvik Barat, Vinay Kulkarni, Tony Clark, Balbir Barn: Enterprise Modeling as a Decision
Making Aid: A Systematic Mapping Study. PoEM 2016: 289-298
I Vinay Kulkarni, Souvik Barat, Tony Clark, and Balbir Barn. Toward overcoming accidental
complexity in organisational decision-making. In Model Driven Engineering Languages and
Systems (MODELS), 2015 ACM/IEEE 18th International Conference on, pages 368-377. IEEE,
2015.
I Vinay Kulkarni, Souvik Barat, Tony Clark, Balbir Barn: A Wide-Spectrum Approach to
Modelling and Analysis of Organisation for Machine-Assisted Decision-Making. EOMAS@CAiSE
2015: 87-101
I Vinay Kulkarni, Souvik Barat, Tony Clark, Balbir Barn: Using simulation to address
intrinsic complexity in multi-modelling of enterprises for decision making. SummerSim
2015: 9:1-9:11
I Balbir Barn, Tony Clark, and Vinay Kulkarni. Can organisational theory and multi-agent
systems influence next generation enterprise modelling? In International Conference on
Software Technologies, pages 202-216. Springer, 2014.
I Vinay Kulkarni, Tony Clark, Souvik Barat, Balbir Barn: Model Based Enterprise Simulation
and Analysis - A Pragmatic Approach Reducing the Burden on Experts. ER Workshops 2014:
3-12
Get Involved
http://tonyclark.github.io/ESL/