<!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>Optimization of a compiler from PDDL to Picat (Short Paper)</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Francesco Contaldo</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Marco De Bortoli</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Agostino Dovier</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Universita degli Studi di Udine Dipartimento di Scienze Matematiche</institution>
          ,
          <addr-line>Informatiche e Fisiche</addr-line>
        </aff>
      </contrib-group>
      <abstract>
        <p>Picat is a new constraint logic programming language that has obtained promising results in international competitions. These results have been achieved thanks to several features. The most e ective of them is an e cient handling of a tabling technique applied to search algorithms. A compiler from PDDL to Picat, which automatically enables to run PDDL models in Picat, has been recently developed. This paper describes a method which automatically optimizes the output of such a compiler, using a di erent representation of the states that better takes advantage of Picat's Tabling technique.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>One of the rst and most important research areas in AI is planning. It deals with
the search for a strategy, in order to resolve a speci c problem, in a given world
with xed rules. The operation of nding this sequence of actions, performed by
the planner, can be seen as the search for a path in a direct graph, where every
node represents a state of the world, and every edge corresponds to an action.</p>
      <p>
        The ancestor of modern planners is STRIPS (Stanford Research Institute
Problem Solver [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]), the language used by Shakey the robot. It was developed
at the end of the 60's and was the rst robot that could reason about its own
actions and plan what to do based on a given goal.
      </p>
      <p>
        The popularity of planning was increasing, but there were no common
guidelines or modeling style, at least until the 1998, when PDDL (Planning Domain
De nition Language) was proposed [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. Since then, also thanks to its use in the
International Planning Competitions [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], PDDL and its extensions (e.g., [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]) are
the reference for planning domain modeling.
      </p>
      <p>
        Picat [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] is a recently designed rule-based, declarative programming
language, provided with a large number of features inherited from several
programming paradigms, such as imperative, scripting, logic and constraint
programming, and external interfaces with constraint solvers, SAT solvers, and MIP
solvers. One of the most successful features of Picat up to now is the planner
module, that allows to obtain e cient results on IPC benchmarks. Benchmarks
can be encoded directly in the planner module of Picat (as done, e.g., in [
        <xref ref-type="bibr" rid="ref10 ref2">2, 10</xref>
        ]);
however, due to the relevance of PDDL in the community, it will be useful to
directly use them within Picat. For this purpose a rst compiler from PDDL to
Picat (written in Picat) has been presented in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ].
      </p>
      <p>
        In this paper we propose a method, inspired by Planning Graph technique [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ],
that optimizes the compiler in order to produce an encoding that better exploits
the Picat's tabling capabilities. In particular it uses the Structured state
representation (as opposed to Factored state representation used by PDDL).
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Preliminaries</title>
      <p>We assume the reader has a basic knowledge of Planning, PDDL, and Picat
(Prolog-like) syntax.</p>
      <p>State representation used in PDDL is known as Factored Representation: a
state is identi ed by a set of atoms, i.e. a set of predicates denoting that some
primitive properties of the world are true. An atom can be rigid, if it represents
a never changing property (e.g. the fact that in location (x; y) there is a wall),
or uent, that can be false or true depending on the current state (e.g. the fact
that in location (x; y) at time t there is a robot). Below there is an example of a
factored representation (inspired by the problem known as Nomystery ), encoded
in PDDL and Picat, respectively:
f a t ( t r u c k 1 , l o c 1 ) , . . . , c o n n e c t e d ( l o c 1 , l o c 2 ) g
$ [ a t ( t r u c k 1 , l o c 1 ) , . . , c o n n e c t e d ( l o c 2 , l o c 3 ) ]</p>
      <p>In a Structured Rapresentation the state is represented using internal data
structures, such as lists or sets, and where it is possible it enables a reduction
of the symmetries. The use of data structures is very suitable for the tabling
technique used by Picat. In fact the states that are memorized during the plan
seek can share common elements present in the structures used to represent
them, reducing the usage of memory during the computation.</p>
      <p>Considering the Nomystery domain described above, one of its possible
structured state representations do not use the predicate connect, because it is a rigid
predicate that describes the map and there is no need to replicate it in every
state. However, it is possible to go further, memorizing the state simply as:
s ( f l o c 1 , l o c 2 , l o c 3 g )
In this state representation the three trucks are directly encoded using their
positions, avoiding the presence of symmetric states during the search. Since
all the trucks are identical there will be no signi cant di erence among two
equals states in which the position of two trucks is exchanged. E.g. one of the
two states can be at(truck1; loc1); at(truck2; loc2) and the other one can be
at(truck2; loc1); at(truck1; loc2). At the end \s" can have other arguments, e.g.,
storing the set of desired truck destinations, or other domain informations.</p>
      <p>
        Picat implements two main search techniques to nd a plan: depth- rst
and resource-bounded. Both of the previously mentioned approaches exploit
the Picat's tabling technique that enables the planner to memorize the
visited states and thus to avoid the re-computation of already-visited branches. In
depth- rst, the solver keeps applying actions until it nds either a dead end,
an already-visited state or a goal state, otherwise it backtracks and it explores
other branches. In the second approach the planner adds a resource amount
value that is used by the planner as convenience measure to decide whether it is
advantageous to re-explore an already visited failing state. [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ].
3
      </p>
    </sec>
    <sec id="sec-3">
      <title>Optimizing the compiler</title>
      <p>
        The goal of the optimization is to automatically transform a model based on
a factored state representation, inherited from PDDL and obtained using the
compiler presented in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], into a model based on a structured state representation
that exploits the Picat's Tabling technique [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
      </p>
      <p>The main intention is to identify the rigid elements and the uent elements
inside each main predicate (i.e., those that appear in the e ect of some action,
the uent one) in order to reduce the size of them. At this point it is fundamental
to distinguish the meaning of the adjectives rigid and uent. In the rst section
these two attributes are used to classify the predicates in the domain. So, in
this case the rigid elements represent the static information inside a single
predicate, while the uent elements represent the dynamic information that evolves
according to each action taken by the planner. As a matter of fact the predicate
at(truck,location) from Nomystery encodes a static information: the name
of the truck. Clearly the name of an entity is something that cannot evolve or
change during the di erent explored states so it is possible to de ne it rigid.
Instead the location of each truck is more meaningful, it can assume di erent
values during the seek in order to nd the goal con guration. Thus each main
predicate will be represented only by its uent elements and, where it is
possible, some predicates are merged together if they were sharing the same rigid
element at the beginning of the compiling phase. Then the state representation
is changed accordingly, introducing a term whose arguments are sets of list, one
for each new main predicate, and all the actions are modi ed to deal with the
new data structures.</p>
      <p>The underlying algorithm of the compiler can be split in two main parts.
The rst one is a preprocessing step which is inspired by the Planning Graph
technique. This step aims to \ground" as predicates as possible, starting from
the initial problem state an iterative and terminating procedure tries to apply
a xed number of actions in order to instantiate the larger possible number of
predicates. In this iterative procedure an action is applied only once and it stops
when a xed point is reached: there is no new action applicable to the current
state or all the actions have been already applied. When the computational step
has nished the analysis one starts. The goal of this last step is to identify
the rigid elements inside each predicates performing an arithmetic mean of the
positions of the elements that di er among the same grounded predicates. Then
the analysis is lifted to the whole problem level working with all the elements
of all the predicates at same time. The main idea that is behind this is step
is to built a DAG of dependencies among all the predicates elements, thus,
for each main predicates in the domains, there exists a directed edge from its
rigid elements and its remaining elements that become temporary uent. At
the end the DAG is used to modify the main predicates of the domain, holding
the original de nition of the rigid predicates. The obtained result should be a
more compact state representation since the static elements are deleted from the
predicates, then the number of the predicates used can be reduced performing a
merge between two predicates that shared the same rigid elements.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Results and conclusions</title>
      <p>The e ect of the compiler optimization has been tested on three models as
benchmarks: Floortile, Tetris, Nomystery, from the IPC list of benchmarks.</p>
      <p>Nomystery</p>
      <p>Instance
Nomystery 0
Nomystery 1
Nomystery 2
Nomystery 3</p>
      <p>SUM</p>
      <p>Structured Factored
Representation Representation
bound time bound time(s)
6 1 6 2.70
9 18.96 9 34.04
13 159.05 13 376.13
15 125.58 15 421.43</p>
      <p>304,59 834,30</p>
      <p>Tetris
Instance
Tetris 0
Tetris 1
Tetris 2
Tetris 3
Tetris 4
Tetris 5</p>
      <p>SUM
Floortile
Instance
Floortile 0
Floortile 1
Floortile 2
Floortile 3
Floortile 4
Floortile 5</p>
      <p>SUM</p>
      <p>Structured Factored
Representation Representation
bound time bound time(s)
2 0 2 0
9 0.15 9 0.16
10 0.05 10 0.352
16 0.22 16 0.587
16 5.39 16 11.554
16 13.473 16 201.157</p>
      <p>19.283 213.81</p>
      <p>Structured Factored
Representation Representation
bound time bound time(s)
14 0.005 14 0.007
15 0.057 15 0.088
12 0.17 12 0.21
14 3.09 14 3.194
24 10.34 24 12.95
26 309.41 26 308.37</p>
      <p>323.072 325.019</p>
      <p>The computational results, reported in Table 1, highlight an improvement of
the performance in all instances tested of Nomystery, Tetris and for the most
one of Floortile. Focusing on the global time, obtained by the summation of
all the times for a speci c problem, it can be observed how all the problems
encoded using the optimization have better performance than the ones encoded
with the factored representation. As for Nomystery and Tetris we have obtained
an improvement of 60% and 90%, respectively. On the other hand, concerning
the Floortile problem we have gained only 2 seconds in the global measurement.
The running time required by the optimization process is on average around the
350 ms, thus, it is not an overhead for medium-big size problems.</p>
      <p>We have also tested direct, manually optimized, Picat encodings of the three
benchmarks. The running time on the instances tested are negligible (below 50ms
| same results as state-of-the-art planners). Other work is needed to automatize
the compiler process to lead to encodings with the same performances.
Acknowledgments. We thank Roman Bartak and Neng-Fa Zhou for their help in
various stages of this work. A. Dovier is partially supported by INdAM-GNCS
2015{2017 projects.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <article-title>International planning competitions web site</article-title>
          . http://ipc.icaps-conference.org/. Accessed:
          <fpage>2017</fpage>
          -05-10.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>Roman</given-names>
            <surname>Bartak</surname>
          </string-name>
          , Agostino Dovier, and
          <string-name>
            <surname>Neng-Fa Zhou</surname>
          </string-name>
          .
          <article-title>On modeling planning problems in tabled logic programming</article-title>
          . In M. Falaschi and E. Albert, editors,
          <source>Proc. of PPDP</source>
          , Siena, Italy,
          <source>July 14-16</source>
          ,
          <year>2015</year>
          , pages
          <fpage>31</fpage>
          {
          <fpage>42</fpage>
          . ACM,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3. Marco De Bortoli, Roman Bartak, Agostino Dovier, and
          <string-name>
            <surname>Neng-Fa Zhou</surname>
          </string-name>
          .
          <article-title>Compiling and executing PDDL in picat</article-title>
          . In C.
          <article-title>Fiorentini and A</article-title>
          . Momigliano, editors,
          <source>Proceedings of the 31st Italian Conference on Computational Logic</source>
          , Milano, Italy, June 20-22,
          <year>2016</year>
          ., volume
          <volume>1645</volume>
          <source>of CEUR Workshop Proceedings</source>
          , pages
          <volume>132</volume>
          {
          <fpage>147</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>Agostino</given-names>
            <surname>Dovier</surname>
          </string-name>
          , Andrea Formisano, and
          <string-name>
            <given-names>Enrico</given-names>
            <surname>Pontelli</surname>
          </string-name>
          .
          <article-title>Perspectives on logicbased approaches for reasoning about actions and change</article-title>
          . In M. Balduccini and Tran Cao Son, editors,
          <source>Logic Programming</source>
          ,
          <article-title>Knowledge Representation, and Nonmonotonic Reasoning - Essays Dedicated to Michael Gelfond on the Occasion of His 65th Birthday</article-title>
          , LNCS
          <volume>6565</volume>
          , pages
          <fpage>259</fpage>
          {
          <fpage>279</fpage>
          . Springer,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>Richard</given-names>
            <surname>Fikes</surname>
          </string-name>
          and
          <string-name>
            <surname>Nils J. Nilsson. STRIPS:</surname>
          </string-name>
          <article-title>A new approach to the application of theorem proving to problem solving</article-title>
          .
          <source>Artif. Intell.</source>
          ,
          <volume>2</volume>
          (
          <issue>3</issue>
          /4):
          <volume>189</volume>
          {
          <fpage>208</fpage>
          ,
          <year>1971</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>Maria</given-names>
            <surname>Fox</surname>
          </string-name>
          and
          <string-name>
            <given-names>Derek</given-names>
            <surname>Long</surname>
          </string-name>
          .
          <source>Pddl2</source>
          .
          <article-title>1: an extension to pddl for expressing temporal planning domains</article-title>
          .
          <source>In Journal of Arti cial Intelligence Research</source>
          ,
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>B. Cenk</given-names>
            <surname>Gazen</surname>
          </string-name>
          and
          <article-title>Craig A. Knoblock. Combining the expressivity of UCPOP with the e ciency of graphplan</article-title>
          . In S. Steel and R. Alami, editors,
          <source>Proc. of ECP'97</source>
          , Toulouse, France, LNCS
          <volume>1348</volume>
          , pages
          <fpage>221</fpage>
          {
          <fpage>233</fpage>
          . Springer,
          <year>1997</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>M.</given-names>
            <surname>Gelfond</surname>
          </string-name>
          and
          <string-name>
            <given-names>V.</given-names>
            <surname>Lifschitz</surname>
          </string-name>
          .
          <article-title>Action languages</article-title>
          .
          <source>Electronic Transactions on Articial Intelligence</source>
          ,
          <volume>2</volume>
          :
          <fpage>193</fpage>
          {
          <fpage>210</fpage>
          ,
          <year>1998</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>D.</given-names>
            <surname>Mcdermott</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Ghallab</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Howe</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Knoblock</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Ram</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Veloso</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Weld</surname>
          </string-name>
          , and
          <string-name>
            <given-names>D.</given-names>
            <surname>Wilkins. PDDL - The Planning Domain De nition Language</surname>
          </string-name>
          .
          <source>Technical Report TR-98-003</source>
          ,
          <article-title>Yale Center for Computational Vision</article-title>
          and Control,
          <year>1998</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Neng-Fa</surname>
            <given-names>Zhou</given-names>
          </string-name>
          , Roman Bartak, and
          <string-name>
            <given-names>Agostino</given-names>
            <surname>Dovier</surname>
          </string-name>
          .
          <article-title>Planning as tabled logic programming</article-title>
          .
          <source>TPLP</source>
          ,
          <volume>15</volume>
          (
          <issue>4-5</issue>
          ):
          <volume>543</volume>
          {
          <fpage>558</fpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Neng-Fa</surname>
            <given-names>Zhou</given-names>
          </string-name>
          , Hakan Kjellerstrand, and
          <string-name>
            <given-names>Jonathan</given-names>
            <surname>Fruhman</surname>
          </string-name>
          .
          <article-title>Constraint Solving and Planning with Picat</article-title>
          .
          <source>Springer Briefs in Intelligent Systems</source>
          . Springer,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>