Embedding ASP in mobile systems: discussion and preliminary implementation
Francesco Calimeri, Davide Fuscà, Stefano Germano, Simona Perri, and Jessica Zangari
Department of Mathematics and Computer Science, University of Calabria, Italy {calimeri,fusca,germano,perri,zangari}@mat.unical.it
Answer Set Programming (ASP) is a well-established declarative problem solving paradigm which became widely used in AI and recognized as a powerful tool for knowledge representation and reasoning (KRR), especially for its high expressiveness and the ability to deal also with incomplete knowledge. Recently, thanks to the availability of a number of robust and ecient implementations, ASP has been increasingly employed in a number of dierent domains, and used for the development of industrial-level and enterprise applications. Notably, this has been fostered by the release of a variety of proper development tools and interoperability mechanisms for allowing interaction and integration with external systems; however, there is still a lack of proper means for an eective applicability of ASP in the mobile setting. In this preliminary work, we present a novel general framework for embedding ASP in external systems, and in particular within applications for mobile devices. We show the use of the framework by illustrating the integration of the ASP system DLV into Android applications, and the development of , a customizable health app that helps the user to meet her daily tness goals, as a proof of concept. Abstract.
DLVfit
Keywords:
Answer Set Programming, DLV, Android, Mobile
1 Introduction Answer Set Programming (ASP) [4,5,11,12,17,23,24] is a powerful declarative formalism for knowledge representation and reasoning developed in the eld of logic programming and nonmonotonic reasoning. After more than twenty years of scientic research, the theoretical properties of ASP are well understood and the solving technology, as witnessed by the availability of a number of robust and ecient systems [7], is mature for practical applications; indeed, ASP has been increasingly employed in a number of dierent domains, and used for the development of industrial-level and enterprise applications [8,22]. Notably, this has been fostered by the release of a variety of proper development tools and interoperability mechanisms for allowing interaction and integration with external systems [6,14,15,16]. However, the worldwide commercial and industrial scenario
signicantly changed in the latest years; smartphones, or smart/wearable devices in general, are constantly gaining popularity as computational power and features increase, in terms of sensors, communication means and applications availability. In this context, that forced the whole ICT industry to radically change, there is no work in literature about ASP systems that can natively run on mobile devices, to our knowledge; this leaves the potential of ASP still undisclosed in this scenario. Indeed, having a native ASP solver along with proper development tools for the integration of ASP modules within standard software products, would pave the way to a new generation of mobile applications, that might signicantly take advantage from the knowledge representation and reasoning capabilities of ASP. At rst, this could be of great help for the ASP developers that, beside porting already existing ASP-based applications to the mobile world, can also think of completely new scenarios for the fruitful application of ASP, both in research and industry. In this preliminary work, we introduce embASP, a novel framework for the integration of ASP in external systems; notably, it can be easily extended in order to match any platform and ASP solver through plain Java Object-Oriented programming. In order to show the potential of embASP, we present here an actual implementation of the framework for the Android platform [1] and the
DLV
system [21], thus eectively bringing ASP on mobile systems. Furthermore,
as a proof of concept, we present DLVfit, an ASP-based mobile health app designed and implemented by means of the embASP framework, thus resulting easy to use and customize. The framework, along with a beta version of DLVfit and the details about the logic program therein employed, is freely available online [13].
2 The embASP Framework We start by illustrating the abstract architecture of embASP, and then provide the reader with some insights about a specialization designed for making use of the
2.1
DLV
system within Android applications.
Abstract Architecture
The framework consists of three dierent layers, and Figure 1 shows how they interact:
the rst layer, ASPHandler, acts like a façade to the user of the framework: it contains all functions needed in order to manage input and output of the
ASP solver; the second layer, Solver Handler, acts as a middleware between the façade and the actual solver, providing the native functions that allow the invocation
of the solver; the third layer, ASPSolver, concerns the actual solver and contains the functions to run and make use of it.
ASPHANDLER
SOLVER HANDLER Android Service Java Native Interface (JNI)
ASP SOLVER DLV
Fig. 1: Abstract Architecture of the embASP framework. Overshadowed components are related to the specialization for
2.2
DLV
on Android.
Framework implementation
The abstract architecture (Figure 1) has been kept simple, and conceived in order to t any Java compliant environment, as well as any kind of ASP solvers. Basically, the execution works as follows: given a logic program
P,
the AS-
PHandler (asynchronously) calls the Solver Handler, providing it with
P,
along with the proper options for the solver at hand; then, the Solver Handler starts the ASPSolver by invoking the native functions of the solver. Eventually, the results are published and turned back to the caller via a callback function by the ASPHandler. The ASPSolver features a general interface, while within its implementation specic calls to the particular solvers it is specialized for. Notably, the framework allows to dynamically change at runtime the underlying logic program (from the addition of new rules, to the activation of dierent optimization statements, to the update of the facts base, towards a brand new program), and also to change solver options; this enables changes of behaviour while the application is running. Figure 2 shows how the layers are eectively implemented in embASP: the
ASPService and ASPHandler, along with their subclasses, represent the Solver Handler and the ASPHandler layers, respectively, while the dierent solvers
compose the ASPSolver layer. Notably, if needed, one can raise from the use of a single ASP system to the management of multiple instances of dierent solvers. The abstract class
ASPHandler
provides all means for preparing input
for the solvers, in several ways (simple strings, les, Java Objects); in addition, it manages the setting of all options for the actual ASP solvers; it also features proper methods for making the reasoning start. The abstract class
ASPService
Client
ASP HANDLER ASPHandler
Mapper
AnswerSetCallback
AnswerSet ASPHandler_Solver1
...
AnswerSets
ASPHandler_SolverN
AnswerSets_Solver1
...
AnswerSets_SolverN
SOLVER HANDLER ASPService
ASPService_Solver1
...
ASPService_SolverN
ASP SOLVER Solver1
SolverN
Fig. 2: embASP: class diagram.
is in charge of managing invocations to the actual ASP solvers, and gathering the results. Each solver invocation is asynchronous; thus, once a reasoning task has produced the answer set(s), a callback function is automatically red. It can be specied by implementing the
AnswerSetCallback interface, and all answer sets AnswerSets class.
are captured and parsed by the The framework features a
mapper to convert the output from the solvers into
Java Objects: the process is guided by proper annotations over involved classes. In order to map a class to a predicate, there are two types of annotations:
@Predicate(string_name), for the predicate name (the target must be a class), and @Term(integer_position), for the term and its position in the atom (the target must be a eld of a class annotated via @Predicate ). Currently, the data types supported by the ASP solvers are strings and integers; on the Java side, yet allowing for more advanced integration with Java objects, embASP preserves the mapping; however, whenever the ASP data types will be changed, the framework design will allow it to be easily extended accordingly. The mapping works also the other way around, i.e., from objects to strings, so that the input can be also specied as plain Java Objects. The mapper is meant to help the developer at dividing an application into two separated modules: an ASP reasoning module and a Java module. Indeed, the mapper acts like a middle-ware that enables the communication among the
modules, and facilitates the developer's job by providing her with an explicit and ready-made mapping between Java objects and the logic part, without the need for any translation from string to objects and vice-versa. Such separation helps at keeping things simple when developing complex application: think about a scenario in which dierent gures are involved, such as Android/Java developers and KRR experts; both gures can benet from the fact that the knowledge base and the reasoning modules can be designed and developed independently from the rest of the Java-based application. We note here that, as already outlined above, in the spirit of generality and usability, the framework allows the developer to design and build applications that make use of multiple concurrent instances of an ASP solver; in addition, if needed, dierent specializations of the ASPSolver layer can be used at once, thus making possible the actual concurrent run of dierent ASP solvers. Figure 2 shows an example of how the framework can be extended for multiple solvers in order to t the specic needs of the users. The
ASPHandler
class must be
extended, and each concrete class extending it should start a proper
ASPService.
Moreover, in order to deal with the specic output of the solver at hand, the
AnswerSets class must be specialized as well. In general, the number of dierent solvers that the framework can manage is only limited by the computational resources featured by the platform/device the application will be executed.
3 An embASP Specialization for Android and
DLV
As already introduced above, we present here a specialization of embASP explicitly tailored for the development of native Android applications making use of ASP by means of the
DLV
system.
Android is by far the most used mobile operating system worldwide; the ocial version has been originally released, and is currently developed, by Google, and its popularity is due also to an open source nature, that allows any manufacturer to customize and adapt it to an incredibly wide range of devices, not just smartphones. The Android development model is based on Java (indeed, running Android apps are managed by a special Java Virtual Machine, currently called
ART [2]), and Google provides the developers with a large set of tools
and libraries.
DLV
[21] is the rst ASP system which is undergoing an industrial
exploitation by a spin-o company called DLVSystem Ltd. [9], thus fostering the interest of several industries in ASP and
DLV
itself [8,19,22].
We provide next some details about the specialization of the embASP framework for
DLV
and Android, and some technical aspects concerning the actual
porting of such solver on the Android platform.
3.1
The
embASP Specialization
The additional components w.r.t. the abstract architecture needed to implement the specialization are depicted as overshadowed in Figure 1; Figure 3 reports the resulting hierarchy of classes.
Embedding ASP in mobile systems: discussion and ...
mapping; however, whenever the ASP data types will be changed, the ... and its popularity is due also to an open source nature, that allows any manufac-.
1. The GSM network can be divided into three major parts. The Mobile Station. (hand-held ... A subscriber with an appropriate SIM can use the network services.
Windows 7, Mac OS 4 and Android. .... Latest version of Android is Android 2.2 (Froyo) which is based on Linux Kernel 2.6.32 and ... Adobe flash 10.1 support.
(APPLICATION ORIENTED COURSE). ASP-1 : SECRETARIAL PRACTICE. Time : 2 hours. Maximum Marks : 50. (VVeightage : 70%) ... As the General Manager of Manica Steel. 10. Enterprise, write a letter to the Regional Manager of State Bank of India to open an E
Oct 21, 2009 - the number of embedded trajectories increases so does net- ...... Song S, Miller KD, Abbott LF (2000) Competitive Hebbian learning through.
model, we propose efficient solutions to identify moving RFID tags, according to the .... the amount of energy reflected by an object is dependent on the reflective area ...... an alternative scheme to estimate the number of tags. Our methodology ...
State Key Laboratory of Novel Software Technology,. Department of Computer .... which contains the uplink frequency and data encoding, the Q parameter ...... [18] S. R. Jeffery, M. Garofalakis, and M. J. Franklin, âAdaptive cleaning for rfid data .
This work was supported by the National Science Council of R.O.C. under contracts ... Department of Computer Science, National Tsing Hua University, Hsinchu,. Taiwan, R.O.C. (e-mail: ...... Ph.D. degree in computer science and information.
Yijia Chen. School of Computer Science. Fudan University ... p-EMB(K) is W[1]-hard for the classes K of all grids and all walls. See Section 2 and in particular ...
â¡AT&T Labs â Research, [email protected] .... and distortion in âstandardâ embedding, which we call âmetric embeddingâ for distinction. A contractive ...
39.2%. 5.2. ImageNet. ImageNet (Deng et al., 2009) is a large scale image dataset organized according to WordNet (Fellbaum, 1998). Con- cepts in WordNet ...
the best approximation factor for unweighted graphs into the line is O(n1/2), and even for ... â¡AT&T Labs â Research, [email protected] ..... In constructing H from G, we add an edge between two vertices u1 and u2 if and only if u1 ...
Apr 2, 2009 - The tourism boom started in the early 1980's when a phenomenal number of Europeans flocked to this mountain hideaway. The people soon got used to the .... (DTI) and accredited by Department of Tourism (DOT). This study came up with a pr
Jan 17, 2013 - contain no nonlinearities (other than in the feature representation in x and y) they can be limited in their ability to fit large complex datasets, and ...
3 Group/network and participation . .... The individual provides a service to others, or acts for the benefit of others at a personal cost. They do this in the general ...
DOCUMENTATION OF THE CARNATION PRODUCTION AND MARKETING OF. MOUNTAIN BLOOM ..... advantages of this production and marketing system and they could also adopt it in their own locality. 11 ..... From the sales proceeds, the cooperative deducts the tran
Apr 2, 2009 - like the Department of Trade and Industry, and the Department of Tourism should be facilitated by .... (DTI) and accredited by Department of Tourism (DOT). This study ..... Sagada authorities introduced some tourist programs.
This thesis, titled âSOCIAL CAPITAL AMONG MEMBERS OF LEPANTO ..... employees of the Lepanto Consolidated Mining Company (LCMCO). With the ..... 3.26. Neutral. Coop Collector. 50. 3.38. Much. Audit Committee. 50. 3.3. Neutral. Credit Committee. 50.
advantages of this production and marketing system and they could also .... found that a pre-treatment with Ag No3 + sodium Thiosulfate + sucrose gave the best.