<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Generating Filmstrip Models from Actor-Based Systems</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Tony Clark</string-name>
          <email>T.Clark@shu.ac.uk</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Vinay Kulkarni, Souvik Barat</string-name>
          <email>Souvik.Baratg@tcs.com</email>
          <email>fVinay.Vkulkarni,Souvik.Baratg@tcs.com</email>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Balbir Barn</string-name>
          <email>B.Barn@mdx.ac.uk</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Middlesex University</institution>
          ,
          <addr-line>London</addr-line>
          ,
          <country country="UK">United Kingdom</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Sheffield Hallam University</institution>
          ,
          <addr-line>Sheffield</addr-line>
          ,
          <country country="UK">United Kingdom</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Tata Consultancy Services Research</institution>
          ,
          <addr-line>Pune</addr-line>
          ,
          <country country="IN">India</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>-Actor-based systems are hard to analyse because of their inherent complexity arising from large=scale concurrency and stochastic behaviour. History traces can be produced from such a system that describes what happened during execution leading to a challenge as to how the traces are processed. This tool demonstration shows a novel actor-based language ESL and its development environment EDB that has been extended to produce histories stored in temporal databases, and to use a logic programming language to construct graphical filmstrips from the databases. Index Terms-Agent-based modeling Fig. 1. Overall Process</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>I. INTRODUCTION</title>
    </sec>
    <sec id="sec-2">
      <title>EDB (the ESL DeBugger) is a tool that supports</title>
      <p>the analysis of simulation behaviours. Simulations
are represented as executable agent models
represented using the actor-language ESL (Executable
Simulation Language). This demonstration shows
how agent models are represented in EDB and
how executions can be captured as time-stamped
facts in a knowledge-base. ESL supports logic
programming in the form of rule-sets that are
parameterised with respect to knowledge-bases. The
logic programming language provides temporal
operators that are used to map temporal
knowledgebases to filmstrips. EDB provides graphical features
for displaying and playing filmstrips forwards and
backwards. We demonstrate these features using a
simple case study involving customers in a shop.</p>
      <p>Figure 1 describes the overall EDB-based process
for creating and interacting with filmstrips arising
from actor-based simulation models represented in</p>
    </sec>
    <sec id="sec-3">
      <title>ESL. A simulation model is defined in terms of</title>
      <p>the actor structure and their individual behaviours.
The structure is equivalent to a class diagram and
the behaviour of each actor is defined as a
statemachine driven by the messages received by the
associated actor. The models are translated into code
that is executed to produce a knowledge-base that
contains time-stamped actor-states. Mapping rules
are used to process the knowledge-base, producing
a sequence of diagram models that are displayed
as a filmstrip. The user can then play the filmstrip
backwards and forwards.</p>
    </sec>
    <sec id="sec-4">
      <title>The rest of this paper is structured as follows:</title>
      <p>section II describes a simple case study that is
modelled in section III; section IV describes the</p>
    </sec>
    <sec id="sec-5">
      <title>ESL implementation of the simulation model and</title>
      <p>the production of a knowledge-base; section V
shows how the knowledge-base is transformed into
filmstrips and how they are displayed by EDB.</p>
    </sec>
    <sec id="sec-6">
      <title>Section VI places ESL and EDB in relation to other work.</title>
      <p>
        Figure 2 shows a case study that is taken from
[
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]. A shop provides stock on the shop-floor.
      </p>
    </sec>
    <sec id="sec-7">
      <title>Customers enter the shop and may browse until</title>
      <p>they either leave, seek help or decide on a purchase.
Items must be purchased at tills and multiple
customers are serviced via a queue. Shop assistants
may be on the shop-floor, helping a customer or
may service a till. A queueing customer can only
make a purchase when they reach the head of a
queue at a serviced till. A customer who waits too
long at an unserviced till, or for whom help is not
available, will become unhappy and leave the shop.</p>
    </sec>
    <sec id="sec-8">
      <title>The shop would like to minimise unhappiness.</title>
    </sec>
    <sec id="sec-9">
      <title>In addition the shop owner has noticed that stock</title>
      <p>is going missing. A criminal gang is known to be
operating in the area. Typically they operate by
engaging all the assistants in a shop whilst one of
the gang members leaves the shop without paying
for the goods.</p>
    </sec>
    <sec id="sec-10">
      <title>An actor-based implementation of the case study</title>
      <p>will necessarily have stochastic behaviour and
therefore be difficult to verify. A formal approach
to verification is often challenging to achieve due to
the state explosion when simulations become large.</p>
    </sec>
    <sec id="sec-11">
      <title>Furthermore, interacting with a running simulation</title>
      <p>or producing printed output can either change the
behaviour or overwhelm the developer. Our
approach compliments such approaches by providing
a graphical representation of the simulation that can
be post-processed.</p>
    </sec>
    <sec id="sec-12">
      <title>ESL is a statically typed actor language. Actors</title>
      <p>have behaviour types that are equivalent to
component interface types, and have behaviour
definitions that are equivalent to module definitions.
Actor behaviour in ESL is implemented as message
handling rules that can be generated from state
machines. This section outlines the behaviour type
(structure) and behaviour (state-machine) models
that are derived from the case study. Figure 3 shows
the behaviour types for the shop simulation. In
addition to domain actors such as customer and
assistant, the transactions at a till are represented
as actors. Figure 4 shows the behaviour of the actors
represented as state machines. An actor receives
messages that are either sent by other actors or
are Time messages produced automatically by ESL.</p>
    </sec>
    <sec id="sec-13">
      <title>Optionally, an actor can replace its behaviour when it handles a message, for example this occurs in figure 4(c) where a customer joins a till-queue.</title>
    </sec>
    <sec id="sec-14">
      <title>IV. ESL IMPLEMENTATION</title>
    </sec>
    <sec id="sec-15">
      <title>ESL is a statically typed text-based language.</title>
      <p>Actor models, such as those described in the
previous section, are translated into ESL. EDB provides
support for ESL development in the form of static
type checking. The following code fragment shows
how the shop models are translated into ESL.
data State = NotInShop( I n t )
| Browsing( I n t ) | Queuing(Int , I n t )
| SeekingHelp( I n t ) | GettingHelp(Int , I n t )
| OnFloor( I n t ) | GoTill( I n t )
| AtTill(Int , I n t ) | Helping(Int , I n t )
| Raid | NoRaid;
type Customer = Act {
export state::State; getId::() ! I n t ;
help::(Assistant) ! Void;
Time( I n t );
SaleConcluded();
SaleTimedOut();</p>
      <p>Helped()
}
type Facts = KB[State];
facts::Facts = kb[Facts]{ NoRaid };
a c t customer(id::Int ,tills::Tills)::Customer {
state::State = NotInShop(id);
getId():: I n t = id;
counter:: I n t = 0;
helpedBy::Assistant = n u l l ;
Time(n:: I n t ) when state = NotInShop(id) !
probably(probOfEnteringShop) {</p>
    </sec>
    <sec id="sec-16">
      <title>Actor states are defined as an algebraic data</title>
      <p>type State as shown above. The states are used
to control the behaviour of the actors and are
also recorded in a knowledge-base for subsequent
processing by the filmstrip mapping rules.</p>
    </sec>
    <sec id="sec-17">
      <title>Each actor has a behaviour type definition such as</title>
    </sec>
    <sec id="sec-18">
      <title>Customer containing the operation and message sig</title>
      <p>nature. All message names are implicitly exported,
property names and operations are local in any
behaviour implementation unless they are exported
by the type.</p>
    </sec>
    <sec id="sec-19">
      <title>The knowledge-base facts conforms to the type</title>
    </sec>
    <sec id="sec-20">
      <title>State and therefore contains time-stamped state</title>
      <p>information.</p>
      <p>The behaviour definition customer shows a
fragment of the implementation of the customer
behaviour defined in figure 4. All actors in ESL are
supplied with Time messages at regular intervals
in order to drive the simulation. The customer
behaviour shows a message handler that responds
to a Time message that occurs when the customer
is not in the shop and has a given probability of
entering. Note how the change of state is recorded
in the knowledge-base.</p>
    </sec>
    <sec id="sec-21">
      <title>V. FILMSTRIP GENERATION</title>
      <p>Filmstrips are produced by translating temporal
knowledge-bases into sequences of pictures. This is
achieved in a two-stage process: (1) the
knowledgebase is translated into a sequence of system states;
(2) each state is translated into a picture. Both
stages are performed using the features of ESL: (1)
temporal logic programming; (2) functional pattern
matching. Mapping from a knowledge-base to a
sequence of system states is performed using the
rules shown in figure 5 where a history is created
as a sequence of shop-states as defined by the rule
hist which is supplied with customer, assistant
and till identifiers. The hist rule uses the temporal
operator next to step through the knowledge-base. At
each time-step, the rule state is used to construct a
shop-state. The rules in figure 5 show how the cOut
and raid components of the shop-state are extracted
from the knowledge-base. A raid is detected by
rule isRaid when there is a current Raid state
recorded in the knowledge base; notice that is may
be necessary to step backwards in time through the
facts in the knowledge-base before the appropriate
fact is found. The identifiers of customers who
(a) Assistant Behaviour
(b) Customer Behaviour
(c) No Transactions Behaviour
(d) Transacted Behaviour
(e) No Tills Behaviour
(f) A Till Behaviour
(g) A Transaction Behaviour
are currently outside the shop is calculated by the
call getCStates(n,cIds,cOut) which extracts the
nth customer state and filters the list of customer
identifiers for those customers currently in that
state. The calculation uses the rule recent to ensure
that the desired state is the most recent: this will
be false if the particular customer is most recently
in an alternative state. A fact f is currently in the
knowledge-base if fact(f) is true.
type PictureElement =</p>
      <p>Rectangle(Int ,Int ,Int ,Int ,Str)
| Circle(Int ,Int ,Int ,Str)
| Line(Int ,Int ,Int ,Int ,Str)
| Image(Int ,Int ,Int ,Int ,Str)
| Text(Int ,Int ,Str ,Str)
type Pics = [Picture(Int ,Int ,[PictureElement])];
type EDB = Act {</p>
      <p>Filmstrip(Str ,Pics)
}
The data type above shows the different picture
elements that can be drawn on each frame of a
filmstrip. The message Filmstrip(title,pictures)
displays the sequence of pictures with a slider that
can be used to move forwards and backwards;
moving the slider changes the picture that is displayed.
type Solver = Rules {</p>
      <p>hist([ I n t ],[ I n t ],[ I n t ],[ShopState])
};
solver::Solver = rules {
hist::([ I n t ],[ I n t ],[ I n t ],[ShopState]);
hist(cIds,aIds,tIds,[s])</p>
      <p>state(cIds,aIds,tIds,s), end, !;
hist(cIds,aIds,tIds,[s|ss])
state(cIds,aIds,tIds,s), !,
next[hist(cIds,aIds,tIds,ss)];
custStates::(Int ,[State]);
custStates(id,[NotInShop(id),</p>
      <p>Browsing(id),
SeekingHelp(id),
GettingHelp(id,aId),</p>
      <p>Queuing(id,tId)]);
state::([ I n t ],[ I n t ],[ I n t ],ShopState);
state(cIds,aIds,tIds,Shop(cOut,f,b,h,t,raid))
isRaid(raid),
getCStates(0,cIds,cOut),
// extraction of f,b,h,t omitted.
// listing continues in right-hand column.
isRaid::( I n t );
isRaid(0) fact(NoRaid), !;
isRaid(1) fact(Raid), !;
isRaid(raid) prev[isRaid(raid)];
getCStates::(Int ,[ I n t ],[ I n t ]);
getCStates(_,[],[]) !;
getCStates(n,[id|idsIn],[id|idsOut])
custStates(id,ss),
nth[State](n,ss,s),
delete[State](s,ss,ss’),
recent(id,s,ss’), !,
getCStates(n,idsIn,idsOut);
getCStates(n,[id|idsIn],idsOut)</p>
      <p>getCStates(n,idsIn,idsOut);
recent::(Int ,State,[State]);
recent(id,f,fs) fact(f), !;
recent(id,f,fs) facts(fs), !, f a l s e ;
recent(id,f,fs) prev[recent(id,f,fs)];
facts::([State]);
facts([]) f a l s e , !;
facts([f|fs]) fact(f), !;
facts([_|fs]) facts(fs);
}
0, customers (2,3,6) are queueing at till 1 where
c will try to establish fact q in rule base r
usassistant 1 is serving.
ing knowledge-base k and then perform command
c. Figure 6 shows a fragment of the function
toPicture that maps system states to pictures using
pattern-matching functions.
shown in figure 7 where figure 7(a) shows the start
of time, figure 7(b) shows the situation after all the</p>
    </sec>
    <sec id="sec-22">
      <title>VI. RELATED WORK</title>
    </sec>
    <sec id="sec-23">
      <title>The use of MAS for system simulation has been explored by a number of researchers, for example present a generic language for the formal specification and analysis of dynamic properties of MAS</title>
      <p>
        Interactions with the resulting filmstrip in EDB is in [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. In [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], Bosse et al.
customers and assistants have joined the simulation; that supports the specification of both qualitative
(a) Start of Filmstrip
      </p>
      <p>(b) Customers and Assistants Arrive
(c) Waiting for Help</p>
      <p>
        (d) Queuing and Being Served
and quantitative aspects, and subsumes specification
languages based on differential equations. However,
this is not an executable language. It has been
specialised for simulation and has produced the
LEADSTO language [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] which is a declarative
order-sorted temporal language where time is
described by real numbers and where properties are
modelled as direct temporal dependencies between
properties in successive states. Though quite useful
in specifying simulations of dynamic systems, it
does not provide any help in animating the resultant
behaviour. Temporal logics have been used to
specify the behaviour of MAS [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] and to analyse the
specification for properties using theorem proving
or model checking. Our approach uses a similar
collection of temporal operators, however we are
applying the behaviour specifications post-hoc in
order to investigate whether a given behaviour took
place. The need to analyse agent-based simulations
is related to the field of agent-based system testing.
      </p>
      <p>
        As noted in [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ] attempting to obtain assurance
of a system’s correctness by testing the system as a
whole is not feasible. Our approach is intended to be
a pragmatic partial solution that is used selectively
in collaboration with a domain expert. Managing
temporal data is becoming increasingly important
for many applications [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. Our work is related
to process mining from the event logs that are
created by enterprise systems [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] where queries
can be formulated in terms of a temporal logic
and applied to data produced by monitoring real
business systems.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Tibor</given-names>
            <surname>Bosse</surname>
          </string-name>
          , Catholijn M Jonker, Lourens Van der Meij, Alexei Sharpanskykh, and
          <string-name>
            <given-names>Jan</given-names>
            <surname>Treur</surname>
          </string-name>
          .
          <article-title>Specification and verification of dynamics in cognitive agent models</article-title>
          .
          <source>In IAT</source>
          , pages
          <fpage>247</fpage>
          -
          <lpage>254</lpage>
          . Citeseer,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Tibor</given-names>
            <surname>Bosse</surname>
          </string-name>
          ,
          <string-name>
            <surname>Catholijn M Jonker</surname>
            , Lourens Van Der Meij, and
            <given-names>Jan</given-names>
          </string-name>
          <string-name>
            <surname>Treur</surname>
          </string-name>
          .
          <article-title>LEADSTO: a language and environment for analysis of dynamics by simulation</article-title>
          .
          <source>In German Conference on Multiagent System Technologies</source>
          , pages
          <fpage>165</fpage>
          -
          <lpage>178</lpage>
          . Springer,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>Nils</given-names>
            <surname>Bulling and Wiebe Van der Hoek</surname>
          </string-name>
          . Preface:
          <article-title>Special issue on logical aspects of multi-agent systems</article-title>
          .
          <source>Studia Logica</source>
          ,(Special Issue),
          <year>2016</year>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Philippe</given-names>
            <surname>Caillou</surname>
          </string-name>
          , Benoit Gaudou, Arnaud Grignard, Chi Quang Truong, and
          <string-name>
            <given-names>Patrick</given-names>
            <surname>Taillandier</surname>
          </string-name>
          .
          <article-title>A simpleto-use BDI architecture for agent-based modeling and simulation</article-title>
          .
          <source>In The Eleventh Conference of the European Social Simulation Association (ESSA</source>
          <year>2015</year>
          ),
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>Stephane</given-names>
            <surname>Galland</surname>
          </string-name>
          , Luk Knapen, Nicolas Gaud, Davy Janssens, Olivier Lamotte, Abderrafiaa Koukam,
          <string-name>
            <given-names>Geert</given-names>
            <surname>Wets</surname>
          </string-name>
          , et al.
          <article-title>Multi-agent simulation of individual mobility behavior in carpooling</article-title>
          . Transportation Research Part C: Emerging Technologies,
          <volume>45</volume>
          :
          <fpage>83</fpage>
          -
          <lpage>98</lpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>Martin</given-names>
            <surname>Kaufmann</surname>
          </string-name>
          , Amin Amiri Manjili, Panagiotis Vagenas,
          <source>Peter Michael Fischer, Donald Kossmann</source>
          , Franz Fa¨rber, and Norman May.
          <article-title>Timeline index: A unified data structure for processing queries on temporal data in SAP HANA</article-title>
          .
          <source>In Proceedings of the 2013 ACM SIGMOD International Conference on Management of Data</source>
          , pages
          <fpage>1173</fpage>
          -
          <lpage>1184</lpage>
          . ACM,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Rudolf</given-names>
            <surname>Kruse</surname>
          </string-name>
          , Matthias Steinbrecher, and
          <string-name>
            <given-names>Christian</given-names>
            <surname>Moewes</surname>
          </string-name>
          .
          <article-title>Temporal pattern mining</article-title>
          .
          <source>In Signals and Electronic Systems (ICSES)</source>
          , 2010 International Conference on, pages
          <fpage>3</fpage>
          -
          <lpage>8</lpage>
          . IEEE,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>Margus</given-names>
            <surname>Ra</surname>
          </string-name>
          ¨im, Claudio Di Ciccio, Fabrizio Maria Maggi, Massimo Mecella, and
          <string-name>
            <given-names>Jan</given-names>
            <surname>Mendling</surname>
          </string-name>
          .
          <article-title>Log-based understanding of business processes through temporal logic query checking</article-title>
          .
          <source>In OTM Conferences</source>
          , pages
          <fpage>75</fpage>
          -
          <lpage>92</lpage>
          . Springer,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>Gabriel</given-names>
            <surname>Santos</surname>
          </string-name>
          , Tiago Pinto, Hugo Morais, Tiago M Sousa, Ivo F Pereira,
          <article-title>Ricardo Fernandes, Isabel Prac¸a, and Zita Vale. Multi-agent simulation of competitive electricity markets: Autonomous systems cooperation for european market modeling</article-title>
          .
          <source>Energy Conversion and Management</source>
          ,
          <volume>99</volume>
          :
          <fpage>387</fpage>
          -
          <lpage>399</lpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <surname>Peer-Olaf Siebers</surname>
            and
            <given-names>Uwe</given-names>
          </string-name>
          <string-name>
            <surname>Aickelin</surname>
          </string-name>
          .
          <article-title>A first approach on modelling staff proactiveness in retail simulation models</article-title>
          .
          <source>J. Artificial Societies and Social Simulation</source>
          ,
          <volume>14</volume>
          (
          <issue>2</issue>
          ),
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <surname>Dhirendra</surname>
            <given-names>Singh</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lin Padgham</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Brian</given-names>
            <surname>Logan</surname>
          </string-name>
          .
          <article-title>Integrating BDI agents with agent-based simulation platforms</article-title>
          .
          <source>Autonomous Agents and Multi-Agent Systems</source>
          ,
          <volume>30</volume>
          (
          <issue>6</issue>
          ):
          <fpage>1050</fpage>
          -
          <lpage>1071</lpage>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>Michael</given-names>
            <surname>Winikoff</surname>
          </string-name>
          and
          <string-name>
            <given-names>Stephen</given-names>
            <surname>Cranefield</surname>
          </string-name>
          .
          <article-title>On the testability of BDI agent systems</article-title>
          .
          <source>J. Artif. Intell. Res.(JAIR)</source>
          ,
          <volume>51</volume>
          :
          <fpage>71</fpage>
          -
          <lpage>131</lpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>