|
From: <tom...@us...> - 2008-04-25 01:38:36
|
Revision: 1253
http://jason.svn.sourceforge.net/jason/?rev=1253&view=rev
Author: tomklapiscak
Date: 2008-04-24 18:38:25 -0700 (Thu, 24 Apr 2008)
Log Message:
-----------
JASDL pre-release (version 0.1) complete
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/README
trunk/applications/jasdl-owlapi/build.xml
trunk/applications/jasdl-owlapi/examples/commerce/.classpath
trunk/applications/jasdl-owlapi/examples/commerce/bin/build.xml
trunk/applications/jasdl-owlapi/examples/commerce/bin/c-build.xml
trunk/applications/jasdl-owlapi/examples/commerce/commerce.mas2j
trunk/applications/jasdl-owlapi/examples/commerce/onts/commerce.owl
trunk/applications/jasdl-owlapi/examples/commerce/onts/society.owl
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/society.asl
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/customer.asl
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/delivery_van.asl
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/pa.asl
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/shop.asl
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/CommerceEnvironment.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/CommerceView.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/model/CommerceModel.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/model/ModelAgent.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/model/ModelCrate.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/model/ModelCustomer.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/model/ModelCustomerListener.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/model/ModelDeliveryVan.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/model/ModelMobileAgent.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/model/ModelObject.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/model/ModelPA.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/model/ModelShop.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/env/model/Product.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/exception/CommerceException.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/exception/ModelAgentException.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/exception/ModelDeliveryVanException.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/exception/ModelMobileAgentException.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/exception/ModelShopException.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/ui/customer/CustomerUIPanel.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/util/Common.java
trunk/applications/jasdl-owlapi/lib/bebops.jar
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgent.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgentConfigurator.java
trunk/applications/jasdl-owlapi/src/jasdl/util/JASDLCommon.java
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/examples/travel_agent/
trunk/applications/jasdl-owlapi/src/jasdl/test/
Property Changed:
----------------
trunk/applications/jasdl-owlapi/doc/
Modified: trunk/applications/jasdl-owlapi/README
===================================================================
--- trunk/applications/jasdl-owlapi/README 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/README 2008-04-25 01:38:25 UTC (rev 1253)
@@ -2,58 +2,56 @@
Copyright (C) 2008 Thomas Klapiscak (t.g...@du...)
JASDL is distributed under the LGPL license (see COPYING and COPYING.LESSER)
+Thank you for downloading this pre-release of JASDL.
-*** Running JASDL ***
+My apologies that the documentation is somewhat lacking for this release - this will be addressed soon. For now, the AgentSpeak code for the commerce example is richly commented and so should give you an idea of what is going on. For documentation of the additional internal actions that JASDL provides please consult the jasdl.ia.* package javadocs.
-Firstly, please check you are using the latest revision of the entire Jason trunk from the SVN before use.
+PLEASE NOTE: Your .jason/user.properties file must contain the jasonJar property pointing to a Jason .jar built using source from the Jason SVN revision 1240 or later. Please consult Jason documentation for instructions how to do this.
-To run a JASDL agent, its class-path must include all jars under the sub-directories:
- * trunk/applications/jasdl-owlapi/lib
- * trunk/applications/jmca/lib
- * All standard Jason libraries, please ensure that these are built from the latest revision of the Jason trunk.
+JASDL requires JDK version 5 or later to compile and run.
-The (unmodified) travel_agent example (trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j)
-must be run in-situ within the Jason trunk. All necessary ant tasks will be performed by its custom build script.
-
-*** Configuring JASDL ***
+If you have any questions, please don't hesitate to email and I'd be glad to help.
-Please refer to /trunk/jason/applications/jasdl-owlapi/examples/travel_agent/config.mas2j for an example of how to configure JASDL agents.
-
-
-
********************************************************
+
--- Directory Structure ---
The JASDL distribution is structured as such:
-
- README - This file
+ src/ - JASDL source code
+
+ bin/ - Compilation target for JASDL classes
+
+ lib/ - Libraries that JASDL and applications developed using it are dependent upon
+
docs/
- mas2jconfig - Instructions on mas2j setup for a JASDL agent
- java - Java docs for JASDL
+ mas2jconfig - Instructions on configuration of a JASDL agent
+ java - Javadocs for JASDL
-
-
+ examples/ - Examples of applications developed using JASDL
+ commerce/ - An example JASDL application simulating an "e-commerce" scenario. Please consult commerce/README for more information
+
+
+
********************************************************
-*** Known issues ***
+--- Compiling JASDL ---
-The -+ operator does not function properly. Until this problem is fixed the operation must be performed in two steps as shown here:
--+a;
-becomes:
--a;
-+a;
+To compile JASDL run ant on its base directory (the directory this file is in).
-When TG is applied to complex test goals, unifications do not propagate correctly
+********************************************************
-Trigger generalisation is not properly applied when searching for an suitable failure event for intended means that are not in the top level of an intention.
+--- Running JASDL ---
-Complex test goals resulting from queries against the ontology (those whose event has a SE-Literal, e.g. ?hotel(hilton)[o(travel)]), prevent their instantiating intention from properly generating failure events.
+A Jason agent developed using JASDL can be run like any other. Please consult docs/mas2jconfig for instructions on how to setup the .mas2j file of a JASDL agent and examples/commerce/commerce.mas2j for an example.
+********************************************************
+--- Known issues ---
+
Any test queries (and hence ask messages) that might result in the trigger generalisation mechanism being employed will need to include the "jasdl_tg_cause(_)" annotation (the parameter will not be unified and so is best left anonymous for clarity). If future work deems this issue unavoidable, JASDL will make a pass through the plan library and add this annotation automatically where required so the developer need not worry about it.
+*******************************************************
-
-Thank you for your interest in JASDL!
+Finally, thank you for your interest in JASDL! I look forward to hearing your feedback.
Modified: trunk/applications/jasdl-owlapi/build.xml
===================================================================
--- trunk/applications/jasdl-owlapi/build.xml 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/build.xml 2008-04-25 01:38:25 UTC (rev 1253)
@@ -1,44 +1,69 @@
<project basedir="." default="jar" name="jasdl">
- <property name="jason.dir" value="../.."/>
- <property name="apps.dir" value="${jason.dir}/applications"/>
- <property name="jmca.dir" value="${apps.dir}/jmca"/>
- <property name="bebops.dir" value="${apps.dir}/bebops"/>
- <property name="bebops.jar" value="${bebops.dir}/lib/bebops.jar"/>
- <property name="asunit.dir" value="${apps.dir}/as-unit-test"/>
+
+ <property file="${user.home}/.jason/user.properties"/>
+
<property name="source.dir" value="${basedir}/src" />
<property name="build.dir" value="${basedir}/bin" />
- <property name="apidocs.dir" value="${basedir}/doc/api" />
+ <property name="apidocs.dir" value="${basedir}/doc/api/java" />
<property name="lib.dir" value="${basedir}/lib" />
<property name="jasdl.jar" value="${lib.dir}/jasdl.jar" />
+
+
+ <!-- Distribution properties -->
+ <property name="version.jasdl" value="0"/>
+ <property name="release.jasdl" value="1"/>
+
+ <property name="dist.dir" value="${user.home}/tmp/jasdl-owlapi-${version.jasdl}.${release.jasdl}" />
+ <property name="dist.file" value="${dist.dir}.zip" />
+
+
+ <!-- For conveniently building bebops, jason and jmca if present -->
+ <property name="jason.dir" value="../../../jason"/>
+ <property name="apps.dir" value="${jason.dir}/applications"/>
+ <property name="bebops.dir" value="${apps.dir}/bebops"/>
+ <property name="bebops.jar" value="${bebops.dir}/lib/bebops.jar"/>
+ <property name="jmca.dir" value="${apps.dir}/jmca"/>
+ <property name="jmca.jar" value="${jmca.dir}/lib/jmca.jar"/>
+ <property name="jason.dir" value="${apps.dir}/jmca"/>
+
+ <available file="${jason.dir}" type="dir" property="jason.available"/>
+
+ <target name="jason" if="jason.available">
+ <echo message="Building Jason (${jason.dir})"/>
+ <ant dir="${jason.dir}" inheritAll="false" target="jar"/>
+ </target>
-
+ <available file="${bebops.dir}" type="dir" property="bebops.available"/>
+ <target name="bebops" if="bebops.available">
+ <echo message="Building Bebops"/>
+ <ant dir="${bebops.dir}" inheritAll="false"/>
+ <copy file="${bebops.jar}" todir="${lib.dir}"/>
+ </target>
+
+ <available file="${jmca.dir}" type="dir" property="jmca.available"/>
+
+ <target name="jmca" if="jmca.available">
+ <echo message="Building JMCA"/>
+ <ant dir="${jmca.dir}" inheritAll="false"/>
+ <copy file="${jmca.jar}" todir="${lib.dir}"/>
+ </target>
+
+
<path id="project.classpath">
- <pathelement location="${jason.dir}/lib/jason.jar"/>
- <pathelement location="${jmca.dir}/lib/jmca.jar"/>
- <pathelement location="${asunit.dir}/lib/asunit.jar"/>
+ <pathelement location="${jasonJar}"/> <!-- taken from ./jason/user.properties -->
<fileset dir="./lib">
<include name="**/*.jar"/>
</fileset>
</path>
- <path id="test.classpath">
- <path refid="project.classpath" />
- <pathelement location="${build.dir}" />
- </path>
-
<target name="init">
<tstamp/>
<mkdir dir="${build.dir}"/>
- <available file="${bebops.dir}" type="dir" property="bebops.available"/>
</target>
- <target name="bebops" depends="init" if="bebops.available">
- <ant dir="${bebops.dir}" inheritAll="false"/>
- <copy file="${bebops.jar}" todir="${lib.dir}"/>
- </target>
- <target name="compile" depends="init, bebops">
+ <target name="compile" depends="init,jason,bebops,jmca">
<javac srcdir="src" destdir="${build.dir}" debug="true" deprecation="true" optimize="true" nowarn="true" source="1.5" target="1.5">
<classpath refid="project.classpath" />
</javac>
@@ -54,18 +79,6 @@
<delete dir="${apidocs.dir}"/>
</target>
-
- <target name="test" depends="jar">
- <junit printsummary="yes" failureProperty="test.failure">
- <classpath refid="test.classpath" />
- <formatter type="plain" usefile="false" />
- <batchtest>
- <fileset dir="${source.dir}" includes="jasdl/test/*Test.java" />
- </batchtest>
- </junit>
- <fail message="test failed" if="test.failure" />
- </target>
-
<target name="apidoc" depends="compile" >
<javadoc
packagenames="jasdl.*"
@@ -81,5 +94,43 @@
</javadoc>
</target>
+ <target name="dist" depends="clean, jar, apidoc">
+ <echo message="Generating JASDL ${version.jasdl}.${release.jasdl}" />
+
+ <fixcrlf srcdir="${basedir}" eol="crlf" includes="**/*.txt,**/*.bat" />
+
+ <delete failonerror="no" includeEmptyDirs="true" >
+ <fileset dir="${dist.dir}" />
+ <fileset file="${dist.file}" />
+ </delete>
+
+ <mkdir dir="${dist.dir}" />
+
+ <copy todir="${dist.dir}">
+ <fileset dir="${basedir}" includes="build.xml" />
+ <fileset dir="${basedir}" includes="COPYING" />
+ <fileset dir="${basedir}" includes="COPYING.LESSER" />
+ <fileset dir="${basedir}" includes="log4j.properties" />
+ <fileset dir="${basedir}" includes="README" />
+
+ <fileset dir="${basedir}" includes="doc/**/*" />
+ <fileset dir="${basedir}" includes="lib/**/*" />
+ <fileset dir="${basedir}" includes="src/**/*" />
+
+ <fileset dir="${basedir}" includes="examples/commerce/commerce.mas2j" />
+ <fileset dir="${basedir}" includes="examples/commerce/logging.properties" />
+ <fileset dir="${basedir}" includes="examples/commerce/README" />
+
+ <fileset dir="${basedir}" includes="examples/commerce/bin/c-build.xml" />
+ <fileset dir="${basedir}" includes="examples/commerce/src/**/*" />
+ <fileset dir="${basedir}" includes="examples/commerce/onts/**/*" />
+
+
+ </copy>
+
+ <zip basedir="${dist.dir}/.." includes="jasdl-owlapi*/**/*" zipfile="${dist.file}"/>
+ </target>
+
+
</project>
Property changes on: trunk/applications/jasdl-owlapi/doc
___________________________________________________________________
Name: svn:ignore
+ api
Modified: trunk/applications/jasdl-owlapi/examples/commerce/.classpath
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/.classpath 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/.classpath 2008-04-25 01:38:25 UTC (rev 1253)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/home/tom/workspace/jason/lib/jason.jar" sourcepath="/home/tom/workspace/jason/src">
<attributes>
<attribute name="javadoc_location" value="file:/home/tom/workspace/jason/doc/api/"/>
@@ -13,5 +12,6 @@
<attribute name="javadoc_location" value="file:/home/tom/workspace/owlapi/antbuild/build/javadoc/"/>
</attributes>
</classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
Modified: trunk/applications/jasdl-owlapi/examples/commerce/bin/build.xml
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/bin/build.xml 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/bin/build.xml 2008-04-25 01:38:25 UTC (rev 1253)
@@ -2,10 +2,10 @@
<!--
- This file was generated by Jason ?
+ This file was generated by Jason 1.0.2
http://jason.sf.net
- April 22, 2008 - 19:07:12
+ April 25, 2008 - 00:06:35
-->
<project name ="commerce"
@@ -23,7 +23,6 @@
<pathelement location="${build.dir}"/>
<pathelement location="${jasonJar}"/>
<fileset dir="../../lib" > <include name="**/*.jar" /> </fileset>
- <pathelement location="../../../jmca/lib/jmca.jar"/>
</path>
Modified: trunk/applications/jasdl-owlapi/examples/commerce/bin/c-build.xml
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/bin/c-build.xml 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/bin/c-build.xml 2008-04-25 01:38:25 UTC (rev 1253)
@@ -1,15 +1,12 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<project name ="custombuild" basedir="..">
- <!-- Ensure we are using the latest build of Jason -->
- <property name="jasonJar" value="../../../../lib/jason.jar"/>
-
+
<import file="build.xml"/>
- <target name="user-init">
- <ant dir="../../../../" inheritAll="false" target="jar"/>
- <ant dir="../../../jmca" inheritAll="false"/>
- <ant dir="../.." inheritAll="false"/>
+ <target name="user-init">
+ <!-- compile JASDL for convenience -->
+ <ant dir="../../" inheritAll="false" target="jar"/>
</target>
<target name="user-end">
Modified: trunk/applications/jasdl-owlapi/examples/commerce/commerce.mas2j
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/commerce.mas2j 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/commerce.mas2j 2008-04-25 01:38:25 UTC (rev 1253)
@@ -1,12 +1,18 @@
/* .mas2j configuration of the commerce MAS
- * Note:
+ * Notes:
* - this takes advantage of defaults for many of the settings available
* for the configuration of a JASDL agent. Please consult docs/mas2jconfiguration
* for full documentation of these.
* - in the interests of simplicitly, all agents make use of the same label mappings for ontologies
* and (automatic and manual) alias mappings for ontological entities.
- * There could be set arbitrarily for each agent (and the .asl code updated accordingly) and JASDL would
- * still function correctly.
+ * These could be set arbitrarily for each agent (and the .asl code updated accordingly) and JASDL would
+ * still function correctly.
+ * - Each agent in the society must have associated with it an individual in society.owl (with a matching name) and
+ * a ModelAgent instance in the CommerceModel (where its ID matches agent name).
+ * - Although ontology URIs reference related local resources on the file system, they could equally reference (reachable) remote or local
+ * resources (e.g. http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl). In fact, any valid URI can be used here.
+ * - Since we make extensive use of inverse object properties, we enable the experimental "contraction" feature to ensure their removals
+ * are properly handled.
*/
MAS commerce {
@@ -22,7 +28,8 @@
[
jasdl_ontologies="c,s",
jasdl_c_uri="/onts/commerce.owl",
- jasdl_s_uri="/onts/society.owl"
+ jasdl_s_uri="/onts/society.owl",
+ jasdl_useContraction = "true"
]
#3
agentArchClass jasdl.architecture.JASDLAgArch
@@ -33,7 +40,8 @@
[
jasdl_ontologies="c,s",
jasdl_c_uri="/onts/commerce.owl",
- jasdl_s_uri="/onts/society.owl"
+ jasdl_s_uri="/onts/society.owl",
+ jasdl_useContraction = "true"
]
#4
agentArchClass jasdl.architecture.JASDLAgArch
@@ -44,7 +52,8 @@
[
jasdl_ontologies="c,s",
jasdl_c_uri="/onts/commerce.owl",
- jasdl_s_uri="/onts/society.owl"
+ jasdl_s_uri="/onts/society.owl",
+ jasdl_useContraction = "true"
]
#3
agentArchClass jasdl.architecture.JASDLAgArch
@@ -55,8 +64,7 @@
[
jasdl_ontologies="c,s",
jasdl_c_uri="/onts/commerce.owl",
- jasdl_s_uri="/onts/society.owl",
-
+ jasdl_s_uri="/onts/society.owl",
jasdl_useContraction = "true"
]
#3
@@ -66,7 +74,6 @@
classpath: "../../lib/**/*.jar"; // JASDL's libraries
- "../../../jmca/lib/jmca.jar"; // JMCA
aslSourcePath: "src/asl";
}
Modified: trunk/applications/jasdl-owlapi/examples/commerce/onts/commerce.owl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/onts/commerce.owl 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/onts/commerce.owl 2008-04-25 01:38:25 UTC (rev 1253)
@@ -21,7 +21,12 @@
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:commerce="http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#">
- <owl:Ontology rdf:about=""/>
+ <owl:Ontology rdf:about="">
+ <rdfs:comment
+ >Individuals (i.e. brands of product) are not instantiated in this ontology schema (since product catalogue varies between shops and should not be shared information). Instead, they are instantiated by the CommerceModel class using SE-Percepts.</rdfs:comment>
+ <rdfs:comment
+ >The full potential for expressing types of products has not been explored here. For example, we could define a "contains" object property, relating a class of products to a notable ingredient that a customer may wish to avoid such as an allergen (e.g. lactose, gluten, etc).</rdfs:comment>
+ </owl:Ontology>
@@ -292,14 +297,6 @@
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#ReadyMeal -->
-
- <owl:Class rdf:about="#ReadyMeal">
- <rdfs:subClassOf rdf:resource="#Grocery"/>
- </owl:Class>
-
-
-
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#RootVegetable -->
<owl:Class rdf:about="#RootVegetable">
@@ -309,15 +306,6 @@
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#ShepherdsPie -->
-
- <owl:Class rdf:about="#ShepherdsPie">
- <rdfs:subClassOf rdf:resource="#MeatProduct"/>
- <rdfs:subClassOf rdf:resource="#ReadyMeal"/>
- </owl:Class>
-
-
-
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Vegetable -->
<owl:Class rdf:about="#Vegetable">
@@ -326,15 +314,6 @@
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#VegetableCurry -->
-
- <owl:Class rdf:about="#VegetableCurry">
- <rdfs:subClassOf rdf:resource="#ReadyMeal"/>
- <owl:disjointWith rdf:resource="#ShepherdsPie"/>
- </owl:Class>
-
-
-
<!-- http://www.w3.org/2002/07/owl#Thing -->
<owl:Class rdf:about="&owl;Thing"/>
Modified: trunk/applications/jasdl-owlapi/examples/commerce/onts/society.owl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/onts/society.owl 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/onts/society.owl 2008-04-25 01:38:25 UTC (rev 1253)
@@ -40,6 +40,8 @@
<owl:ObjectProperty rdf:about="#employs">
<rdf:type rdf:resource="&owl;InverseFunctionalProperty"/>
+ <rdfs:comment
+ >Inverse of isEmployedBy. An agent can employ many other agents (but each agent may only be employed by one agent)</rdfs:comment>
<rdfs:domain rdf:resource="#Agent"/>
<rdfs:range rdf:resource="#Agent"/>
</owl:ObjectProperty>
@@ -50,6 +52,8 @@
<owl:ObjectProperty rdf:about="#isEmployedBy">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
+ <rdfs:comment
+ >Inverse of isEmployedByemploys. Each agent may only be employed by one agent (but an agent can employ many other agents)</rdfs:comment>
<rdfs:domain rdf:resource="#Agent"/>
<rdfs:range rdf:resource="#Agent"/>
<owl:inverseOf rdf:resource="#employs"/>
@@ -61,6 +65,10 @@
<owl:ObjectProperty rdf:about="#ownedBy">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
+ <rdfs:comment
+ >An agent is owned by exactly one company. Inverse of owns</rdfs:comment>
+ <rdfs:domain rdf:resource="#Agent"/>
+ <rdfs:range rdf:resource="#Company"/>
</owl:ObjectProperty>
@@ -69,6 +77,9 @@
<owl:ObjectProperty rdf:about="#owns">
<rdf:type rdf:resource="&owl;InverseFunctionalProperty"/>
+ <rdfs:comment
+ >A company can own many agents. Inverse of ownedBy</rdfs:comment>
+ <rdfs:domain rdf:resource="#Company"/>
<owl:inverseOf rdf:resource="#ownedBy"/>
</owl:ObjectProperty>
@@ -216,15 +227,15 @@
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/society.owl#delivery_van_3 -->
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/society.owl#delivery_van3 -->
- <rdf:Description rdf:about="#delivery_van_3"/>
+ <DeliveryVan rdf:about="#delivery_van3"/>
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/society.owl#delivery_van_4 -->
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/society.owl#delivery_van4 -->
- <rdf:Description rdf:about="#delivery_van_4"/>
+ <DeliveryVan rdf:about="#delivery_van4"/>
@@ -250,7 +261,7 @@
<Supermarket rdf:about="#shop1">
<employs rdf:resource="#delivery_van1"/>
- <employs rdf:resource="#delivery_van_4"/>
+ <employs rdf:resource="#delivery_van4"/>
<ownedBy rdf:resource="#tescos_inc"/>
</Supermarket>
@@ -268,7 +279,7 @@
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/society.owl#shop3 -->
<GreenGrocers rdf:about="#shop3">
- <employs rdf:resource="#delivery_van_3"/>
+ <employs rdf:resource="#delivery_van3"/>
<ownedBy rdf:resource="#tescos_inc"/>
</GreenGrocers>
@@ -291,20 +302,20 @@
<rdf:Description>
<rdf:type rdf:resource="&owl;AllDifferent"/>
<owl:distinctMembers rdf:parseType="Collection">
- <rdf:Description rdf:about="#customer3"/>
<rdf:Description rdf:about="#customer2"/>
- <rdf:Description rdf:about="#shop2"/>
+ <rdf:Description rdf:about="#delivery_van1"/>
+ <rdf:Description rdf:about="#pa2"/>
+ <rdf:Description rdf:about="#shop1"/>
<rdf:Description rdf:about="#delivery_van2"/>
<rdf:Description rdf:about="#pa1"/>
- <rdf:Description rdf:about="#delivery_van_3"/>
<rdf:Description rdf:about="#customer1"/>
<rdf:Description rdf:about="#tescos_inc"/>
<rdf:Description rdf:about="#shop3"/>
- <rdf:Description rdf:about="#shop1"/>
- <rdf:Description rdf:about="#pa2"/>
- <rdf:Description rdf:about="#delivery_van_4"/>
- <rdf:Description rdf:about="#delivery_van1"/>
+ <rdf:Description rdf:about="#delivery_van3"/>
<rdf:Description rdf:about="#pa3"/>
+ <rdf:Description rdf:about="#shop2"/>
+ <rdf:Description rdf:about="#customer3"/>
+ <rdf:Description rdf:about="#delivery_van4"/>
</owl:distinctMembers>
</rdf:Description>
</rdf:RDF>
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl 2008-04-25 01:38:25 UTC (rev 1253)
@@ -1,15 +1,41 @@
+/*
+ * Copyright (C) 2008 Thomas Klapiscak (t.g...@du...)
+ *
+ * This file is part of JASDL.
+ *
+ * JASDL is free software: you can redistribute it and/or modify
+ * it under the terms of the Lesser GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * JASDL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Lesser GNU General Public License for more details.
+ *
+ * You should have received a copy of the Lesser GNU General Public License
+ * along with JASDL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+!abolish_order(Order) :
- order(Order)[o(c)]
+ order(Order)[o(c)] // must be a known order
<-
- // Abolish beliefs about purchases included in this order, we no longer need them
+ // Abolish beliefs about purchases included in this order, we no longer need them
.findall(Purchase, includes(Order, Purchase)[o(c)], Purchases);
!abolish_purchases(Purchases);
-order(Order)[o(c), source(_)];
- // note: inverse of hasOrder
+ // note: inverse of hasOrder
-hasCustomer(Order, Customer)[o(c), source(_)].
-
+
+/*
+ * Terminal case
+ */
+!abolish_purchases([]).
+
+/*
+ * Recursive case
+ */
+!abolish_purchases([Purchase|Purchases])
<-
!abolish_purchase(Purchase);
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/society.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/society.asl 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/society.asl 2008-04-25 01:38:25 UTC (rev 1253)
@@ -1,9 +1,30 @@
/*
+ * Copyright (C) 2008 Thomas Klapiscak (t.g...@du...)
+ *
+ * This file is part of JASDL.
+ *
+ * JASDL is free software: you can redistribute it and/or modify
+ * it under the terms of the Lesser GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * JASDL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Lesser GNU General Public License for more details.
+ *
+ * You should have received a copy of the Lesser GNU General Public License
+ * along with JASDL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/*
* PA is employed by a single customer (enforced by the fact that employs is inverse functional - and isEmployedBy is functional)
- * Unfortunately, since employs has an inverse property, it cannot also be transitive
+ * Unfortunately, since employs has an inverse property, it cannot also be transitive.
*/
// Using SE-Literals in rules.
// In this case essentially grounding the domain of an object property with a commonly used value (i.e. my name)
isEmployedBy(Employer) :- .my_name(Me) & isEmployedBy(Me, Employer)[o(s)].
+
employs(Employee) :- .my_name(Me) & employs(Me, Employee)[o(s)].
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/customer.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/customer.asl 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/customer.asl 2008-04-25 01:38:25 UTC (rev 1253)
@@ -1,23 +1,49 @@
+/*
+ * Copyright (C) 2008 Thomas Klapiscak (t.g...@du...)
+ *
+ * This file is part of JASDL.
+ *
+ * JASDL is free software: you can redistribute it and/or modify
+ * it under the terms of the Lesser GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * JASDL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Lesser GNU General Public License for more details.
+ *
+ * You should have received a copy of the Lesser GNU General Public License
+ * along with JASDL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
{include("common/society.asl")}
{include("common/commerce.asl")}
-/* Orders specified incrementally and tracked by PA. Allows real-time feedback about e.g. product availability
- * Notice that ontology and syntactic translation is providing a well-defined shared vocabulary between agents.
- * Note with an accurate ontology alignment our agents could communicate even without prior agreement on terms.
+/*
+ * Some Notes:
+ * The ontologies and syntactic translation protocol is providing a well-defined shared vocabulary between agents.
+ * With an accurate ontology alignment our agents could communicate even without prior agreement on terms.
* - the structural information in the ontology gives us a richer palette for semantic matching over and above that available through
* e.g. synonym matching.
- * Assuming central repository of agents and their types (society.owl schema)
+ * We are assuming central repository of agents and their types (society.owl schema). We are also assuming agent's cannot falsify their names
+ * (in fact, security is not an issue considered yet throughout the system).
* IDs are propagated through annotations to match product request brands with quantities
*/
+
+/**
+ * Will instantiate a unique order ID and associated it with this customer if none known.
+ * Fails quietly otherwise.
+ */
+!init
<-
- // ask the PA if it already has a current order listed for this custoemr
+ // ask the PA if it already has a current order listed for this custoemr
?employs(PA);
.send(PA, askOne, order(Order)[o(c)], false);
- // ... it does not, give it a new order ID and associate it with this customer
+ // ... it does not, give it a new order ID and associate it with this customer
?employs(PA);
jasdl.ia.get_anonymous_individual(Order);
@@ -28,7 +54,10 @@
.send(PA, tell, order(Order)[o(c)]);
.send(PA, tell, hasOrder(Me, Order)[o(c)]).
-
+
+/**
+ * Fail quietly
+ */
-!init.
@@ -37,32 +66,31 @@
*/
+ui_product_request(ProductDescription, ShopDescription, Qty)[source(percept)]
<-
- !init;
-
- // Get a PA employed by me
- ?employs(PA);
-
- // Explicitly discard the percept - in case an identical request comes in next perception cycle (we still want to catch it)
- -ui_product_request(ProductDescription, ShopDescription, Qty)[source(percept)];
-
- // Must be defined locally in order to take advantage of syntactic translation.
- // If these were simply sent as string to PA and this agent had different entity aliases / ontology labels
- // then the PA would not be able to understand the request.
-
- jasdl.ia.define_class(suitableProduct, ProductDescription);
- jasdl.ia.define_class(suitableShop, ShopDescription);
-
- // Request a suitable brand from the PA
- .send(PA, achieve, suitable(suitableProduct(_)[o(self)], suitableShop(_)[o(self)], Qty)).
+ !init;
+
+ // Get a PA employed by me
+ ?employs(PA);
+
+ // Explicitly discard the percept - in case an identical request comes in next perception cycle (we still want to catch it)
+ -ui_product_request(ProductDescription, ShopDescription, Qty)[source(percept)];
+
+ // Must be defined locally in order to take advantage of syntactic translation.
+ // If these were simply sent as string to PA and this agent had different entity aliases / ontology labels
+ // then the PA would not be able to understand the request.
+ jasdl.ia.define_class(suitableProduct, ProductDescription);
+ jasdl.ia.define_class(suitableShop, ShopDescription);
+
+ // Request a suitable brand from the PA
+ .send(PA, achieve, suitable(suitableProduct(_)[o(self)], suitableShop(_)[o(self)], Qty)).
/*
* The user has hit the "confirm order" button on the customer UI.
*/
+ui_confirm_order[source(Percept)]
<-
- // Find the PA I employ
+ // Find the PA I employ
?employs(PA);
- // Ask the PA to achieve the state of affairs such that the customer's current order is confirmed with the necessary shop agents.
+ // Ask the PA to achieve the state of affairs such that the customer's current order is confirmed with the necessary shop agents.
.send(PA, achieve, order_confirmed).
/**
@@ -70,18 +98,16 @@
* thus displaying a dialog box on the customer UI.
*/
+message(Message)[source(PA)] : pA(PA)[o(s)]
- <-
- // We no longer need (or want) this belief
+ <-
+ // We no longer need (or want) this belief
-message(Message)[source(PA)];
- // Display the dialog on the customer UI
+ // Display the dialog on the customer UI
message(Message).
/**
* The PA has asked for approval from the customer to make a purchase (identified by the approve annotation).
* This results in the execution of the "approve" environmental action. This displays a confirm dialog on the
* customer UI and suspends the thread awaiting a response.
- * The event and resulting response is annotated with the id annotation, thus allowing the PA to match
- * the approval response with the correct purchase.
*/
+?approve(Brand, Answer)
<-
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/delivery_van.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/delivery_van.asl 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/delivery_van.asl 2008-04-25 01:38:25 UTC (rev 1253)
@@ -1,13 +1,40 @@
+/*
+ * Copyright (C) 2008 Thomas Klapiscak (t.g...@du...)
+ *
+ * This file is part of JASDL.
+ *
+ * JASDL is free software: you can redistribute it and/or modify
+ * it under the terms of the Lesser GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * JASDL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Lesser GNU General Public License for more details.
+ *
+ * You should have received a copy of the Lesser GNU General Public License
+ * along with JASDL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
{include("common/society.asl")}
{include("common/commerce.asl")}
+/**
+ * The code for this agent doesn't make particularily intersting use of JASDL features,
+ * so don't worry about it too much.
+ */
+
!init.
+/**
+ * All delivery vans are available at the start of the simulation.
+ */
+!init
<-
.my_name(Me);
?isEmployedBy(Me, Employer)[o(s)];
- .send(Employer, tell, available(Me)).
+ .send(Employer, tell, available).
+!hasPosition(Me, X, Y)[source(Employer)] : .my_name(Me) & hasPosition(Me, X, Y) & isEmployedBy(Employer)
@@ -20,7 +47,7 @@
isEmployedBy(Employer)
<-
move_towards(X, Y);
- .wait(10); // <- simulate movement speed
+ .wait(5); // <- simulate movement speed
!!hasPosition(Me, X, Y)[source(Employer)].
@load_all_2[atomic]
@@ -47,6 +74,6 @@
unload(Purchase); // Unload purchase
!!unload(Purchases)[source(Employer)]. // Unload remaining purchases
-+?~cargo(Purchase) : not cargo(Purchase). // (not cargo) implies ~cargo for the delivery van
++?~cargo(Purchase) : not cargo(Purchase). // (not cargo) implies ~cargo for the delivery van (i.e. we make CWA for this belief)
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/pa.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/pa.asl 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/pa.asl 2008-04-25 01:38:25 UTC (rev 1253)
@@ -1,3 +1,22 @@
+/*
+ * Copyright (C) 2008 Thomas Klapiscak (t.g...@du...)
+ *
+ * This file is part of JASDL.
+ *
+ * JASDL is free software: you can redistribute it and/or modify
+ * it under the terms of the Lesser GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * JASDL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Lesser GNU General Public License for more details.
+ *
+ * You should have received a copy of the Lesser GNU General Public License
+ * along with JASDL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
{include("common/society.asl")}
{include("common/commerce.asl")}
@@ -2,4 +21,6 @@
-/** Plans that are called by the customer agent */
-
+/**
+ * Accepts two SE-Literals used to represent two classes, one describing a desired type of product and the other the
+ * type of shop that should (initially) be asked.
+ */
+!suitable(ProductClass, ShopClass, Qty)
@@ -14,14 +35,15 @@
jasdl.ia.get_individual(ShopClass, Shop);
// Generate a unique (guaranteed across entire agent society) request identifier (individual) for the new purchase
- jasdl.ia.get_anonymous_individual(ID);
-
+ jasdl.ia.get_anonymous_individual(ID);
+
+ // Get the rendering in Namespace-prefix Manchester OWL Syntax
jasdl.ia.get_class_definition(ProductClass, ProductDescription);
- // Add the condition that the product must be in stock (this is not something the customer should be concerned with)
+ // Add the condition that the product must be in stock (this is not something the customer should be concerned with)
.concat("(",ProductDescription,") and c:hasInStock some integer [ >= ",Qty,"]",ProductDescriptionInStock);
- // Parse the product description into a class
+ // Parse the ammended product description into a class
jasdl.ia.define_class(productInStock, ProductDescriptionInStock);
.print("Asking ",Shop,":", ProductDescriptionInStock);
@@ -29,15 +51,16 @@
// Ask for all brands that match these criteria
.send(Shop, askOne,
productInStock(Brand)[o(self), id(ID), stockist(Stockist), jasdl_tg_cause(_)],
- productInStock(Brand)[o(self), id(ID), stockist(Stockist), jasdl_tg_cause(_)]);
-
- .print(Stockist);
+ productInStock(Brand)[o(self), id(ID), stockist(Stockist), jasdl_tg_cause(_)]);
// ask for the customer's approval
!!approve(ID, Brand, ProductDescription, Shop, Qty, Order, Stockist).
-
+/**
+ * Results in the "approve" customer environmental action. If this succeeds, we commit the purchase
+ * details to the belief base.
+ */
+!approve(ID, Brand, ProductDescription, Shop, Qty, Order, Stockist)
<-
?isEmployedBy(Customer);
@@ -51,96 +74,95 @@
+includes(Order, ID)[o(c)];
+purchase(ID)[o(c)];
+hasQuantity(ID, Qty)[o(c)].
-
+
+/**
+ * The customer has rejected this purchase. Try asking the shop for other brands of this type.
+ */
-!approve(ID, Brand, ProductDescription, Shop, Qty, Order, Stockist)
<-
?isEmployedBy(Customer);
// Get the class describing the type of product, adding the additional requirement that it
// also not be the individual rejected by the customer
- jasdl.ia.define_class(ammendedProductClass, "(",ProductDescription,") and not {c:",Brand,"}");
+ jasdl.ia.define_class(ammendedProductClass, "(",ProductDescription,") and (not {c:",Brand,"})");
// We use the same achieve goal used by a customer here, effectively emulating a customer request, but with the ammended product
// description, given the customer's rejection
!suitable(ammendedProductClass(_)[o(self)], shop(Shop)[o(s)], Qty).
-
+/**
+ * The product request has failed. No shop can find a product matching these (possibly ammended) criteria.
+ */
-!suitable(ProductClass, ShopClass, Qty)
<-
?isEmployedBy(Customer);
.send(Customer, tell, message("I am sorry but I am unable to service your request."));
.fail.
-
+/**
+ * The customer has confirmed their current order, instantiate the order confirmation process.
+ */
+!order_confirmed[source(Customer)] : isEmployedBy(Customer)
- <-
+ <-
?hasOrder(Customer, Order)[o(c)];
.findall(ID, purchase(ID)[o(c)], Purchases);
!order_confirmed(Purchases, []).
+/**
+ * The customer has attempted to confirm an order before any purchases have been made, let them know.
+ */
-!order_confirmed[source(Customer)] : isEmployedBy(Customer) & not hasOrder(Customer, _)[o(c)]
- <-
+ <-
.send(Customer, tell, message("You must request some products first")).
+/**
+ * Recursive case of the order confirmation process.
+ */
+!order_confirmed([Purchase|Purchases], Shops)
<-
- // Get the details of this purchase
+ // Get the details of this purchase
?hasBrand(Purchase, Brand)[o(c)];
?hasQuantity(Purchase, Qty)[o(c)];
- // JASDL current doesn't support domain-unground property queries
- // Instead, we use inverse properties such as this one (includedIn is the inverse of includes)
- // Note that both types of assertions have exactly the same meaning as far as JASDL is concerned
+
+ // JASDL current doesn't support domain-unground property queries
+ // Instead, we use inverse properties such as this one (includedIn is the inverse of includes)
+ // Note that both types of assertions have exactly the same meaning as far as JASDL is concerned
?includedIn(Purchase, Order)[o(c)];
- // ... and send them to the appropriate shop agent
+ // ... and send them to the appropriate shop agent
?hasShop(Purchase, Shop)[o(c)];
.send(Shop, tell, purchase(Purchase)[o(c)]);
.send(Shop, tell, includedIn(Purchase, Order)[o(c)]);
.send(Shop, tell, hasBrand(Purchase, Brand)[o(c)]);
.send(Shop, tell, hasQuantity(Purchase, Qty)[o(c)]);
- // Confirm the remaining purchases
+ // Confirm the remaining purchases
+ // (Here we drop the head of Purchases, and add to the list of shops responsible for delivery of this order)
!order_confirmed(Purchases, [Shop|Shops]).
-
+/**
+ * Terminal case of the order confirmation process.
+ */
+!order_confirmed([], Shops)
<-
- // Now we have sent all purchase details, send the location where the order should be delivered to (i.e. the customer)
+ // Now we have sent all purchase details, send the location where the order should be delivered to (i.e. the customer)
?isEmployedBy(Customer);
?hasOrder(Customer, Order)[o(c)];
+
+ // Inform ALL shops involved in this purchase for whom this order is on behalf of
.send(Shops, tell, hasCustomer(Order, Customer)[o(c)]);
- // ... and finish with the order itself, which will instantiate the dispatch process in the shop agents
+ // ... and finish with the order itself, which will instantiate the dispatch process in ALL invovled shop agents
.send(Shops, tell, order(Order)[o(c)]);
- // abolish the order (and all included purchases), we no longer need it
+ // abolish the order (and all included purchases), we no longer need it
!abolish_order(Order);
- // Inform the customer
- .send(Customer, tell, message("Your order has been confirmed and will be dispatched shortly.")).
-
-
-/******************************************************************************/
-
-
-
-+failed(Message)[id(ID), source(Shop)] :
- shop(Shop)[o(s)]
- <-
- // Remove this belief, we no longer need it
- -failed(Message)[id(ID), source(Shop)];
-
- // Delete all trace of the purchase
- !abolish_purchase(ID);
-
- // Get the customer
- ?isEmployedBy(Customer);
-
- // Pass the news on to the customer
+ // Inform the customer
+ .concat("Your order has been confirmed and will be dispatched shortly by ",Shops," respectively.", Message);
.send(Customer, tell, message(Message)).
-
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/shop.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/shop.asl 2008-04-24 22:26:31 UTC (rev 1252)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/shop.asl 2008-04-25 01:38:25 UTC (rev 1253)
@@ -1,3 +1,22 @@
+/*
+ * Copyright (C) 2008 Thomas Klapiscak (t.g...@du...)
+ *
+ * This file is part of JASDL.
+ *
+ * JASDL is free software: you can redistribute it and/or modify
+ * it under the terms of the Lesser GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * JASDL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Lesser GNU General Public License for more details.
+ *
+ * You should have received a copy of the Lesser GNU General Public License
+ * along with JASDL. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
{include("common/society.asl")}
{include("common/commerce.asl")}
@@ -2,7 +21,9 @@
/*
- * Unify with a shop that is a member of the class specified by Expression
- *
- * This is a good example of how certain JASDL features (such as run-time class definition and SE-Literal queries)
+ * Unify PossibleStockist with a shop that is a member of the class specified by Expression. Additionally, we add
+ * the constraints that it not be exhausted (i.e. already tried and failed) for this purchase ID, it is in the same
+ * company as this shop and is not this shop.
+ * This is a good example of how certain JASDL features (such as SE-Literal queries and run-time class definitions)
* can be conveniently expressed within a rule.
*/
+
possibleStockist(ID, Expression, PossibleStockist) :-
@@ -14,7 +35,6 @@
not exhausted(ID)[source(PossibleStockist)] &
not (PossibleStockist == Me).
-
/**
* Unify with a shop, other than this one, that is owned by the same company as this one.
@@ -24,120 +44,144 @@
.my_name(Me) &
ownedBy(Me, Company)[o(s)] &
owns(Company, Shop)[o(s)] &
- (not Shop==Me).
+ (not Shop==Me).
-
/*
- * This shop has managed to find a suitable product in its belief base, directly
- * in response to a PA. Respond to the PA, keeping id annotation intact so the
- * PA can match this response with the customer's request.
+ * The single term of the jasdl_tg_cause annotation is unified with the original cause of this trigger generalisation.
+ * This allows us to use a generalised plan, while still having access to the information given by the (more specific) event that
+ * led to the invocation of this plan.
+ *
+ * This shop has managed to find a suitable product in its belief base.
+ * We know this is the case since the original query leading to generalisation to this is in the context (OriginalQuery).
+ * Respond to the PA, keeping id annotation intact so we can match this response with the customer's request elsewhere.
+ * The up till now unground stockist annotation is grounded with the name of this agent - ultimately informing the PA
+ * of whom it should submit the delivery request to.
*/
@found_product_for_PA
+?product(Brand)[o(c), id(ID), stockist(Me), jasdl_tg_cause(OriginalQuery)] :
OriginalQuery // the agent has found a suitable product within its belief base
- <-
+ <-
.print("Recieved request and is able to service it");
.my_name(Me);
jasdl.ia.get_individual(OriginalQuery, Brand).
+
+/** TODO: Match other, more specific, types of product and opportunistically present special offers to the PA
+ * i.e. "buy two get one free on all types of milk" using a plan such as:
+ *
+ * +?milk(Brand)[o(c), id(ID), stockist(Me), jasdl_tg_cause(OriginalQuery)] :
+ * OriginalQuery
+ * <-
+ * ...
+ */
/**
- * Notice that the two plans below also with "not OriginalQuery" in their context will take precence over this one,
+ * We are unable to find a suitable product, moreover, we are unable to establish a possible stockist to try on behalf of the PA.
+ * Notice that the plans below also with "not OriginalQuery" in their context will take precence over this one,
* since their are both more specific than owl:thing (which is the most general concept) - additionally, plan ordering
* is irrelevant here since JASDL automatically assigns precence according to concept specificity for trigger generalisation
*/
-+?thing(Brand)[o(owl), id(_), stockist(_), jasdl_tg_cause(OriginalQuery)] :
- not OriginalQuery // the agent has found a suitable product within its belief base
++?thing(Brand)[o(owl), id(ID), stockist(_), jasdl_tg_cause(OriginalQuery)] :
+ not OriginalQuery // the agent has not found a suitable product within its belief base
<-
+ !reset(ID);
.print("Recieved request and is UNABLE to service it");
.fail.
/**
* Requested a type of product that this agent cannot supply, try asking any other shop.
*/
-+?product(Brand)[o(c), id(ID), stockist(PossibleStockist), jasdl_tg_cause(OriginalQuery)] :
- not OriginalQuery &
- possibleStockist(ID, "s:shop", PossibleStockist)
- <-
- .print("Unknown GENERAL PRODUCT requested");
- !exhausted(ID);
- ?stocked_by_another_shop(PossibleStockist, ID, OriginalQuery, Brand).
++?product(Brand)[o(c), id(ID), stockist(Stockist), jasdl_tg_cause(OriginalQuery)] :
+ not OriginalQuery & // the agent has not found a suitable product within its belief base
+ possibleStockist(ID, "s:shop", Try)
+ <-
+ .print("Unknown GENERAL PRODUCT requested");
+ !exhausted(ID);
+ ?stocked_by_another_shop(Try, ID, OriginalQuery, Brand, Stockist).
/**
* Requested a type of vegetable product that this agent cannot supply, try asking a greengrocer or a supermarket.
*/
-+?vegetable(Brand)[o(c), id(ID), stockist(PossibleStockist), jasdl_tg_cause(OriginalQuery)] :
- not OriginalQuery &
- possibleStockist(ID, "s:greenGrocers or s:supermarket", PossibleStockist)
- <-
- .print("Unknown VEGETABLE PRODUCT requested");
- !exhausted(ID);
- ?stocked_by_another_shop(PossibleStockist, ID, OriginalQuery, Brand).
++?vegetable(Brand)[o(c), id(ID), stockist(Stockist), jasdl_tg_cause(OriginalQuery)] :
+ not OriginalQuery & // the agent has not found a suitable product within its belief base
+ possibleStockist(ID, "s:greenGrocers or s:supermarket", Try)
+ <-
+ .print("Unknown VEGETABLE PRODUCT requested");
+ !exhausted(ID);
+ ?stocked_by_another_shop(Try, ID, OriginalQuery, Brand, Stockist).
/**
* Requested a type of meat product that this agent cannot supply, try asking a butchers.
*/
-+?meatProduct(Brand)[o(c), id(ID), stockist(PossibleStockist), jasdl_tg_cause(OriginalQuery)] :
- not OriginalQuery &
- possibleStockist(ID, "s:butchers", PossibleStockist)
- <-
- .print("Unknown MEAT PRODUCT requested");
- !exhausted(ID);
- ?stocked_by_another_shop(PossibleStockist, ID, OriginalQuery, Brand).
++?meatProduct(Brand)[o(c), id(ID), stockist(Stockist), jasdl_tg_cause(OriginalQuery)] :
+ not OriginalQuery & // the agent has not found a suitable product within its belief base
+ possibleStockist(ID, "s:butchers", Try)
+ <-
+ .print("Unknown MEAT PRODUCT requested");
+ !exhausted(ID);
+ ?stocked_by_another_shop(Try, ID, OriginalQuery, Brand, Stockist).
+
+/**
+ * Try the shop identified by PossibleStockist, preserving the necessary annotations.
+ */
++?stocked_by_another_shop(PossibleStockist, ID, Query, Answer, Stockist) :
+ shopInSameCompany(PossibleStockist) // Must be a known shop in this company
+ <-
+ .print("Trying ", PossibleStockist);
+ .add_annot(Query, id(ID), Q1);
+ .add_annot(Q1, stockist(Stockist), Q2);
+ .add_annot(Q2, jasdl_tg_cause(_), Q3);
+ .send(PossibleStockist, askOne, Q3, Q3);
+ jasdl.ia.get_individual(Q3, Answer).
+
-+?stocked_by_another_shop(PossibleStockist, ID, Query, Answer)
- <-
- .print("Trying ", PossibleStockist);
- .add_annot(Query, id(ID), Q1);
- .add_annot(Q1, stockist(PossibleStockist), Q2);
- .add_annot(Q2, jasdl_tg_cause(_), Q3);
- .send(PossibleStockist, askOne, Q3, Q3);
- jasdl.ia.get_individual(Q3, Answer).
-
-
-
/**
- * Inform all shops that I have already been tried for this order and unable to service it
+ * Inform all other known shops within this company that I have already been tried for this order and unable to service it
* (so I am not asked again)
*/
+!exhausted(ID)
- <-
- .findall(Shop, shop(Shop)[o(s)], Shops);
- .send(Shops, tell, exhausted(ID)).
-
+ <-
+ .print("Setting exhausted status for purchase ", ID);
+ .findall(Shop, shopInSameCompany(Shop), Shops);
+ .send(Shops, tell, exhausted(ID)).
+
+/**
+ * Reset the exhausted status for a product for this shop and across all other known shops in this company.
+ */
+!reset(ID)
- <-
- .findall(Shop, shopInSameCompany(Shop), Shops);
- .send(Shops, untell, exhausted(ID)).
-
+ <-
+ .print("Resetting exhausted status for purchase ", ID);
+ .findall(Shop, shopInSameCompany(Shop), Shops);
+ .abolish(exhausted(ID)[source(_)]);
+ .send(Shops, untell, exhausted(ID)[source(_)]).
+/**
+ * Another shop has "reset" the exhausted status for a product, ensure all exhausted beliefs for this purchase ID are abolished accordingly.
+ */
+-exhausted(ID)[source(Shop)] :
+ shopInSameCompany(Shop)
+ <-
+ .abolish(exhausted(ID)).
+
/**
* All plans below this point deal with coordinating delivery with a delivery van employed by the shop.
* Note that these are not so interesting in terms of exploring JASDL extensions to Jason's core functionality, so
* don't worry about them too much.
*/
-
-/**
- * Attempts to find an avaiable delivery van (identified by available(Van)).
- * Once found, it deletes the van's status as available.
- * This plan must be atomic to prevent a van being allocated simultaneously to more
- * than one order (i.e. multiple ?'s before we get a chance to remove the van's available status)
- */
-
/**
* An order request has been recieved from a PA, coordinate delivery of it
*/
+order(Order)[o(c), source(PA)] :
hasCustomer(Order, Customer)[o(c)] &
employs(Customer, PA)[o(s)]
- <-
+ <-
// Delopy crates containing product
!deploy(Order);
// Obtain an available van (or suspend this intention until one it available)
- !allocate_available(Van);
+ !wait_available(Van);
// Instruct this van to move to shop's position
!recall(Van);
// Instruct the van to load the deployed products into its cargo hold
@@ -149,106 +193,120 @@
// Abolish beliefs about this order (and all included purchases), we no longer need them
!abolish_order(Order);
// Make the van available again
- +available(Van).
-
-@available[atomic]
-+!allocate_available(Van)
- <-
- ?available(Van)[source(_)];
- -available(Van)[source(_)].
+ +available[source(Van)].
+
-/*
+ /*
* The agent has attempted to find an available van (see above) within the belief base but has failed.
- * Simply suspend the intention until a van notifies the agent that it is available.
+ * Wait until we become aware that there is an agent that it is available (thus resuming the intention).
*/
-+?available(Van)
- <-
- .concat("+",available(Van)[source(_)], WaitFor);
- .wait(WaitFor);
- ?available(Van)[source(_)].
++!wait_available(Van) : not available[source(Van)]
+ <-
+ .wait(800);
+ !wait_available(Van).
+
/**
+ * This must remain atomic to prevent the same van being allocated more than once at any one time.
+ */
+ @allocate_available[atomic]
++!wait_available(Van) : available[source(Van)]
+ <-
+ -available[source(Van)].
+
+
+/**
* Achieve the state of affairs such that a van has loaded an entire order into its cargo.
* (Suspends the intention until this is so)
*/
+!load(Order, Van) : .my_name(Me) & inVicinityOf(Van)
- <-
- -hasPosition(Van, X, Y)[source(Van)];
- .findall(PID, includes(Order, PID)[o(c)], PIDs);
- .send(Van, achieve, load(PIDs));
- L=loading_complete[source(Van)];
- .concat("+", L, WaitFor);
- .wait(WaitFor);
- -L.
-
+ <-
+ -hasPosition(Van, X, Y)[source(Van)];
+ .findall(PID, includes(Order, PID)[o(c)], PIDs);
+ .send(Van, achieve, load(PIDs));
+ !wait_loading_complete(Van).
+
++!wait_loading_complete(Van) : not loading_complete[source(Van)]
+ <-
+ .wait(400);
+ !wait_loading_complete(Van).
+
++!wait_loading_complete(Van) : loading_complete[source(Van)]
+ <-
+ -loading_complete[source(Van)].
+
/**
* Achieve the state of affairs such that a van has unloaded its entire cargo at its current destination
* (Suspends the intention until this is so)
*/
+!unload(Order, Van)
- <-
- .findall(PID, includes(Order, PID)[o(c)], PIDs);
- .send(Van, achieve, unload(PIDs));
- L=unloading_complete[source(Van)];
- .concat("+", L, WaitFor);
-...
[truncated message content] |