|
From: <tom...@us...> - 2008-04-22 18:25:21
|
Revision: 1240
http://jason.svn.sourceforge.net/jason/?rev=1240&view=rev
Author: tomklapiscak
Date: 2008-04-22 11:25:14 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
Pre-release nearly complete
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/README
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/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/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/ModelShop.java
trunk/applications/jasdl-owlapi/examples/commerce/src/java/commerce/ui/customer/CustomerUIPanel.java
trunk/applications/jasdl-owlapi/src/jasdl/JASDLParams.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgent.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgentConfigurator.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/package.html
trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JASDLPlanLibrary.java
trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/JASDLBeliefBase.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/JASDLOntologyManager.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/define_class.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/get_anonymous_individual.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/get_class_definition.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/get_functor.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/get_individual.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/get_types.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/is_annotation_gathering_enabled.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/is_belief_revision_enabled.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/is_contraction_enabled.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/set_annotation_gathering_enabled.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/set_belief_revision_enabled.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/set_contraction_enabled.java
trunk/applications/jasdl-owlapi/src/jasdl/util/JASDLCommon.java
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/NsPrefixOWLEntityChecker.java
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/URIOWLEntityChecker.java
Added Paths:
-----------
trunk/applications/jasdl-owlapi/doc/
trunk/applications/jasdl-owlapi/doc/mas2jconfiguration
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/src/jasdl/bridge/DLUnifier.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/send.java
Property Changed:
----------------
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/
Modified: trunk/applications/jasdl-owlapi/README
===================================================================
--- trunk/applications/jasdl-owlapi/README 2008-04-22 16:46:22 UTC (rev 1239)
+++ trunk/applications/jasdl-owlapi/README 2008-04-22 18:25:14 UTC (rev 1240)
@@ -20,6 +20,23 @@
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
+
+ docs/
+ mas2jconfig - Instructions on mas2j setup for a JASDL agent
+ java - Java docs for JASDL
+
+
+
+
+********************************************************
+
*** Known issues ***
The -+ operator does not function properly. Until this problem is fixed the operation must be performed in two steps as shown here:
@@ -32,6 +49,11 @@
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.
+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.
+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!
Added: trunk/applications/jasdl-owlapi/doc/mas2jconfiguration
===================================================================
--- trunk/applications/jasdl-owlapi/doc/mas2jconfiguration (rev 0)
+++ trunk/applications/jasdl-owlapi/doc/mas2jconfiguration 2008-04-22 18:25:14 UTC (rev 1240)
@@ -0,0 +1,161 @@
+The following file documents how to configure a Jason agent to make use of JASDL.
+
+
+********************************************************
+--- Necessary settings for standard Jason parameters ---
+
+For each JASDL agent, the following must be set to use JASDL classes (or extensions thereof) as shown.
+
+ agentArchClass jasdl.architecture.JASDLAgArch
+ agentClass jasdl.asSemantics.JASDLAgent
+ beliefBaseClass jasdl.bb.JASDLBeliefBase;
+
+If your MAS makes use of an environment class, the following must be set to use a JASDL class (or an extension thereof) as shown:
+
+ environment: jasdl.env.JASDLEnvironment
+
+Additionally, we must ensure all of the libraries JASDL is dependent upon are in the classpath of a JASDL agent.
+This is not an issue if the libraries are under the agent's directory. However, to avoid unneccesary duplication,
+since commerce and travel_agent are nested within the JASDL distribution, we set the classpath for these as follows:
+
+ classpath: "../../lib/**/*.jar";
+
+********************************************************
+
+
+********************************************************
+--- Necessary JASDL agent settings ---
+
+For each JASDL agent, the following must be specified in its user parameters.
+
+ jasdl_ontologies = "<o_1>, <o_2> ...., <o_n>"
+
+ Where each <o_n> is an atomic label used to identify the ontology within the "o" annotation in the agent's
+ .asl code.
+
+Additionally, for each <o_n>, we must specify the reachable physical URI of the ontology so it can be loaded, as follows:
+
+ jasdl_<o_n>_uri = "<uri>"
+
+ Where <uri> is a valid URI. Note that this can also be specified relative to the execution path of the agent (i.e. the location
+ of the .mas2j file).
+
+********************************************************
+
+
+********************************************************
+--- Optional JASDL agent settings ---
+
+For each JASDL agent, the following settings may be specified in its user parameters. Note that these configure advanced
+features of JASDL, and will not be necessary in some circumstances.
+
+ jasdl_<o>_mapping_strategies = "<class_1>, <class_2> ..., <class_n>"
+
+ Where <o> is some atomic ontology label specified in jasdl_ontologies (see above), and each <class_n>
+ is the fully-qualified class name of an implementation of the jasdl.bridge.mapping.aliasing.MappingStrategy interface.
+ This specifies the automatic mapping strategies that will be applied to the ontological entities
+ contained within <o>. Such a strategy should apply a consistent mapping from the fragment of an entity URI
+ to the atomic functor used to refer to it in the agent's .asl code. For example:
+
+ jasdl_travel_mapping_strategies = "jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy",
+ which decapitalises the first letter of any resource whose fragment begins with an upper case letter
+ (in order to make it compatible with AgentSpeak syntax). For instance, this would cause
+ "http://www.owl-ontologies.com/travel.owl#Hotel" to map to the alias "hotel", thus we could refer to
+ this entity with the SE-Literal hotel(X)[o(travel)].
+
+ Note that if an automatic mapping strategy results in a name clash (two identical aliases), JASDL will
+ assign the offending resource an anonymous label. For example, if we applied the strategy above and we had the
+ resources "http://.../travel.owl#Hotel" and "http://.../travel.hotel" (encountered in that order), the latter
+ would be assigned the alias "anon_alias_<n>", where <n> is an integer guaranteeing the uniqueness of the
+ anonymous label.
+
+ This setting defaults to "jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy"
+
+ jasdl_default_mappings_strategies = "<class_1>, <class_2> ..., <class_n>"
+
+ Where each <class_n> is the fully-qualified class name of an implementation of the jasdl.bridge.mapping.aliasing.MappingStrategy interface.
+ This specifies the mapping strategies that will be applied to any ontologies / ontological entities instantiated
+ during the execution of the agent.
+
+ This setting defaults to "jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy"
+
+ jasdl_<o>_manual_mappings = "<alias_1>=<fragment_1> ... , <alias_n>=<fragment_n>"
+
+ Where each alias_n is the desired alias for the entity referred to by the URI fragment <fragment_n> (which identifies a resource
+ in the ontology referred to by <0>, e.g. "Hotel" might refer to "http://.../travel.owl#Hotel"). We might wish to map
+ the alias "hotel" to this resource, which would achieve using the pair "hotel=Hotel".
+
+ It is predicted that this setting will be of most use when the agent designer is aware of, and wishes to prevent,
+ a name clash that will result from the automatic mapping strategies specified (thus causing an entity to be assigned an
+ anonymous alias).
+
+ This setting defaults to ""
+
+ jasdl_reasonerClass = "<class>"
+
+ Where <class> is the fully-qualified class name of an implementation of the org.semanticweb.owl.inference.OWLReasoner
+ interface, supported by the OWL-API. Currently, JASDL defaults to use Pellet ("org.mindswap.pellet.owlapi.Reasoner").
+ However, there is experimental support for FaCT++ ("uk.ac.manchester.cs.factplusplus.owlapi.Reasoner"), but you advised
+ against its use for now, since JASDL support for it is largely untested and very buggy.
+
+ This setting defaults to "org.mindswap.pellet.owlapi.Reasoner".
+
+The following features are used to enable or support features of JASDL that are currently highly experimental. Moreover,
+they are all computationally expensive to execute and can slow the execution of a JASDL agent significantly.
+As a result, their usage is (for now) discouraged.
+
+ jasdl_useAnnotationGathering = "<boolean>"
+
+ If set to "true", when quering the belief base for an SE-Literal, the resulting SE-Literal, x, will possess
+ not only the annotations explicitly asserted to belong to it, but also the annotations of all SE-Literals
+ whose corresponding assertion in some way contributes to the entailement of x.
+
+ This setting defaults to "false".
+
+ jasdl_useContraction = "<boolean>"
+
+ If set to "true", when removing an SE-Literal, x, from the belief base, JASDL will remove not only x itself,
+ but also all SE-Literals whose corresponding assertion in some way contributes to the entailement of x.
+
+ IMPORTANT NOTE: a common problem when contraction is disabled is encountered when attempting to remove an asserted
+ object property using a SE-Literal removal that refers to the inverse of the asserted property. Without
+ contraction, the assertion will not be removed - the object property used in the original assertion must be used.
+
+ This setting defaults to "false".
+
+ jasdl_useBeliefRevision = "<boolean>"
+
+ If set to "true", JASDL employs its (experimental) DL-based belief revision mechanism.
+
+ This setting defaults to "false". In which case, JASDL employs its legacy consistency assurance mechanism
+ whereby inconsistent assertions are simply rolled back, giving precedence to earlier ones.
+
+ This setting defaults to "false".
+
+ jasdl_known_agents = "<ag_1>, <ag_2> ..., <ag_n>"
+
+ Where each <ag_n> is the name of an agent we might refer to in the source annotation of an SE-Literal.
+ This, combined with their assigned trust ratings (see below), is currently used (only) by JASDL's
+ experimental DL-based belief revision and belief base contraction support.
+
+ In these cases, it is used by the "incision function", which determines which supporting assertions to
+ undermine when attempting to contract a belief (removing the belief itself and all assertions leading to its entailement).
+ Assertions associated (by the source annotation) with least-trusted agents
+ (i.e. those with lowest trust rating - see below) are removed first.
+
+ This setting defaults to "".
+
+ jasdl_<ag_n>_trustRating = "<float>"
+
+ Where each <ag_n> is the name of an agent we might refer to in the source annotation of an SE-Literal, one for each
+ specified in the known_agents setting (see above) and <float> is a numerical value between 0 and 1. See above for
+ discussion on how this is used.
+
+ This setting is mandatory for each agent specified by known_agents and so has no default.
+
+********************************************************
+
+
+
+
+
Modified: trunk/applications/jasdl-owlapi/examples/commerce/bin/build.xml
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/bin/build.xml 2008-04-22 16:46:22 UTC (rev 1239)
+++ trunk/applications/jasdl-owlapi/examples/commerce/bin/build.xml 2008-04-22 18:25:14 UTC (rev 1240)
@@ -5,7 +5,7 @@
This file was generated by Jason ?
http://jason.sf.net
- April 20, 2008 - 17:28:53
+ April 22, 2008 - 19:07:12
-->
<project name ="commerce"
Modified: trunk/applications/jasdl-owlapi/examples/commerce/bin/c-build.xml
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/bin/c-build.xml 2008-04-22 16:46:22 UTC (rev 1239)
+++ trunk/applications/jasdl-owlapi/examples/commerce/bin/c-build.xml 2008-04-22 18:25:14 UTC (rev 1240)
@@ -7,7 +7,7 @@
<import file="build.xml"/>
<target name="user-init">
- <ant dir="../../../../" inheritAll="false" target="plugin"/>
+ <ant dir="../../../../" inheritAll="false" target="jar"/>
<ant dir="../../../jmca" inheritAll="false"/>
<ant dir="../.." inheritAll="false"/>
</target>
Modified: trunk/applications/jasdl-owlapi/examples/commerce/commerce.mas2j
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/commerce.mas2j 2008-04-22 16:46:22 UTC (rev 1239)
+++ trunk/applications/jasdl-owlapi/examples/commerce/commerce.mas2j 2008-04-22 18:25:14 UTC (rev 1240)
@@ -1,4 +1,13 @@
-/* Jason Project */
+/* .mas2j configuration of the commerce MAS
+ * Note:
+ * - 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.
+ */
MAS commerce {
@@ -7,13 +16,15 @@
environment: commerce.env.CommerceEnvironment
agents:
+
+
shop
[
jasdl_ontologies="c,s",
jasdl_c_uri="/onts/commerce.owl",
jasdl_s_uri="/onts/society.owl"
]
- #2
+ #3
agentArchClass jasdl.architecture.JASDLAgArch
agentClass jasdl.asSemantics.JASDLAgent
beliefBaseClass jasdl.bb.JASDLBeliefBase;
@@ -24,7 +35,7 @@
jasdl_c_uri="/onts/commerce.owl",
jasdl_s_uri="/onts/society.owl"
]
- #2
+ #4
agentArchClass jasdl.architecture.JASDLAgArch
agentClass jasdl.asSemantics.JASDLAgent
beliefBaseClass jasdl.bb.JASDLBeliefBase;
@@ -44,7 +55,9 @@
[
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
Modified: trunk/applications/jasdl-owlapi/examples/commerce/onts/commerce.owl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/onts/commerce.owl 2008-04-22 16:46:22 UTC (rev 1239)
+++ trunk/applications/jasdl-owlapi/examples/commerce/onts/commerce.owl 2008-04-22 18:25:14 UTC (rev 1240)
@@ -40,7 +40,6 @@
<owl:ObjectProperty rdf:about="#contains">
<rdf:type rdf:resource="&owl;TransitiveProperty"/>
- <rdfs:range rdf:resource="#Ingredient"/>
<rdfs:domain rdf:resource="#Product"/>
</owl:ObjectProperty>
@@ -59,7 +58,6 @@
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#hasCustomer -->
<owl:ObjectProperty rdf:about="#hasCustomer">
- <rdf:type rdf:resource="&owl;InverseFunctionalProperty"/>
<rdfs:domain rdf:resource="#Order"/>
</owl:ObjectProperty>
@@ -68,13 +66,21 @@
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#hasOrder -->
<owl:ObjectProperty rdf:about="#hasOrder">
- <rdf:type rdf:resource="&owl;FunctionalProperty"/>
<rdfs:range rdf:resource="#Order"/>
<owl:inverseOf rdf:resource="#hasCustomer"/>
</owl:ObjectProperty>
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#hasShop -->
+
+ <owl:ObjectProperty rdf:about="#hasShop">
+ <rdf:type rdf:resource="&owl;FunctionalProperty"/>
+ <rdfs:domain rdf:resource="#Purchase"/>
+ </owl:ObjectProperty>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#includedIn -->
<owl:ObjectProperty rdf:about="#includedIn">
@@ -123,16 +129,6 @@
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#hasProductDescription -->
-
- <owl:DatatypeProperty rdf:about="#hasProductDescription">
- <rdf:type rdf:resource="&owl;FunctionalProperty"/>
- <rdfs:domain rdf:resource="#Purchase"/>
- <rdfs:range rdf:resource="&xsd;string"/>
- </owl:DatatypeProperty>
-
-
-
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#hasQuantity -->
<owl:DatatypeProperty rdf:about="#hasQuantity">
@@ -143,25 +139,6 @@
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#hasShopDescription -->
-
- <owl:DatatypeProperty rdf:about="#hasShopDescription">
- <rdfs:domain rdf:resource="#Purchase"/>
- <rdfs:range rdf:resource="&xsd;string"/>
- </owl:DatatypeProperty>
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#hasVolume -->
-
- <owl:DatatypeProperty rdf:about="#hasVolume">
- <rdf:type rdf:resource="&owl;FunctionalProperty"/>
- <rdfs:domain rdf:resource="#Product"/>
- <rdfs:range rdf:resource="&xsd;double"/>
- </owl:DatatypeProperty>
-
-
-
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#hasWeight -->
<owl:DatatypeProperty rdf:about="#hasWeight">
@@ -183,26 +160,10 @@
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Allergen -->
-
- <owl:Class rdf:about="#Allergen">
- <rdfs:subClassOf rdf:resource="#Ingredient"/>
- <rdfs:comment
- >Ingredients that are common allergens</rdfs:comment>
- </owl:Class>
-
-
-
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Beef -->
<owl:Class rdf:about="#Beef">
- <owl:equivalentClass>
- <owl:Restriction>
- <owl:onProperty rdf:resource="#contains"/>
- <owl:hasValue rdf:resource="#BeefIngredient"/>
- </owl:Restriction>
- </owl:equivalentClass>
- <rdfs:subClassOf rdf:resource="#Meat"/>
+ <rdfs:subClassOf rdf:resource="#MeatProduct"/>
<owl:disjointWith rdf:resource="#Chicken"/>
<owl:disjointWith rdf:resource="#Lamb"/>
</owl:Class>
@@ -212,12 +173,6 @@
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Bread -->
<owl:Class rdf:about="#Bread">
- <owl:equivalentClass>
- <owl:Restriction>
- <owl:onProperty rdf:resource="#contains"/>
- <owl:hasValue rdf:resource="#Gluten"/>
- </owl:Restriction>
- </owl:equivalentClass>
<rdfs:subClassOf rdf:resource="#Grocery"/>
</owl:Class>
@@ -234,94 +189,18 @@
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Chicken -->
<owl:Class rdf:about="#Chicken">
- <owl:equivalentClass>
- <owl:Restriction>
- <owl:onProperty rdf:resource="#contains"/>
- <owl:hasValue rdf:resource="#ChickenIngredient"/>
- </owl:Restriction>
- </owl:equivalentClass>
- <rdfs:subClassOf rdf:resource="#Meat"/>
+ <rdfs:subClassOf rdf:resource="#MeatProduct"/>
<owl:disjointWith rdf:resource="#Lamb"/>
</owl:Class>
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#ContainsGluten -->
-
- <owl:Class rdf:about="#ContainsGluten">
- <owl:equivalentClass>
- <owl:Class>
- <owl:intersectionOf rdf:parseType="Collection">
- <owl:Restriction>
- <owl:onProperty rdf:resource="#contains"/>
- <owl:hasValue rdf:resource="#Gluten"/>
- </owl:Restriction>
- <rdf:Description rdf:about="#Grocery"/>
- </owl:intersectionOf>
- </owl:Class>
- </owl:equivalentClass>
- </owl:Class>
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#ContainsLactose -->
-
- <owl:Class rdf:about="#ContainsLactose">
- <owl:equivalentClass>
- <owl:Class>
- <owl:intersectionOf rdf:parseType="Collection">
- <owl:Restriction>
- <owl:onProperty rdf:resource="#contains"/>
- <owl:hasValue rdf:resource="#Lactose"/>
- </owl:Restriction>
- <rdf:Description rdf:about="#Grocery"/>
- </owl:intersectionOf>
- </owl:Class>
- </owl:equivalentClass>
- </owl:Class>
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#ContainsMeat -->
-
- <owl:Class rdf:about="#ContainsMeat">
- <owl:equivalentClass>
- <owl:Class>
- <owl:intersectionOf rdf:parseType="Collection">
- <rdf:Description rdf:about="#Grocery"/>
- <owl:Restriction>
- <owl:onProperty rdf:resource="#contains"/>
- <owl:someValuesFrom rdf:resource="#MeatIngredient"/>
- </owl:Restriction>
- </owl:intersectionOf>
- </owl:Class>
- </owl:equivalentClass>
- </owl:Class>
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#ContainsNuts -->
-
- <owl:Class rdf:about="#ContainsNuts">
- <owl:equivalentClass>
- <owl:Class>
- <owl:intersectionOf rdf:parseType="Collection">
- <owl:Restriction>
- <owl:onProperty rdf:resource="#contains"/>
- <owl:hasValue rdf:resource="#Nuts"/>
- </owl:Restriction>
- <rdf:Description rdf:about="#Grocery"/>
- </owl:intersectionOf>
- </owl:Class>
- </owl:equivalentClass>
- </owl:Class>
-
-
-
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Cream -->
<owl:Class rdf:about="#Cream">
<rdfs:subClassOf rdf:resource="#Dairy"/>
+ <owl:disjointWith rdf:resource="#Butter"/>
+ <owl:disjointWith rdf:resource="#Milk"/>
</owl:Class>
@@ -329,12 +208,6 @@
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Dairy -->
<owl:Class rdf:about="#Dairy">
- <owl:equivalentClass>
- <owl:Restriction>
- <owl:onProperty rdf:resource="#contains"/>
- <owl:hasValue rdf:resource="#Lactose"/>
- </owl:Restriction>
- </owl:equivalentClass>
<rdfs:subClassOf rdf:resource="#Grocery"/>
</owl:Class>
@@ -343,13 +216,7 @@
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Fish -->
<owl:Class rdf:about="#Fish">
- <owl:equivalentClass>
- <owl:Restriction>
- <owl:onProperty rdf:resource="#contains"/>
- <owl:hasValue rdf:resource="#FishIngredient"/>
- </owl:Restriction>
- </owl:equivalentClass>
- <rdfs:subClassOf rdf:resource="#Meat"/>
+ <rdfs:subClassOf rdf:resource="#MeatProduct"/>
<owl:disjointWith rdf:resource="#Beef"/>
<owl:disjointWith rdf:resource="#Chicken"/>
<owl:disjointWith rdf:resource="#Lamb"/>
@@ -357,20 +224,18 @@
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Grocery -->
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#GreenVegetable -->
- <owl:Class rdf:about="#Grocery">
- <rdfs:subClassOf rdf:resource="#Product"/>
+ <owl:Class rdf:about="#GreenVegetable">
+ <rdfs:subClassOf rdf:resource="#Vegetable"/>
</owl:Class>
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Ingredient -->
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Grocery -->
- <owl:Class rdf:about="#Ingredient">
- <rdfs:subClassOf rdf:resource="#Grocery"/>
- <rdfs:comment
- >Ingredients that must be noted since some people cannot eat them</rdfs:comment>
+ <owl:Class rdf:about="#Grocery">
+ <rdfs:subClassOf rdf:resource="#Product"/>
</owl:Class>
@@ -378,40 +243,25 @@
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Lamb -->
<owl:Class rdf:about="#Lamb">
- <owl:equivalentClass>
- <owl:Restriction>
- <owl:onProperty rdf:resource="#contains"/>
- <owl:hasValue rdf:resource="#LambIngredient"/>
- </owl:Restriction>
- </owl:equivalentClass>
- <rdfs:subClassOf rdf:resource="#Meat"/>
+ <rdfs:subClassOf rdf:resource="#MeatProduct"/>
</owl:Class>
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Meat -->
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#MeatProduct -->
- <owl:Class rdf:about="#Meat">
+ <owl:Class rdf:about="#MeatProduct">
<rdfs:subClassOf rdf:resource="#Grocery"/>
<owl:disjointWith rdf:resource="#Vegetable"/>
</owl:Class>
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#MeatIngredient -->
-
- <owl:Class rdf:about="#MeatIngredient">
- <rdfs:subClassOf rdf:resource="#Ingredient"/>
- <rdfs:comment
- >Types of meat that food may contain</rdfs:comment>
- </owl:Class>
-
-
-
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Milk -->
<owl:Class rdf:about="#Milk">
<rdfs:subClassOf rdf:resource="#Dairy"/>
+ <owl:disjointWith rdf:resource="#Butter"/>
</owl:Class>
@@ -430,20 +280,6 @@
<owl:Class rdf:about="#Product">
<rdfs:subClassOf rdf:resource="&owl;Thing"/>
- <rdfs:subClassOf>
- <owl:Class>
- <owl:unionOf rdf:parseType="Collection">
- <owl:Restriction>
- <owl:onProperty rdf:resource="#hasVolume"/>
- <owl:someValuesFrom rdf:resource="&xsd;double"/>
- </owl:Restriction>
- <owl:Restriction>
- <owl:onProperty rdf:resource="#hasWeight"/>
- <owl:someValuesFrom rdf:resource="&xsd;double"/>
- </owl:Restriction>
- </owl:unionOf>
- </owl:Class>
- </rdfs:subClassOf>
</owl:Class>
@@ -464,15 +300,19 @@
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#RootVegetable -->
+
+ <owl:Class rdf:about="#RootVegetable">
+ <rdfs:subClassOf rdf:resource="#Vegetable"/>
+ <owl:disjointWith rdf:resource="#GreenVegetable"/>
+ </owl:Class>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#ShepherdsPie -->
<owl:Class rdf:about="#ShepherdsPie">
- <owl:equivalentClass>
- <owl:Restriction>
- <owl:onProperty rdf:resource="#contains"/>
- <owl:hasValue rdf:resource="#BeefIngredient"/>
- </owl:Restriction>
- </owl:equivalentClass>
+ <rdfs:subClassOf rdf:resource="#MeatProduct"/>
<rdfs:subClassOf rdf:resource="#ReadyMeal"/>
</owl:Class>
@@ -490,6 +330,7 @@
<owl:Class rdf:about="#VegetableCurry">
<rdfs:subClassOf rdf:resource="#ReadyMeal"/>
+ <owl:disjointWith rdf:resource="#ShepherdsPie"/>
</owl:Class>
@@ -497,88 +338,4 @@
<!-- http://www.w3.org/2002/07/owl#Thing -->
<owl:Class rdf:about="&owl;Thing"/>
-
-
-
- <!--
- ///////////////////////////////////////////////////////////////////////////////////////
- //
- // Individuals
- //
- ///////////////////////////////////////////////////////////////////////////////////////
- -->
-
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#BeefIngredient -->
-
- <MeatIngredient rdf:about="#BeefIngredient"/>
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#ChickenIngredient -->
-
- <MeatIngredient rdf:about="#ChickenIngredient"/>
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#FishIngredient -->
-
- <MeatIngredient rdf:about="#FishIngredient"/>
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Gluten -->
-
- <Allergen rdf:about="#Gluten"/>
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Lactose -->
-
- <Allergen rdf:about="#Lactose"/>
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#LambIngredient -->
-
- <MeatIngredient rdf:about="#LambIngredient"/>
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#Nuts -->
-
- <Allergen rdf:about="#Nuts"/>
-
-
-
- <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#sdfsdf -->
-
- <Product rdf:about="#sdfsdf">
- <hasInStock rdf:datatype="&xsd;int">1</hasInStock>
- </Product>
-
-
-
- <!--
- ///////////////////////////////////////////////////////////////////////////////////////
- //
- // General axioms
- //
- ///////////////////////////////////////////////////////////////////////////////////////
- -->
-
- <rdf:Description>
- <rdf:type rdf:resource="&owl;AllDifferent"/>
- <owl:distinctMembers rdf:parseType="Collection">
- <rdf:Description rdf:about="#BeefIngredient"/>
- <rdf:Description rdf:about="#LambIngredient"/>
- <rdf:Description rdf:about="#Gluten"/>
- <rdf:Description rdf:about="#ChickenIngredient"/>
- <rdf:Description rdf:about="#FishIngredient"/>
- <rdf:Description rdf:about="#Nuts"/>
- <rdf:Description rdf:about="#Lactose"/>
- </owl:distinctMembers>
- </rdf:Description>
</rdf:RDF>
Modified: trunk/applications/jasdl-owlapi/examples/commerce/onts/society.owl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/onts/society.owl 2008-04-22 16:46:22 UTC (rev 1239)
+++ trunk/applications/jasdl-owlapi/examples/commerce/onts/society.owl 2008-04-22 18:25:14 UTC (rev 1240)
@@ -216,6 +216,18 @@
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/society.owl#delivery_van_3 -->
+
+ <rdf:Description rdf:about="#delivery_van_3"/>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/society.owl#delivery_van_4 -->
+
+ <rdf:Description rdf:about="#delivery_van_4"/>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/society.owl#pa1 -->
<PA rdf:about="#pa1"/>
@@ -238,6 +250,7 @@
<Supermarket rdf:about="#shop1">
<employs rdf:resource="#delivery_van1"/>
+ <employs rdf:resource="#delivery_van_4"/>
<ownedBy rdf:resource="#tescos_inc"/>
</Supermarket>
@@ -252,6 +265,15 @@
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/society.owl#shop3 -->
+
+ <GreenGrocers rdf:about="#shop3">
+ <employs rdf:resource="#delivery_van_3"/>
+ <ownedBy rdf:resource="#tescos_inc"/>
+ </GreenGrocers>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/society.owl#tescos_inc -->
<Company rdf:about="#tescos_inc"/>
@@ -269,17 +291,20 @@
<rdf:Description>
<rdf:type rdf:resource="&owl;AllDifferent"/>
<owl:distinctMembers rdf:parseType="Collection">
- <rdf:Description rdf:about="#pa3"/>
<rdf:Description rdf:about="#customer3"/>
- <rdf:Description rdf:about="#delivery_van1"/>
- <rdf:Description rdf:about="#pa2"/>
- <rdf:Description rdf:about="#shop1"/>
+ <rdf:Description rdf:about="#customer2"/>
+ <rdf:Description rdf:about="#shop2"/>
+ <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="#customer2"/>
<rdf:Description rdf:about="#tescos_inc"/>
- <rdf:Description rdf:about="#delivery_van2"/>
- <rdf:Description rdf:about="#shop2"/>
+ <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="#pa3"/>
</owl:distinctMembers>
</rdf:Description>
</rdf:RDF>
Property changes on: trunk/applications/jasdl-owlapi/examples/commerce/src/asl
___________________________________________________________________
Name: svn:ignore
+ sho222p.asl
Added: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl (rev 0)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl 2008-04-22 18:25:14 UTC (rev 1240)
@@ -0,0 +1,27 @@
++!abolish_order(Order) :
+ order(Order)[o(c)]
+ <-
+ // 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
+ -hasCustomer(Order, Customer)[o(c), source(_)].
+
++!abolish_purchases([]).
++!abolish_purchases([Purchase|Purchases])
+ <-
+ !abolish_purchase(Purchase);
+ !abolish_purchases(Purchases).
+
+
++!abolish_purchase(ID) :
+ purchase(ID)[o(c)]
+ <-
+ -hasProductDescription(ID, _)[o(c), source(_)];
+ -includedIn(ID, _)[o(c), source(_)];
+ -hasQuantity(ID, _)[o(c), source(_)];
+ -purchase(ID)[o(c), source(_)];
+ -hasShop(ID, _)[o(c), source(_)].
+
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/customer.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/customer.asl 2008-04-22 16:46:22 UTC (rev 1239)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/customer.asl 2008-04-22 18:25:14 UTC (rev 1240)
@@ -1,4 +1,5 @@
{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.
@@ -8,12 +9,35 @@
* Assuming central repository of agents and their types (society.owl schema)
* IDs are propagated through annotations to match product request brands with quantities
*/
+
++!init
+ <-
+ // 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
+ ?employs(PA);
-
+ jasdl.ia.get_anonymous_individual(Order);
+
+ .my_name(Me);
+ +order(Order)[o(c)];
+ +hasOrder(Me, Order)[o(c)]; // note: inverse of hasCustomer
+
+ .send(PA, tell, order(Order)[o(c)]);
+ .send(PA, tell, hasOrder(Me, Order)[o(c)]).
+
+-!init.
+
+
+/**
+ * The user has hit the "submit request" button on the customer UI.
+ */
+ui_product_request(ProductDescription, ShopDescription, Qty)[source(percept)]
- <-
- .print("UI recieved request");
+ <-
+ !init;
// Get a PA employed by me
?employs(PA);
@@ -26,23 +50,45 @@
// then the PA would not be able to understand the request.
jasdl.ia.define_class(suitableProduct, ProductDescription);
- jasdl.ia.define_class(suitableShop, ShopDescription);
+ jasdl.ia.define_class(suitableShop, ShopDescription);
-
// Request a suitable brand from the PA
- jasdl.ia.send(PA, achieve, suitable(suitableProduct(_)[o(self)], suitableShop(_)[o(self)], Qty)).
-
-
-+!product(Brand)[o(c), source(PA), approve, id(ID)] :
- employs(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)]
<-
- approve(Brand);
- .send(PA, tell, approved(product(Brand)[o(c), id(ID)])).
+ // 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.
+ .send(PA, achieve, order_confirmed).
+
+/**
+ * A message has been recieved from the PA. Execute the "message" environmental action,
+ * 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
+ -message(Message)[source(PA)];
+ // Display the dialog on the customer UI
+ message(Message).
--!product(Brand)[o(c), source(PA), approve, id(ID)] :
- employs(PA)
+/**
+ * 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)
<-
- .send(PA, tell, rejected(product(Brand)[o(c), id(ID)])).
+ // Execute the "approve" environmental action
+ approve(Brand);
+ // Will only be reached if the user hits "OK" - otherwise the above environmental action will fail
+ Answer = true.
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-22 16:46:22 UTC (rev 1239)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/delivery_van.asl 2008-04-22 18:25:14 UTC (rev 1240)
@@ -1,4 +1,5 @@
{include("common/society.asl")}
+{include("common/commerce.asl")}
!init.
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/pa.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/pa.asl 2008-04-22 16:46:22 UTC (rev 1239)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/pa.asl 2008-04-22 18:25:14 UTC (rev 1240)
@@ -1,131 +1,146 @@
{include("common/society.asl")}
+{include("common/commerce.asl")}
+/** Plans that are called by the customer agent */
-+!suitable(ProductClass, ShopClass, Qty)[source(Customer)] :
- isEmployedBy(Customer)
- <-
- ?hasOrder(Customer, Order)[o(c)];
- .print(Order);
++!suitable(ProductClass, ShopClass, Qty)
+ <-
+ ?isEmployedBy(Customer);
+
+ ?hasOrder(Customer, Order)[o(c)];
+
+ ?ShopClass;
+ jasdl.ia.get_individual(ShopClass, Shop);
- ?ShopClass;
- 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_class_definition(ProductClass, ProductDescription);
+
+ // 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
+ jasdl.ia.define_class(productInStock, ProductDescriptionInStock);
+
+ .print("Asking ",Shop,":", ProductDescriptionInStock);
+
+ // 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);
- // Generate a unique (guaranteed across entire agent society) request identifier (individual)
- jasdl.ia.get_anonymous_individual(ID);
-
- jasdl.ia.get_class_definition(ShopClass, ShopDescription);
- 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)
- .concat("(",ProductDescription,") and c:hasInStock some integer [ >= ",Qty,"]",ProductDescriptionInStock);
-
- // Parse the product description into a class
- jasdl.ia.define_class(productInStock, ProductDescriptionInStock);
-
- .print("Asking ",Shop,":", ProductDescriptionInStock);
-
- // Ask for all brands that match these criteria
- //jasdl.ia.send(Shop, achieve, suitable(description(Brand)[o(self)])[id(ID)]).
- jasdl.ia.send(Shop, askOne, productInStock(Brand)[o(self), id(ID)]);
+ // ask for the customer's approval
+ !!approve(ID, Brand, ProductDescription, Shop, Qty, Order, Stockist).
+
- +purchase(ID)[o(c)];
- +includes(Order, ID)[o(c)];
- +hasQuantity(ID, Qty)[o(c)];
- +hasProductDescription(ID, ProductDescription)[o(c)];
- +hasShopDescription(ID, ShopDescription)[o(c)].
-
-
-+product(Brand)[o(c), id(ID), source(Shop)] :
- shop(Shop)[o(s)] // from a known shop
+
++!approve(ID, Brand, ProductDescription, Shop, Qty, Order, Stockist)
<-
- !approve(product(Brand)[o(c), id(ID)]).
-
-+referral(Referred)[id(ID), source(Shop)] :
- shop(Referred)[o(s)] &
- shop(Shop)[o(s)]
+ ?isEmployedBy(Customer);
+ .send(Customer, askOne,
+ approve(Brand, Answer),
+ approve(Brand, true));
+
+ // Commit the purchase details to the belief base
+ +hasBrand(ID, Brand)[o(c)];
+ +hasShop(ID, Stockist)[o(c)];
+ +includes(Order, ID)[o(c)];
+ +purchase(ID)[o(c)];
+ +hasQuantity(ID, Qty)[o(c)].
+
+-!approve(ID, Brand, ProductDescription, Shop, Qty, Order, Stockist)
<-
- -referral(Referred)[id(ID), source(Shop)];
- .print("referred to ", Referred).
+ ?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,"}");
+
+ // 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).
-+failed[id(ID), source(Shop)] :
- shop(Shop)[o(s)]
- <-
- !abolish_purchase(ID);
- .print("Failed!").
-+!approve(A)
+-!suitable(ProductClass, ShopClass, Qty)
+ <-
+ ?isEmployedBy(Customer);
+ .send(Customer, tell, message("I am sorry but I am unable to service your request."));
+ .fail.
+
+
++!order_confirmed[source(Customer)] : isEmployedBy(Customer)
<-
+ ?hasOrder(Customer, Order)[o(c)];
+ .findall(ID, purchase(ID)[o(c)], Purchases);
+ !order_confirmed(Purchases, []).
+
+-!order_confirmed[source(Customer)] : isEmployedBy(Customer) & not hasOrder(Customer, _)[o(c)]
+ <-
+ .send(Customer, tell, message("You must request some products first")).
+
+
++!order_confirmed([Purchase|Purchases], Shops)
+ <-
- // get my employer (rule expressed in terms of SE-Literals, see common/society.asl)
- ?isEmployedBy(Employer);
+ // 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
+ ?includedIn(Purchase, Order)[o(c)];
- .my_name(Me);
- .add_annot(A, source(Me), B);
-
- // ask customer for approval
- // We add the approve annotation to isolate this
- // type of query from others
- .add_annot(B, approve, C);
- .send(Employer, achieve, C).
-
-+approved(product(Brand)[o(c), id(ID)])[source(Employer)] :
- isEmployedBy(Employer)
+ // ... 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
+ !order_confirmed(Purchases, [Shop|Shops]).
+
+
++!order_confirmed([], Shops)
<-
- +hasBrand(ID, Brand)[o(c)];
- .print("Approved ", Brand, " (id: ", ID, ")").
+ // 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)];
+ .send(Shops, tell, hasCustomer(Order, Customer)[o(c)]);
+
+ // ... and finish with the order itself, which will instantiate the dispatch process in the shop agents
+ .send(Shops, tell, order(Order)[o(c)]);
+
+ // abolish the order (and all included purchases), we no longer need it
+ !abolish_order(Order);
-@sdfdsf[breakpoint]
-+rejected(product(Brand)[o(c), id(ID)])[source(Employer)] :
- isEmployedBy(Employer)
- <-
- ?includedIn(ID, Order)[o(c)];
- ?hasQuantity(ID, Qty)[o(c)];
- ?hasProductDescription(ID, ProductDescription)[o(c)];
- ?hasShopDescription(ID, ShopDescription)[o(c)];
-
- !abolish_purchase(ID);
-
- .concat("(",ProductDescription,") and not {c:",Brand,"}", AmmendedProductDescription);
+ // Inform the customer
+ .send(Customer, tell, message("Your order has been confirmed and will be dispatched shortly.")).
- .print("Rejected ", Brand, " (id: ", ID, ")");
+
+/******************************************************************************/
+
- // We need this individual to be instantiated in our own commerce ontology
- // to allow us to safely refer to it in class expressions
- //+product(Brand)[o(c)];
- // 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, AmmendedProductDescription);
++failed(Message)[id(ID), source(Shop)] :
+ shop(Shop)[o(s)]
+ <-
+ // Remove this belief, we no longer need it
+ -failed(Message)[id(ID), source(Shop)];
- // Get the class describing the desired type of shop, without changing any requirements
- jasdl.ia.define_class(shopClass, ShopDescription);
+ // Delete all trace of the purchase
+ !abolish_purchase(ID);
- .print("Rejected ", Brand, ". Retry with shop=", ShopDescription, " and product=", AmmendedProductDescription);
-
- // 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)], shopClass(_)[o(self)], Qty)[source(Employer)].
+ // Get the customer
+ ?isEmployedBy(Customer);
+
+ // Pass the news on to the customer
+ .send(Customer, tell, message(Message)).
-+!abolish_purchase(ID) :
- purchase(ID)[o(c)]
- <-
- -hasProductDescription(ID, _)[o(c), source(self)];
- -hasShopDescription(ID, _)[o(c), source(self)];
- -includedIn(ID, _)[o(c), source(self)];
- -hasQuantity(ID, _)[o(c), source(self)];
- -purchase(ID)[o(c), source(self)].
-
-/* Opening a new order.
- * Will only be generated with no order can be found (or at least none by this name)
- */
-+?hasOrder(Customer, Order)[o(c)] :
- isEmployedBy(Customer)
- <-
- jasdl.ia.get_anonymous_individual(Order);
- +hasOrder(Customer, Order)[o(c)].
-
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/shop.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/shop.asl 2008-04-22 16:46:22 UTC (rev 1239)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/shop.asl 2008-04-22 18:25:14 UTC (rev 1240)
@@ -1,113 +1,176 @@
{include("common/society.asl")}
+{include("common/commerce.asl")}
-+!kqml_received(Sender, askOne, Content[o(O), id(ID)], MsgId) :
- pA(PA)[o(s)]
- <-
- .add_annot(Content, source(Sender), X);
- .add_annot(X, o(O), Y);
- .add_annot(Y, id(ID), Z);
- ?Z.
+/*
+ * 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)
+ * can be conveniently expressed within a rule.
+ */
+possibleStockist(ID, Expression, PossibleStockist) :-
+ jasdl.ia.define_class(possibleStockist, Expression) &
+ possibleStockist(PossibleStockist)[o(self)] &
+ shopInSameCompany(PossibleStockist) & // note: this constraint could be more flexible by using an expression such as '' in the above class definition
+ 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.
+ */
+shopInSameCompany(Shop) :-
+ shop(Shop)[o(s)] &
+ .my_name(Me) &
+ ownedBy(Me, Company)[o(s)] &
+ owns(Company, Shop)[o(s)] &
+ (not Shop==Me).
-
-
-
-+?product(Brand)[o(c), id(ID), source(PA)] : JASDL_TG_CAUSE
+/*
+ * 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.
+ */
+@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
<-
- //.add_annot(JASDL_TG_CAUSE, id(ID), Response);
- //.send(PA, tell, Response).
- jasdl.ia.get_individual(JASDL_TG_CAUSE, Brand);
- .print("Sending ", JASDL_TG_CAUSE);
- .send(PA, tell, product(Brand)[o(c), id(ID)]).
+ .print("Recieved request and is able to service it");
+ .my_name(Me);
+ jasdl.ia.get_individual(OriginalQuery, Brand).
-/** Plans dealing with a failure to find a suitable product within the belief-base of this agent */
-
-+?thing(Brand)[o(owl), id(ID), source(PA)] :
- not JASDL_TG_CAUSE
+/**
+ * Notice that the two 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
<-
- .print("Requested unknown product, moreover, no other shops in this company can be identified to potentially service this request");
- .send(PA, tell, failure[id(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), source(PA)] :
- not JASDL_TG_CAUSE &
- .my_name(Me) &
- ownedBy(Me, Owner)[o(s)] &
- jasdl.ia.define_class(mightStock, "s:shop and s:ownedBy value s:",Owner," and (not {s:",Me,"})") &
- mightStock(Shop)[o(self)]
+/**
+ * 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("Requested unknown product, attempting to refer to any other shop owned by this company");
- .send(PA, tell, referral(Shop)[id(ID)]).
+ .print("Unknown VEGETABLE PRODUCT requested");
+ !exhausted(ID);
+ ?stocked_by_another_shop(PossibleStockist, ID, OriginalQuery, Brand).
/**
- * No suitable product has been found in this agent's belief base. However,
- * because it is a type of meat product, it might be worth looking for butchers
- * owned by this company and referring to PA to them (if any are known).
- */
-+?meat(Brand)[o(c), id(ID), source(PA)] :
- not JASDL_TG_CAUSE &
- .my_name(Me) &
- ownedBy(Me, Owner)[o(s)] &
- jasdl.ia.define_class(mightStock, "s:butchers and s:ownedBy value s:",Owner," and (not {s:",Me,"})") &
- mightStock(Butchers)[o(self)]
+ * 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("Requested unknown meat product, attempting to refer to a butchers owned by this company");
- .send(PA, tell, referral(Butchers)[id(ID)]).
-
-/****************************************************************/
-
-
-
+ .print("Unknown MEAT PRODUCT requested");
+ !exhausted(ID);
+ ?stocked_by_another_shop(PossibleStockist, ID, OriginalQuery, Brand).
-
-+!add_to_order(Order, Brand, Qty)[source(PA)] :
- product(Brand)[o(c)] & // check known product brand
- hasCustomer(Order, Customer)[o(c)] & employs(Customer, PA)[o(s)] & // check PA is authorised to speak on behalf of customer whose order it is
- hasInStock(Brand, StockLevel)[o(c)] & StockLevel>=Qty // check we have enough stock
++?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).
- // get a unique purchase identifier
- jasdl.ia.get_anonymous_individual(PID);
- // add purchase
- +purchase(PID)[o(c)];
- +includes(Order, PID)[o(c)];
- +hasBrand(PID, Brand)[o(c)];
- +hasQuantity(PID, Qty)[o(c)];
- .send(PA, tell, confirmed(Order, Brand, Qty)).
+
+/**
+ * Inform all shops 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)).
+
++!reset(ID)
+ <-
+ .findall(Shop, shopInSameCompany(Shop), Shops);
+ .send(Shops, untell, exhausted(ID)).
+
-
-
-+!confirm_order(Order)[source(PA)] :
+
+
+/**
+ * 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)]
<-
- !deploy(Order);
- !allocate_available(Van);
- !recall(Van);
- !load(Order, Van);
- !dispatch(Order, Van);
- !unload(Order, Van);
- +available(Van);
- .abolish(includes(Order, _)[o(c)]);
- .send(Customer, tell, order_complete(Order)).
-
-
-
+ // Delopy crates containing product
+ !deploy(Order);
+ // Obtain an available van (or suspend this intention until one it available)
+ !allocate_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
+ !load(Order, Van);
+ // Instruct the van to move to the customer's position
+ !dispatch(Order, Van);
+ // Instruct the van to unload its cargo at its current position (i.e. the customer's)
+ !unload(Order, Van);
+ // 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(Van)[source(_)];
+ -available(Van)[source(_)].
+
+/*
+ * 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.
+ */
+?available(Van)
<-
- .concat("+",available(Van)[source(_)], WaitFor);
- .wait(WaitFor);
- ?available(Van)[source(_)].
+ .concat("+",available(Van)[source(_)], WaitFor);
+ .wait(WaitFor);
+ ?available(Van)[source(_)].
+/**
+ * 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)];
@@ -118,6 +181,10 @@
.wait(WaitFor);
-L.
+/**
+ * Achieve the state of affairs such that a van has unloaded its entire cargo at its current destination
+ * (Suspends the intention un...
[truncated message content] |