|
From: <jom...@us...> - 2014-12-10 20:42:33
|
Revision: 1819
http://sourceforge.net/p/jason/svn/1819
Author: jomifred
Date: 2014-12-10 20:42:30 +0000 (Wed, 10 Dec 2014)
Log Message:
-----------
add EIS-jason
Modified Paths:
--------------
trunk/build.xml
trunk/pom.xml
Added Paths:
-----------
trunk/applications/eis-jason/
trunk/applications/eis-jason/.classpath
trunk/applications/eis-jason/.project
trunk/applications/eis-jason/.settings/
trunk/applications/eis-jason/.settings/org.eclipse.jdt.core.prefs
trunk/applications/eis-jason/Carriage-1agent.mas2j
trunk/applications/eis-jason/Carriage-2agents.mas2j
trunk/applications/eis-jason/build.xml
trunk/applications/eis-jason/doc/
trunk/applications/eis-jason/doc/Makefile
trunk/applications/eis-jason/doc/eis-jason.html
trunk/applications/eis-jason/doc/eis-jason.tex
trunk/applications/eis-jason/doc/jason.css
trunk/applications/eis-jason/examples/
trunk/applications/eis-jason/examples/domestic-robot/
trunk/applications/eis-jason/examples/domestic-robot/DomesticRobot.mas2j
trunk/applications/eis-jason/examples/domestic-robot/EISHouseEnv.java
trunk/applications/eis-jason/examples/domestic-robot/HouseEnv.java
trunk/applications/eis-jason/examples/domestic-robot/HouseModel.java
trunk/applications/eis-jason/examples/domestic-robot/HouseView.java
trunk/applications/eis-jason/examples/domestic-robot/build.xml
trunk/applications/eis-jason/examples/domestic-robot/doc/
trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle
trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf
trunk/applications/eis-jason/examples/domestic-robot/doc/eis-doc.txt
trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png
trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar
trunk/applications/eis-jason/examples/domestic-robot/owner.asl
trunk/applications/eis-jason/examples/domestic-robot/robot.asl
trunk/applications/eis-jason/examples/domestic-robot/supermarket.asl
trunk/applications/eis-jason/examples/domestic-robot/time/
trunk/applications/eis-jason/examples/domestic-robot/time/check.java
trunk/applications/eis-jason/examples/elevator/
trunk/applications/eis-jason/examples/elevator/.classpath
trunk/applications/eis-jason/examples/elevator/.project
trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf
trunk/applications/eis-jason/examples/elevator/ag.asl
trunk/applications/eis-jason/examples/elevator/elevator.mas2j
trunk/applications/eis-jason/examples/elevator/lib/
trunk/applications/eis-jason/examples/elevator/lib/eis-0.3.jar
trunk/applications/eis-jason/examples/elevator/lib/eis-jason.jar
trunk/applications/eis-jason/examples/elevator/lib/elevatorenv.jar
trunk/applications/eis-jason/lib/
trunk/applications/eis-jason/lib/eis-0.3.jar
trunk/applications/eis-jason/lib/eis-jason.jar
trunk/applications/eis-jason/lib/eiscarriage-0.3.jar
trunk/applications/eis-jason/lib/jason.jar
trunk/applications/eis-jason/readme.txt
trunk/applications/eis-jason/src/
trunk/applications/eis-jason/src/asl/
trunk/applications/eis-jason/src/asl/robot.asl
trunk/applications/eis-jason/src/asl/robot1.asl
trunk/applications/eis-jason/src/asl/robot2.asl
trunk/applications/eis-jason/src/java/
trunk/applications/eis-jason/src/java/jason/
trunk/applications/eis-jason/src/java/jason/eis/
trunk/applications/eis-jason/src/java/jason/eis/EISAdapter.java
trunk/applications/eis-jason/src/java/jason/eis/JasonAdapter.java
trunk/applications/eis-jason/src/java/jason/eis/Translator.java
Added: trunk/applications/eis-jason/.classpath
===================================================================
(Binary files differ)
Index: trunk/applications/eis-jason/.classpath
===================================================================
--- trunk/applications/eis-jason/.classpath 2014-11-03 10:51:43 UTC (rev 1818)
+++ trunk/applications/eis-jason/.classpath 2014-12-10 20:42:30 UTC (rev 1819)
Property changes on: trunk/applications/eis-jason/.classpath
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Added: trunk/applications/eis-jason/.project
===================================================================
(Binary files differ)
Index: trunk/applications/eis-jason/.project
===================================================================
--- trunk/applications/eis-jason/.project 2014-11-03 10:51:43 UTC (rev 1818)
+++ trunk/applications/eis-jason/.project 2014-12-10 20:42:30 UTC (rev 1819)
Property changes on: trunk/applications/eis-jason/.project
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Added: trunk/applications/eis-jason/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/applications/eis-jason/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/applications/eis-jason/.settings/org.eclipse.jdt.core.prefs 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,12 @@
+#Thu Feb 11 17:32:52 BRST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added: trunk/applications/eis-jason/Carriage-1agent.mas2j
===================================================================
--- trunk/applications/eis-jason/Carriage-1agent.mas2j (rev 0)
+++ trunk/applications/eis-jason/Carriage-1agent.mas2j 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,22 @@
+/*
+ Example of Jason EIS integration
+
+ In this example one agent acts on two entities (robot1 and robot2)
+
+ -- created on September 08, 2009
+*/
+
+MAS demo1ag {
+ infrastructure: Centralised
+
+ // Environment initialisation
+ environment: jason.eis.EISAdapter(
+ "lib/eiscarriage-0.3.jar", // jar file containing the environment implementation
+ agent_entity(robot,robot1), agent_entity(robot,robot2) // agent x entities relation
+ )
+
+ agents:
+ robot;
+
+ aslSourcePath: "src/asl";
+}
\ No newline at end of file
Added: trunk/applications/eis-jason/Carriage-2agents.mas2j
===================================================================
--- trunk/applications/eis-jason/Carriage-2agents.mas2j (rev 0)
+++ trunk/applications/eis-jason/Carriage-2agents.mas2j 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,24 @@
+/*
+ Example of Jason EIS integration
+
+ In this example there is one agent for each entity and they have
+ the same identities (agent is "robot1" and entity is "robot1")
+
+ -- created on September 08, 2009
+*/
+
+MAS demo2ag {
+ infrastructure: Centralised
+
+ environment: jason.eis.EISAdapter(
+ "lib/eiscarriage-0.3.jar" // jar file containing the environment implementation
+ // agent x entities relation:
+ // agent_entity(robot1,robot1), agent_entity(robot2,robot2)) // the default relation:
+ )
+
+ agents:
+ robot1;
+ robot2;
+
+ aslSourcePath: "src/asl";
+}
\ No newline at end of file
Added: trunk/applications/eis-jason/build.xml
===================================================================
(Binary files differ)
Index: trunk/applications/eis-jason/build.xml
===================================================================
--- trunk/applications/eis-jason/build.xml 2014-11-03 10:51:43 UTC (rev 1818)
+++ trunk/applications/eis-jason/build.xml 2014-12-10 20:42:30 UTC (rev 1819)
Property changes on: trunk/applications/eis-jason/build.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Added: trunk/applications/eis-jason/doc/Makefile
===================================================================
--- trunk/applications/eis-jason/doc/Makefile (rev 0)
+++ trunk/applications/eis-jason/doc/Makefile 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,19 @@
+TARGET = eis-jason
+
+html: $(TARGET).tex Makefile
+ latex2html -split 0 -style jason.css \
+ -white -image_type=png \
+ -dir html -mkdir -toc_stars \
+ -show_section_numbers -noinfo -address "Jomi F. Hubner" -html_version 3.2,math \
+ -no_navigation $(TARGET).tex
+ cp html/$(TARGET).html .
+ rm -rf html
+
+clean:
+ rm -f $(TARGET).ps *.log $(TARGET).aux $(TARGET).out || true
+ rm -rf auto || true
+ rm -rf *pdf || true
+ find . -name *bak -exec rm {} \; || true
+ find . -name *~ -exec rm {} \; || true
+ rm -rf html
+
Added: trunk/applications/eis-jason/doc/eis-jason.html
===================================================================
--- trunk/applications/eis-jason/doc/eis-jason.html (rev 0)
+++ trunk/applications/eis-jason/doc/eis-jason.html 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,390 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+
+<!--Converted with LaTeX2HTML 2008 (1.71)
+original version by: Nikos Drakos, CBLU, University of Leeds
+* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
+* with significant contributions from:
+ Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
+<HTML>
+<HEAD>
+<TITLE>Jason and EIS integration (release 0.3)</TITLE>
+<META NAME="description" CONTENT="Jason and EIS integration (release 0.3)">
+<META NAME="resource-type" CONTENT="document">
+<META NAME="distribution" CONTENT="global">
+
+<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
+<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
+
+<LINK REL="STYLESHEET" HREF="jason.css">
+
+</HEAD>
+
+<BODY >
+
+<P>
+
+<H1 ALIGN="CENTER">Jason and EIS integration
+<BR><FONT SIZE="-1">(release 0.3)</FONT></H1>
+<DIV>
+
+</DIV>
+
+<P>
+
+<H3>Abstract:</H3>
+<DIV>
+This document describes (i) how to use environments developed as
+ defined by the Environment Interface Standard
+ (<A HREF="http://cig.in.tu-clausthal.de/eis">EIS</A>) in
+ <A HREF="http://jason.sf.net">Jason</A> projects; and (ii) how Jason
+ environment can be adapted to be used as EIS environment.
+</DIV>
+<P>
+
+<P>
+<BR>
+
+<H2><A NAME="SECTION00010000000000000000">
+Contents</A>
+</H2>
+<!--Table of Contents-->
+
+<UL>
+<LI><A NAME="tex2html12"
+ HREF="eis-jason.html#SECTION00020000000000000000">Using EIS environments in Jason</A>
+<UL>
+<LI><A NAME="tex2html13"
+ HREF="eis-jason.html#SECTION00021000000000000000">Jason Project Definition</A>
+<LI><A NAME="tex2html14"
+ HREF="eis-jason.html#SECTION00022000000000000000">Agent programming</A>
+<LI><A NAME="tex2html15"
+ HREF="eis-jason.html#SECTION00023000000000000000">Code of robot1.asl in project demo2ag</A>
+<LI><A NAME="tex2html16"
+ HREF="eis-jason.html#SECTION00024000000000000000">Code of robot2.asl in project demo2ag</A>
+<LI><A NAME="tex2html17"
+ HREF="eis-jason.html#SECTION00025000000000000000">Code of robot.asl in project demo1ag</A>
+<LI><A NAME="tex2html18"
+ HREF="eis-jason.html#SECTION00026000000000000000">How to create a project with Jason-EIS integration</A>
+</UL>
+<BR>
+<LI><A NAME="tex2html19"
+ HREF="eis-jason.html#SECTION00030000000000000000">EISifying Jason environments</A>
+<LI><A NAME="tex2html20"
+ HREF="eis-jason.html#SECTION00040000000000000000">Data Translation</A>
+</UL>
+<!--End of Table of Contents-->
+<P>
+
+<H1><A NAME="SECTION00020000000000000000">
+Using EIS environments in Jason</A>
+</H1>
+
+<P>
+Jason projects can use EIS environments by means of the
+EISAdapter. EISAdapter is a Jason environment, i.e. it follows all
+requirements of an environment for Jason projects, that delegates
+perception and action to an EIS environment. It basically maps agents
+actions to EIS actions and gives EIS perception back to Jason agents.
+
+<P>
+
+<H2><A NAME="SECTION00021000000000000000">
+Jason Project Definition</A>
+</H2>
+
+<P>
+EIS has the concept of <I>entities</I> which are associated to agents
+that can then control those entities. Since Jason does not have this
+concept, we propose two solutions:
+
+<UL>
+<LI>The relation agent-entity is very simple: each agent has exactly
+ one entity and their names are the same. In this case, the Jason
+ designer does not need to specify the relation.
+</LI>
+<LI>The designer defines all the relations in the project.
+</LI>
+</UL>
+
+<P>
+The Carriage example is used in the sequence to illustrate the two
+solutions (see EIS documentation for more details about this
+environment).
+
+<P>
+Using the first solution, the Jason project for the Carriage environment is:
+<PRE>
+MAS demo2ag {
+ infrastructure: Centralised
+
+ environment: jason.eis.EISAdapter(
+ "lib/eis-0.2-carriage.jar" // jar file containing the
+ // environment implementation
+ )
+
+ agents:
+ robot1;
+ robot2;
+}
+</PRE>
+Notice that the environment class is
+<TT>jason.eis.EISAdapter</TT>. This class loads the EIS environment
+provided in the jar file and delegates action/perception to
+it. Regarding entities, each agent will control an entity that has the
+same name as it, i.e. agent robot1 controls entity robot1 and agent
+robot2 controls entity robot2.
+
+<P>
+Using the second solution, the Jason project for the Carriage environment is:
+<PRE>
+MAS demo1ag {
+ infrastructure: Centralised
+
+ environment: jason.eis.EISAdapter(
+ "lib/eis-0.2-carriage.jar" // jar file containing the
+ // environment implementation
+ agent_entity(robot,robot1),
+ agent_entity(robot,robot2) // agent x entities relation
+ )
+
+ agents:
+ robot;
+}
+</PRE>
+In this case, the entities associated to each agent are explicitly
+defined by pairs <agent>, <entity>. In the above example, agent robot
+will control both entities of the environment.
+
+<P>
+If parameters in the form ``id = value'' need to be used, the map
+structure have to be used, for instance:
+<PRE>
+MAS wumpus {
+
+ infrastructure: Centralised
+
+ environment: jason.eis.EISAdapter(
+ "lib/wumpusenv.jar", // EIS environment
+ agent_entity(ag,agent), // entities
+ map(file,"maps/wumpus.kt5.wld")) // initialisation parameters
+ agents:
+ ag;
+}
+</PRE>
+
+<P>
+
+<H2><A NAME="SECTION00022000000000000000">
+Agent programming</A>
+</H2>
+
+<P>
+The agents are programmed as usual. When the agent needs to handle
+entities, two solutions are implemented.
+
+<P>
+<DL>
+<DT><STRONG>perception</STRONG></DT>
+<DD>every perception given by the EIS environment is
+ annotated with the entity that has produced the perception. E.g.,
+ the perception in the Carriage example is:
+<PRE>
+carriagePos(2)[entity(robot2),source(percept)]
+</PRE>
+
+<P>
+</DD>
+<DT><STRONG>action</STRONG></DT>
+<DD>actions are sent to all entities by default, e.g.:
+<PRE>
+... push; ...
+</PRE>
+
+<P>
+When the programmer wants to define a target entity he/she has to
+ use a special action <TT>ae</TT> with to arguments: the action and
+ the entity (as string). E.g.:
+<PRE>
+ae(push,"robot1")
+</PRE>
+</DD>
+</DL>
+
+<P>
+As examples, it follows the code of the three agents used in the two
+projects cited in the previous section.
+
+<P>
+
+<H2><A NAME="SECTION00023000000000000000">
+Code of robot1.asl in project demo2ag</A>
+</H2>
+<PRE>
+!start. // initial goal
+
++!start // plan to achieve the goal
+ <- push; // act on its entity
+ !!start. // continue doing the same
+</PRE>
+Notice that actions are used as usual in Jason.
+
+<P>
+
+<H2><A NAME="SECTION00024000000000000000">
+Code of robot2.asl in project demo2ag</A>
+</H2>
+<PRE>
+!start. // initial goal
+
++!start
+ <- wait;
+ push;
+ !!start.
+
++step(X) : carriagePos(C)
+ <- .print("Step ",X,", carriage at ",C).
+</PRE>
+
+<P>
+
+<H2><A NAME="SECTION00025000000000000000">
+Code of robot.asl in project demo1ag</A>
+</H2>
+<PRE>
+!start1. // this agent has two intentions, one for each entity
+!start2.
+
+
++!start1 <- ae(push,"robot1"); !!start1. // act on entity robot1
++!start2 <- ae(wait,"robot2"); ae(push,"robot2"); !!start2. // act on entity robot2
+
++step(X) : carriagePos(C)
+ <- .print("Step ",X,", carriage at ",C).
+</PRE>
+
+<P>
+
+<H2><A NAME="SECTION00026000000000000000">
+How to create a project with Jason-EIS integration</A>
+</H2>
+
+<OL>
+<LI>Copy eis.jar, eis-jason.jar and the environment .jar files to the lib directory of your project.
+</LI>
+<LI>Define the environment of Jason project as described in the second section of this document.
+
+<P>
+</LI>
+</OL>
+<H1><A NAME="SECTION00030000000000000000">
+EISifying Jason environments</A>
+</H1>
+
+<P>
+Jason Environments (those defined to be included in Jason Projects)
+can be used as an EIS environment quite easily. Only entities have to
+be defined, since they do not belong to the Jason concept of environment.
+
+<P>
+The domestic-robot example is used to illustrate the process. All the
+code and more details are included in the JasonEIS 0.3
+(<TT><A NAME="tex2html1"
+ HREF="../examples/domestic-robot/doc/eis-doc.txt">../examples/domestic-robot/doc/eis-doc.txt</A></TT>).
+
+<P>
+<DIV ALIGN="CENTER">
+
+ <IMG WIDTH="800" SRC="../examples/domestic-robot/doc/overview.png" />
+
+</DIV>
+
+<P>
+The following steps describes how to ``export'' a Jason Environment to EIS:
+
+<OL>
+<LI>Create a new class that extends the Jason Adapter for EIS
+ environment. In its constructor instantiate the Jason Environment
+ class and define the entities:
+<PRE>
+public class EISHouseEnv extends JasonAdapter {
+
+ public EISHouseEnv() {
+ jasonEnv = new HouseEnv(); // create the instance of Jason Environment
+ try {
+ addEntity("robot");
+ addEntity("owner");
+ addEntity("supermarket");
+ } catch (EntityException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
+</PRE>
+ The JasonAdapter class will be in charge to map perception and
+ action between Jason and EIS. It also maps the INIT command to the
+ init method in Jason environments and the KILL command to the stop
+ method. (The other commands are ignored since they do not have
+ counter part in Jason.)
+
+<P>
+</LI>
+<LI>Create a jar file that includes your new class, the Jason
+ classes, and the Jason-EIS classes. For instance (from build.xml of
+ domestic-robot):
+<PRE>
+ <target name="jar" depends="compile">
+ <delete file="${ant.project.name}.jar" />
+ <copy file="${jasonJar}" tofile="${ant.project.name}.jar" />
+ <jar update="yes" jarfile="${ant.project.name}.jar" >
+ <fileset dir="${build.dir}">
+ <include name="**/*.class" />
+ </fileset>
+ <fileset dir="${jason-eis-dir}/bin/classes">
+ <include name="jason/**/*.class" />
+ </fileset>
+ <manifest>
+ <attribute name="Main-Class" value="EISHouseEnv"/>
+ </manifest>
+ </jar>
+ </target>
+</PRE>
+</LI>
+</OL>
+
+<P>
+
+<H1><A NAME="SECTION00040000000000000000">
+Data Translation</A>
+</H1>
+
+<P>
+Data types in EIS and Jason are different, they are so translated as
+defined in the following table.
+
+<P>
+<TABLE CELLPADDING=3 BORDER="1">
+<TR><TD ALIGN="CENTER"><I>Type in EIS</I></TD>
+<TD ALIGN="CENTER"><I>Type in Jason</I></TD>
+</TR>
+<TR><TD ALIGN="CENTER">Identifier</TD>
+<TD ALIGN="CENTER">Term</TD>
+</TR>
+<TR><TD ALIGN="CENTER">Numeral</TD>
+<TD ALIGN="CENTER">NumberTerm</TD>
+</TR>
+<TR><TD ALIGN="CENTER">ParameterList</TD>
+<TD ALIGN="CENTER">ListTerm</TD>
+</TR>
+<TR><TD ALIGN="CENTER">Function</TD>
+<TD ALIGN="CENTER">Literal</TD>
+</TR>
+</TABLE>
+
+<P>
+<BR><HR>
+<ADDRESS>
+Jomi F. Hubner
+</ADDRESS>
+</BODY>
+</HTML>
Added: trunk/applications/eis-jason/doc/eis-jason.tex
===================================================================
--- trunk/applications/eis-jason/doc/eis-jason.tex (rev 0)
+++ trunk/applications/eis-jason/doc/eis-jason.tex 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,268 @@
+\documentclass{article}
+\usepackage{graphicx}
+\usepackage{html}
+\usepackage{hthtml}
+
+
+\begin{document}
+
+\title{Jason and EIS integration \\\small{(release 0.3)}}
+%\author{Jomi F. H\"ubner}
+\maketitle
+
+\begin{abstract}
+ This document describes (i) how to use environments developed as
+ defined by the Environment Interface Standard
+ (\htlink{EIS}{http://cig.in.tu-clausthal.de/eis}) in
+ \htlink{Jason}{http://jason.sf.net} projects; and (ii) how Jason
+ environment can be adapted to be used as EIS environment.
+\end{abstract}
+
+\tableofcontents
+
+
+\section*{Using EIS environments in Jason}
+
+Jason projects can use EIS environments by means of the
+EISAdapter. EISAdapter is a Jason environment, i.e. it follows all
+requirements of an environment for Jason projects, that delegates
+perception and action to an EIS environment. It basically maps agents
+actions to EIS actions and gives EIS perception back to Jason agents.
+
+
+\subsection*{Jason Project Definition}
+
+EIS has the concept of \emph{entities} which are associated to agents
+that can then control those entities. Since Jason does not have this
+concept, we propose two solutions:
+\begin{itemize}
+\item The relation agent-entity is very simple: each agent has exactly
+ one entity and their names are the same. In this case, the Jason
+ designer does not need to specify the relation.
+\item The designer defines all the relations in the project.
+\end{itemize}
+
+The Carriage example is used in the sequence to illustrate the two
+solutions (see EIS documentation for more details about this
+environment).
+
+Using the first solution, the Jason project for the Carriage environment is:
+\begin{verbatim}
+MAS demo2ag {
+ infrastructure: Centralised
+
+ environment: jason.eis.EISAdapter(
+ "lib/eis-0.2-carriage.jar" // jar file containing the
+ // environment implementation
+ )
+
+ agents:
+ robot1;
+ robot2;
+}
+\end{verbatim}
+Notice that the environment class is
+\texttt{jason.eis.EISAdapter}. This class loads the EIS environment
+provided in the jar file and delegates action/perception to
+it. Regarding entities, each agent will control an entity that has the
+same name as it, i.e. agent robot1 controls entity robot1 and agent
+robot2 controls entity robot2.
+
+Using the second solution, the Jason project for the Carriage environment is:
+\begin{verbatim}
+MAS demo1ag {
+ infrastructure: Centralised
+
+ environment: jason.eis.EISAdapter(
+ "lib/eis-0.2-carriage.jar" // jar file containing the
+ // environment implementation
+ agent_entity(robot,robot1),
+ agent_entity(robot,robot2) // agent x entities relation
+ )
+
+ agents:
+ robot;
+}
+\end{verbatim}
+In this case, the entities associated to each agent are explicitly
+defined by pairs <agent>, <entity>. In the above example, agent robot
+will control both entities of the environment.
+
+If parameters in the form ``id = value'' need to be used, the map
+structure have to be used, for instance:
+\begin{verbatim}
+MAS wumpus {
+
+ infrastructure: Centralised
+
+ environment: jason.eis.EISAdapter(
+ "lib/wumpusenv.jar", // EIS environment
+ agent_entity(ag,agent), // entities
+ map(file,"maps/wumpus.kt5.wld")) // initialisation parameters
+ agents:
+ ag;
+}
+\end{verbatim}
+
+\subsection*{Agent programming}
+
+The agents are programmed as usual. When the agent needs to handle
+entities, two solutions are implemented.
+
+\begin{description}
+\item[perception] every perception given by the EIS environment is
+ annotated with the entity that has produced the perception. E.g.,
+ the perception in the Carriage example is:
+\begin{verbatim}
+carriagePos(2)[entity(robot2),source(percept)]
+\end{verbatim}
+
+\item[action] actions are sent to all entities by default, e.g.:
+\begin{verbatim}
+... push; ...
+\end{verbatim}
+
+ When the programmer wants to define a target entity he/she has to
+ use a special action \texttt{ae} with to arguments: the action and
+ the entity (as string). E.g.:
+\begin{verbatim}
+ae(push,"robot1")
+\end{verbatim}
+\end{description}
+
+As examples, it follows the code of the three agents used in the two
+projects cited in the previous section.
+
+\subsection*{Code of robot1.asl in project demo2ag}
+\begin{verbatim}
+!start. // initial goal
+
++!start // plan to achieve the goal
+ <- push; // act on its entity
+ !!start. // continue doing the same
+\end{verbatim}
+Notice that actions are used as usual in Jason.
+
+
+\subsection*{Code of robot2.asl in project demo2ag}
+\begin{verbatim}
+!start. // initial goal
+
++!start
+ <- wait;
+ push;
+ !!start.
+
++step(X) : carriagePos(C)
+ <- .print("Step ",X,", carriage at ",C).
+\end{verbatim}
+
+\subsection*{Code of robot.asl in project demo1ag}
+\begin{verbatim}
+!start1. // this agent has two intentions, one for each entity
+!start2.
+
+
++!start1 <- ae(push,"robot1"); !!start1. // act on entity robot1
++!start2 <- ae(wait,"robot2"); ae(push,"robot2"); !!start2. // act on entity robot2
+
++step(X) : carriagePos(C)
+ <- .print("Step ",X,", carriage at ",C).
+\end{verbatim}
+
+\subsection*{How to create a project with Jason-EIS integration}
+\begin{enumerate}
+\item Copy eis.jar, eis-jason.jar and the environment .jar files to the lib directory of your project.
+\item Define the environment of Jason project as described in the second section of this document.
+\end{itemize}
+
+
+\section*{EISifying Jason environments}
+
+Jason Environments (those defined to be included in Jason Projects)
+can be used as an EIS environment quite easily. Only entities have to
+be defined, since they do not belong to the Jason concept of environment.
+
+The domestic-robot example is used to illustrate the process. All the
+code and more details are included in the JasonEIS 0.3
+(\url{../examples/domestic-robot/doc/eis-doc.txt}).
+
+\begin{center}
+\begin{rawhtml}
+ <IMG WIDTH="800" SRC="../examples/domestic-robot/doc/overview.png" />
+\end{rawhtml}
+\end{center}
+
+The following steps describes how to ``export'' a Jason Environment to EIS:
+\begin{enumerate}
+\item Create a new class that extends the Jason Adapter for EIS
+ environment. In its constructor instantiate the Jason Environment
+ class and define the entities:
+\begin{verbatim}
+public class EISHouseEnv extends JasonAdapter {
+
+ public EISHouseEnv() {
+ jasonEnv = new HouseEnv(); // create the instance of Jason Environment
+ try {
+ addEntity("robot");
+ addEntity("owner");
+ addEntity("supermarket");
+ } catch (EntityException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
+\end{verbatim}
+ The JasonAdapter class will be in charge to map perception and
+ action between Jason and EIS. It also maps the INIT command to the
+ init method in Jason environments and the KILL command to the stop
+ method. (The other commands are ignored since they do not have
+ counter part in Jason.)
+
+% Note that Jason Environments suppose that the init method is always
+% called; while EIS defines INIT command as optional. The above
+% solution guarantees that init will be called, but it can be called
+% twice (in the constructor and by the INIT command). With that
+% solution the Jason environment have to be prepared to have its init
+% method called twice.
+
+
+\item Create a jar file that includes your new class, the Jason
+ classes, and the Jason-EIS classes. For instance (from build.xml of
+ domestic-robot):
+\begin{verbatim}
+ <target name="jar" depends="compile">
+ <delete file="${ant.project.name}.jar" />
+ <copy file="${jasonJar}" tofile="${ant.project.name}.jar" />
+ <jar update="yes" jarfile="${ant.project.name}.jar" >
+ <fileset dir="${build.dir}">
+ <include name="**/*.class" />
+ </fileset>
+ <fileset dir="${jason-eis-dir}/bin/classes">
+ <include name="jason/**/*.class" />
+ </fileset>
+ <manifest>
+ <attribute name="Main-Class" value="EISHouseEnv"/>
+ </manifest>
+ </jar>
+ </target>
+\end{verbatim}
+\end{enumerate}
+
+
+
+\section*{Data Translation}
+
+Data types in EIS and Jason are different, they are so translated as
+defined in the following table.
+
+\begin{tabular}{cc}
+ \emph{Type in EIS} & \emph{Type in Jason} \\ \hline
+ Identifier & Term \\
+ Numeral & NumberTerm \\
+ ParameterList & ListTerm \\
+ Function & Literal
+\end{tabular}
+
+\end{enumerate}
Added: trunk/applications/eis-jason/doc/jason.css
===================================================================
--- trunk/applications/eis-jason/doc/jason.css (rev 0)
+++ trunk/applications/eis-jason/doc/jason.css 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,81 @@
+/* Century Schoolbook font is very similar to Computer Modern Math: cmmi */
+.MATH { font-family: "Century Schoolbook", serif; }
+.MATH I { font-family: "Century Schoolbook", serif; font-shape: italic }
+.BOLDMATH { font-family: "Century Schoolbook", serif; font-weight: bold }
+
+/* implement both fixed-size and relative sizes */
+SMALL.XTINY { font-size : xx-small }
+SMALL.TINY { font-size : x-small }
+SMALL.SCRIPTSIZE { font-size : smaller }
+SMALL.FOOTNOTESIZE { font-size : small }
+SMALL.SMALL { }
+BIG.LARGE { }
+BIG.XLARGE { font-size : large }
+BIG.XXLARGE { font-size : x-large }
+BIG.HUGE { font-size : larger }
+BIG.XHUGE { font-size : xx-large }
+
+a {
+ text-decoration: none;
+}
+
+/* Page background color */
+body { background-color: white;
+ font-family: verdana, arial, helvetica, sanserif; }
+/* mathematics styles */
+DIV.displaymath { } /* math displays */
+TD.eqno { } /* equation-number cells */
+
+
+H0 {
+ color: black;
+ font-size: 170%;
+ text-align: center;
+ display: block;
+ border-top: 1px solid black;
+ border-bottom: 1px solid black;
+
+ /*margin-left: -1em;*/
+ padding-top: 20px;
+ padding-bottom: 20px;
+ padding-left: 10px;
+ padding-right: 10px;
+}
+
+H1 {
+ color: darkblue;
+ font-size: 130%;
+ display: block;
+ text-align: left;
+
+ padding-top: 10px;
+ padding-bottom: 0px;
+ /*padding-left: 10px; */
+ padding-right: 10px;
+ /*margin-left: -1em;*/
+ border-bottom: 1px solid black;
+}
+
+H2 {
+ color: darkblue;
+ font-size: 110%;
+ display: block;
+ text-align: left;
+
+ padding-top: 5px;
+ padding-bottom: 0px;
+ /*padding-left: 10px; */
+ padding-right: 10px;
+ /*margin-left: -1em;*/
+}
+
+HR { width: 100%; height: 1px;}
+
+PRE
+{
+ padding: 1em;
+ white-space: pre;
+ background-color: #F8F8F8;
+ border: 1px solid black;
+ font-family: Courier, fixed, serif;
+}
Added: trunk/applications/eis-jason/examples/domestic-robot/DomesticRobot.mas2j
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/DomesticRobot.mas2j (rev 0)
+++ trunk/applications/eis-jason/examples/domestic-robot/DomesticRobot.mas2j 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,25 @@
+/* Jason Project
+
+ The environment is accessed by means of EIS
+
+ Jason Agent -> EIS -> Jason Environment
+
+*/
+
+MAS domestic_robot {
+ infrastructure: Centralised
+
+ environment: jason.eis.EISAdapter(
+ "eis-domestic-robot.jar", // jar file containing the environment implementation
+ // agent x entities relation:
+ agent_entity(robot,robot), agent_entity(owner,owner), agent_entity(supermarket,supermarket),
+ // environment parameters
+ map(arg1,gui(on)) // replace for gui(off) to disable the environment GUI
+ )
+
+ agents: robot;
+ owner;
+ supermarket;
+
+}
+
Property changes on: trunk/applications/eis-jason/examples/domestic-robot/DomesticRobot.mas2j
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/domestic-robot/EISHouseEnv.java
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/EISHouseEnv.java (rev 0)
+++ trunk/applications/eis-jason/examples/domestic-robot/EISHouseEnv.java 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,33 @@
+import jason.eis.JasonAdapter;
+import eis.exceptions.EntityException;
+import eis.iilang.Action;
+
+
+public class EISHouseEnv extends JasonAdapter {
+
+ public EISHouseEnv() {
+ jasonEnv = new HouseEnv(); // create the instance of Jason Environment
+ try {
+ addEntity("robot");
+ addEntity("owner");
+ addEntity("supermarket");
+ } catch (EntityException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ protected boolean isSupportedByEntity(Action arg0, String arg1) {
+ return true;
+ }
+
+ @Override
+ protected boolean isSupportedByEnvironment(Action arg0) {
+ return true;
+ }
+
+ @Override
+ protected boolean isSupportedByType(Action arg0, String arg1) {
+ return true;
+ }
+}
Added: trunk/applications/eis-jason/examples/domestic-robot/HouseEnv.java
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/HouseEnv.java (rev 0)
+++ trunk/applications/eis-jason/examples/domestic-robot/HouseEnv.java 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,128 @@
+import jason.asSyntax.*;
+import jason.environment.Environment;
+import jason.environment.grid.Location;
+import java.util.logging.Logger;
+
+public class HouseEnv extends Environment {
+
+ // common literals
+ public static final Literal of = Literal.parseLiteral("open(fridge)");
+ public static final Literal clf = Literal.parseLiteral("close(fridge)");
+ public static final Literal gb = Literal.parseLiteral("get(beer)");
+ public static final Literal hb = Literal.parseLiteral("hand_in(beer)");
+ public static final Literal sb = Literal.parseLiteral("sip(beer)");
+ public static final Literal hob = Literal.parseLiteral("has(owner,beer)");
+
+ public static final Literal af = Literal.parseLiteral("at(robot,fridge)");
+ public static final Literal ao = Literal.parseLiteral("at(robot,owner)");
+
+ static Logger logger = Logger.getLogger(HouseEnv.class.getName());
+
+ HouseModel model = null; // the model of the grid
+ HouseView view = null;
+
+ @Override
+ public void init(String[] args) {
+ model = new HouseModel();
+ if (args.length == 0 || args.length == 1 && !args[0].equals("gui(off)")) {
+ if (view != null) { // in case init is called twice
+ view.setVisible(false);
+ view.dispose();
+ }
+ view = new HouseView(model);
+ model.setView(view);
+ }
+
+ updatePercepts();
+ }
+
+ public void stop() {
+ if (view != null) {
+ view.setVisible(false);
+ view.dispose();
+ }
+ }
+
+
+ /** creates the agents percepts based on the HouseModel */
+ void updatePercepts() {
+ // clear the percepts of the agents
+ clearPercepts("robot");
+ clearPercepts("owner");
+
+ // get the robot location
+ Location lRobot = model.getAgPos(0);
+
+ // add agent location to its percepts
+ if (lRobot.equals(model.lFridge)) {
+ addPercept("robot", af);
+ }
+ if (lRobot.equals(model.lOwner)) {
+ addPercept("robot", ao);
+ }
+
+ // add beer "status" the percepts
+ if (model.fridgeOpen) {
+ addPercept("robot", Literal.parseLiteral("stock(beer,"+model.availableBeers+")"));
+ }
+ if (model.sipCount > 0) {
+ addPercept("robot", hob);
+ addPercept("owner", hob);
+ }
+ }
+
+
+ @Override
+ public boolean executeAction(String ag, Structure action) {
+ System.out.println("["+ag+"] doing: "+action);
+ boolean result = false;
+ if (action.equals(of)) { // of = open(fridge)
+ result = model.openFridge();
+
+ } else if (action.equals(clf)) { // clf = close(fridge)
+ result = model.closeFridge();
+
+ } else if (action.getFunctor().equals("move_towards")) {
+ String l = action.getTerm(0).toString();
+ Location dest = null;
+ if (l.equals("fridge")) {
+ dest = model.lFridge;
+ } else if (l.equals("owner")) {
+ dest = model.lOwner;
+ }
+
+ try {
+ result = model.moveTowards(dest);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ } else if (action.equals(gb)) {
+ result = model.getBeer();
+
+ } else if (action.equals(hb)) {
+ result = model.handInBeer();
+
+ } else if (action.equals(sb)) {
+ result = model.sipBeer();
+
+ } else if (action.getFunctor().equals("deliver")) {
+ // wait 4 seconds to finish "deliver"
+ try {
+ Thread.sleep(4000);
+ result = model.addBeer( (int)((NumberTerm)action.getTerm(1)).solve());
+ } catch (Exception e) {
+ logger.info("Failed to execute action deliver!"+e);
+ }
+
+ } else {
+ logger.info("Failed to execute action "+action);
+ }
+
+ if (result) {
+ updatePercepts();
+ try { Thread.sleep(100); } catch (Exception e) {}
+ }
+ return result;
+ }
+}
Property changes on: trunk/applications/eis-jason/examples/domestic-robot/HouseEnv.java
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/domestic-robot/HouseModel.java
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/HouseModel.java (rev 0)
+++ trunk/applications/eis-jason/examples/domestic-robot/HouseModel.java 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,110 @@
+import jason.environment.grid.GridWorldModel;
+import jason.environment.grid.Location;
+
+/** class that implements the Model of Domestic Robot application */
+public class HouseModel extends GridWorldModel {
+
+ // constants for the grid objects
+ public static final int FRIDGE = 16;
+ public static final int OWNER = 32;
+
+ // the grid size
+ public static final int GSize = 7;
+
+ boolean fridgeOpen = false; // whether the fridge is open
+ boolean carryingBeer = false; // whether the robot is carrying beer
+ int sipCount = 0; // how many sip the owner did
+ int availableBeers = 2; // how many beers are available
+
+ Location lFridge = new Location(0,0);
+ Location lOwner = new Location(GSize-1,GSize-1);
+
+ public HouseModel() {
+ // create a 7x7 grid with one mobile agent
+ super(GSize, GSize, 1);
+
+ // initial location of robot (column 3, line 3)
+ // ag code 0 means the robot
+ setAgPos(0, GSize/2, GSize/2);
+
+ // initial location of fridge and owner
+ add(FRIDGE, lFridge);
+ add(OWNER, lOwner);
+ }
+
+ boolean openFridge() {
+ if (!fridgeOpen) {
+ fridgeOpen = true;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ boolean closeFridge() {
+ if (fridgeOpen) {
+ fridgeOpen = false;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ boolean moveTowards(Location dest) {
+ Location r1 = getAgPos(0);
+ if (r1.x < dest.x) r1.x++;
+ else if (r1.x > dest.x) r1.x--;
+ if (r1.y < dest.y) r1.y++;
+ else if (r1.y > dest.y) r1.y--;
+ setAgPos(0, r1); // move the robot in the grid
+
+ // repaint the fridge and owner locations
+ if (view != null) {
+ view.update(lFridge.x,lFridge.y);
+ view.update(lOwner.x,lOwner.y);
+ }
+ return true;
+ }
+
+ boolean getBeer() {
+ if (fridgeOpen && availableBeers > 0 && !carryingBeer) {
+ availableBeers--;
+ carryingBeer = true;
+ if (view != null)
+ view.update(lFridge.x,lFridge.y);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ boolean addBeer(int n) {
+ availableBeers += n;
+ if (view != null)
+ view.update(lFridge.x,lFridge.y);
+ return true;
+ }
+
+ boolean handInBeer() {
+ if (carryingBeer) {
+ sipCount = 10;
+ carryingBeer = false;
+ if (view != null)
+ view.update(lOwner.x,lOwner.y);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ boolean sipBeer() {
+ if (sipCount > 0) {
+ sipCount--;
+ if (view != null)
+ view.update(lOwner.x,lOwner.y);
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
Added: trunk/applications/eis-jason/examples/domestic-robot/HouseView.java
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/HouseView.java (rev 0)
+++ trunk/applications/eis-jason/examples/domestic-robot/HouseView.java 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,59 @@
+import jason.environment.grid.*;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+
+
+/** class that implements the View of Domestic Robot application */
+public class HouseView extends GridWorldView {
+
+ HouseModel hmodel;
+
+ public HouseView(HouseModel model) {
+ super(model, "Domestic Robot", 700);
+ hmodel = model;
+ defaultFont = new Font("Arial", Font.BOLD, 16); // change default font
+ setVisible(true);
+ repaint();
+ }
+
+ /** draw application objects */
+ @Override
+ public void draw(Graphics g, int x, int y, int object) {
+ Location lRobot = hmodel.getAgPos(0);
+ super.drawAgent(g, x, y, Color.lightGray, -1);
+ switch (object) {
+ case HouseModel.FRIDGE:
+ if (lRobot.equals(hmodel.lFridge)) {
+ super.drawAgent(g, x, y, Color.yellow, -1);
+ }
+ g.setColor(Color.black);
+ drawString(g, x, y, defaultFont, "Fridge ("+hmodel.availableBeers+")");
+ break;
+ case HouseModel.OWNER:
+ if (lRobot.equals(hmodel.lOwner)) {
+ super.drawAgent(g, x, y, Color.yellow, -1);
+ }
+ String o = "Owner";
+ if (hmodel.sipCount > 0) {
+ o += " ("+hmodel.sipCount+")";
+ }
+ g.setColor(Color.black);
+ drawString(g, x, y, defaultFont, o);
+ break;
+ }
+ }
+
+ @Override
+ public void drawAgent(Graphics g, int x, int y, Color c, int id) {
+ Location lRobot = hmodel.getAgPos(0);
+ if (!lRobot.equals(hmodel.lOwner) && !lRobot.equals(hmodel.lFridge)) {
+ c = Color.yellow;
+ if (hmodel.carryingBeer) c = Color.orange;
+ super.drawAgent(g, x, y, c, -1);
+ g.setColor(Color.black);
+ super.drawString(g, x, y, defaultFont, "Robot");
+ }
+ }
+}
Added: trunk/applications/eis-jason/examples/domestic-robot/build.xml
===================================================================
(Binary files differ)
Index: trunk/applications/eis-jason/examples/domestic-robot/build.xml
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/build.xml 2014-11-03 10:51:43 UTC (rev 1818)
+++ trunk/applications/eis-jason/examples/domestic-robot/build.xml 2014-12-10 20:42:30 UTC (rev 1819)
Property changes on: trunk/applications/eis-jason/examples/domestic-robot/build.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle
===================================================================
(Binary files differ)
Index: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle 2014-11-03 10:51:43 UTC (rev 1818)
+++ trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle 2014-12-10 20:42:30 UTC (rev 1819)
Property changes on: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.graffle
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf
===================================================================
(Binary files differ)
Index: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf 2014-11-03 10:51:43 UTC (rev 1818)
+++ trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf 2014-12-10 20:42:30 UTC (rev 1819)
Property changes on: trunk/applications/eis-jason/examples/domestic-robot/doc/cdHouse.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/domestic-robot/doc/eis-doc.txt
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/doc/eis-doc.txt (rev 0)
+++ trunk/applications/eis-jason/examples/domestic-robot/doc/eis-doc.txt 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,68 @@
+EIS Documentation for Domestic-Robot environment
+------------------------------------------------
+
+* Environment description
+
+A domestic robot has the goal of serving beer to its owner. Its
+mission is quite simple, it just receives some beer requests from the
+owner, goes to the fridge, takes out a bottle of beer, and brings it
+back to the owner. However, the robot should also be concerned with
+the beer stock (and eventually order more beer using the supermarket� its
+home delivery service) and some rules hard-wired into the robot by
+the Department of Health (in this example this rule defines the limit
+of daily beer consumption).
+
+A more detailed description is provided in the Jason Book, chapter 3.
+
+* Jar-file: eis-documestic-robot.jar
+
+* Entities: one robot, one owner, and one supermarket
+
+* Actions
+
+ (see overview.png for a Prometheus diagram)
+
+- for entity robot:
+ - open(fridge)
+ - get(beer)
+ - close(fridge)
+ - hand_in(beer)
+ - move_towards(Place)
+
+- for entity owner
+ - sip(beer)
+
+- for entity supermarket
+ - deliver(beer,N)
+
+Most of the actions have obvious meanings, except perhaps
+move_towards. Again, to simplify the example, the way the robot moves
+in the house is greatly simplified. We assume that when it performs
+the action move_towards(fridge), its hardware (or the simulator)
+performs one step towards the fridge, so the robot does not need to be
+concerned with the path to reach the fridge.
+
+* Percepts
+
+- at(robot,Place): to simplify the example, only two places are
+ perceived: fridge (when the robot is in front of the fridge) and
+ owner (when the robot is next to the owner). Thus, depending on its
+ location in the house, the robot will perceive either
+ at(robot,fridge) or at(robot,owner), or of course no at percept at
+ all (in case it is in neither of those places).
+
+- stock(beer,N): when the fridge is open, the robot will perceive how
+ many beers are stored in the fridge (the quantity is represented by
+ the variable N).
+
+- has(owner,beer): is perceived by the robot and the owner when the
+ owner has a (non-empty) bottle of beer.
+
+
+* Environment-management
+
+The environment supports INIT commands with one parameter: "gui(on)" or
+"gui(off)". This parameter creates or not the GUI of the environment.
+
+The KILL command is also supported and simply closes the GUI window.
+
Added: trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png
===================================================================
(Binary files differ)
Index: trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png 2014-11-03 10:51:43 UTC (rev 1818)
+++ trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png 2014-12-10 20:42:30 UTC (rev 1819)
Property changes on: trunk/applications/eis-jason/examples/domestic-robot/doc/overview.png
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+image/png
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar
===================================================================
(Binary files differ)
Index: trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar 2014-11-03 10:51:43 UTC (rev 1818)
+++ trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar 2014-12-10 20:42:30 UTC (rev 1819)
Property changes on: trunk/applications/eis-jason/examples/domestic-robot/eis-domestic-robot.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/java-archive
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/domestic-robot/owner.asl
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/owner.asl (rev 0)
+++ trunk/applications/eis-jason/examples/domestic-robot/owner.asl 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,30 @@
+/* Initial goals */
+
+!get(beer). // initial goal: get a beer
+!check_bored. // initial goal: verify whether I am getting bored
+
++!get(beer) : true
+ <- .send(robot, achieve, has(owner,beer)).
+
++has(owner,beer) : true
+ <- !drink(beer).
+-has(owner,beer) : true
+ <- !get(beer).
+
+// while I have beer, sip
++!drink(beer) : has(owner,beer)
+ <- sip(beer);
+ !drink(beer).
++!drink(beer) : not has(owner,beer)
+ <- true.
+
++!check_bored : true
+ <- .random(X); .wait(X*5000+2000); // i get bored at random times
+ .send(robot, askOne, time(_), R); // when bored, I ask the robot about the time
+ .print(R);
+ !!check_bored.
+
++msg(M)[source(Ag)] : true
+ <- .print("Message from ",Ag,": ",M);
+ -msg(M).
+
Property changes on: trunk/applications/eis-jason/examples/domestic-robot/owner.asl
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/domestic-robot/robot.asl
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/robot.asl (rev 0)
+++ trunk/applications/eis-jason/examples/domestic-robot/robot.asl 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,70 @@
+/* Initial beliefs and rules */
+
+// initially, I believe that there is some beer in the fridge
+available(beer,fridge).
+
+// my owner should not consume more than 10 beers a day :-)
+limit(beer,10).
+
+too_much(B) :-
+ .date(YY,MM,DD) &
+ .count(consumed(YY,MM,DD,_,_,_,B),QtdB) &
+ limit(B,Limit) &
+ QtdB > Limit.
+
+
+/* Plans */
+
++!has(owner,beer)
+ : available(beer,fridge) & not too_much(beer)
+ <- !at(robot,fridge);
+ open(fridge);
+ get(beer);
+ close(fridge);
+ !at(robot,owner);
+ hand_in(beer);
+ //?has(owner,beer);
+ // remember that another beer has been consumed
+ .date(YY,MM,DD); .time(HH,NN,SS);
+ +consumed(YY,MM,DD,HH,NN,SS,beer).
+
++!has(owner,beer)
+ : not available(beer,fridge)
+ <- .send(supermarket, achieve, order(beer,5));
+ !at(robot,fridge). // go to fridge and wait there.
+
++!has(owner,beer)
+ : too_much(beer) & limit(beer,L)
+ <- .concat("The Department of Health does not allow me to give you more than ", L,
+ " beers a day! I am very sorry about that!",M);
+ .send(owner,tell,msg(M)).
+
+
+-!has(_,_)[code_line(CL)]
+ : true
+ <- .current_intention(I);
+ .print("Failed to achieve goal '!has(_,_)'. Line: ",CL,". Current intention is: ",I).
+
++!at(robot,P) : at(robot,P) <- true.
++!at(robot,P) : not at(robot,P)
+ <- move_towards(P);
+ !at(robot,P).
+
+// when the supermarket makes a delivery, try the 'has' goal again
++delivered(beer,_Qtd,_OrderId)[source(supermarket)]
+ : true
+ <- +available(beer,fridge);
+ !has(owner,beer).
+
+// when the fridge is opened, the beer stock is perceived
+// and thus the available belief is updated
++stock(beer,0)
+ : available(beer,fridge)
+ <- -available(beer,fridge).
++stock(beer,N)
+ : N > 0 & not available(beer,fridge)
+ <- -+available(beer,fridge).
+
++?time(T) : true
+ <- time.check(T).
+
Property changes on: trunk/applications/eis-jason/examples/domestic-robot/robot.asl
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/domestic-robot/supermarket.asl
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/supermarket.asl (rev 0)
+++ trunk/applications/eis-jason/examples/domestic-robot/supermarket.asl 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,10 @@
+last_order_id(1). // initial belief
+
+// plan to achieve the goal "order" for agent Ag
++!order(Product,Qtd)[source(Ag)] : true
+ <- ?last_order_id(N);
+ OrderId = N + 1;
+ -+last_order_id(OrderId);
+ deliver(Product,Qtd);
+ .send(Ag, tell, delivered(Product,Qtd,OrderId)).
+
Property changes on: trunk/applications/eis-jason/examples/domestic-robot/supermarket.asl
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/domestic-robot/time/check.java
===================================================================
--- trunk/applications/eis-jason/examples/domestic-robot/time/check.java (rev 0)
+++ trunk/applications/eis-jason/examples/domestic-robot/time/check.java 2014-12-10 20:42:30 UTC (rev 1819)
@@ -0,0 +1,21 @@
+package time;
+
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.StringTermImpl;
+import jason.asSyntax.Term;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class check extends DefaultInternalAction {
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ String time = (new SimpleDateFormat("HH:mm:ss")).format(new Date());
+ ts.getLogger().info("Check Time="+time);
+ return un.unifies(args[0], new StringTermImpl(time));
+ }
+}
+
Property changes on: trunk/applications/eis-jason/examples/domestic-robot/time/check.java
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/elevator/.classpath
===================================================================
(Binary files differ)
Index: trunk/applications/eis-jason/examples/elevator/.classpath
===================================================================
--- trunk/applications/eis-jason/examples/elevator/.classpath 2014-11-03 10:51:43 UTC (rev 1818)
+++ trunk/applications/eis-jason/examples/elevator/.classpath 2014-12-10 20:42:30 UTC (rev 1819)
Property changes on: trunk/applications/eis-jason/examples/elevator/.classpath
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/elevator/.project
===================================================================
(Binary files differ)
Index: trunk/applications/eis-jason/examples/elevator/.project
===================================================================
--- trunk/applications/eis-jason/examples/elevator/.project 2014-11-03 10:51:43 UTC (rev 1818)
+++ trunk/applications/eis-jason/examples/elevator/.project 2014-12-10 20:42:30 UTC (rev 1819)
Property changes on: trunk/applications/eis-jason/examples/elevator/.project
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Added: trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf
===================================================================
(Binary files differ)
Index: trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf
===================================================================
--- trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf 2014-11-03 10:51:43 UTC (rev 1818)
+++ trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf 2014-12-10 20:42:30 UTC (rev 1819)
Property changes on: trunk/applications/eis-jason/examples/elevator/ElevatorEnvironment.pdf
____________...
[truncated message content] |