Information Technology Reference
In-Depth Information
3
From Theory to Practice
We evaluated our work, within a government-funded project, in which we devel-
oped a complex graphical user interface and designed HAI to act as an interface
between the UI layer and the MAS. The objective of the UI was to control and to
visualise the results of an agent-based trac simulation framework, which adds
perceptions and attitudes of drivers to the simulation process [9]. To emphasise
the operation principle of HAI, we describe some of the steps, done.
def initMap = {
def i = new Invocation(name: "initMap", invocationId: null)
i.invocationId = hai.invoke(MapServiceAgent.INIT, BERLIN)
if(!i.save()){println "cannot save invocation id"}
}
Listing 1.1. Causing the HAI-Agent to search a spezific action.
For our work, we used GRAILS [12] as application framework. Since GRAILS
is based on Groovy we had almost no trouble in using HAI for this project
( hai ). For the simulation framework, a simulation environment (city) had to
be selected, first. Since different maps had different complexity and size, we
were not able to define a suitable initialisation time-out. Instead, we applied
asynchronous communication and realised the initialisation process by active
waiting. Listing 1.1 illustrates our implementation, which causes the HAI-Agent
to search for an agent which offers the MapServiceAgent.INIT action. The HAI-
Agent converts the method call into an agent message, which is forwarded to
the agent-system. After forwarding the message, an ID is generated, stored and
returned to the UI as confirmation and in order to allow the UI actively check
for answers. Since the simulation environment is vital for the simulation itself,
the UI waits as long as an answer arrives or a time-out expired. Listing 1.2 shows
the method which is called periodical to check for an answer.
def lookForAnswer = {
def inv = Invocation.findByName("initMap")
if(inv != null){
if(timeout()){
hai.deleteInvocation(inv.invocationId)
}else{
def res = hai.lookForInvocationResult(inv.invocationId)
if(res != null){
inv.delete(flush:true)
render(view: "/settings/index", params:["map":res])
}
}
}
}
Listing 1.2. Periodical check for an answer.
In order to support the many configuration parameters of the simulation
framework, we made use of so called “configuration objects”, which we stored
within a database. Listing 1.3 shows a method ( findObject ) which uses the
HaiDBBean to send data from the user interface to the agent-system. Since both,
the agent-system and the user interface use the same data model, no translation
was implemented.
Search WWH ::




Custom Search