RASP stands for Resourced Answer Set Programming. It is an extension
of Answer Set Programming
that supports declarative reasoning on consumption and production
of resources.
Resources are modeled by special atoms,
called amount-atoms, to which quantities are associated
in order to represent the available amounts of a certain resources.
The firing of a RASP-rule involving amount-atoms can both consume and
produce resources, in the specified amounts. A RASP-rule can be fired several times, according
to its definition and to the available quantities of required
resources.
R-facts describe those resources available from the beginning.
Produced or available resources can be consumed to produce other resources.
Different solution of a RASP-problem, i.e., different
answer sets of a RASP-program, correspond to
different possible allocations of available resources.
Various forms of preferences and conditional preferences on resource usage can be expressed
(see [CF08b] for details on the semantics of preference).
Preferences might be expressed by using any binary relation
(i.e., non-linear preference orders are admitted, cf., [CF09,CFP10,CF10]).
A description of RASP and its semantics is given in [CF07].
(See also [CF09,CFP10] for the new syntax).
What is raspberry?
Raspberry is a prototypical implementation of a translator
from ground RASP to ASP.
The language of RASP is an extension of ASP.
Hence, the translator leaves unchanged the ASP portion of the input program
and translates RASP-rules (those involving amount-atoms) into suitable ASP fragments.
Basically, the output ASP program is made of: (i) the ASP rules initially occurring in the given RASP-program;
(ii) the translation of the RASP-rules; (iii) an ASP-based inference engine that handle amounts and resources.
Then, an ASP-solver such as clasp or smodels can be used.
In presence of preferences, all answer sets or just a most preferred answer set (by exploiting optimization statements
offered by clasp and smodels) can be computed.
How can I use it?
Simply write a RASP program in a file and translate it with raspberry.
The easiest way is:
raspberry -i input_file -o output_file
Then, use an ASP-solver to process the contents of output_file.
Raspberry can produce outputs in (few) slightly different syntax. So, commonly available
grounder and solvers, such as gringo/clasp or lparse/smodels can be used (see WARNING below).
Here is a summary of raspberry's command-line options:
Usage raspberry [-h] [-i ] [-o ] [-m] [-n ] [-y] [-po|-pp] [-l0|-l1|-l2|-l3]
In case of multiple antithetic options, the last one has effect
-h print this message
-i read input from (default: stdin)
-o write output to file (default: stdout)
-n set max amount-value to (default: 30)
-y do not add #hide statements for RASP reserved key-words
-m set off optimization (default: on) used for p-list treatment
[-po|-pp] select the default def_policy in rule firing
Options: -po=Optional (default), -pp=Prodigal
[-l0|-l1|-l2|-l3] select output language
Output language options:
-l0: Evaluate sums using aggregates of the form:
sum[p(X,Y):q(X):r(Y)=Y]
Only positive integers are used (consumptions and productions are handled separatedly).
-l1: Evaluate sums using weight constraints of the form:
N[p(X,Y):q(X):r(Y)=Y]N
Only positive integers are used (consumptions and productions are handled separatedly).
-l2: Evaluate sums using weight constraints of the form:
#weight p(X,Y)=Y.
N[p(X,Y):q(X):r(Y)]N
Only positive integers are used (consumptions and productions are handled separatedly).
-l3: (default) Evaluate sums using aggregates of the form:
sum[p(X,Y):q(X):r(Y)=Y]
Consumptions are modeled through negative integers.
Options l3 (default) should be used to produce a program processable by gringo (tested with gringo 3.0.5).
Option l2 should work for lparse.
Options l0,l1 might be useful, but won't be maintained in future releases.
WARNING
Raspberry's output is not compatible with the input language required by
newer versions of the grounder gringo (e.g. gringo 4.x.x).
Please use gringo 3.0.5 as grounder and clasp (up to version 3.1.3) as solver
(available in http://potassco.sourceforge.net).
Changes to support new gringo input syntax are under consideration.
How can I get it?
Currently, a C++ implementation can be downloaded, unpacked, and easily used (see the examples below).
A prototype is available as executable precompiled under linux:
Translation in ASP obtained with "raspberry -i example3cilc.rasp -o example3cilc.asp": example3cilc.asp (most preferred solition)
Solutions obtained by "gringo example3cilc.asp |clasp 0 > example3cilc.sol": example3cilc.sol
Translation in ASP obtained with "raspberry -i example3cilc.rasp -o example3cilc_m.asp -m ": example3cilc_m.asp (all solutions)
Solutions obtained by "gringo example3cilc_m.asp |clasp 0 > example3cilc_m.sol": example3cilc_m.sol
Example:
Calvin-Benson-Bassham cycle.
Source RASP program (max 6 turns, 2 molecules produced): calvin_exe_N1.rasp
Source RASP program (max 18 turns, 6 molecules produced): calvin_exe_N3.rasp
Translation in ASP obtained with "raspberry -n 60 -i calvin_exe_N3.rasp -o calvin_exe_N3.asp": calvin_exe_N3.asp
Solutions obtained by "gringo calvin_exe_N3.asp |clasp > calvin_exe_N3.sol": calvin_exe_N3.sol
Example:
Assembling computers.
Source RASP program (most preferred assembling of 7 computers): computers_exe_N5.rasp
Source RASP program (most preferred assembling of 11 computers): computers_exe_N9.rasp
Translation in ASP obtained with "raspberry -i computers_exe_N5.rasp -o computers_exe_N5.asp": computers_exe_N5.asp
Solutions obtained by "gringo computers_exe_N5.asp |clasp 0 > computers_exe_N5.sol": computers_exe_N5.sol
...other examples may come...
TO DO:
I.e., some parts of the implementation still to be completed...
some of the policies in rule firings (thrifty is missing)
global constraint on resource balance
handling of rule-costs and cost-based preferences
compound resource-sets (conjunctive and disjunctive) [appeared in version 2.6.1, to be completed in 2.6.x (for some x>1)]
embedding in a friendly user-interface (post processing of computed answer sets, cleaning the output, ...)
preferences on rules
...
People:
Stefania Costantini, Università di L'Aquila
Andrea Formisano, Università di Perugia
Davide Petturiti, Università di Perugia
References:
[CFP10] S.Costantini, A.Formisano and D.Petturiti.
Extending and implementing RASP.
Fundamenta Informaticae, 105(1-2):1-33, 2010.
(draft.pdf)
[CF10] S.Costantini and A.Formisano.
Answer Set Programming with Resources..
J. of Logic and Computation, 20(2):533-571, 2010.
Advance Access published November 6, 2009. doi:10.1093/logcom/exp071.
(draft.pdf)
[CF09] S.Costantini and A.Formisano.
Modeling preferences on resource consumption and production in ASP.
J. of Algorithms in Cognition, Informatics and Logic, 64(1), 2009.
(draft.pdf)
[CFP12] S.Costantini, A.Formisano, D.Pearce.
Strong Equivalence of RASP Programs.
Correct Reasoning, Lecture Notes in Computer Science 7265. Springer, 2012.
[CF08a] S.Costantini and A.Formisano.
Conditional preferences in P-RASP.
LANMR'08--Fourth Latin American Workshop on Non-Monotonic Reasoning. Puebla, Mexico. October, 2008.
[CF08b] S.Costantini and A.Formisano.
Modeling preferences on resource consumption and production in ASP.
ASPOCP'08--Workshop on Answer Set Programming and Other Computing Paradigms. ICLP08 workshop. Udine, Italy. December, 2008.
[CF07] S.Costantini and A.Formisano.
Answer Set Programming with Resources.
ASP’07--Answer Set Programming:
Advances in Theory and Implementation. ICLP07 workshop. Porto, Portugal. September, 2007.
An extended version of this paper is here.