You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
(35) |
Apr
(96) |
May
(39) |
Jun
(25) |
Jul
(7) |
Aug
(7) |
Sep
(44) |
Oct
(17) |
Nov
(14) |
Dec
(9) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(5) |
Feb
(28) |
Mar
(26) |
Apr
(14) |
May
(3) |
Jun
(3) |
Jul
(13) |
Aug
(41) |
Sep
(12) |
Oct
|
Nov
(2) |
Dec
(17) |
| 2010 |
Jan
(9) |
Feb
(5) |
Mar
(11) |
Apr
(3) |
May
(4) |
Jun
(2) |
Jul
(3) |
Aug
(8) |
Sep
(2) |
Oct
(11) |
Nov
(3) |
Dec
(1) |
| 2011 |
Jan
|
Feb
(1) |
Mar
(8) |
Apr
(4) |
May
(4) |
Jun
(5) |
Jul
(3) |
Aug
(2) |
Sep
(7) |
Oct
(4) |
Nov
(4) |
Dec
(2) |
| 2012 |
Jan
|
Feb
|
Mar
(4) |
Apr
(11) |
May
(8) |
Jun
(2) |
Jul
(7) |
Aug
(6) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(3) |
| 2013 |
Jan
|
Feb
(1) |
Mar
(7) |
Apr
(3) |
May
(1) |
Jun
(4) |
Jul
(8) |
Aug
(4) |
Sep
(4) |
Oct
(6) |
Nov
(8) |
Dec
(6) |
| 2014 |
Jan
|
Feb
|
Mar
(2) |
Apr
(4) |
May
(6) |
Jun
(10) |
Jul
|
Aug
(7) |
Sep
(15) |
Oct
(4) |
Nov
(1) |
Dec
(1) |
| 2015 |
Jan
|
Feb
(1) |
Mar
(10) |
Apr
(4) |
May
(6) |
Jun
(1) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(5) |
Nov
(6) |
Dec
(12) |
| 2016 |
Jan
(1) |
Feb
(4) |
Mar
(7) |
Apr
(30) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <jom...@us...> - 2008-04-08 16:38:36
|
Revision: 1206
http://jason.svn.sourceforge.net/jason/?rev=1206&view=rev
Author: jomifred
Date: 2008-04-08 09:38:29 -0700 (Tue, 08 Apr 2008)
Log Message:
-----------
jason team: dummies can push cows!
Modified Paths:
--------------
trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
trunk/applications/jason-team/src/asl/dummy.asl
trunk/applications/jason-team/src/java/arch/ACProxy.java
trunk/applications/jason-team/src/java/arch/CowboyArch.java
trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
trunk/applications/jason-team/src/java/env/WorldModel.java
trunk/applications/jason-team/src/java/jia/Search.java
trunk/applications/jason-team/src/java/jia/direction.java
trunk/src/jason/environment/grid/Location.java
Added Paths:
-----------
trunk/applications/jason-team/src/java/jia/Vec.java
trunk/applications/jason-team/src/java/jia/herd_position.java
trunk/applications/jason-team/src/java/test/
trunk/applications/jason-team/src/java/test/TestBasicHerding.java
Modified: trunk/applications/jason-team/AC-Local-JasonTeam.mas2j
===================================================================
--- trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-07 13:27:34 UTC (rev 1205)
+++ trunk/applications/jason-team/AC-Local-JasonTeam.mas2j 2008-04-08 16:38:29 UTC (rev 1206)
@@ -42,5 +42,5 @@
agentClass agent.SelectEvent
beliefBaseClass agent.UniqueBelsBB("gsize(_,_)","steps(_)","cell(_,_,key)","corral(_,_,_,_)","pratio(_)");
- aslSourcePath: "src/asl";
+ aslSourcePath: "src/asl";
}
Modified: trunk/applications/jason-team/src/asl/dummy.asl
===================================================================
--- trunk/applications/jason-team/src/asl/dummy.asl 2008-04-07 13:27:34 UTC (rev 1205)
+++ trunk/applications/jason-team/src/asl/dummy.asl 2008-04-08 16:38:29 UTC (rev 1206)
@@ -33,13 +33,31 @@
!move.
+/* -- reaction to cows -- */
+
++pos(_,_,_) // new cycle
+ : cell(_,_,cow(_)) // I see cows
+ <- jia.herd_position(X,Y); // compute new location
+ .print("COWS! going to ",X,",",Y);
+ -+target(X,Y). // go to there
+
+
+/* -- what todo when arrive at location */
+
++!decide_target // chose a new random pos
+ : not cell(_,_,cow(_))
+ <- ?random_pos(NX,NY);
+ -+target(NX,NY).
++!decide_target.
+
/* -- plans to move to a destination represented in the belief target(X,Y)
-- (it is a kind of persistent goal)
*/
// if the target is changed, "restart" move
-+target(_,_)
++target(NX,NY)
<- .drop_desire(move);
+ jia.set_target(NX,NY);
!!move.
// I still do not know my location
@@ -55,9 +73,7 @@
(not target(_,_) | // I have no target OR
target(X,Y) | // I am at target OR
(target(BX,BY) & jia.direction(X, Y, BX, BY, skip))) // is impossible to go to target
- <- ?random_pos(NX,NY);
- jia.set_target(NX,NY);
- -+target(NX,NY).
+ <- !decide_target.
// does one step towards target
+!move
Modified: trunk/applications/jason-team/src/java/arch/ACProxy.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-04-07 13:27:34 UTC (rev 1205)
+++ trunk/applications/jason-team/src/java/arch/ACProxy.java 2008-04-08 16:38:29 UTC (rev 1206)
@@ -160,7 +160,9 @@
lpos.addTerm(new NumberTermImpl(step));
percepts.add(lpos);
- int enemyId = 1;
+ arq.getModel().clearCowsList();
+
+ int enemyId = 1;
// add in perception what is around
NodeList nl = perception.getElementsByTagName("cell");
for (int i=0; i < nl.getLength(); i++) {
Modified: trunk/applications/jason-team/src/java/arch/CowboyArch.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-07 13:27:34 UTC (rev 1205)
+++ trunk/applications/jason-team/src/java/arch/CowboyArch.java 2008-04-08 16:38:29 UTC (rev 1206)
@@ -237,9 +237,8 @@
return l;
}
-
void cowPerceived(int x, int y) {
- model.add(WorldModel.COW, x, y);
+ model.addCow(x,y);
}
void enemyPerceived(int x, int y) {
Modified: trunk/applications/jason-team/src/java/arch/LocalWorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-04-07 13:27:34 UTC (rev 1205)
+++ trunk/applications/jason-team/src/java/arch/LocalWorldModel.java 2008-04-08 16:38:29 UTC (rev 1206)
@@ -2,6 +2,8 @@
import jason.environment.grid.Location;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Random;
import env.WorldModel;
@@ -19,6 +21,8 @@
private Random random = new Random();
+ List<Location> cows = new ArrayList<Location>();
+
//private Logger logger = Logger.getLogger("jasonTeamSimLocal.mas2j." + LocalWorldModel.class.getName());
public static LocalWorldModel create(int w, int h, int nbAg) {
@@ -40,6 +44,33 @@
}
}
+ public void clearCowsList() {
+ cows.clear();
+ }
+ public void addCow(int x, int y) {
+ add(WorldModel.COW, x, y);
+ cows.add(new Location(x,y));
+ }
+ public void addCow(Location l) {
+ addCow(l.x, l.y);
+ }
+ public List<Location> getCows() {
+ return cows;
+ }
+
+ public Location nearFree(Location l) throws Exception {
+ int w = 1;
+ while (true) {
+ for (int x=l.x-w; x<=l.x+w;x++)
+ if (isFree(x,l.y))
+ return new Location(x,l.y);
+ for (int y=l.y-w; y<=l.y+w;y++)
+ if (isFree(l.x,y))
+ return new Location(l.x,y);
+ w++;
+ }
+ }
+
public int getVisited(Location l) {
return visited[l.x][l.y];
}
Modified: trunk/applications/jason-team/src/java/env/WorldModel.java
===================================================================
--- trunk/applications/jason-team/src/java/env/WorldModel.java 2008-04-07 13:27:34 UTC (rev 1205)
+++ trunk/applications/jason-team/src/java/env/WorldModel.java 2008-04-08 16:38:29 UTC (rev 1206)
@@ -77,6 +77,10 @@
return l.x >= corralUL.x && l.x <= corralDR.x &&
l.y >= corralUL.y && l.y <= corralDR.y;
}
+
+ public Location getCorralCenter() {
+ return new Location( (corralUL.x + corralDR.x)/2, (corralUL.y + corralDR.y)/2);
+ }
public int getCowsBlue() {
return cowsBlue;
@@ -228,4 +232,19 @@
return s.toString();
}
+
+ public static Location getNewLocationForAction(Location pos, WorldModel.Move action) {
+ switch (action) {
+ case west : return new Location(pos.x-1,pos.y);
+ case east : return new Location(pos.x+1,pos.y);
+ case north : return new Location(pos.x,pos.y-1);
+ case northeast: return new Location(pos.x+1,pos.y-1);
+ case northwest: return new Location(pos.x-1,pos.y-1);
+ case south : return new Location(pos.x,pos.y+1);
+ case southeast: return new Location(pos.x+1,pos.y+1);
+ case southwest: return new Location(pos.x-1,pos.y+1);
+ }
+ return null;
+ }
+
}
Modified: trunk/applications/jason-team/src/java/jia/Search.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/Search.java 2008-04-07 13:27:34 UTC (rev 1205)
+++ trunk/applications/jason-team/src/java/jia/Search.java 2008-04-08 16:38:29 UTC (rev 1206)
@@ -22,19 +22,32 @@
final LocalWorldModel model;
final Location from, to;
final boolean considerAgentsAsObstacles;
- int[] actionsOrder;
+ final boolean considerCorralAsObstacles;
+ final boolean considerCowsAsObstacles;
+ WorldModel.Move[] actionsOrder;
int nbStates = 0;
AgArch agArch;
- static final int[] defaultActions = { 1, 2, 3, 4, 5, 6, 7, 8 }; // initial order of actions
+ public static final WorldModel.Move[] defaultActions = { // initial order of actions
+ WorldModel.Move.west,
+ WorldModel.Move.east,
+ WorldModel.Move.north,
+ WorldModel.Move.northeast,
+ WorldModel.Move.northwest,
+ WorldModel.Move.south,
+ WorldModel.Move.southeast,
+ WorldModel.Move.southwest
+ };
Logger logger = Logger.getLogger(Search.class.getName());
- Search(LocalWorldModel m, Location from, Location to, int[] actions, boolean considerAgentsAsObstacles, AgArch agArch) {
+ public Search(LocalWorldModel m, Location from, Location to, WorldModel.Move[] actions, boolean considerAgentsAsObstacles, boolean considerCorralAsObstacles, boolean considerCowsAsObstacles, AgArch agArch) {
this.model = m;
this.from = from;
this.to = to;
this.considerAgentsAsObstacles = considerAgentsAsObstacles;
+ this.considerCorralAsObstacles = considerCorralAsObstacles;
+ this.considerCowsAsObstacles = considerCowsAsObstacles;
this.agArch = agArch;
if (actions != null) {
this.actionsOrder = actions;
@@ -45,14 +58,14 @@
/** used normally to discover the distance from 'from' to 'to' */
Search(LocalWorldModel m, Location from, Location to, AgArch agArch) {
- this(m,from,to,null,false, agArch);
+ this(m,from,to,null,false, false, false, agArch);
}
public Nodo search() throws Exception {
Busca searchAlg = new AEstrela();
//searchAlg.ssetMaxAbertos(1000);
- GridState root = new GridState(from, WorldModel.Move.skip, this);
- root.setIsRoot();
+ GridState root = new GridState(from, WorldModel.Move.skip, this, 1);
+ root.setAsRoot();
return searchAlg.busca(root);
}
@@ -113,22 +126,24 @@
final Search ia;
final int hashCode;
boolean isRoot = false;
+ int cost = 1;
- public GridState(Location l, WorldModel.Move op, Search ia) {
- this.pos = l;
- this.op = op;
- this.ia = ia;
- hashCode = pos.hashCode();
+ public GridState(Location l, WorldModel.Move op, Search ia, int cost) {
+ this.pos = l;
+ this.op = op;
+ this.ia = ia;
+ this.cost = cost;
+ hashCode = pos.hashCode();
ia.nbStates++;
}
- public void setIsRoot() {
+ public void setAsRoot() {
isRoot = true;
}
public int custo() {
- return 1;
+ return cost;
}
public boolean ehMeta() {
@@ -140,7 +155,7 @@
}
public int h() {
- return pos.distance(ia.to);
+ return pos.maxBorder(ia.to);
}
public List<Estado> sucessores() {
@@ -148,22 +163,13 @@
if (ia.nbStates > 50000) {
ia.logger.info("*** It seems I am in a loop!");
return s;
- } else if (!ia.agArch.isRunning()) {
+ } else if (ia.agArch != null && !ia.agArch.isRunning()) {
return s;
}
// all directions
for (int a = 0; a < ia.actionsOrder.length; a++) {
- switch (ia.actionsOrder[a]) {
- case 1: suc(s,new Location(pos.x-1,pos.y), WorldModel.Move.west); break;
- case 2: suc(s,new Location(pos.x+1,pos.y), WorldModel.Move.east); break;
- case 3: suc(s,new Location(pos.x,pos.y-1), WorldModel.Move.north); break;
- case 4: suc(s,new Location(pos.x+1,pos.y-1), WorldModel.Move.northeast); break;
- case 5: suc(s,new Location(pos.x-1,pos.y-1), WorldModel.Move.northwest); break;
- case 6: suc(s,new Location(pos.x,pos.y+1), WorldModel.Move.south); break;
- case 7: suc(s,new Location(pos.x+1,pos.y+1), WorldModel.Move.southeast); break;
- case 8: suc(s,new Location(pos.x-1,pos.y+1), WorldModel.Move.southwest); break;
- }
+ suc(s, WorldModel.getNewLocationForAction(pos, ia.actionsOrder[a]), ia.actionsOrder[a]);
}
// if it is root state, sort the option by least visited
@@ -172,18 +178,51 @@
}
return s;
}
-
+
private void suc(List<Estado> s, Location newl, WorldModel.Move op) {
- if (ia.model.isFreeOfObstacle(newl) && !ia.model.hasObject(WorldModel.CORRAL, newl)) {
- if (ia.considerAgentsAsObstacles) {
- if ((ia.model.isFree(WorldModel.AGENT,newl) && ia.model.isFree(WorldModel.COW,newl)) || ia.from.distance(newl) > 3) {
- s.add(new GridState(newl,op,ia));
- }
- } else {
- s.add(new GridState(newl,op,ia));
+ if (!ia.model.inGrid(newl))
+ return;
+ if (ia.model.hasObject(WorldModel.OBSTACLE, newl))
+ return;
+ if (ia.considerCorralAsObstacles && ia.model.hasObject(WorldModel.CORRAL, newl))
+ return;
+ if (ia.considerAgentsAsObstacles && ia.model.hasObject(WorldModel.AGENT,newl) && ia.from.maxBorder(newl) <= 2)
+ return;
+ if (ia.considerCowsAsObstacles && ia.model.hasObject(WorldModel.COW,newl) && ia.from.maxBorder(newl) <= 2)
+ return;
+
+ int cost = 1;
+
+ if (ia.considerCowsAsObstacles) {
+ cost += countCowsBeside(newl,1);
+ cost += countCowsBeside(newl,2);
+ }
+
+ s.add(new GridState(newl,op,ia, cost));
+ }
+
+ private int countCowsBeside(Location l, int d) {
+ int c = 0;
+ for (int x = l.x-d; x <= l.x+d; x++) {
+ for (int y = l.y-d; y <= l.y+d; y++) {
+ if (ia.model.hasObject(WorldModel.COW, x, y)) {
+ c++;
+ }
}
- }
+ }
+ return c;
+ /*
+ if (ia.model.hasObject(WorldModel.COW, l.x, l.y)) c++;
+ if (ia.model.hasObject(WorldModel.COW, l.x+1, l.y)) c++;
+ if (ia.model.hasObject(WorldModel.COW, l.x-1, l.y)) c++;
+ if (ia.model.hasObject(WorldModel.COW, l.x, l.y+1)) c++;
+ if (ia.model.hasObject(WorldModel.COW, l.x, l.y-1)) c++;
+ if (ia.model.hasObject(WorldModel.COW, l.x+1, l.y+1)) c++;
+ if (ia.model.hasObject(WorldModel.COW, l.x-1, l.y+1)) c++;
+ if (ia.model.hasObject(WorldModel.COW, l.x+1, l.y-1)) c++;
+ if (ia.model.hasObject(WorldModel.COW, l.x-1, l.y-1)) c++;
+ */
}
public boolean equals(Object o) {
Added: trunk/applications/jason-team/src/java/jia/Vec.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/Vec.java (rev 0)
+++ trunk/applications/jason-team/src/java/jia/Vec.java 2008-04-08 16:38:29 UTC (rev 1206)
@@ -0,0 +1,101 @@
+package jia;
+
+import jason.environment.grid.Location;
+
+import java.util.List;
+
+import arch.LocalWorldModel;
+
+
+public class Vec {
+
+ public final int x,y;
+
+ public Vec(int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ /** create a vector based on a location in the model */
+ public Vec(LocalWorldModel model, Location l) {
+ this.x = l.x;
+ this.y = model.getHeight()-l.y-1;
+ }
+
+ public int getX() { return x; }
+ public int getY() { return y; }
+ public Location getLocation(LocalWorldModel model) {
+ return new Location(x, model.getHeight()-y-1);
+ }
+
+ public double magnitude() {
+ return Math.sqrt(x*x + y*y);
+ }
+
+ public Vec add(Vec v) {
+ return new Vec(x + v.x, y + v.y);
+ }
+ public Vec sub(Vec v) {
+ return new Vec(x - v.x, y - v.y);
+ }
+ public Vec product(double e) {
+ return new Vec((int)(x * e), (int)(y *e));
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null) return false;
+ if (o == this) return true;
+ if (o instanceof Vec) {
+ Vec v = (Vec)o;
+ return (x == v.x) && (y == v.y);
+ }
+ return false;
+ }
+
+ public static Vec max(List<Vec> vs) {
+ Vec max = null;
+ if (vs.size() > 0)
+ max = vs.get(0);
+ for (Vec v: vs) {
+ if (max.magnitude() < v.magnitude())
+ max = v;
+ }
+ return max;
+ }
+
+ public static Vec mean(List<Vec> vs) {
+ if (vs.isEmpty())
+ return new Vec(0,0);
+ int x = 0, y = 0;
+ for (Vec v: vs) {
+ x += v.x;
+ y += v.y;
+ }
+ return new Vec(x/vs.size(), y/vs.size());
+ }
+
+
+
+
+ public static Vec stddev(List<Vec> vs) {
+ if (vs.isEmpty())
+ return new Vec(0,0);
+ Vec mean = mean(vs);
+ int x = 0, y = 0;
+ for (Vec v: vs) {
+ x += Math.pow(v.x - mean.x,2);
+ y += Math.pow(v.y - mean.y,2);
+ }
+ x = x / vs.size();
+ y = y / vs.size();
+
+ return new Vec( (int)Math.sqrt(x), (int)Math.sqrt(y));
+ }
+
+
+ @Override
+ public String toString() {
+ return x + "," + y;
+ }
+}
Modified: trunk/applications/jason-team/src/java/jia/direction.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/direction.java 2008-04-07 13:27:34 UTC (rev 1205)
+++ trunk/applications/jason-team/src/java/jia/direction.java 2008-04-08 16:38:29 UTC (rev 1206)
@@ -11,9 +11,10 @@
import java.util.Random;
import java.util.logging.Level;
+import busca.Nodo;
+
import arch.CowboyArch;
import arch.LocalWorldModel;
-import busca.Nodo;
import env.WorldModel;
/**
@@ -24,9 +25,15 @@
*/
public class direction extends DefaultInternalAction {
- int[] actionsOrder = { 1, 2, 3, 4, 5, 6, 7, 8}; // initial order of actions
+ WorldModel.Move[] actionsOrder = new WorldModel.Move[WorldModel.nbActions];
Random random = new Random();
+ public direction() {
+ for (int i=0; i<WorldModel.nbActions; i++) {
+ actionsOrder[i] = Search.defaultActions[i];
+ }
+ }
+
@Override
public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
try {
@@ -50,11 +57,11 @@
// randomly change the place of two actions in actionsOrder
int i1 = random.nextInt(WorldModel.nbActions);
int i2 = random.nextInt(WorldModel.nbActions);
- int temp = actionsOrder[i2];
+ WorldModel.Move temp = actionsOrder[i2];
actionsOrder[i2] = actionsOrder[i1];
actionsOrder[i1] = temp;
- Search astar = new Search(model, from, to, actionsOrder, true, ts.getUserAgArch());
+ Search astar = new Search(model, from, to, actionsOrder, true, true, true, ts.getUserAgArch());
Nodo solution = astar.search();
if (solution != null) {
WorldModel.Move m = astar.firstAction(solution);
Added: trunk/applications/jason-team/src/java/jia/herd_position.java
===================================================================
--- trunk/applications/jason-team/src/java/jia/herd_position.java (rev 0)
+++ trunk/applications/jason-team/src/java/jia/herd_position.java 2008-04-08 16:38:29 UTC (rev 1206)
@@ -0,0 +1,67 @@
+package jia;
+
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.NumberTermImpl;
+import jason.asSyntax.Term;
+import jason.environment.grid.Location;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+
+import arch.CowboyArch;
+import arch.LocalWorldModel;
+import env.WorldModel;
+
+/**
+ * Gives a good location to herd cows
+ *
+ * @author jomi
+ */
+public class herd_position extends DefaultInternalAction {
+
+ public static final double maxStdDev = 3;
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
+ try {
+
+ LocalWorldModel model = ((CowboyArch)ts.getUserAgArch()).getModel();
+
+ Location agTarget = model.nearFree(getAgTarget(model));
+ return un.unifies(terms[0], new NumberTermImpl(agTarget.x)) &&
+ un.unifies(terms[1], new NumberTermImpl(agTarget.y));
+ } catch (Throwable e) {
+ ts.getLogger().log(Level.SEVERE, "herd_position error: "+e, e);
+ }
+ return false;
+ }
+
+ public Location getAgTarget(LocalWorldModel model) throws Exception {
+ List<Vec> cowsTarget = new ArrayList<Vec>();
+ for (Location c: model.getCows()) {
+ Search s = new Search(model, c, model.getCorralCenter(), null, false, false, false, null);
+ Location cowTarget = WorldModel.getNewLocationForAction(c, s.firstAction(s.search()));
+ cowsTarget.add(new Vec(model, cowTarget));
+ }
+
+ Vec stddev = Vec.stddev(cowsTarget);
+
+ // remove max if stddev is too big
+ while (stddev.magnitude() > maxStdDev) {
+ cowsTarget.remove(Vec.max(cowsTarget));
+ stddev = Vec.stddev(cowsTarget);
+ }
+
+ Vec mean = Vec.mean(cowsTarget);
+ if (mean.magnitude() > 0) {
+ double incvalue = (Vec.max(cowsTarget).sub(mean).magnitude()+2) / mean.magnitude();
+ return mean.product(incvalue+1).getLocation(model);
+ } else {
+ return null;
+ }
+ }
+}
+
Added: trunk/applications/jason-team/src/java/test/TestBasicHerding.java
===================================================================
--- trunk/applications/jason-team/src/java/test/TestBasicHerding.java (rev 0)
+++ trunk/applications/jason-team/src/java/test/TestBasicHerding.java 2008-04-08 16:38:29 UTC (rev 1206)
@@ -0,0 +1,124 @@
+package test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import jason.environment.grid.Location;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import jia.Search;
+import jia.Vec;
+import jia.herd_position;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import arch.LocalWorldModel;
+import busca.Nodo;
+import env.WorldModel;
+
+public class TestBasicHerding {
+
+ Vec cow;
+ Vec[] cows;
+ Vec cowboy;
+ LocalWorldModel model;
+
+ @Before
+ public void scenario() {
+ model = new LocalWorldModel(50,50);
+ model.setCorral(new Location(0,49), new Location(2,49));
+
+ cow = new Vec(6,7);
+ cowboy = new Vec(3,5);
+
+ cows = new Vec[4];
+ cows[0] = cow;
+ cows[1] = new Vec(5,30);
+ cows[2] = new Vec(4,8);
+ cows[3] = new Vec(5,10);
+
+ for (int i=0; i<cows.length; i++)
+ model.addCow(cows[i].getLocation(model));
+
+ }
+
+ @Test
+ public void testVect() {
+ //assertEquals(new Vec(6,7), cow.add(cowboy));
+ //assertEquals(new Location(6,42), cow.add(cowboy).getLocation(model));
+ assertEquals(new Location(3,44), cowboy.getLocation(model));
+ assertEquals(new Location(1,49), model.getCorralCenter());
+ assertEquals(new Vec(3,2), cow.sub(cowboy)); //new Vec(model, cowboy.getLocation(model), cow.add(cowboy).getLocation(model)));
+ }
+
+ /*
+ @Test
+ public void oneCow() throws Exception {
+ // get the location the cow should go
+ Location cowLocation = cow.getLocation(model);
+
+ // search cow desired location
+ Search s = new Search(model, cowLocation, model.getCorralCenter(), null, false, false, false, null);
+ Nodo path = s.search();
+ assertEquals(8, path.g()); //firstAction(path));
+
+ // cow target in direction to corral
+ Location cowTarget = WorldModel.getNewLocationForAction(cowLocation, s.firstAction(path));
+ //assertEquals(new Location(5,43), cowTarget);
+ Vec cowVecTarget = new Vec(model, cowTarget);
+ //assertEquals(new Vec(5,6), cowVecTarget);
+
+ // agent target to push cow into corral
+ Vec agVecTarget = cow.sub(cowVecTarget).product(2).add(cow);
+ Location agTarget = agVecTarget.getLocation(model);
+ //assertEquals(new Location(8,40), agTarget);
+
+ s = new Search(model, cowboy.getLocation(model), agTarget, null, true, true, true, null);
+ path = s.search();
+ System.out.println(path.g() + " " + path.montaCaminho());
+ assertEquals(12, path.g());
+ }
+ */
+
+
+ @Test
+ public void moreCows() throws Exception {
+ // get the location the cows should go
+ List<Vec> cowsTarget = new ArrayList<Vec>();
+ for (int i=0; i<cows.length; i++) {
+ Search s = new Search(model, cows[i].getLocation(model), model.getCorralCenter(), null, false, false, false, null);
+ Location cowTarget = WorldModel.getNewLocationForAction(cows[i].getLocation(model), s.firstAction(s.search()));
+ cowsTarget.add(new Vec(model, cowTarget));
+ }
+ //System.out.println(cowsTarget);
+
+ Vec stddev = Vec.stddev(cowsTarget);
+ assertEquals(new Vec(0,9), stddev);
+
+ // remove max if stddev is too big
+ while (stddev.magnitude() > 3) {
+ cowsTarget.remove(Vec.max(cowsTarget));
+ stddev = Vec.stddev(cowsTarget);
+ }
+ assertTrue(stddev.magnitude() < 3);
+
+ Vec mean = Vec.mean(cowsTarget);
+ assertEquals(new Vec(5,7), mean);
+ double incvalue = (Vec.max(cowsTarget).sub(mean).magnitude()+2) / mean.magnitude();
+ //System.out.println( incvalue);
+ Vec agTarget = mean.product(incvalue+1);
+ //System.out.println(agTarget);
+ assertEquals(new Vec(7,10), agTarget);
+
+ Location byIA = new herd_position().getAgTarget(model);
+ assertEquals(byIA, agTarget.getLocation(model));
+
+ Search s = new Search(model, cowboy.getLocation(model), agTarget.getLocation(model), null, true, true, true, null);
+ Nodo path = s.search();
+ //System.out.println(path.g() + " " + path.montaCaminho());
+ assertEquals(14, path.g());
+
+ }
+}
Modified: trunk/src/jason/environment/grid/Location.java
===================================================================
--- trunk/src/jason/environment/grid/Location.java 2008-04-07 13:27:34 UTC (rev 1205)
+++ trunk/src/jason/environment/grid/Location.java 2008-04-08 16:38:29 UTC (rev 1206)
@@ -1,7 +1,7 @@
package jason.environment.grid;
public final class Location {
- public int x, y;
+ public final int x, y;
public Location(int x, int y) {
this.x = x;
@@ -13,6 +13,16 @@
return Math.abs(x - l.x) + Math.abs(y - l.y);
}
+ /** calculates the Euclidean distance between two points */
+ public double distanceEuclidean(Location l) {
+ return Math.sqrt(Math.pow(x - l.x, 2) + Math.pow(y - l.y, 2));
+ }
+
+ /** returns Math.max( Math.abs(this.x - l.x) , Math.abs(this.y - l.y)) */
+ public int maxBorder(Location l) {
+ return Math.max( Math.abs(this.x - l.x) , Math.abs(this.y - l.y));
+ }
+
public boolean isNeigbour(Location l) {
return
distance(l) == 1 ||
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-04-07 13:27:41
|
Revision: 1205
http://jason.svn.sourceforge.net/jason/?rev=1205&view=rev
Author: jomifred
Date: 2008-04-07 06:27:34 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
set next version as 1.1
Modified Paths:
--------------
trunk/applications/jason-eclipse-plugin/README-jason-eclipse-plugin.txt
trunk/applications/jason-team/readme.txt
trunk/build.xml
trunk/doc/faq/faq.tex
trunk/release-notes.txt
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
Modified: trunk/applications/jason-eclipse-plugin/README-jason-eclipse-plugin.txt
===================================================================
--- trunk/applications/jason-eclipse-plugin/README-jason-eclipse-plugin.txt 2008-04-07 12:21:23 UTC (rev 1204)
+++ trunk/applications/jason-eclipse-plugin/README-jason-eclipse-plugin.txt 2008-04-07 13:27:34 UTC (rev 1205)
@@ -1,7 +1,7 @@
-Jason Plugin for Eclipse
-
-Requirements
-. Jason >= 1.0.1
-. Eclipse >= 3.2
-
-More information at http://jasonplugin.wikidot.com
\ No newline at end of file
+Jason Plugin for Eclipse
+
+Requirements
+. Jason >= 1.0.1
+. Eclipse >= 3.2
+
+More information at http://jasonplugin.wikidot.com
Modified: trunk/applications/jason-team/readme.txt
===================================================================
--- trunk/applications/jason-team/readme.txt 2008-04-07 12:21:23 UTC (rev 1204)
+++ trunk/applications/jason-team/readme.txt 2008-04-07 13:27:34 UTC (rev 1205)
@@ -1,66 +1,66 @@
-/*
- * Jason Team for the
- * Multi-Agent Programming Contest 2008
- * (http://cig.in.tu-clausthal.de/agentcontest2008)
- *
- * By
- * Jomi F. Hubner (EMSE, France)
- * Rafael H. Bordini (Durhma, UK)
- * Gauthier Picard (EMSE, France)
- */
-
-
-To run this team:
-
-1. update sources of Jason
- cd Jason-svn
- svn update
- ant plugin
-
-2. run massim-server
- cd applications/jason-team/massim-server
- ./startServer.sh
-
-3. run massim-agents (6 agents developed by the ContestTeam)
- cd ../massim-agents
- ./startAgents.sh
-
-4. run Jason dummies (for now we do not have a team)
- a. by JasonIDE
- ../../bin/jason.sh
- open an run AC-Local-JasonTeam.mas2j
-
- b. by Ant (only after run once by JasonIDE)
- ant -f bin/build.xml
-
-5. start the simulation
- go to shell running startServer.sh and press ENTER
-
-6. you can get the agents location with the command
-
- tail -f world-status.txt
-
-7. the get the graphical view of some agent, add gui=yes in
- the agent's option (.mas2j file)
-
-
-
----- OLD ----
-
-Our team can run in three configurations (Jason 1.0.2 is required):
-
-1. With a local simulator developed by us to test the team.
-
- Using JasonIDE, open the project Local-JasonTeam.mas2j and
- run it.
-
-2. With the competition simulator running at localhost.
-
- Using JasonIDE, open the project AC-Local-JasonTeam.mas2j
- and run it.
-
-3. With the competition simulator (during the tournament)
-
- Using JasonIDE, open the project AC-JasonTeam.mas2j
- and run it.
-
+/*
+ * Jason Team for the
+ * Multi-Agent Programming Contest 2008
+ * (http://cig.in.tu-clausthal.de/agentcontest2008)
+ *
+ * By
+ * Jomi F. Hubner (EMSE, France)
+ * Rafael H. Bordini (Durhma, UK)
+ * Gauthier Picard (EMSE, France)
+ */
+
+
+To run this team:
+
+1. update sources of Jason
+ cd Jason-svn
+ svn update
+ ant plugin
+
+2. run massim-server
+ cd applications/jason-team/massim-server
+ ./startServer.sh
+
+3. run massim-agents (6 agents developed by the ContestTeam)
+ cd ../massim-agents
+ ./startAgents.sh
+
+4. run Jason dummies (for now we do not have a team)
+ a. by JasonIDE
+ ../../bin/jason.sh
+ open an run AC-Local-JasonTeam.mas2j
+
+ b. by Ant (only after run once by JasonIDE)
+ ant -f bin/build.xml
+
+5. start the simulation
+ go to shell running startServer.sh and press ENTER
+
+6. you can get the agents location with the command
+
+ tail -f world-status.txt
+
+7. the get the graphical view of some agent, add gui=yes in
+ the agent's option (.mas2j file)
+
+
+
+---- OLD ----
+
+Our team can run in three configurations (Jason 1.0.2 is required):
+
+1. With a local simulator developed by us to test the team.
+
+ Using JasonIDE, open the project Local-JasonTeam.mas2j and
+ run it.
+
+2. With the competition simulator running at localhost.
+
+ Using JasonIDE, open the project AC-Local-JasonTeam.mas2j
+ and run it.
+
+3. With the competition simulator (during the tournament)
+
+ Using JasonIDE, open the project AC-JasonTeam.mas2j
+ and run it.
+
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-04-07 12:21:23 UTC (rev 1204)
+++ trunk/build.xml 2008-04-07 13:27:34 UTC (rev 1205)
@@ -14,7 +14,7 @@
<property name="dist.properties" value="${basedir}/bin/dist.properties" />
<property name="version" value="1" />
- <property name="release" value="0.2" />
+ <property name="release" value="1" />
<property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" />
<property name="distFile" value="${env.HOME}/Jason-${version}.${release}" />
Modified: trunk/doc/faq/faq.tex
===================================================================
--- trunk/doc/faq/faq.tex 2008-04-07 12:21:23 UTC (rev 1204)
+++ trunk/doc/faq/faq.tex 2008-04-07 13:27:34 UTC (rev 1205)
@@ -17,7 +17,7 @@
\html{\begin{rawhtml}<h0><b><i>Jason</i></b> FAQ
- <br><font size="-1">(for version 1.0.1)</font></h0>
+ <br><font size="-1">(for version 1.1)</font></h0>
\end{rawhtml}}
\latex{\begin{center}{\Huge\jason FAQ}\end{center}}
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-04-07 12:21:23 UTC (rev 1204)
+++ trunk/release-notes.txt 2008-04-07 13:27:34 UTC (rev 1205)
@@ -20,8 +20,8 @@
. A list of goals can be sent with the "achieve" performative:
.send(bob,achieve,[g1,g2,g3])
- Note that each will become a separate intention of bob (if
- the message is accepted).
+ Note that each goal will become a separate intention of bob
+ (if the message is accepted).
New example:
. the Jason team used in the Agent Contest 2007 was added to the
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-04-07 12:21:23 UTC (rev 1204)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-04-07 13:27:34 UTC (rev 1205)
@@ -339,28 +339,7 @@
) { return new Trigger(teOp,teType,F); }
}
-/* Literal */
-Literal literal() : { Pred F; Token k; boolean type = Literal.LPos; }
-{
- ( ( [ <TK_NEG> { type = Literal.LNeg; }
- ]
- F=pred() { if (F.getFunctor().indexOf(".") >= 0) {
- try {
- return new InternalActionLiteral(F, curAg);
- } catch (Exception e) {
- if (getArithFunction(F) == null) // it is not a registered function
- throw new ParseException(getSourceRef(F)+" The internal action class for '"+F+"' was not found!");
- }
- }
- return new Literal(type,F);
- }
- )
- | k=<TK_TRUE> { return Literal.LTrue; }
- | k=<TK_FALSE> { return Literal.LFalse; }
- )
-}
-
/* Plan body */
Object plan_body() : { Object F; Object R = null; }
{
@@ -411,6 +390,27 @@
}
+/* Literal */
+Literal literal() : { Pred F; Token k; boolean type = Literal.LPos; }
+{
+ ( ( [ <TK_NEG> { type = Literal.LNeg; }
+ ]
+ F=pred() { if (F.getFunctor().indexOf(".") >= 0) {
+ try {
+ return new InternalActionLiteral(F, curAg);
+ } catch (Exception e) {
+ if (getArithFunction(F) == null) // it is not a registered function
+ throw new ParseException(getSourceRef(F)+" The internal action class for '"+F+"' was not found!");
+ }
+ }
+ return new Literal(type,F);
+ }
+ )
+ | k=<TK_TRUE> { return Literal.LTrue; }
+ | k=<TK_FALSE> { return Literal.LFalse; }
+ )
+}
+
/* Annotated Formulae */
Pred pred() : { Token K; Pred p; List l; ListTerm lt;}
{
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-04-07 12:21:23 UTC (rev 1204)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-04-07 13:27:34 UTC (rev 1205)
@@ -434,50 +434,6 @@
throw new Error("Missing return statement in function");
}
-/* Literal */
- final public Literal literal() throws ParseException {
- Pred F; Token k; boolean type = Literal.LPos;
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case TK_NEG:
- case TK_BEGIN:
- case TK_END:
- case ATOM:
- switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
- case TK_NEG:
- jj_consume_token(TK_NEG);
- type = Literal.LNeg;
- break;
- default:
- jj_la1[17] = jj_gen;
- ;
- }
- F = pred();
- if (F.getFunctor().indexOf(".") >= 0) {
- try {
- {if (true) return new InternalActionLiteral(F, curAg);}
- } catch (Exception e) {
- if (getArithFunction(F) == null) // it is not a registered function
- {if (true) throw new ParseException(getSourceRef(F)+" The internal action class for '"+F+"' was not found!");}
- }
- }
- {if (true) return new Literal(type,F);}
- break;
- case TK_TRUE:
- k = jj_consume_token(TK_TRUE);
- {if (true) return Literal.LTrue;}
- break;
- case TK_FALSE:
- k = jj_consume_token(TK_FALSE);
- {if (true) return Literal.LFalse;}
- break;
- default:
- jj_la1[18] = jj_gen;
- jj_consume_token(-1);
- throw new ParseException();
- }
- throw new Error("Missing return statement in function");
- }
-
/* Plan body */
final public Object plan_body() throws ParseException {
Object F; Object R = null;
@@ -490,7 +446,7 @@
if (!(R instanceof PlanBody)) {if (true) throw new ParseException(getSourceRef(R)+" "+R+" is not a body literal!");}
break;
default:
- jj_la1[19] = jj_gen;
+ jj_la1[17] = jj_gen;
;
}
if (F instanceof PlanBody && R instanceof PlanBody) {
@@ -534,18 +490,18 @@
formType = BodyType.delAddBel;
break;
default:
- jj_la1[20] = jj_gen;
+ jj_la1[18] = jj_gen;
;
}
break;
default:
- jj_la1[21] = jj_gen;
+ jj_la1[19] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
default:
- jj_la1[22] = jj_gen;
+ jj_la1[20] = jj_gen;
;
}
B = log_expr();
@@ -568,6 +524,50 @@
throw new Error("Missing return statement in function");
}
+/* Literal */
+ final public Literal literal() throws ParseException {
+ Pred F; Token k; boolean type = Literal.LPos;
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case TK_NEG:
+ case TK_BEGIN:
+ case TK_END:
+ case ATOM:
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
+ case TK_NEG:
+ jj_consume_token(TK_NEG);
+ type = Literal.LNeg;
+ break;
+ default:
+ jj_la1[21] = jj_gen;
+ ;
+ }
+ F = pred();
+ if (F.getFunctor().indexOf(".") >= 0) {
+ try {
+ {if (true) return new InternalActionLiteral(F, curAg);}
+ } catch (Exception e) {
+ if (getArithFunction(F) == null) // it is not a registered function
+ {if (true) throw new ParseException(getSourceRef(F)+" The internal action class for '"+F+"' was not found!");}
+ }
+ }
+ {if (true) return new Literal(type,F);}
+ break;
+ case TK_TRUE:
+ k = jj_consume_token(TK_TRUE);
+ {if (true) return Literal.LTrue;}
+ break;
+ case TK_FALSE:
+ k = jj_consume_token(TK_FALSE);
+ {if (true) return Literal.LFalse;}
+ break;
+ default:
+ jj_la1[22] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ throw new Error("Missing return statement in function");
+ }
+
/* Annotated Formulae */
final public Pred pred() throws ParseException {
Token K; Pred p; List l; ListTerm lt;
@@ -1236,10 +1236,10 @@
jj_la1_1();
}
private static void jj_la1_0() {
- jj_la1_0 = new int[] {0x8000000,0x10cb00,0x8000000,0x80000000,0x8000000,0x10000,0x10cb00,0x8000000,0x8000000,0x20000000,0x10000,0x0,0x0,0x0,0x80000000,0x80000000,0x30cb80,0x800,0x10cb00,0x0,0x0,0x80000000,0x80000000,0x10c000,0x0,0x0,0x0,0x3acf80,0x0,0x200080,0x0,0x3acb80,0x3acb80,0x0,0x0,0x3acf80,0x3acb80,0x0,0x3acb80,0x0,0x0,0x0,0x3000,0x3000,0x0,0x32cb80,0x200080,0x0,};
+ jj_la1_0 = new int[] {0x8000000,0x10cb00,0x8000000,0x80000000,0x8000000,0x10000,0x10cb00,0x8000000,0x8000000,0x20000000,0x10000,0x0,0x0,0x0,0x80000000,0x80000000,0x30cb80,0x0,0x0,0x80000000,0x80000000,0x800,0x10cb00,0x10c000,0x0,0x0,0x0,0x3acf80,0x0,0x200080,0x0,0x3acb80,0x3acb80,0x0,0x0,0x3acf80,0x3acb80,0x0,0x3acb80,0x0,0x0,0x0,0x3000,0x3000,0x0,0x32cb80,0x200080,0x0,};
}
private static void jj_la1_1() {
- jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x1,0x2,0xc,0x10,0x10,0x0,0x0,0x0,0x20,0x4,0x5c,0x5c,0x0,0x80,0x400,0x200,0x488,0x200,0x400,0x800,0x488,0x488,0x800,0x2000,0x88,0x88,0x3fc000,0x488,0x3fc000,0xc,0xc,0xc00000,0xc00000,0x1000000,0x88,0x0,0x400,};
+ jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x1,0x2,0xc,0x10,0x10,0x0,0x20,0x4,0x5c,0x5c,0x0,0x0,0x0,0x80,0x400,0x200,0x488,0x200,0x400,0x800,0x488,0x488,0x800,0x2000,0x88,0x88,0x3fc000,0x488,0x3fc000,0xc,0xc,0xc00000,0xc00000,0x1000000,0x88,0x0,0x400,};
}
final private JJCalls[] jj_2_rtns = new JJCalls[1];
private boolean jj_rescan = false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <bo...@us...> - 2008-04-07 12:21:30
|
Revision: 1204
http://jason.svn.sourceforge.net/jason/?rev=1204&view=rev
Author: bordini
Date: 2008-04-07 05:21:23 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
Edited the release notes for imminent release 1.1
Modified Paths:
--------------
trunk/release-notes.txt
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-04-03 13:25:42 UTC (rev 1203)
+++ trunk/release-notes.txt 2008-04-07 12:21:23 UTC (rev 1204)
@@ -1,28 +1,32 @@
--------------
-version 1.0.2
--------------
+-----------
+version 1.1
+-----------
New features
-. Performance improvements: in general, an application runs 30%
+. Performance improvements: in general, applications run 30%
faster.
. Arithmetic functions: math.abs, math.max, ...
see doc/index.html and demo/function for more information
-. Compiler warns about singleton variables in plans and rules
- (see plugin options to disable this feature)
+. Compiler warns about "singleton variables" in plans and rules
+ (see plugin options to disable this feature). If you don't use
+ anonymous variables for logical variables whose contents will
+ not be used, you may want to disable this feature.
. Terms can be logical expressions, as in the following
example of .findall usage:
.findall(X, (a(X) & X > 10), L)
-. A list of goals can be sent by achieve performative:
+. A list of goals can be sent with the "achieve" performative:
.send(bob,achieve,[g1,g2,g3])
+ Note that each will become a separate intention of bob (if
+ the message is accepted).
New example:
-. the Jason team used in the Agent Contest 2007 was added in the
- examples (directory gold-miners-II)
-. a GUI is added in the IPD example
+. the Jason team used in the Agent Contest 2007 was added to the
+ examples (folder gold-miners-II)
+. a GUI was added to the IPD example
New demo:
. function: shows how to create new arithmetic functions.
@@ -32,12 +36,12 @@
. .union, .intersection and .difference of sets.
Bugs fixed:
-. the internal action .concat does not clone the lists properly
-. +?b(X) plans does not "return" the X value
-. +!A catch events like +p
-. JDBC belief base does not work with null values
-. The MAS does not stop running when the "stop" button is pressed
-. The parser allows to mix initial beliefs and goals with plans.
+. the internal action .concat did not clone the lists properly
+. +?b(X) plans did not "return" the X value (bug in 1.0.1 only)
+. +!A used to catch events of the form +p
+. JDBC belief base did not work with null values
+. The MAS did not stop running when the "stop" button is pressed
+. The parser allowed mixing initial beliefs and goals with plans.
-------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-03 13:25:50
|
Revision: 1203
http://jason.svn.sourceforge.net/jason/?rev=1203&view=rev
Author: tomklapiscak
Date: 2008-04-03 06:25:42 -0700 (Thu, 03 Apr 2008)
Log Message:
-----------
Removed unnecessary .jars
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/lib/bebops.jar
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/lib/pellet/jena/
trunk/applications/jasdl-owlapi/lib/pellet/junit/
trunk/applications/jasdl-owlapi/lib/pellet/owlapi/
Modified: trunk/applications/jasdl-owlapi/lib/bebops.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-03 01:24:28
|
Revision: 1202
http://jason.svn.sourceforge.net/jason/?rev=1202&view=rev
Author: tomklapiscak
Date: 2008-04-02 18:24:25 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Implemented experimental annotation gathering functionality (using Bebops library). Disabled by default, can be enabled in .mas2j (jasdl_useAnnotationGathering="true").
Implemented jasdl.ia.is_annotation_gathering_enabled and jasdl_ia.is_belief_revision_enabled internal actions to test status of experiemental features.
Implemented jasdl.ia.set_annotation_gathering_enabled and jasdl.ia.set_belief_revision_enabled internal actions to complement .mas2j settings.
Implemented workaround for strange behaviour when using Pellets isConsistent(OWLOntology) method (with agent.isBBConsistent() method).
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/build.xml
trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl
trunk/applications/jasdl-owlapi/lib/bebops.jar
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlIncisionFunction.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java
trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlException.java
Added Paths:
-----------
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/set_annotation_gathering_enabled.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/set_belief_revision_enabled.java
Modified: trunk/applications/jasdl-owlapi/build.xml
===================================================================
--- trunk/applications/jasdl-owlapi/build.xml 2008-04-02 21:13:50 UTC (rev 1201)
+++ trunk/applications/jasdl-owlapi/build.xml 2008-04-03 01:24:25 UTC (rev 1202)
@@ -2,12 +2,16 @@
<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 name="source.dir" value="${basedir}/src" />
<property name="build.dir" value="${basedir}/bin" />
<property name="apidocs.dir" value="${basedir}/doc/api" />
- <property name="jar.file" value="${basedir}/lib/jasdl.jar" />
+ <property name="lib.dir" value="${basedir}/lib" />
+ <property name="jasdl.jar" value="${lib.dir}/jasdl.jar" />
+
<path id="project.classpath">
<pathelement location="${jason.dir}/lib/jason.jar"/>
@@ -26,21 +30,27 @@
<target name="init">
<tstamp/>
<mkdir dir="${build.dir}"/>
+ <available file="${bebops.dir}" type="dir" property="bebops.available"/>
</target>
- <target name="compile" depends="init">
+ <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">
<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>
</target>
<target name="jar" depends="compile">
- <jar destfile="${jar.file}" basedir="./bin" includes="**/*.class"/>
+ <jar destfile="${jasdl.jar}" basedir="./bin" includes="**/*.class"/>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
- <delete file="${jar.file}"/>
+ <delete file="${jasdl.jar}"/>
<delete dir="${apidocs.dir}"/>
</target>
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-04-02 21:13:50 UTC (rev 1201)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-04-03 01:24:25 UTC (rev 1202)
@@ -32,6 +32,7 @@
travel_agent.asl
[
jasdl_useBeliefRevision = "true", // use experimental DL-based belief revision mechanism
+ jasdl_useAnnotationGathering = "true", // use experimental annotation gathering mechanism
/*
* To use FaCT++, set the below. Must have libFaCTPlusPlusJNI.so in /usr/lib (or the equivalent for Mac or Windows)
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl 2008-04-02 21:13:50 UTC (rev 1201)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl 2008-04-03 01:24:25 UTC (rev 1202)
@@ -19,12 +19,12 @@
*/
!start(total).
-!start(ubb1).!example_UBB_1.!end(ubb1).
-!start(ubb2).!example_UBB_2.!end(ubb2).
+!start(ubb1).!example_UBB.!end(ubb1).
+!start(ubb2).!example_brf.!end(ubb2).
!start(qbb).!example_QBB.!end(qbb).
!start(rpp).!example_RPP.!end(rpp).
!start(all_different).!example_all_different.!end(all_different).
-//!example_annotation_gathering.
+!start(annnotation_gathering).!example_annotation_gathering.!end(annnotation_gathering).
!start(ksaa).!example_KSAA.!end(ksaa).
//!end(total) is within example_KSAA_complete to allow inter-agent communication to finish
@@ -42,9 +42,9 @@
.print("Execution time for counter ",A,": ",TotalTime,"s").
@example_ubb_1[atomic]
-+!example_UBB_1
++!example_UBB
<-
- .print("Example: Updating Belief Base 1");
+ .print("Example: Updating Belief Base");
+hotel(hilton)[o(travel)]; // hilton is a hotel
+hasRating(hilton, threeStarRating)[o(travel)]; // hilton has three-star rating
+town(london)[o(travel)];
@@ -58,12 +58,23 @@
+museums(scienceMuseum)[o(travel)];
+hasActivity(london, scienceMuseum)[o(travel)];
+hotel(travel_lodge)[o(travel)];
- .print("Completed: Updating Belief Base 1").
+ .print("Completed: Updating Belief Base").
+
+@example_brf[atomic]
++!example_brf
+ <-
+ jasdl.ia.is_belief_revision_enabled(true);
+ !example_brf_continue.
-@example_ubb_2[atomic]
-+!example_UBB_2
+@example_brf_fail[atomic]
+-!example_brf
+ <-
+ .print("Belief revision feature disabled, skipping").
+
+@example_brf_continue[atomic]
++!example_brf_continue
<-
- .print("Example: Updating Belief Base 2");
+ .print("Example: Belief Revision");
jasdl.ia.define_class(tiny, "travel:urbanArea and travel:hasActivity max 1 travel:activity");
+tiny(newcastle)[o(self), source(tom)];
@@ -83,25 +94,19 @@
+ruralArea(somewhere)[o(travel), source(tom)];
?ruralArea(somewhere)[o(travel)];
-
-
-
- .print("DL-based belief revision is enabled"); // without, the above test-goal will fail, since legacy mechanism simply removes incoming inconsistent beliefs
-
-
// since the classes destination and and contact are disjoint (and ruralArea is a subclass of destination),
// and since we trust ben less than tom, the belief addition below will fail (and tom's assertion above will persist),
// thus failing the whole plan.
+contact(somewhere)[o(travel), source(ben)];
- .print("Failed: Updating Belief Base 2").
+ .print("Failed: Belief Revision").
-@example_UBB_2_failure[atomic]
--!example_UBB_2
+@example_brf_continue_fail[atomic]
+-!example_brf_continue
<-
// Notice this does not hold, since belief revision rejected the less trusted assertion made by ben.
?~contact(somewhere)[o(travel)];
- .print("Completed: Updating Belief Base 2").
+ .print("Completed: Belief Revision").
@example_qbb[atomic, breakpoint]
+!example_QBB
@@ -157,18 +162,22 @@
@example_all_different[atomic]
+!example_all_different
<-
- .print("Example: all_different assertion");
+
+
+ .print("Example: all_different assertion");
+destination(butlins)[o(travel)];
+hotel(butlins_hotel)[o(travel)];
+hasAccommodation(butlins, butlins_hotel)[o(travel)];
+yoga(butlins_yoga)[o(travel)];
- +sunbathing(butlins_sunbathing)[o(travel)];
+ +sunbathing(butlins_sunbathing)[o(travel)];
+hasActivity(butlins, butlins_yoga)[o(travel)];
+ //jasdl.ia.all_different([butlins_yoga, butlins_sunbathing], travel); - DEPRECATED (see below)
+hasActivity(butlins, butlins_sunbathing)[o(travel)];
- //jasdl.ia.all_different([butlins_yoga, butlins_sunbathing], travel); - DEPRECATED (see below)
- +all_different([butlins_yoga, butlins_sunbathing])[o(self), something]; // all_different now represented as an se-literal. We can now query, inspect and send these assertions
+ +all_different([butlins_yoga, butlins_sunbathing])[o(self)]; // all_different now represented as an se-literal. We can now query, inspect and send these assertions
+
// Query below will not succeed unless butlins_yoga and butlins_sunbathing are different individuals since family destination requires min 2 *different* activities.
// Note: OWL doesn't make UNA and since these individuals do not belong to disjoint classes, therefore they must be explicitly asserted as different.
+
?familyDestination(butlins)[o(travel)];
?all_different([butlins_yoga, butlins_sunbathing, hilton])[o(self)];
/* ?all_different([hilton, fourSeasons])[o(travel)]; */ // Will fail, since hilton and fourSeasons cannot be established as distinct
@@ -178,6 +187,17 @@
@example_annotation_gathering[atomic]
+!example_annotation_gathering
<-
+ jasdl.ia.is_annotation_gathering_enabled(true); // why does True not fail immediately? possible Jason bug?
+ !example_annotation_gathering_continue.
+
+@example_annotation_gathering_fail[atomic]
+-!example_annotation_gathering
+ <-
+ .print("Annotation gathering feature disabled, skipping").
+
+@example_annotation_gathering_continue[atomic]
++!example_annotation_gathering_continue
+ <-
.print("Example: annotation gathering");
+ruralArea(kingsworthy)[o(travel), annotation];
?destination(kingsworthy)[o(travel), annotation];
@@ -190,9 +210,10 @@
+urbanArea(x)[o(travel), source(tom)];
+ruralArea(y)[o(travel), source(ben)];
// because knowledge from tom and ben contributed to the inference that x and y are distinct
- ?all_different([x,y])[o(travel), source(tom), source(ben)];
+ ?all_different([x,y])[o(self), source(tom), source(ben)];
// notice "something" annotation is gathered (added in !example_all_different) here since it all_different assertion contributes to this inference
+ +all_different([butlins_yoga, butlins_sunbathing])[o(self), something];
?familyDestination(butlins)[o(travel), something];
.print("Complete: annotation gathering").
Modified: trunk/applications/jasdl-owlapi/lib/bebops.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-02 21:13:50 UTC (rev 1201)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-03 01:24:25 UTC (rev 1202)
@@ -98,10 +98,12 @@
private HashMap<Atom, Float> trustMap;
private boolean beliefRevisionEnabled;
+ private boolean annotationGatheringEnabled;
private List<MappingStrategy> defaultMappingStrategies = JasdlConfigurator.DEFAULT_MAPPING_STRATEGIES;
- public JasdlAgent(){
+
+ public JasdlAgent() throws Exception{
super();
// instantiate managers
@@ -160,7 +162,7 @@
public List<Literal> getABoxState() throws JasdlException{
List<Literal> bels = new Vector<Literal>();
for(OWLOntology ontology : ontologyManager.getOntologies()){
- for(OWLIndividualAxiom axiom : ontology.getIndividualAxioms()){
+ for(OWLIndividualAxiom axiom : ontology.getIndividualAxioms()){
Literal l = axiomToSELiteralConverter.convert(axiom).getLiteral();
bels.add(l);
}
@@ -184,10 +186,12 @@
public List<Literal>[] brf(Literal beliefToAdd, Literal beliefToDel, Intention i) throws RevisionFailedException {
// TODO: what annotations should revision contractions contain? all! (or none? - same effect)
+
// No! the same. -a[x] only undermines assertions leading to a[x]!
// if we are performing belief-revision all annotations will be gathered (shortcut - use none?) ensuring axiom will be obliterated
// annotations never solely lead to conflicts.
+ // TODO: these is a bug hiding in this somewhere. Using below causes strange failures
if(!isBeliefRevisionEnabled()){ // if experimental feature is disabled
return super.brf(beliefToAdd, beliefToDel, i);
}
@@ -210,13 +214,19 @@
BeliefBaseSemiRevisor bbrev = new BeliefBaseSemiRevisor(axiomToAdd, getOntologyManager(), new JasdlReasonerFactory(), getLogger());
List<OWLAxiom> contractList = bbrev.revise(new TBoxAxiomKernelsetFilter(), new JasdlIncisionFunction(this, sl));
- // will only have reached here if new belief is accepted.
- addList.add(beliefToAdd);
+
for(OWLAxiom contract : contractList){
removeList.add(axiomToSELiteralConverter.convert((OWLIndividualAxiom)contract).getLiteral());
}
- revisionApplied = true;
+ if(!removeList.isEmpty()){
+ getLogger().info("brf: contracted "+removeList);
+ revisionApplied = true;
+ }
+
+ addList.add(beliefToAdd); // will only reach here if belief accepted (or bef is disabled)
+
}catch(BebopsRevisionFailedException e){
+ getLogger().info("brf: rejected "+e.getMessage());
throw new RevisionFailedException(); // propagate upwards
}catch(NotEnrichedException e){
// can't perform DL-based belief revision on SN-Literals
@@ -233,6 +243,7 @@
// Need to perform removals before additions so our ontology instance never becomes inconsistent
for(Literal removed : removeList){
+
boolean ok = false;
if(revisionApplied){
ok = true;
@@ -246,7 +257,8 @@
}
ok = believes(removed, u);
if(ok) removed.apply(u);
- }
+ }
+
if(ok){
if(getBB().remove(removed)){
if(toReturn == null){
@@ -545,7 +557,8 @@
}
} catch (OWLReasonerException e) {
throw new JasdlException("Unable to refresh reasoner. Reason: "+e);
- }
+ }
+
}
@@ -561,9 +574,25 @@
Log4JLogger kb_logger = (Log4JLogger)pellet.getKB().log;
kb_logger.getLogger().setLevel(level);
}
- }
+ }
/**
+ * For some reason, use of pellet's isConsistent(OWLOntology) method causes strange behaviour.
+ * So we wrap it's isConsistent() method here.
+ * TODO: resolve this issue properly
+ * @return
+ * @throws JasdlException
+ */
+ public boolean isBBConsistent() throws JasdlException{
+ if(getReasoner() instanceof org.mindswap.pellet.owlapi.Reasoner){
+ return((org.mindswap.pellet.owlapi.Reasoner)getReasoner()).isConsistent();
+ }else{
+ //TODO: FaCT++
+ throw new JasdlException("isBBConsistent not implemented for FaCT++ reasoner");
+ }
+ }
+
+ /**
* *Must* be unique within society!
* @return
*/
@@ -676,7 +705,20 @@
return trustMap.get(name);
}
+
+
+ public boolean isAnnotationGatheringEnabled() {
+ return annotationGatheringEnabled;
+ }
+
+
+
+ public void setAnnotationGatheringEnabled(boolean annotationGatheringEnabled) {
+ this.annotationGatheringEnabled = annotationGatheringEnabled;
+ }
+
+
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-04-02 21:13:50 UTC (rev 1201)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-04-03 01:24:25 UTC (rev 1202)
@@ -20,6 +20,7 @@
import java.util.Vector;
import java.util.logging.Level;
+import org.mindswap.pellet.PelletOptions;
import org.semanticweb.owl.inference.OWLReasoner;
import org.semanticweb.owl.model.OWLEntity;
import org.semanticweb.owl.model.OWLOntology;
@@ -34,14 +35,15 @@
public static String MAS2J_TRUSTRATING = "_trustRating";
public static String MAS2J_KNOWNAGENTS = "_knownAgents";
public static String MAS2J_USEBELIEFREVISION = "_useBeliefRevision";
+ public static String MAS2J_USEANNOTATIONGATHERING = "_useAnnotationGathering";
public static String MAS2J_REASONERCLASS = "_reasonerClass";
public static List<MappingStrategy> DEFAULT_MAPPING_STRATEGIES = Arrays.asList( new MappingStrategy[] { new DecapitaliseMappingStrategy()} );
public static String DEFAULT_REASONER_CLASS = "org.mindswap.pellet.owlapi.Reasoner";
public static boolean DEFAULT_USEBELIEFREVISION = false;
+ public static boolean DEFAULT_USEANNOTATIONGATHERING = false;
-
/**
* List of reserved ontology labels. Currently:
* <ul>
@@ -65,6 +67,7 @@
loadReasoner(stts);
loadDefaultMappingStrategies(stts);
setUseBeliefRevision(stts);
+ setUseAnnotationGathering(stts);
loadOntologies(stts);
applyManualMappings(stts);
loadKnownAgents(stts);
@@ -108,7 +111,17 @@
}
}
+ private void setUseAnnotationGathering(Settings stts) throws JasdlException{
+ try{
+ // set whether to use belief revision or not
+ String useAnnotationGathering = prepareUserParameter(stts, MAS2J_PREFIX + MAS2J_USEANNOTATIONGATHERING);
+ agent.setAnnotationGatheringEnabled(Boolean.parseBoolean(useAnnotationGathering));
+ }catch(JasdlConfigurationException e){
+ agent.setAnnotationGatheringEnabled(DEFAULT_USEANNOTATIONGATHERING);
+ }
+ }
+
/**
* Load ontologies as specified in .mas2j settings
* @param stts .mas2j settings
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-02 21:13:50 UTC (rev 1201)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-03 01:24:25 UTC (rev 1202)
@@ -45,7 +45,8 @@
boolean containsAxiom = ontology.containsAxiom(axiom);
if(!containsAxiom){
- agent.getOntologyManager().applyChange(new AddAxiom(ontology, axiom));
+ agent.getOntologyManager().applyChange(new AddAxiom(ontology, axiom));
+ agent.refreshReasoner();
}
boolean containsAllAnnots = true;
@@ -55,13 +56,16 @@
if(!ontology.containsAxiom(annotAxiom)){
containsAllAnnots = false;
agent.getOntologyManager().applyChange(new AddAxiom(ontology, annotAxiom));
+ agent.refreshReasoner();
}
- }
+ }
- if(!containsAxiom || !containsAllAnnots){
- agent.refreshReasoner();
- if(!agent.isBeliefRevisionEnabled()){ // if brf disabled, resort to legacy consistency maintenance mechanism
- if(!agent.getReasoner().isConsistent(ontology)){
+
+
+ if(!containsAxiom || !containsAllAnnots){
+ if(!agent.isBeliefRevisionEnabled()){ // if brf disabled, resort to legacy consistency maintenance mechanism
+ if(!agent.isBBConsistent()){
+ getLogger().info("legacy consistency assurance: rejected "+axiom);
RemoveAxiom rem = new RemoveAxiom(ontology, axiom);
agent.getOntologyManager().applyChange(rem);
agent.refreshReasoner();
@@ -192,6 +196,8 @@
getLogger().fine("Getting relevancies for "+l);
+
+
Set<Literal> relevant = new HashSet<Literal>();
try{
SELiteral sl = agent.getSELiteralFactory().construct(l);
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlIncisionFunction.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlIncisionFunction.java 2008-04-02 21:13:50 UTC (rev 1201)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlIncisionFunction.java 2008-04-03 01:24:25 UTC (rev 1202)
@@ -15,7 +15,7 @@
import bebops.common.IncisionFunction;
-public class JasdlIncisionFunction implements IncisionFunction{
+public class JasdlIncisionFunction extends IncisionFunction{
private JasdlAgent agent;
@@ -39,23 +39,21 @@
* Currently calculated using ASSERTED source annotations only.
* No source annotation is taken as trust = 0;
*/
- public Set<OWLAxiom> apply(Set<Set<OWLAxiom>> kernelset) {
+ public Set<OWLAxiom> applyToOne(Set<OWLAxiom> akernel){
try{
Set<OWLAxiom> chosen = new HashSet<OWLAxiom>();
- for(Set<OWLAxiom> akernel : kernelset){
- if(!akernel.isEmpty()){
- OWLAxiom leastTrusted = null; // guaranteed to take a value
- float minTrustRating = 1f;
- for(OWLAxiom axiom : akernel){
- float trustRating = getTrustRating(axiom);
- agent.getLogger().finest("Trust rating of "+axiom+"="+trustRating);
- if(trustRating <= minTrustRating){
- minTrustRating = trustRating;
- leastTrusted = axiom;
- }
+ if(!akernel.isEmpty()){
+ OWLAxiom leastTrusted = null; // guaranteed to take a value
+ float minTrustRating = 1f;
+ for(OWLAxiom axiom : akernel){
+ float trustRating = getTrustRating(axiom);
+ agent.getLogger().finest("Trust rating of "+axiom+"="+trustRating);
+ if(trustRating <= minTrustRating){
+ minTrustRating = trustRating;
+ leastTrusted = axiom;
}
- chosen.add(leastTrusted);
- }
+ }
+ chosen.add(leastTrusted);
}
return chosen;
}catch(Exception e){
@@ -66,6 +64,7 @@
/**
* Currently returns the trust rating of the most trusted source. Future work will look at better ways of calculating this.
+ * TODO: Essentially duplicating work here. Annotation gathering (performed by AxiomToSELiteralConverter) requires axiom-pinponting - so does contraction.
* @param axiom
* @return
* @throws JasdlException
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java 2008-04-02 21:13:50 UTC (rev 1201)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java 2008-04-03 01:24:25 UTC (rev 1202)
@@ -1,6 +1,8 @@
package jasdl.bridge.factory;
import jasdl.asSemantics.JasdlAgent;
+import jasdl.bb.JasdlReasonerFactory;
+import jasdl.bb.TBoxAxiomKernelsetFilter;
import jasdl.bridge.mapping.aliasing.Alias;
import jasdl.bridge.mapping.aliasing.AllDifferentPlaceholder;
import jasdl.bridge.seliteral.SELiteral;
@@ -17,20 +19,27 @@
import java.util.List;
import java.util.Set;
import java.util.Vector;
+import java.util.logging.Logger;
+import org.semanticweb.owl.inference.OWLReasonerException;
import org.semanticweb.owl.model.OWLAxiom;
import org.semanticweb.owl.model.OWLAxiomAnnotationAxiom;
import org.semanticweb.owl.model.OWLClassAssertionAxiom;
import org.semanticweb.owl.model.OWLConstant;
import org.semanticweb.owl.model.OWLDataPropertyAssertionAxiom;
import org.semanticweb.owl.model.OWLDifferentIndividualsAxiom;
+import org.semanticweb.owl.model.OWLException;
import org.semanticweb.owl.model.OWLIndividual;
import org.semanticweb.owl.model.OWLIndividualAxiom;
import org.semanticweb.owl.model.OWLObjectPropertyAssertionAxiom;
import org.semanticweb.owl.model.OWLOntology;
+import org.semanticweb.owl.model.OWLOntologyChangeException;
+import org.semanticweb.owl.model.OWLOntologyCreationException;
import org.semanticweb.owl.model.OWLTypedConstant;
+import bebops.pinpointing.KernelOperator;
+
/**
* Accepts an arbitrary OWLIndividualAxiom and, depending on its type, creates a SE-Literal encoding of it.
* Will always result in a ground SELiteral (since OWLIndividualAxioms must always be ground)<p>
@@ -50,7 +59,8 @@
*/
private JasdlAgent agent;
- public AxiomToSELiteralConverter(JasdlAgent agent){
+
+ public AxiomToSELiteralConverter(JasdlAgent agent) throws OWLReasonerException, OWLOntologyCreationException, OWLOntologyChangeException{
this.agent = agent;
}
@@ -59,19 +69,53 @@
* TODO: Shift to a factory?
* @param sl
*/
- public static List<Term> getAssertedAnnotations(OWLAxiom axiom, OWLOntology ontology){
+ public List<Term> getAssertedAnnotations(OWLAxiom axiom){
List<Term> result = new Vector<Term>();
- // get annotations
- Set<OWLAxiomAnnotationAxiom> annotAxioms = axiom.getAnnotationAxioms(ontology);
- for(OWLAxiomAnnotationAxiom annotAxiom : annotAxioms){ // remember, possibly semantically-naive payload!
- Term annot = Literal.parse(annotAxiom.getAnnotation().getAnnotationValueAsConstant().getLiteral());
- result.add(annot);
+ // get annotations from all known ontologies
+ for(OWLOntology ontology : agent.getOntologyManager().getOntologies()){
+ Set<OWLAxiomAnnotationAxiom> annotAxioms = axiom.getAnnotationAxioms(ontology);
+ for(OWLAxiomAnnotationAxiom annotAxiom : annotAxioms){ // remember, possibly semantically-naive payload!
+ Term annot = Literal.parse(annotAxiom.getAnnotation().getAnnotationValueAsConstant().getLiteral());
+ result.add(annot);
+ }
}
return result;
}
+ public List<Term> getInferredAnnotations(OWLAxiom axiom) throws JasdlException{
+ try {
+ List<Term> annots = new Vector<Term>();
+ KernelOperator kernelOperator = new KernelOperator(agent.getOntologyManager(), new JasdlReasonerFactory());
+ //Set<OWLAxiom> supportingAxioms = OWLReasonerAdapter.flattenSetOfSets((kernelOperator.apply(axiom, true)));
+ Set<OWLAxiom> supportingAxioms = (new TBoxAxiomKernelsetFilter()).applyToOne((kernelOperator.applySingle(axiom, true)));
+ getLogger().finest("Explanation for "+axiom+": "+supportingAxioms);
+ for(OWLAxiom supportingAxiom : supportingAxioms){
+ annots.addAll(getAssertedAnnotations(supportingAxiom));
+ }
+ getLogger().finest("Annotations: "+annots);
+ return annots;
+ } catch (OWLException e) {
+ throw new JasdlException("Annotation gathering failed for "+axiom, e);
+ }
+ }
+
/**
+ * Utility method to get the annotations of an axiom as an array of terms within the ontology referenced by alias
+ * @param alias
+ * @param axiom
+ * @return
+ * @throws UnknownMappingException
+ */
+ private Term[] getAnnots(Alias alias, OWLAxiom axiom) throws JasdlException{
+ List<Term> annots = getAssertedAnnotations(axiom);
+ if(agent.isAnnotationGatheringEnabled()) annots.addAll(getInferredAnnotations(axiom)); // optional, experimental feature
+ return (Term[])annots.toArray(new Term[annots.size()]);
+ }
+
+
+
+ /**
* Polymorphically applies appropriate factory method depending on specialisation of axiom
* @param axiom
* @return
@@ -176,18 +220,10 @@
return agent.getSELiteralFactory().construct(alias, is, getAnnots(alias, axiom));
}
- /**
- * Utility method to get the annotations of an axiom as an array of terms within the ontology referenced by alias
- * @param alias
- * @param axiom
- * @return
- * @throws UnknownMappingException
- */
- private Term[] getAnnots(Alias alias, OWLAxiom axiom) throws UnknownMappingException{
- OWLOntology ontology = agent.getLabelManager().getRight(alias.getLabel());
- List<Term> collection = getAssertedAnnotations(axiom, ontology);
- return (Term[])collection.toArray(new Term[collection.size()]);
- }
+ public Logger getLogger(){
+ return agent.getLogger();
+ }
+
}
Added: trunk/applications/jasdl-owlapi/src/jasdl/ia/is_annotation_gathering_enabled.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/ia/is_annotation_gathering_enabled.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/ia/is_annotation_gathering_enabled.java 2008-04-03 01:24:25 UTC (rev 1202)
@@ -0,0 +1,61 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.ia;
+
+import jasdl.asSemantics.JasdlAgent;
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Term;
+
+import java.util.logging.Logger;
+
+/**
+ * @author Tom Klapiscak
+ *
+ * Usage jasdl.ia.define_class(classname, classexpr, label), where:
+ * - classname is an atomic name used to refer to this class in future. Must begin with a lowercase letter and not clash with any AgentSpeak keyword
+ * - classexpr is a expression defining this class
+ *
+ * Changed class name to atom only - forces valid alias syntax
+ *
+ */
+public class is_annotation_gathering_enabled extends DefaultInternalAction {
+
+
+ private Logger logger = Logger.getLogger("jasdl."+is_annotation_gathering_enabled.class.getName());
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ try {
+ JasdlAgent agent = (JasdlAgent)ts.getAg();
+ Literal res = agent.isAnnotationGatheringEnabled() ? Literal.LTrue : Literal.LFalse;
+ return un.unifies(args[0], res);
+ } catch (Exception e) {
+ logger.warning("Error in internal action 'jasdl.ia.is_annotation_gathering_enabled'! Reason:");
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+
+
+}
\ No newline at end of file
Added: trunk/applications/jasdl-owlapi/src/jasdl/ia/is_belief_revision_enabled.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/ia/is_belief_revision_enabled.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/ia/is_belief_revision_enabled.java 2008-04-03 01:24:25 UTC (rev 1202)
@@ -0,0 +1,61 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.ia;
+
+import jasdl.asSemantics.JasdlAgent;
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Term;
+
+import java.util.logging.Logger;
+
+/**
+ * @author Tom Klapiscak
+ *
+ * Usage jasdl.ia.define_class(classname, classexpr, label), where:
+ * - classname is an atomic name used to refer to this class in future. Must begin with a lowercase letter and not clash with any AgentSpeak keyword
+ * - classexpr is a expression defining this class
+ *
+ * Changed class name to atom only - forces valid alias syntax
+ *
+ */
+public class is_belief_revision_enabled extends DefaultInternalAction {
+
+
+ private Logger logger = Logger.getLogger("jasdl."+is_belief_revision_enabled.class.getName());
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ try {
+ JasdlAgent agent = (JasdlAgent)ts.getAg();
+ Literal res = agent.isBeliefRevisionEnabled() ? Literal.LTrue : Literal.LFalse;
+ return un.unifies(args[0], res);
+ } catch (Exception e) {
+ logger.warning("Error in internal action 'jasdl.ia.is_belief_revision_enabled'! Reason:");
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+
+
+}
\ No newline at end of file
Added: trunk/applications/jasdl-owlapi/src/jasdl/ia/set_annotation_gathering_enabled.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/ia/set_annotation_gathering_enabled.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/ia/set_annotation_gathering_enabled.java 2008-04-03 01:24:25 UTC (rev 1202)
@@ -0,0 +1,67 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.ia;
+
+import jasdl.asSemantics.JasdlAgent;
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Term;
+
+import java.util.logging.Logger;
+
+/**
+ * @author Tom Klapiscak
+ *
+ * Usage jasdl.ia.define_class(classname, classexpr, label), where:
+ * - classname is an atomic name used to refer to this class in future. Must begin with a lowercase letter and not clash with any AgentSpeak keyword
+ * - classexpr is a expression defining this class
+ *
+ * Changed class name to atom only - forces valid alias syntax
+ *
+ */
+public class set_annotation_gathering_enabled extends DefaultInternalAction {
+
+
+ private Logger logger = Logger.getLogger("jasdl."+set_annotation_gathering_enabled.class.getName());
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ try {
+ JasdlAgent agent = (JasdlAgent)ts.getAg();
+ if(args[0].equals(Literal.LTrue)){
+ agent.setAnnotationGatheringEnabled((true));
+ }else if(args[0].equals(Literal.LFalse)){
+ agent.setAnnotationGatheringEnabled(false);
+ }else{
+ throw new Exception("Argument must be boolean");
+ }
+ return true;
+ } catch (Exception e) {
+ logger.warning("Error in internal action 'jasdl.ia.set_annotation_gathering_enabled'! Reason:");
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+
+
+}
\ No newline at end of file
Added: trunk/applications/jasdl-owlapi/src/jasdl/ia/set_belief_revision_enabled.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/ia/set_belief_revision_enabled.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/ia/set_belief_revision_enabled.java 2008-04-03 01:24:25 UTC (rev 1202)
@@ -0,0 +1,67 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.ia;
+
+import jasdl.asSemantics.JasdlAgent;
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Term;
+
+import java.util.logging.Logger;
+
+/**
+ * @author Tom Klapiscak
+ *
+ * Usage jasdl.ia.define_class(classname, classexpr, label), where:
+ * - classname is an atomic name used to refer to this class in future. Must begin with a lowercase letter and not clash with any AgentSpeak keyword
+ * - classexpr is a expression defining this class
+ *
+ * Changed class name to atom only - forces valid alias syntax
+ *
+ */
+public class set_belief_revision_enabled extends DefaultInternalAction {
+
+
+ private Logger logger = Logger.getLogger("jasdl."+set_belief_revision_enabled.class.getName());
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ try {
+ JasdlAgent agent = (JasdlAgent)ts.getAg();
+ if(args[0].equals(Literal.LTrue)){
+ agent.setBeliefRevisionEnabled(true);
+ }else if(args[0].equals(Literal.LFalse)){
+ agent.setBeliefRevisionEnabled(false);
+ }else{
+ throw new Exception("Argument must be boolean");
+ }
+ return true;
+ } catch (Exception e) {
+ logger.warning("Error in internal action 'jasdl.ia.set_belief_revision_enabled'! Reason:");
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+
+
+}
\ No newline at end of file
Modified: trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-02 21:13:50 UTC (rev 1201)
+++ trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-03 01:24:25 UTC (rev 1202)
@@ -165,7 +165,10 @@
*/
private static int NUM_ENTITIES_TEST_ADD = 3;
@Test
- public void testAddLiteral() throws Exception{
+ public void testAddLiteral() throws Exception{
+ // ensure annotation gathering disabled for this test - we are only checking handling of annotation additions is correct
+ agent.setAnnotationGatheringEnabled(false);
+
Atom[][] annotSets = new Atom[][] {new Atom[]{}, new Atom[] {new Atom("x")}, new Atom[] {new Atom("x"), new Atom("y")} }; // TODO: No real reason to check annotation handling for ALL types of entity - exactly the same code is used
for(OWLOntology ontology : agent.getOntologyManager().getOntologies()){ // test against all known ontologies
for(int run=0; run<=1; run++){ // run twice to ensure duplicate additions are rejected
Modified: trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlException.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlException.java 2008-04-02 21:13:50 UTC (rev 1201)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlException.java 2008-04-03 01:24:25 UTC (rev 1202)
@@ -23,6 +23,11 @@
public class JasdlException extends JasonException {
+
+ public JasdlException(String msg, Exception cause) {
+ super(msg, cause);
+ }
+
public JasdlException(String message){
super(message);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-02 21:13:52
|
Revision: 1201
http://jason.svn.sourceforge.net/jason/?rev=1201&view=rev
Author: tomklapiscak
Date: 2008-04-02 14:13:50 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
cleanup
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/
trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-02 21:12:27
|
Revision: 1200
http://jason.svn.sourceforge.net/jason/?rev=1200&view=rev
Author: tomklapiscak
Date: 2008-04-02 14:12:22 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Added bebops.jar
Added Paths:
-----------
trunk/applications/jasdl-owlapi/lib/bebops.jar
Added: trunk/applications/jasdl-owlapi/lib/bebops.jar
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jasdl-owlapi/lib/bebops.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-02 21:11:27
|
Revision: 1199
http://jason.svn.sourceforge.net/jason/?rev=1199&view=rev
Author: tomklapiscak
Date: 2008-04-02 14:11:25 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Bebops (Belief Base Operations Library) now standalone. Used by JASDL as .jar
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java
Added Paths:
-----------
trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlIncisionFunction.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlReasonerFactory.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/TBoxAxiomKernelsetFilter.java
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl 2008-04-02 19:40:02 UTC (rev 1198)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl 2008-04-02 21:11:25 UTC (rev 1199)
@@ -84,10 +84,11 @@
?ruralArea(somewhere)[o(travel)];
- +isLocatedAt(x, x)[o(travel)]; // rejected since isLocated at is irreflexive
+
.print("DL-based belief revision is enabled"); // without, the above test-goal will fail, since legacy mechanism simply removes incoming inconsistent beliefs
+
// since the classes destination and and contact are disjoint (and ruralArea is a subclass of destination),
// and since we trust ben less than tom, the belief addition below will fail (and tom's assertion above will persist),
// thus failing the whole plan.
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-02 19:40:02 UTC (rev 1198)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-02 21:11:25 UTC (rev 1199)
@@ -3,10 +3,9 @@
import static jasdl.util.Common.strip;
import jasdl.asSyntax.JasdlPlanLibrary;
import jasdl.bb.JasdlBeliefBase;
-import jasdl.bb.revision.BeliefBaseSemiRevisor;
-import jasdl.bb.revision.JasdlIncisionFunction;
-import jasdl.bb.revision.JasdlReasonerFactory;
-import jasdl.bb.revision.TBoxAxiomKernelsetFilter;
+import jasdl.bb.JasdlIncisionFunction;
+import jasdl.bb.JasdlReasonerFactory;
+import jasdl.bb.TBoxAxiomKernelsetFilter;
import jasdl.bridge.factory.AliasFactory;
import jasdl.bridge.factory.AxiomToSELiteralConverter;
import jasdl.bridge.factory.SELiteralFactory;
@@ -69,6 +68,8 @@
import org.semanticweb.owl.model.OWLOntologyManager;
import uk.ac.manchester.cs.owl.mansyntaxrenderer.ManchesterOWLSyntaxOWLObjectRendererImpl;
+import bebops.semirevision.BeliefBaseSemiRevisor;
+import bebops.util.exception.BebopsRevisionFailedException;
public class JasdlAgent extends JmcaAgent{
@@ -215,8 +216,8 @@
removeList.add(axiomToSELiteralConverter.convert((OWLIndividualAxiom)contract).getLiteral());
}
revisionApplied = true;
- }catch(RevisionFailedException e){
- throw e; // propagate upwards
+ }catch(BebopsRevisionFailedException e){
+ throw new RevisionFailedException(); // propagate upwards
}catch(NotEnrichedException e){
// can't perform DL-based belief revision on SN-Literals
addList.add(beliefToAdd);
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-02 19:40:02 UTC (rev 1198)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-02 21:11:25 UTC (rev 1199)
@@ -1,10 +1,6 @@
package jasdl.bb;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.bb.revision.BeliefBaseContractor;
-import jasdl.bb.revision.JasdlIncisionFunction;
-import jasdl.bb.revision.JasdlReasonerFactory;
-import jasdl.bb.revision.TBoxAxiomKernelsetFilter;
import jasdl.bridge.seliteral.SELiteral;
import jasdl.bridge.seliteral.SELiteralAllDifferentAssertion;
import jasdl.util.exception.JasdlException;
@@ -32,6 +28,8 @@
import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.RemoveAxiom;
+import bebops.contraction.BeliefBaseContractor;
+
public class JasdlBeliefBase extends DefaultBeliefBase{
private JasdlAgent agent;
Copied: trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlIncisionFunction.java (from rev 1196, trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlIncisionFunction.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlIncisionFunction.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlIncisionFunction.java 2008-04-02 21:11:25 UTC (rev 1199)
@@ -0,0 +1,97 @@
+package jasdl.bb;
+
+import jasdl.asSemantics.JasdlAgent;
+import jasdl.bridge.seliteral.SELiteral;
+import jasdl.util.exception.JasdlException;
+import jason.asSyntax.Atom;
+import jason.asSyntax.ListTerm;
+import jason.asSyntax.Term;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.semanticweb.owl.model.OWLAxiom;
+import org.semanticweb.owl.model.OWLIndividualAxiom;
+
+import bebops.common.IncisionFunction;
+
+public class JasdlIncisionFunction implements IncisionFunction{
+
+
+ private JasdlAgent agent;
+ private SELiteral toAddLiteral;
+
+ /**
+ * The SELiteral to be added is required for a particularly inelegant hack that allows us
+ * to retrieve the annotations of the NOT YET ADDED axiom.
+ *
+ * @param agent required for getting trust ratings
+ * @param toAdd
+ * @param toAddAnnotations
+ */
+ public JasdlIncisionFunction(JasdlAgent agent, SELiteral toAddLiteral){
+ this.agent = agent;
+ this.toAddLiteral = toAddLiteral;
+ }
+
+ /**
+ * Chooses from each akernel axiom with lowest trust associated with it.
+ * Currently calculated using ASSERTED source annotations only.
+ * No source annotation is taken as trust = 0;
+ */
+ public Set<OWLAxiom> apply(Set<Set<OWLAxiom>> kernelset) {
+ try{
+ Set<OWLAxiom> chosen = new HashSet<OWLAxiom>();
+ for(Set<OWLAxiom> akernel : kernelset){
+ if(!akernel.isEmpty()){
+ OWLAxiom leastTrusted = null; // guaranteed to take a value
+ float minTrustRating = 1f;
+ for(OWLAxiom axiom : akernel){
+ float trustRating = getTrustRating(axiom);
+ agent.getLogger().finest("Trust rating of "+axiom+"="+trustRating);
+ if(trustRating <= minTrustRating){
+ minTrustRating = trustRating;
+ leastTrusted = axiom;
+ }
+ }
+ chosen.add(leastTrusted);
+ }
+ }
+ return chosen;
+ }catch(Exception e){
+ e.printStackTrace(); // TODO: introduce a seperate exception hierarchy once this package has been seperated from JASDL
+ return null;
+ }
+ }
+
+ /**
+ * Currently returns the trust rating of the most trusted source. Future work will look at better ways of calculating this.
+ * @param axiom
+ * @return
+ * @throws JasdlException
+ */
+ private float getTrustRating(OWLAxiom axiom) throws JasdlException{
+ ListTerm sources;
+ if(axiom.equals(toAddLiteral.createAxiom())){ // hack to get the annotations of the NOT YET ADDED toAdd axiom
+ sources = toAddLiteral.getLiteral().getSources();
+ }else{
+ SELiteral sl = agent.getAxiomToSELiteralConverter().convert((OWLIndividualAxiom)axiom); // kernel filter ensures axiom is an OWLIndividualAxiom
+ sources = sl.getLiteral().getSources();
+ }
+ agent.getLogger().finest("Sources of "+axiom+"="+sources);
+ float maxTrustRating = 0f; // if no sources available, trust is 0
+ for(Term source : sources){
+ if(!source.isAtom()){
+ throw new JasdlException("Invalid source annotation "+source);
+ }
+ Atom name = (Atom)source;
+ float trustRating = agent.getTrustRating(name);
+ if(trustRating > maxTrustRating){
+ maxTrustRating = trustRating;
+ }
+ }
+ return maxTrustRating;
+ }
+
+
+}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlReasonerFactory.java (from rev 1196, trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlReasonerFactory.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlReasonerFactory.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlReasonerFactory.java 2008-04-02 21:11:25 UTC (rev 1199)
@@ -0,0 +1,30 @@
+package jasdl.bb;
+
+import org.mindswap.pellet.PelletOptions;
+import org.mindswap.pellet.owlapi.Reasoner;
+import org.semanticweb.owl.inference.OWLReasoner;
+import org.semanticweb.owl.model.OWLOntologyManager;
+
+import com.clarkparsia.explanation.ReasonerFactory;
+
+public class JasdlReasonerFactory implements ReasonerFactory{
+
+ public JasdlReasonerFactory() {
+ super();
+ }
+
+ public boolean requiresExplicitClassification() {
+ return false;
+ }
+
+ public OWLReasoner createReasoner(OWLOntologyManager manager) {
+ Reasoner pellet = new Reasoner(manager);
+ return pellet;
+ }
+
+ public String getReasonerName() {
+ return "reasoner";
+ }
+
+
+}
Added: trunk/applications/jasdl-owlapi/src/jasdl/bb/TBoxAxiomKernelsetFilter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/TBoxAxiomKernelsetFilter.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/TBoxAxiomKernelsetFilter.java 2008-04-02 21:11:25 UTC (rev 1199)
@@ -0,0 +1,14 @@
+package jasdl.bb;
+
+import org.semanticweb.owl.model.OWLAxiom;
+import org.semanticweb.owl.model.OWLIndividualAxiom;
+
+import bebops.common.KernelsetFilter;
+
+public class TBoxAxiomKernelsetFilter extends KernelsetFilter {
+
+ public boolean retain(OWLAxiom axiom) {
+ return (axiom instanceof OWLIndividualAxiom);
+ }
+
+}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java 2008-04-02 19:40:02 UTC (rev 1198)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java 2008-04-02 21:11:25 UTC (rev 1199)
@@ -21,7 +21,6 @@
import static jasdl.util.Common.RANGE;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.bb.revision.IndividualAxiomToDescriptionConverter;
import jasdl.bridge.seliteral.SELiteral;
import jasdl.bridge.seliteral.SELiteralAllDifferentAssertion;
import jasdl.bridge.seliteral.SELiteralClassAssertion;
@@ -43,7 +42,9 @@
import org.semanticweb.owl.model.OWLObjectProperty;
import org.semanticweb.owl.model.OWLTypedConstant;
+import bebops.common.IndividualAxiomToDescriptionConverter;
+
/**
* Accepts an arbitrary SEliteral and, depending on its type, creates an OWLIndividualAxiom encoding of it.
* This factory can be used in one of two ways: for <i>creation</i> or for <i>retrieval</i>.<p>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-02 19:40:07
|
Revision: 1198
http://jason.svn.sourceforge.net/jason/?rev=1198&view=rev
Author: tomklapiscak
Date: 2008-04-02 12:40:02 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Seperating out "bbops"
Added Paths:
-----------
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/common/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-02 19:39:05
|
Revision: 1197
http://jason.svn.sourceforge.net/jason/?rev=1197&view=rev
Author: tomklapiscak
Date: 2008-04-02 12:39:02 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Seperating out "bbops" (Belief-Base Operations): a general library for performing semi-revision, contraction, axiom-pinpointing and inconsistency-explanation operations for OWL ontologies.
Added Paths:
-----------
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/pinpointing/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-02 19:22:42
|
Revision: 1196
http://jason.svn.sourceforge.net/jason/?rev=1196&view=rev
Author: tomklapiscak
Date: 2008-04-02 12:22:40 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Seperating out "bbops" (Belief-Base Operations): a general library for performing semi-revision, contraction, axiom-pinpointing and inconsistency-explanation operations for OWL ontologies.
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/BeliefBaseContractor.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/BeliefBaseSemiRevisor.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/IncisionFunction.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/IndividualAxiomToDescriptionConverter.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/IsolatedOntologyOperation.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlReasonerFactory.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/KernelsetFilter.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/TBoxAxiomKernelsetFilter.java
Added Paths:
-----------
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/contraction/
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlIncisionFunction.java
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlIncisionFunction.java
Copied: trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision (from rev 1193, trunk/applications/jasdl-owlapi/src/jasdl/bb/revision)
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/BeliefBaseContractor.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/BeliefBaseContractor.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/BeliefBaseContractor.java 2008-04-02 19:22:40 UTC (rev 1196)
@@ -1,4 +1,4 @@
-package jasdl.bb.revision;
+package jasdl.bb.bbops.revision;
import java.util.List;
import java.util.Set;
@@ -44,43 +44,40 @@
toRemove.add(axiom);
// note: either axiom is a which is contradictory by definition, or another which is entailed by definition
isolatedOntologyManager.applyChange(new RemoveAxiom(isolatedOntology, axiom));
+
+ // gather justifications
+ // apply incision function (same one???)
+ // recursively contract
- //if(!axiom.equals(a)){ // otherwise we wouldn't need to contract a, can simply remove (it can't have any support by definition)
+
+ SatisfiabilityConverter satcon = new SatisfiabilityConverter(isolatedOntologyManager.getOWLDataFactory());
+ OWLDescription description = satcon.convert(axiom);
+ BlackBoxExplanation bbgen = new BlackBoxExplanation(isolatedOntologyManager);
+ HSTExplanationGenerator hstgen = new HSTExplanationGenerator(bbgen);
+ hstgen.setOntology(isolatedOntology);
+ hstgen.setReasoner(isolatedReasoner);
+ hstgen.setReasonerFactory(reasonerFactory);
+ Set<Set<OWLAxiom>> justifications = kernelsetFilter.apply(hstgen.getExplanations(description));
+
+ //Set<Set<OWLAxiom>> justifications = hstgen.getExplanations(description);
+ if(!justifications.isEmpty()){
+ logger.fine("Description of "+axiom+": "+description);
+ logger.fine("Justifications for "+axiom+": "+justifications);
- // require contraction
- // gather justifications
- // apply incision function (same one???)
- // recursively contract
-
- SatisfiabilityConverter satcon = new SatisfiabilityConverter(isolatedOntologyManager.getOWLDataFactory());
- OWLDescription description = satcon.convert(axiom);
- BlackBoxExplanation bbgen = new BlackBoxExplanation(isolatedOntologyManager);
- HSTExplanationGenerator hstgen = new HSTExplanationGenerator(bbgen);
- hstgen.setOntology(isolatedOntology);
- hstgen.setReasoner(isolatedReasoner);
- hstgen.setReasonerFactory(reasonerFactory);
- Set<Set<OWLAxiom>> justifications = kernelsetFilter.apply(hstgen.getExplanations(description));
-
- //Set<Set<OWLAxiom>> justifications = hstgen.getExplanations(description);
- if(!justifications.isEmpty()){
- logger.fine("Description of "+axiom+": "+description);
- logger.fine("Justifications for "+axiom+": "+justifications);
-
-
- Set<OWLAxiom> toContract = incisionFunction.apply(justifications);
- toRemove.addAll(toContract);
- List<OWLOntologyChange> isolatedRemovals = new Vector<OWLOntologyChange>();
- for(OWLAxiom remove : toContract){
- isolatedRemovals.add(new RemoveAxiom(isolatedOntology, remove));
- }
- logger.fine("Removing: "+toContract);
- isolatedOntologyManager.applyChanges(isolatedRemovals);
-
- toRemove.addAll(contract(toContract, kernelsetFilter, incisionFunction));
+ Set<OWLAxiom> toContract = incisionFunction.apply(justifications);
+ toRemove.addAll(toContract);
+ List<OWLOntologyChange> isolatedRemovals = new Vector<OWLOntologyChange>();
+ for(OWLAxiom remove : toContract){
+ isolatedRemovals.add(new RemoveAxiom(isolatedOntology, remove));
}
- //}
+ logger.fine("Removing: "+toContract);
+ isolatedOntologyManager.applyChanges(isolatedRemovals);
+ toRemove.addAll(contract(toContract, kernelsetFilter, incisionFunction));
+ }
+
+
return toRemove;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/BeliefBaseSemiRevisor.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/BeliefBaseSemiRevisor.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/BeliefBaseSemiRevisor.java 2008-04-02 19:22:40 UTC (rev 1196)
@@ -1,4 +1,4 @@
-package jasdl.bb.revision;
+package jasdl.bb.bbops.revision;
import jason.RevisionFailedException;
@@ -9,10 +9,12 @@
import java.util.Vector;
import java.util.logging.Logger;
+import org.semanticweb.owl.inference.OWLReasoner;
import org.semanticweb.owl.inference.OWLReasonerException;
import org.semanticweb.owl.model.AddAxiom;
import org.semanticweb.owl.model.OWLAxiom;
import org.semanticweb.owl.model.OWLException;
+import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.OWLOntologyChangeException;
import org.semanticweb.owl.model.OWLOntologyCreationException;
import org.semanticweb.owl.model.OWLOntologyManager;
@@ -40,7 +42,7 @@
isolatedReasoner.classify();
List<OWLAxiom> delList = new Vector<OWLAxiom>();
if(!isolatedReasoner.isConsistent(isolatedOntology)){
- Set<Set<OWLAxiom>> kernelset = applyKernelOperator();
+ Set<Set<OWLAxiom>> kernelset = applyKernelOperator(toAdd, isolatedOntologyManager, isolatedOntology, isolatedReasoner, reasonerFactory);
kernelset = kernelsetFilter.apply(kernelset);
logger.fine("Explanation of inconsistency due to "+toAdd+": "+kernelset);
Set<OWLAxiom> toContract = incisionFunction.apply(kernelset);
@@ -68,20 +70,20 @@
}
- private Set<Set<OWLAxiom>> applyKernelOperator(){
- BlackBoxExplanation bbgen = new BlackBoxExplanation(isolatedOntologyManager);
+ private Set<Set<OWLAxiom>> applyKernelOperator(OWLAxiom a, OWLOntologyManager ontologyManager, OWLOntology ontology, OWLReasoner reasoner, ReasonerFactory reasonerFactory){
+ BlackBoxExplanation bbgen = new BlackBoxExplanation(ontologyManager);
HSTExplanationGenerator hstgen = new HSTExplanationGenerator(bbgen);
- hstgen.setOntology(isolatedOntology);
- hstgen.setReasoner(isolatedReasoner);
+ hstgen.setOntology(ontology);
+ hstgen.setReasoner(reasoner);
hstgen.setReasonerFactory(reasonerFactory);
- IndividualAxiomToDescriptionConverter conv = new IndividualAxiomToDescriptionConverter(isolatedOntologyManager.getOWLDataFactory());
- toAdd.accept(conv);
+ IndividualAxiomToDescriptionConverter conv = new IndividualAxiomToDescriptionConverter(ontologyManager.getOWLDataFactory());
+ a.accept(conv);
Set<Set<OWLAxiom>> kernelset = hstgen.getExplanations(conv.getDescription());
// since we are dealing with semi-revision, ensure the axiom toAdd is a possible justification in each a-kernel that can be retracted
// doesn't seem to be adding when toAdd is a class assertion?? TODO: Is this a bug??
for(Set<OWLAxiom> akernel : kernelset){
- akernel.add(toAdd);
+ akernel.add(a);
}
return kernelset;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/IncisionFunction.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/IncisionFunction.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/IncisionFunction.java 2008-04-02 19:22:40 UTC (rev 1196)
@@ -1,4 +1,4 @@
-package jasdl.bb.revision;
+package jasdl.bb.bbops.revision;
import java.util.Set;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/IndividualAxiomToDescriptionConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/IndividualAxiomToDescriptionConverter.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/IndividualAxiomToDescriptionConverter.java 2008-04-02 19:22:40 UTC (rev 1196)
@@ -1,4 +1,4 @@
-package jasdl.bb.revision;
+package jasdl.bb.bbops.revision;
import java.util.Collections;
import java.util.HashSet;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/IsolatedOntologyOperation.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/IsolatedOntologyOperation.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/IsolatedOntologyOperation.java 2008-04-02 19:22:40 UTC (rev 1196)
@@ -1,4 +1,4 @@
-package jasdl.bb.revision;
+package jasdl.bb.bbops.revision;
import java.net.URI;
import java.util.List;
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlIncisionFunction.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlIncisionFunction.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlIncisionFunction.java 2008-04-02 19:22:40 UTC (rev 1196)
@@ -1,95 +0,0 @@
-package jasdl.bb.revision;
-
-import jasdl.asSemantics.JasdlAgent;
-import jasdl.bridge.seliteral.SELiteral;
-import jasdl.util.JasdlException;
-import jason.asSyntax.Atom;
-import jason.asSyntax.ListTerm;
-import jason.asSyntax.Term;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.semanticweb.owl.model.OWLAxiom;
-import org.semanticweb.owl.model.OWLIndividualAxiom;
-
-public class JasdlIncisionFunction implements IncisionFunction{
-
-
- private JasdlAgent agent;
- private SELiteral toAddLiteral;
-
- /**
- * The SELiteral to be added is required for a particularly inelegant hack that allows us
- * to retrieve the annotations of the NOT YET ADDED axiom.
- *
- * @param agent required for getting trust ratings
- * @param toAdd
- * @param toAddAnnotations
- */
- public JasdlIncisionFunction(JasdlAgent agent, SELiteral toAddLiteral){
- this.agent = agent;
- this.toAddLiteral = toAddLiteral;
- }
-
- /**
- * Chooses from each akernel axiom with lowest trust associated with it.
- * Currently calculated using ASSERTED source annotations only.
- * No source annotation is taken as trust = 0;
- */
- public Set<OWLAxiom> apply(Set<Set<OWLAxiom>> kernelset) {
- try{
- Set<OWLAxiom> chosen = new HashSet<OWLAxiom>();
- for(Set<OWLAxiom> akernel : kernelset){
- if(!akernel.isEmpty()){
- OWLAxiom leastTrusted = null; // guaranteed to take a value
- float minTrustRating = 1f;
- for(OWLAxiom axiom : akernel){
- float trustRating = getTrustRating(axiom);
- agent.getLogger().finest("Trust rating of "+axiom+"="+trustRating);
- if(trustRating <= minTrustRating){
- minTrustRating = trustRating;
- leastTrusted = axiom;
- }
- }
- chosen.add(leastTrusted);
- }
- }
- return chosen;
- }catch(Exception e){
- e.printStackTrace(); // TODO: introduce a seperate exception hierarchy once this package has been seperated from JASDL
- return null;
- }
- }
-
- /**
- * Currently returns the trust rating of the most trusted source. Future work will look at better ways of calculating this.
- * @param axiom
- * @return
- * @throws JasdlException
- */
- private float getTrustRating(OWLAxiom axiom) throws JasdlException{
- ListTerm sources;
- if(axiom.equals(toAddLiteral.createAxiom())){ // hack to get the annotations of the NOT YET ADDED toAdd axiom
- sources = toAddLiteral.getLiteral().getSources();
- }else{
- SELiteral sl = agent.getAxiomToSELiteralConverter().convert((OWLIndividualAxiom)axiom); // kernel filter ensures axiom is an OWLIndividualAxiom
- sources = sl.getLiteral().getSources();
- }
- agent.getLogger().finest("Sources of "+axiom+"="+sources);
- float maxTrustRating = 0f; // if no sources available, trust is 0
- for(Term source : sources){
- if(!source.isAtom()){
- throw new JasdlException("Invalid source annotation "+source);
- }
- Atom name = (Atom)source;
- float trustRating = agent.getTrustRating(name);
- if(trustRating > maxTrustRating){
- maxTrustRating = trustRating;
- }
- }
- return maxTrustRating;
- }
-
-
-}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlIncisionFunction.java (from rev 1195, trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlIncisionFunction.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlIncisionFunction.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlIncisionFunction.java 2008-04-02 19:22:40 UTC (rev 1196)
@@ -0,0 +1,95 @@
+package jasdl.bb.bbops.revision;
+
+import jasdl.asSemantics.JasdlAgent;
+import jasdl.bridge.seliteral.SELiteral;
+import jasdl.util.exception.JasdlException;
+import jason.asSyntax.Atom;
+import jason.asSyntax.ListTerm;
+import jason.asSyntax.Term;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.semanticweb.owl.model.OWLAxiom;
+import org.semanticweb.owl.model.OWLIndividualAxiom;
+
+public class JasdlIncisionFunction implements IncisionFunction{
+
+
+ private JasdlAgent agent;
+ private SELiteral toAddLiteral;
+
+ /**
+ * The SELiteral to be added is required for a particularly inelegant hack that allows us
+ * to retrieve the annotations of the NOT YET ADDED axiom.
+ *
+ * @param agent required for getting trust ratings
+ * @param toAdd
+ * @param toAddAnnotations
+ */
+ public JasdlIncisionFunction(JasdlAgent agent, SELiteral toAddLiteral){
+ this.agent = agent;
+ this.toAddLiteral = toAddLiteral;
+ }
+
+ /**
+ * Chooses from each akernel axiom with lowest trust associated with it.
+ * Currently calculated using ASSERTED source annotations only.
+ * No source annotation is taken as trust = 0;
+ */
+ public Set<OWLAxiom> apply(Set<Set<OWLAxiom>> kernelset) {
+ try{
+ Set<OWLAxiom> chosen = new HashSet<OWLAxiom>();
+ for(Set<OWLAxiom> akernel : kernelset){
+ if(!akernel.isEmpty()){
+ OWLAxiom leastTrusted = null; // guaranteed to take a value
+ float minTrustRating = 1f;
+ for(OWLAxiom axiom : akernel){
+ float trustRating = getTrustRating(axiom);
+ agent.getLogger().finest("Trust rating of "+axiom+"="+trustRating);
+ if(trustRating <= minTrustRating){
+ minTrustRating = trustRating;
+ leastTrusted = axiom;
+ }
+ }
+ chosen.add(leastTrusted);
+ }
+ }
+ return chosen;
+ }catch(Exception e){
+ e.printStackTrace(); // TODO: introduce a seperate exception hierarchy once this package has been seperated from JASDL
+ return null;
+ }
+ }
+
+ /**
+ * Currently returns the trust rating of the most trusted source. Future work will look at better ways of calculating this.
+ * @param axiom
+ * @return
+ * @throws JasdlException
+ */
+ private float getTrustRating(OWLAxiom axiom) throws JasdlException{
+ ListTerm sources;
+ if(axiom.equals(toAddLiteral.createAxiom())){ // hack to get the annotations of the NOT YET ADDED toAdd axiom
+ sources = toAddLiteral.getLiteral().getSources();
+ }else{
+ SELiteral sl = agent.getAxiomToSELiteralConverter().convert((OWLIndividualAxiom)axiom); // kernel filter ensures axiom is an OWLIndividualAxiom
+ sources = sl.getLiteral().getSources();
+ }
+ agent.getLogger().finest("Sources of "+axiom+"="+sources);
+ float maxTrustRating = 0f; // if no sources available, trust is 0
+ for(Term source : sources){
+ if(!source.isAtom()){
+ throw new JasdlException("Invalid source annotation "+source);
+ }
+ Atom name = (Atom)source;
+ float trustRating = agent.getTrustRating(name);
+ if(trustRating > maxTrustRating){
+ maxTrustRating = trustRating;
+ }
+ }
+ return maxTrustRating;
+ }
+
+
+}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlReasonerFactory.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlReasonerFactory.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/JasdlReasonerFactory.java 2008-04-02 19:22:40 UTC (rev 1196)
@@ -1,4 +1,4 @@
-package jasdl.bb.revision;
+package jasdl.bb.bbops.revision;
import org.mindswap.pellet.PelletOptions;
import org.mindswap.pellet.owlapi.Reasoner;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/KernelsetFilter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/KernelsetFilter.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/KernelsetFilter.java 2008-04-02 19:22:40 UTC (rev 1196)
@@ -1,4 +1,4 @@
-package jasdl.bb.revision;
+package jasdl.bb.bbops.revision;
import java.util.HashSet;
import java.util.Set;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/TBoxAxiomKernelsetFilter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/TBoxAxiomKernelsetFilter.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/bbops/revision/TBoxAxiomKernelsetFilter.java 2008-04-02 19:22:40 UTC (rev 1196)
@@ -1,4 +1,4 @@
-package jasdl.bb.revision;
+package jasdl.bb.bbops.revision;
import org.semanticweb.owl.model.OWLAxiom;
import org.semanticweb.owl.model.OWLIndividualAxiom;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-02 18:55:31
|
Revision: 1195
http://jason.svn.sourceforge.net/jason/?rev=1195&view=rev
Author: tomklapiscak
Date: 2008-04-02 11:55:20 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Locally resident ontologies can now be specified using relative
filenames. Further structural refactoring.
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
trunk/applications/jasdl-owlapi/src/jasdl/architecture/IncomingPropContProcessingStrategy.java
trunk/applications/jasdl-owlapi/src/jasdl/architecture/JasdlAgArch.java
trunk/applications/jasdl-owlapi/src/jasdl/architecture/OutgoingPropContProcessingStrategy.java
trunk/applications/jasdl-owlapi/src/jasdl/architecture/PropContProcessingStrategy.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
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/bb/revision/JasdlIncisionFunction.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AliasFactory.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/MappingManager.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AliasFactory.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label/LabelManager.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralAllDifferentAssertion.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralClassAssertion.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralDataPropertyAssertion.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralObjectPropertyAssertion.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralPropertyAssertion.java
trunk/applications/jasdl-owlapi/src/jasdl/ia/define_class.java
trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
trunk/applications/jasdl-owlapi/src/jasdl/util/Common.java
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/xsd/XSDDataType.java
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/xsd/XSDDataTypeUtils.java
Added Paths:
-----------
trunk/applications/jasdl-owlapi/src/jasdl/util/exception/
trunk/applications/jasdl-owlapi/src/jasdl/util/exception/DuplicateMappingException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/exception/InvalidSELiteralException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlConfigurationException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/exception/NotEnrichedException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/exception/UnknownMappingException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/NSPrefixOWLEntityChecker.java
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/URIOWLEntityChecker.java
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/rendering/
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/rendering/URIOWLObjectRenderer.java
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/xsd/
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/parsing/
trunk/applications/jasdl-owlapi/src/jasdl/util/DuplicateMappingException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/InvalidSELiteralException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlConfigurationException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/NotEnrichedException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/UnknownMappingException.java
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/NSPrefixEntityChecker.java
trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/URIEntityChecker.java
trunk/applications/jasdl-owlapi/src/jasdl/util/xsd/
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-04-02 18:55:20 UTC (rev 1195)
@@ -44,7 +44,7 @@
jasdl_ontologies="travel",
//jasdl_travel_uri="http://www.dur.ac.uk/t.g.klapiscak/onts/travel.owl",
- jasdl_travel_uri="file:///home/tom/workspace/jason/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl",
+ jasdl_travel_uri="/ontologies/travel.owl",
/*jasdl_travel_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy",*/ // defaults can be overriden per-ontology here
jasdl_travel_mapping_manual="small_beach=beach", // these manual mappings will override any automatic mappings made by strategies,
@@ -66,12 +66,12 @@
jasdl_useBeliefRevision = "true",
jasdl_ontologies="holidays,places",
- jasdl_holidays_uri="file:///home/tom/workspace/jason/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl",
+ jasdl_holidays_uri="/ontologies/travel.owl",
jasdl_holidays_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy",
jasdl_holidays_mapping_manual="small_beach=beach, luxuriousHotel=LuxuryHotel", // for demonstration of arbitrary primitive mappings being handled correctly
- jasdl_places_uri="file:///home/tom/workspace/jason/applications/jasdl-owlapi/examples/travel_agent/ontologies/places.owl",
+ jasdl_places_uri="/ontologies/places.owl",
jasdl_places_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy"
]
agentArchClass jasdl.architecture.JasdlAgArch
Modified: trunk/applications/jasdl-owlapi/src/jasdl/architecture/IncomingPropContProcessingStrategy.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/architecture/IncomingPropContProcessingStrategy.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/architecture/IncomingPropContProcessingStrategy.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -26,9 +26,9 @@
import jasdl.bridge.factory.AliasFactory;
import jasdl.bridge.mapping.aliasing.Alias;
import jasdl.bridge.seliteral.SELiteral;
-import jasdl.util.DuplicateMappingException;
-import jasdl.util.JasdlException;
-import jasdl.util.NotEnrichedException;
+import jasdl.util.exception.DuplicateMappingException;
+import jasdl.util.exception.JasdlException;
+import jasdl.util.exception.NotEnrichedException;
import jason.asSyntax.Atom;
import jason.asSyntax.ListTerm;
import jason.asSyntax.Literal;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/architecture/JasdlAgArch.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/architecture/JasdlAgArch.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/architecture/JasdlAgArch.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -20,7 +20,7 @@
package jasdl.architecture;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.JasdlException;
import jason.architecture.AgArch;
import jason.asSemantics.Message;
import jason.asSyntax.ListTerm;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/architecture/OutgoingPropContProcessingStrategy.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/architecture/OutgoingPropContProcessingStrategy.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/architecture/OutgoingPropContProcessingStrategy.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -24,9 +24,9 @@
import jasdl.asSemantics.JasdlAgent;
import jasdl.bridge.seliteral.SELiteral;
import jasdl.bridge.seliteral.SELiteralAllDifferentAssertion;
-import jasdl.util.JasdlException;
-import jasdl.util.NotEnrichedException;
-import jasdl.util.UnknownMappingException;
+import jasdl.util.exception.JasdlException;
+import jasdl.util.exception.NotEnrichedException;
+import jasdl.util.exception.UnknownMappingException;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/architecture/PropContProcessingStrategy.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/architecture/PropContProcessingStrategy.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/architecture/PropContProcessingStrategy.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -20,7 +20,7 @@
package jasdl.architecture;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.JasdlException;
import jason.asSyntax.Literal;
public interface PropContProcessingStrategy {
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,8 +1,6 @@
package jasdl.asSemantics;
import static jasdl.util.Common.strip;
-import jasdl.asSemantics.parsing.NSPrefixEntityChecker;
-import jasdl.asSemantics.parsing.URIEntityChecker;
import jasdl.asSyntax.JasdlPlanLibrary;
import jasdl.bb.JasdlBeliefBase;
import jasdl.bb.revision.BeliefBaseSemiRevisor;
@@ -21,11 +19,14 @@
import jasdl.bridge.mapping.label.LabelManager;
import jasdl.bridge.mapping.label.OntologyURIManager;
import jasdl.bridge.seliteral.SELiteral;
-import jasdl.util.DuplicateMappingException;
-import jasdl.util.InvalidSELiteralException;
-import jasdl.util.JasdlException;
-import jasdl.util.NotEnrichedException;
-import jasdl.util.UnknownMappingException;
+import jasdl.util.exception.DuplicateMappingException;
+import jasdl.util.exception.InvalidSELiteralException;
+import jasdl.util.exception.JasdlException;
+import jasdl.util.exception.NotEnrichedException;
+import jasdl.util.exception.UnknownMappingException;
+import jasdl.util.owlapi.parsing.NSPrefixOWLEntityChecker;
+import jasdl.util.owlapi.parsing.URIOWLEntityChecker;
+import jasdl.util.owlapi.rendering.URIOWLObjectRenderer;
import jason.JasonException;
import jason.RevisionFailedException;
import jason.architecture.AgArch;
@@ -66,7 +67,6 @@
import org.semanticweb.owl.model.OWLOntologyChangeException;
import org.semanticweb.owl.model.OWLOntologyCreationException;
import org.semanticweb.owl.model.OWLOntologyManager;
-import org.semanticweb.owl.util.ShortFormProvider;
import uk.ac.manchester.cs.owl.mansyntaxrenderer.ManchesterOWLSyntaxOWLObjectRendererImpl;
@@ -119,16 +119,10 @@
trustMap = new HashMap<Atom, Float>();
manchesterObjectRenderer = new ManchesterOWLSyntaxOWLObjectRendererImpl();
- manchesterObjectRenderer.setShortFormProvider(new ShortFormProvider(){
- public void dispose() {
- }
- public String getShortForm(OWLEntity entity) {
- return entity.getURI().toString();
- }
- }); // we want fully qualified entity references
+ manchesterObjectRenderer.setShortFormProvider(new URIOWLObjectRenderer());
- manchesterNsPrefixDescriptionParser = new ManchesterOWLSyntaxDescriptionParser(ontologyManager.getOWLDataFactory(), new NSPrefixEntityChecker(this));
- manchesterURIDescriptionParser = new ManchesterOWLSyntaxDescriptionParser(ontologyManager.getOWLDataFactory(), new URIEntityChecker(this));
+ manchesterNsPrefixDescriptionParser = new ManchesterOWLSyntaxDescriptionParser(ontologyManager.getOWLDataFactory(), new NSPrefixOWLEntityChecker(this));
+ manchesterURIDescriptionParser = new ManchesterOWLSyntaxDescriptionParser(ontologyManager.getOWLDataFactory(), new URIOWLEntityChecker(this));
// override plan library
setPL( new JasdlPlanLibrary(this) );
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,23 +1,25 @@
package jasdl.asSemantics;
import static jasdl.util.Common.DELIM;
+import static jasdl.util.Common.getCurrentDir;
import static jasdl.util.Common.strip;
import jasdl.bridge.factory.AliasFactory;
import jasdl.bridge.mapping.aliasing.Alias;
import jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy;
import jasdl.bridge.mapping.aliasing.MappingStrategy;
-import jasdl.util.JasdlConfigurationException;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.JasdlConfigurationException;
+import jasdl.util.exception.JasdlException;
import jason.asSyntax.Atom;
import jason.runtime.Settings;
import java.lang.reflect.Constructor;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
+import java.util.logging.Level;
-import org.apache.log4j.Level;
import org.semanticweb.owl.inference.OWLReasoner;
import org.semanticweb.owl.model.OWLEntity;
import org.semanticweb.owl.model.OWLOntology;
@@ -60,17 +62,13 @@
}
public void configure(Settings stts) throws JasdlException{
- try{
- loadReasoner(stts);
- loadDefaultMappingStrategies(stts);
- setUseBeliefRevision(stts);
- loadOntologies(stts);
- applyManualMappings(stts);
- loadKnownAgents(stts);
- loadTrustRatings(stts);
- }catch(JasdlException e){
- throw new JasdlException("JASDL agent encountered error during configuration. Reason: "+e);
- }
+ loadReasoner(stts);
+ loadDefaultMappingStrategies(stts);
+ setUseBeliefRevision(stts);
+ loadOntologies(stts);
+ applyManualMappings(stts);
+ loadKnownAgents(stts);
+ loadTrustRatings(stts);
}
@SuppressWarnings("unchecked")
@@ -89,7 +87,7 @@
throw new JasdlException("Unknown reasoner class: "+reasonerClass);
}else{
agent.setReasoner(reasoner);
- agent.setReasonerLogLevel(Level.FATAL);
+ agent.setReasonerLogLevel(org.apache.log4j.Level.FATAL);
}
}catch (Throwable e) {
throw new JasdlException("Error instantiating reasoner "+reasonerClass+". Reason: "+e);
@@ -116,19 +114,30 @@
* @param stts .mas2j settings
* @throws JasdlException if instantiation of an ontology fails
*/
- private void loadOntologies(Settings stts) throws JasdlException{
+ private void loadOntologies(Settings stts) throws JasdlConfigurationException{
String[] labels = splitUserParameter( stts, MAS2J_PREFIX + MAS2J_ONTOLOGIES );
for(String label : labels){
if(reservedOntologyLabels.contains(label)){
- throw new JasdlException(label+" is a reserved ontology label");
+ throw new JasdlConfigurationException(label+" is a reserved ontology label");
}
String _uri = prepareUserParameter( stts, MAS2J_PREFIX + "_" + label + MAS2J_URI );
URI uri = null;
try {
- uri = new URI(_uri);
+ try{
+ uri = new URI(_uri);
+ if(!uri.isAbsolute()){
+ throw new URISyntaxException("", "");
+ }
+ }catch(URISyntaxException urie){
+ _uri = "file://"+getCurrentDir()+_uri;
+ uri = new URI(_uri); // try relative path
+ agent.getLogger().fine("Loaded ontology "+_uri+" from relative uri");
+ }
agent.loadOntology(new Atom(label), uri, getMappingStrategies(stts, new Atom(label)));
} catch (Exception e) {
- throw new JasdlException("Unable to instantiate ontology "+_uri+" (\""+label+"\"). Reason: "+e);
+ String msg = "Unable to instantiate ontology \""+_uri+"\" ("+label+")";
+ agent.getLogger().log(Level.SEVERE, msg, e);
+ throw new JasdlConfigurationException(msg+" - "+e);
}
}
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -22,9 +22,9 @@
import static jasdl.util.Common.getTEOp;
import jasdl.asSemantics.JasdlAgent;
import jasdl.bridge.seliteral.SELiteral;
-import jasdl.util.JasdlException;
-import jasdl.util.NotEnrichedException;
-import jasdl.util.UnknownMappingException;
+import jasdl.util.exception.JasdlException;
+import jasdl.util.exception.NotEnrichedException;
+import jasdl.util.exception.UnknownMappingException;
import jason.JasonException;
import jason.asSyntax.Literal;
import jason.asSyntax.Plan;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -20,7 +20,7 @@
package jasdl.asSyntax;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.JasdlException;
import jason.asSemantics.Unifier;
import jason.asSyntax.Plan;
import jason.asSyntax.Trigger;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -7,8 +7,8 @@
import jasdl.bb.revision.TBoxAxiomKernelsetFilter;
import jasdl.bridge.seliteral.SELiteral;
import jasdl.bridge.seliteral.SELiteralAllDifferentAssertion;
-import jasdl.util.JasdlException;
-import jasdl.util.NotEnrichedException;
+import jasdl.util.exception.JasdlException;
+import jasdl.util.exception.NotEnrichedException;
import jason.asSemantics.Unifier;
import jason.asSyntax.Literal;
import jason.asSyntax.Term;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlIncisionFunction.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlIncisionFunction.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlIncisionFunction.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -2,7 +2,7 @@
import jasdl.asSemantics.JasdlAgent;
import jasdl.bridge.seliteral.SELiteral;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.JasdlException;
import jason.asSyntax.Atom;
import jason.asSyntax.ListTerm;
import jason.asSyntax.Term;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AliasFactory.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AliasFactory.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AliasFactory.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -2,7 +2,7 @@
import jasdl.bridge.mapping.aliasing.Alias;
import jasdl.bridge.seliteral.SELiteral;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.JasdlException;
import jason.asSyntax.Atom;
/**
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -4,11 +4,11 @@
import jasdl.bridge.mapping.aliasing.Alias;
import jasdl.bridge.mapping.aliasing.AllDifferentPlaceholder;
import jasdl.bridge.seliteral.SELiteral;
-import jasdl.util.InvalidSELiteralException;
-import jasdl.util.JasdlException;
-import jasdl.util.UnknownMappingException;
-import jasdl.util.xsd.XSDDataType;
-import jasdl.util.xsd.XSDDataTypeUtils;
+import jasdl.util.exception.InvalidSELiteralException;
+import jasdl.util.exception.JasdlException;
+import jasdl.util.exception.UnknownMappingException;
+import jasdl.util.owlapi.xsd.XSDDataType;
+import jasdl.util.owlapi.xsd.XSDDataTypeUtils;
import jason.asSyntax.Atom;
import jason.asSyntax.DefaultTerm;
import jason.asSyntax.Literal;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -8,8 +8,8 @@
import jasdl.bridge.mapping.aliasing.Alias;
import jasdl.bridge.mapping.aliasing.AllDifferentPlaceholder;
import jasdl.bridge.seliteral.SELiteral;
-import jasdl.util.InvalidSELiteralException;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.InvalidSELiteralException;
+import jasdl.util.exception.JasdlException;
import jason.asSyntax.Atom;
import jason.asSyntax.DefaultTerm;
import jason.asSyntax.ListTerm;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -27,8 +27,8 @@
import jasdl.bridge.seliteral.SELiteralClassAssertion;
import jasdl.bridge.seliteral.SELiteralDataPropertyAssertion;
import jasdl.bridge.seliteral.SELiteralObjectPropertyAssertion;
-import jasdl.util.InvalidSELiteralException;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.InvalidSELiteralException;
+import jasdl.util.exception.JasdlException;
import java.util.HashSet;
import java.util.Set;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/MappingManager.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/MappingManager.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/MappingManager.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,7 +1,7 @@
package jasdl.bridge.mapping;
-import jasdl.util.DuplicateMappingException;
-import jasdl.util.UnknownMappingException;
+import jasdl.util.exception.DuplicateMappingException;
+import jasdl.util.exception.UnknownMappingException;
import java.util.HashMap;
import java.util.Set;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AliasFactory.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AliasFactory.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AliasFactory.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,7 +1,7 @@
package jasdl.bridge.mapping.aliasing;
import jasdl.bridge.seliteral.SELiteral;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.JasdlException;
import jason.asSyntax.Atom;
/**
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label/LabelManager.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label/LabelManager.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label/LabelManager.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,7 +1,7 @@
package jasdl.bridge.mapping.label;
import jasdl.bridge.mapping.MappingManager;
-import jasdl.util.DuplicateMappingException;
+import jasdl.util.exception.DuplicateMappingException;
import jason.asSyntax.Atom;
import java.util.HashSet;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -3,10 +3,10 @@
import jasdl.asSemantics.JasdlAgent;
import jasdl.bridge.factory.AliasFactory;
import jasdl.bridge.mapping.aliasing.Alias;
-import jasdl.util.InvalidSELiteralException;
-import jasdl.util.JasdlException;
-import jasdl.util.NotEnrichedException;
-import jasdl.util.UnknownMappingException;
+import jasdl.util.exception.InvalidSELiteralException;
+import jasdl.util.exception.JasdlException;
+import jasdl.util.exception.NotEnrichedException;
+import jasdl.util.exception.UnknownMappingException;
import jason.asSyntax.Atom;
import jason.asSyntax.ListTerm;
import jason.asSyntax.Literal;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralAllDifferentAssertion.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralAllDifferentAssertion.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralAllDifferentAssertion.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,8 +1,8 @@
package jasdl.bridge.seliteral;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.util.InvalidSELiteralException;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.InvalidSELiteralException;
+import jasdl.util.exception.JasdlException;
import jason.asSyntax.ListTerm;
import jason.asSyntax.Literal;
import jason.asSyntax.Term;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralClassAssertion.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralClassAssertion.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralClassAssertion.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -2,7 +2,7 @@
import static jasdl.util.Common.DOMAIN;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.JasdlException;
import jason.asSyntax.Literal;
import org.semanticweb.owl.model.OWLDescription;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralDataPropertyAssertion.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralDataPropertyAssertion.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralDataPropertyAssertion.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -4,10 +4,10 @@
import static jasdl.util.Common.strip;
import static jasdl.util.Common.surroundedBy;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.util.InvalidSELiteralException;
-import jasdl.util.JasdlException;
-import jasdl.util.xsd.XSDDataType;
-import jasdl.util.xsd.XSDDataTypeUtils;
+import jasdl.util.exception.InvalidSELiteralException;
+import jasdl.util.exception.JasdlException;
+import jasdl.util.owlapi.xsd.XSDDataType;
+import jasdl.util.owlapi.xsd.XSDDataTypeUtils;
import jason.asSyntax.Literal;
import jason.asSyntax.Term;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralObjectPropertyAssertion.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralObjectPropertyAssertion.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralObjectPropertyAssertion.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -3,7 +3,7 @@
import static jasdl.util.Common.DOMAIN;
import static jasdl.util.Common.RANGE;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.JasdlException;
import jason.asSyntax.Literal;
import org.semanticweb.owl.model.OWLIndividual;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralPropertyAssertion.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralPropertyAssertion.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralPropertyAssertion.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -6,7 +6,7 @@
import jasdl.asSemantics.JasdlAgent;
import jasdl.bridge.factory.AliasFactory;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.JasdlException;
import jason.asSyntax.Literal;
public abstract class SELiteralPropertyAssertion extends SELiteral{
Modified: trunk/applications/jasdl-owlapi/src/jasdl/ia/define_class.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/ia/define_class.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/ia/define_class.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -21,7 +21,7 @@
import static jasdl.util.Common.strip;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.util.JasdlException;
+import jasdl.util.exception.JasdlException;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -10,9 +10,9 @@
import jasdl.bridge.factory.AliasFactory;
import jasdl.bridge.mapping.aliasing.Alias;
import jasdl.bridge.seliteral.SELiteral;
-import jasdl.util.JasdlException;
-import jasdl.util.xsd.XSDDataType;
-import jasdl.util.xsd.XSDDataTypeUtils;
+import jasdl.util.exception.JasdlException;
+import jasdl.util.owlapi.xsd.XSDDataType;
+import jasdl.util.owlapi.xsd.XSDDataTypeUtils;
import jason.architecture.AgArch;
import jason.architecture.AgArchInfraTier;
import jason.asSyntax.Atom;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/util/Common.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/Common.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/Common.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -19,10 +19,11 @@
*/
package jasdl.util;
-import jason.asSyntax.Literal;
import jason.asSyntax.Trigger;
+import java.io.File;
+
public class Common {
public static String DELIM=",";
@@ -59,5 +60,18 @@
}
}
+ public static String getCurrentDir()
+ {
+ File dir1 = new File (".");
+ String strCurrentDir = "";
+ try {
+ strCurrentDir = dir1.getCanonicalPath();
+ }
+ catch(Exception e) {
+ e.printStackTrace();
+ }
+ return strCurrentDir;
+ }
+
}
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/util/DuplicateMappingException.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/DuplicateMappingException.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/DuplicateMappingException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,29 +0,0 @@
-/*
- * 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/>.
- *
- */
-package jasdl.util;
-
-import jason.JasonException;
-
-
-public class DuplicateMappingException extends JasdlException {
- public DuplicateMappingException(String message){
- super(message);
- }
-}
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/util/InvalidSELiteralException.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/InvalidSELiteralException.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/InvalidSELiteralException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,29 +0,0 @@
-/*
- * 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/>.
- *
- */
-package jasdl.util;
-
-import jason.JasonException;
-
-
-public class InvalidSELiteralException extends JasdlException {
- public InvalidSELiteralException(String message){
- super(message);
- }
-}
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlConfigurationException.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlConfigurationException.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlConfigurationException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,29 +0,0 @@
-/*
- * 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/>.
- *
- */
-package jasdl.util;
-
-import jason.JasonException;
-
-
-public class JasdlConfigurationException extends JasdlException {
- public JasdlConfigurationException(String message){
- super(message);
- }
-}
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlException.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlException.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,29 +0,0 @@
-/*
- * 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/>.
- *
- */
-package jasdl.util;
-
-import jason.JasonException;
-
-
-public class JasdlException extends JasonException {
- public JasdlException(String message){
- super(message);
- }
-}
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/util/NotEnrichedException.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/NotEnrichedException.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/NotEnrichedException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,29 +0,0 @@
-/*
- * 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/>.
- *
- */
-package jasdl.util;
-
-import jason.JasonException;
-
-
-public class NotEnrichedException extends JasdlException {
- public NotEnrichedException(String message){
- super(message);
- }
-}
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/util/UnknownMappingException.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/UnknownMappingException.java 2008-04-02 17:26:44 UTC (rev 1194)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/UnknownMappingException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,29 +0,0 @@
-/*
- * 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/>.
- *
- */
-package jasdl.util;
-
-import jason.JasonException;
-
-
-public class UnknownMappingException extends JasdlException {
- public UnknownMappingException(String message){
- super(message);
- }
-}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/util/exception/DuplicateMappingException.java (from rev 1193, trunk/applications/jasdl-owlapi/src/jasdl/util/DuplicateMappingException.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/exception/DuplicateMappingException.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/exception/DuplicateMappingException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -0,0 +1,29 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.util.exception;
+
+import jason.JasonException;
+
+
+public class DuplicateMappingException extends JasdlException {
+ public DuplicateMappingException(String message){
+ super(message);
+ }
+}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/util/exception/InvalidSELiteralException.java (from rev 1193, trunk/applications/jasdl-owlapi/src/jasdl/util/InvalidSELiteralException.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/exception/InvalidSELiteralException.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/exception/InvalidSELiteralException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -0,0 +1,29 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.util.exception;
+
+import jason.JasonException;
+
+
+public class InvalidSELiteralException extends JasdlException {
+ public InvalidSELiteralException(String message){
+ super(message);
+ }
+}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlConfigurationException.java (from rev 1193, trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlConfigurationException.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlConfigurationException.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlConfigurationException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -0,0 +1,29 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.util.exception;
+
+import jason.JasonException;
+
+
+public class JasdlConfigurationException extends JasdlException {
+ public JasdlConfigurationException(String message){
+ super(message);
+ }
+}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlException.java (from rev 1193, trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlException.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlException.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/exception/JasdlException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -0,0 +1,29 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.util.exception;
+
+import jason.JasonException;
+
+
+public class JasdlException extends JasonException {
+ public JasdlException(String message){
+ super(message);
+ }
+}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/util/exception/NotEnrichedException.java (from rev 1193, trunk/applications/jasdl-owlapi/src/jasdl/util/NotEnrichedException.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/exception/NotEnrichedException.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/exception/NotEnrichedException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -0,0 +1,29 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.util.exception;
+
+import jason.JasonException;
+
+
+public class NotEnrichedException extends JasdlException {
+ public NotEnrichedException(String message){
+ super(message);
+ }
+}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/util/exception/UnknownMappingException.java (from rev 1193, trunk/applications/jasdl-owlapi/src/jasdl/util/UnknownMappingException.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/exception/UnknownMappingException.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/exception/UnknownMappingException.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -0,0 +1,29 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.util.exception;
+
+import jason.JasonException;
+
+
+public class UnknownMappingException extends JasdlException {
+ public UnknownMappingException(String message){
+ super(message);
+ }
+}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing (from rev 1193, trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/parsing)
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/NSPrefixEntityChecker.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/parsing/NSPrefixEntityChecker.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/NSPrefixEntityChecker.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,106 +0,0 @@
-package jasdl.asSemantics.parsing;
-import jasdl.asSemantics.JasdlAgent;
-import jasdl.bridge.factory.AliasFactory;
-import jasdl.bridge.mapping.aliasing.Alias;
-import jason.asSyntax.Atom;
-
-import org.semanticweb.owl.expression.OWLEntityChecker;
-import org.semanticweb.owl.model.OWLClass;
-import org.semanticweb.owl.model.OWLDataProperty;
-import org.semanticweb.owl.model.OWLDataType;
-import org.semanticweb.owl.model.OWLEntity;
-import org.semanticweb.owl.model.OWLIndividual;
-import org.semanticweb.owl.model.OWLObjectProperty;
-
-/**
- * For parsing class-expressions defined with entities in the alias label:functor format.
- * E.g. "(travel:hotel and travel:hasActivity some travel:museums) and owl:thing"
- * @author Tom Klapiscak
- *
- */
-public class NSPrefixEntityChecker implements OWLEntityChecker{
-
- private JasdlAgent agent;
-
- public NSPrefixEntityChecker(JasdlAgent agent){
- this.agent = agent;
- }
-
- public OWLClass getOWLClass(String name) {
- OWLEntity entity = convert(name);
- if(entity == null){
- return null;
- }
- if(entity.isOWLClass()){
- return entity.asOWLClass();
- }else{
- return null;
- }
- }
-
- public OWLDataProperty getOWLDataProperty(String name) {
- OWLEntity entity = convert(name);
- if(entity == null){
- return null;
- }
- if(entity.isOWLDataProperty()){
- return entity.asOWLDataProperty();
- }else{
- return null;
- }
- }
-
- public OWLDataType getOWLDataType(String name) {
- OWLEntity entity = convert(name);
- if(entity == null){
- return null;
- }
- if(entity.isOWLDataType()){
- return entity.asOWLDataType();
- }else{
- return null;
- }
- }
-
- public OWLIndividual getOWLIndividual(String name) {
- OWLEntity entity = convert(name);
- if(entity == null){
- // TODO: instantiate individuals?
- return null;
- }
- if(entity.isOWLIndividual()){
- return entity.asOWLIndividual();
- }else{
- return null;
- }
- }
-
- public OWLObjectProperty getOWLObjectProperty(String name) {
- OWLEntity entity = convert(name);
- if(entity == null){
- return null;
- }
- if(entity.isOWLObjectProperty()){
- return entity.asOWLObjectProperty();
- }else{
- return null;
- }
- }
-
- private OWLEntity convert(String name){
- String[] tokens = name.split(":");
- try {
- Atom functor = new Atom(tokens[1]);
- Atom label = new Atom(tokens[0]);
- Alias alias = AliasFactory.INSTANCE.create(functor, label);
- return (OWLEntity)agent.getAliasManager().getRight(alias); // guaranteed to be an entity? Not for anonymous classes!
- }catch(ClassCastException e){
- // we are dealing with an anonymous class description
- return null;
- } catch (Exception e) {
- return null;
- }
- }
-
-
- }
\ No newline at end of file
Copied: trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/NSPrefixOWLEntityChecker.java (from rev 1193, trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/parsing/NSPrefixEntityChecker.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/NSPrefixOWLEntityChecker.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/NSPrefixOWLEntityChecker.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -0,0 +1,106 @@
+package jasdl.util.owlapi.parsing;
+import jasdl.asSemantics.JasdlAgent;
+import jasdl.bridge.factory.AliasFactory;
+import jasdl.bridge.mapping.aliasing.Alias;
+import jason.asSyntax.Atom;
+
+import org.semanticweb.owl.expression.OWLEntityChecker;
+import org.semanticweb.owl.model.OWLClass;
+import org.semanticweb.owl.model.OWLDataProperty;
+import org.semanticweb.owl.model.OWLDataType;
+import org.semanticweb.owl.model.OWLEntity;
+import org.semanticweb.owl.model.OWLIndividual;
+import org.semanticweb.owl.model.OWLObjectProperty;
+
+/**
+ * For parsing class-expressions defined with entities in the alias label:functor format.
+ * E.g. "(travel:hotel and travel:hasActivity some travel:museums) and owl:thing"
+ * @author Tom Klapiscak
+ *
+ */
+public class NSPrefixOWLEntityChecker implements OWLEntityChecker{
+
+ private JasdlAgent agent;
+
+ public NSPrefixOWLEntityChecker(JasdlAgent agent){
+ this.agent = agent;
+ }
+
+ public OWLClass getOWLClass(String name) {
+ OWLEntity entity = convert(name);
+ if(entity == null){
+ return null;
+ }
+ if(entity.isOWLClass()){
+ return entity.asOWLClass();
+ }else{
+ return null;
+ }
+ }
+
+ public OWLDataProperty getOWLDataProperty(String name) {
+ OWLEntity entity = convert(name);
+ if(entity == null){
+ return null;
+ }
+ if(entity.isOWLDataProperty()){
+ return entity.asOWLDataProperty();
+ }else{
+ return null;
+ }
+ }
+
+ public OWLDataType getOWLDataType(String name) {
+ OWLEntity entity = convert(name);
+ if(entity == null){
+ return null;
+ }
+ if(entity.isOWLDataType()){
+ return entity.asOWLDataType();
+ }else{
+ return null;
+ }
+ }
+
+ public OWLIndividual getOWLIndividual(String name) {
+ OWLEntity entity = convert(name);
+ if(entity == null){
+ // TODO: instantiate individuals?
+ return null;
+ }
+ if(entity.isOWLIndividual()){
+ return entity.asOWLIndividual();
+ }else{
+ return null;
+ }
+ }
+
+ public OWLObjectProperty getOWLObjectProperty(String name) {
+ OWLEntity entity = convert(name);
+ if(entity == null){
+ return null;
+ }
+ if(entity.isOWLObjectProperty()){
+ return entity.asOWLObjectProperty();
+ }else{
+ return null;
+ }
+ }
+
+ private OWLEntity convert(String name){
+ String[] tokens = name.split(":");
+ try {
+ Atom functor = new Atom(tokens[1]);
+ Atom label = new Atom(tokens[0]);
+ Alias alias = AliasFactory.INSTANCE.create(functor, label);
+ return (OWLEntity)agent.getAliasManager().getRight(alias); // guaranteed to be an entity? Not for anonymous classes!
+ }catch(ClassCastException e){
+ // we are dealing with an anonymous class description
+ return null;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+
+ }
\ No newline at end of file
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/URIEntityChecker.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/parsing/URIEntityChecker.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/URIEntityChecker.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -1,99 +0,0 @@
-package jasdl.asSemantics.parsing;
-
-import jasdl.asSemantics.JasdlAgent;
-
-import java.net.URI;
-
-import org.semanticweb.owl.expression.OWLEntityChecker;
-import org.semanticweb.owl.model.OWLClass;
-import org.semanticweb.owl.model.OWLDataProperty;
-import org.semanticweb.owl.model.OWLDataType;
-import org.semanticweb.owl.model.OWLEntity;
-import org.semanticweb.owl.model.OWLIndividual;
-import org.semanticweb.owl.model.OWLObjectProperty;
-
-/**
- * For parsing class-expressions where entities are defined by their fully-qualified URIs.
- * E.g. "http://www.dur.ac.uk.t.g.klapiscak/travel.owl#Hotel and http://www.dur.ac.uk.t.g.klapiscak/travel.owl#Accommodation".
- * @author tom
- *
- */
-public class URIEntityChecker implements OWLEntityChecker{
-
- private JasdlAgent agent;
-
- public URIEntityChecker(JasdlAgent agent){
- this.agent = agent;
- }
-
- public OWLClass getOWLClass(String uri) {
- OWLEntity entity = convert(uri);
- if(entity == null){
- return null;
- }
- if(entity.isOWLClass()){
- return entity.asOWLClass();
- }else{
- return null;
- }
- }
-
- public OWLDataProperty getOWLDataProperty(String uri) {
- OWLEntity entity = convert(uri);
- if(entity == null){
- return null;
- }
- if(entity.isOWLDataProperty()){
- return entity.asOWLDataProperty();
- }else{
- return null;
- }
- }
-
- public OWLDataType getOWLDataType(String uri) {
- OWLEntity entity = convert(uri);
- if(entity == null){
- return null;
- }
- if(entity.isOWLDataType()){
- return entity.asOWLDataType();
- }else{
- return null;
- }
- }
-
- public OWLIndividual getOWLIndividual(String uri) {
- OWLEntity entity = convert(uri);
- if(entity == null){
- return null;
- }
- if(entity.isOWLIndividual()){
- return entity.asOWLIndividual();
- }else{
- return null;
- }
- }
-
- public OWLObjectProperty getOWLObjectProperty(String uri) {
- OWLEntity entity = convert(uri);
- if(entity == null){
- return null;
- }
- if(entity.isOWLObjectProperty()){
- return entity.asOWLObjectProperty();
- }else{
- return null;
- }
- }
-
- private OWLEntity convert(String _uri){
- try {
- URI uri = new URI(_uri);
- return agent.toEntity(uri);
- } catch (Exception e) {
- return null;
- }
- }
-
-
-}
\ No newline at end of file
Copied: trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/URIOWLEntityChecker.java (from rev 1193, trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/parsing/URIEntityChecker.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/URIOWLEntityChecker.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/parsing/URIOWLEntityChecker.java 2008-04-02 18:55:20 UTC (rev 1195)
@@ -0,0 +1,99 @@
+package jasdl.util.owlapi.parsing;
+
+import jasdl.asSemantics.JasdlAgent;
+
+import java.net.URI;
+
+import org.semanticweb.owl.expression.OWLEntityChecker;
+import org.semanticweb.owl.model.OWLClass;
+import org.semanticweb.owl.model.OWLDataProperty;
+import org.semanticweb.owl.model.OWLDataType;
+import org.semanticweb.owl.model.OWLEntity;
+import org.semanticweb.owl.model.OWLIndividual;
+import org.semanticweb.owl.model.OWLObjectProperty;
+
+/**
+ * For parsing class-expressions where entities are defined by their fully-qualified URIs.
+ * E.g. "http://www.dur.ac.uk.t.g.klapiscak/travel.owl#Hotel and http://www.dur.ac.uk.t.g.klapiscak/travel.owl#Accommodation"...
[truncated message content] |
|
From: <tom...@us...> - 2008-04-02 17:26:48
|
Revision: 1194
http://jason.svn.sourceforge.net/jason/?rev=1194&view=rev
Author: tomklapiscak
Date: 2008-04-02 10:26:44 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Structural improvements (problems with last 3 revisions)
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/Alias.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AliasFactory.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AliasManager.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/DecapitaliseMappingStrategy.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/DefinitionManager.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/MappingStrategy.java
Added Paths:
-----------
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AllDifferentPlaceholder.java
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-04-02 17:26:44 UTC (rev 1194)
@@ -43,7 +43,8 @@
jasdl_default_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy", // applied to incoming ontologies and those given no automapping
jasdl_ontologies="travel",
- jasdl_travel_uri="http://www.dur.ac.uk/t.g.klapiscak/onts/travel.owl",
+ //jasdl_travel_uri="http://www.dur.ac.uk/t.g.klapiscak/onts/travel.owl",
+ jasdl_travel_uri="file:///home/tom/workspace/jason/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl",
/*jasdl_travel_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy",*/ // defaults can be overriden per-ontology here
jasdl_travel_mapping_manual="small_beach=beach", // these manual mappings will override any automatic mappings made by strategies,
@@ -65,12 +66,12 @@
jasdl_useBeliefRevision = "true",
jasdl_ontologies="holidays,places",
- jasdl_holidays_uri="http://www.dur.ac.uk/t.g.klapiscak/onts/travel.owl",
+ jasdl_holidays_uri="file:///home/tom/workspace/jason/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl",
jasdl_holidays_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy",
jasdl_holidays_mapping_manual="small_beach=beach, luxuriousHotel=LuxuryHotel", // for demonstration of arbitrary primitive mappings being handled correctly
- jasdl_places_uri="http://www.dur.ac.uk/t.g.klapiscak/onts/places.owl",
+ jasdl_places_uri="file:///home/tom/workspace/jason/applications/jasdl-owlapi/examples/travel_agent/ontologies/places.owl",
jasdl_places_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy"
]
agentArchClass jasdl.architecture.JasdlAgArch
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-04-02 17:09:55 UTC (rev 1193)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-04-02 17:26:44 UTC (rev 1194)
@@ -89,7 +89,7 @@
throw new JasdlException("Unknown reasoner class: "+reasonerClass);
}else{
agent.setReasoner(reasoner);
- agent.setReasonerLogLevel(Level.WARN);
+ agent.setReasonerLogLevel(Level.FATAL);
}
}catch (Throwable e) {
throw new JasdlException("Error instantiating reasoner "+reasonerClass+". Reason: "+e);
Copied: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing (from rev 1189, trunk/applications/jasdl-owlapi/src/jasdl/bridge/alias)
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/Alias.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/alias/Alias.java 2008-04-01 23:35:02 UTC (rev 1189)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/Alias.java 2008-04-02 17:26:44 UTC (rev 1194)
@@ -1,4 +1,4 @@
-package jasdl.bridge.alias;
+package jasdl.bridge.mapping.aliasing;
import jason.asSyntax.Atom;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AliasFactory.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/alias/AliasFactory.java 2008-04-01 23:35:02 UTC (rev 1189)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AliasFactory.java 2008-04-02 17:26:44 UTC (rev 1194)
@@ -1,4 +1,4 @@
-package jasdl.bridge.alias;
+package jasdl.bridge.mapping.aliasing;
import jasdl.bridge.seliteral.SELiteral;
import jasdl.util.JasdlException;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AliasManager.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/alias/AliasManager.java 2008-04-01 23:35:02 UTC (rev 1189)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AliasManager.java 2008-04-02 17:26:44 UTC (rev 1194)
@@ -1,6 +1,6 @@
-package jasdl.bridge.alias;
+package jasdl.bridge.mapping.aliasing;
-import jasdl.bridge.MappingManager;
+import jasdl.bridge.mapping.MappingManager;
import org.semanticweb.owl.model.OWLObject;
Copied: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AllDifferentPlaceholder.java (from rev 1189, trunk/applications/jasdl-owlapi/src/jasdl/bridge/AllDifferentPlaceholder.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AllDifferentPlaceholder.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/AllDifferentPlaceholder.java 2008-04-02 17:26:44 UTC (rev 1194)
@@ -0,0 +1,118 @@
+package jasdl.bridge.mapping.aliasing;
+
+import jason.asSyntax.Atom;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.semanticweb.owl.model.OWLAnnotation;
+import org.semanticweb.owl.model.OWLAnnotationAxiom;
+import org.semanticweb.owl.model.OWLClass;
+import org.semanticweb.owl.model.OWLDataProperty;
+import org.semanticweb.owl.model.OWLDataType;
+import org.semanticweb.owl.model.OWLEntity;
+import org.semanticweb.owl.model.OWLEntityVisitor;
+import org.semanticweb.owl.model.OWLException;
+import org.semanticweb.owl.model.OWLIndividual;
+import org.semanticweb.owl.model.OWLNamedObjectVisitor;
+import org.semanticweb.owl.model.OWLObject;
+import org.semanticweb.owl.model.OWLObjectProperty;
+import org.semanticweb.owl.model.OWLObjectVisitor;
+import org.semanticweb.owl.model.OWLOntology;
+
+/**
+ * Since the all_different has no concrete entity associated with it, we create a "placeholder" so that it remains consistent with
+ * JASDL's mapping mechanisms. Entities of this type will be intercepted and dealt with differently.
+ * Associated with an ontology label which determines hash-code - required since each ontology must have its own placeholder to reference
+ * @author tom
+ *
+ */
+public class AllDifferentPlaceholder implements OWLEntity {
+ private Atom label;
+
+ public AllDifferentPlaceholder(Atom label){
+ this.label = label;
+ }
+
+ public void accept(OWLEntityVisitor visitor) {
+ }
+
+ public Set<OWLAnnotationAxiom> getAnnotationAxioms(OWLOntology ontology) {
+ return null;
+ }
+
+ public Set<OWLAnnotation> getAnnotations(OWLOntology ontology) {
+ return null;
+ }
+
+ public Set<OWLAnnotation> getAnnotations(OWLOntology ontology, URI annotationURI) {
+ return null;
+ }
+
+ public void accept(OWLObjectVisitor visitor) {
+
+ }
+
+ public void accept(OWLNamedObjectVisitor visitor) {
+ }
+
+ public URI getURI() {
+ return null;
+ }
+
+ public boolean equals(Object other){
+ if(!(other instanceof AllDifferentPlaceholder)){
+ return false;
+ }
+ return label.equals(((AllDifferentPlaceholder)other).label);
+ }
+
+ public int hashCode(){
+ return label.hashCode();
+ }
+
+ public OWLClass asOWLClass() {
+ return null;
+ }
+
+ public OWLDataProperty asOWLDataProperty() {
+ return null;
+ }
+
+ public OWLDataType asOWLDataType() {
+ return null;
+ }
+
+ public OWLIndividual asOWLIndividual() {
+ return null;
+ }
+
+ public OWLObjectProperty asOWLObjectProperty() {
+ return null;
+ }
+
+ public boolean isOWLClass() {
+ return false;
+ }
+
+ public boolean isOWLDataProperty() {
+ return false;
+ }
+
+ public boolean isOWLDataType() {
+ return false;
+ }
+
+ public boolean isOWLIndividual() {
+ return false;
+ }
+
+ public boolean isOWLObjectProperty() {
+ return false;
+ }
+
+ public int compareTo(OWLObject arg0) {
+ return 0;
+ }
+
+}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/DecapitaliseMappingStrategy.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/alias/DecapitaliseMappingStrategy.java 2008-04-01 23:35:02 UTC (rev 1189)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/DecapitaliseMappingStrategy.java 2008-04-02 17:26:44 UTC (rev 1194)
@@ -17,7 +17,7 @@
* along with JASDL. If not, see <http://www.gnu.org/licenses/>.
*
*/
-package jasdl.bridge.alias;
+package jasdl.bridge.mapping.aliasing;
public class DecapitaliseMappingStrategy implements MappingStrategy {
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/DefinitionManager.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/alias/DefinitionManager.java 2008-04-01 23:35:02 UTC (rev 1189)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/DefinitionManager.java 2008-04-02 17:26:44 UTC (rev 1194)
@@ -1,6 +1,6 @@
-package jasdl.bridge.alias;
+package jasdl.bridge.mapping.aliasing;
-import jasdl.bridge.MappingManager;
+import jasdl.bridge.mapping.MappingManager;
import org.semanticweb.owl.model.OWLClass;
import org.semanticweb.owl.model.OWLDescription;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/MappingStrategy.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/alias/MappingStrategy.java 2008-04-01 23:35:02 UTC (rev 1189)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/aliasing/MappingStrategy.java 2008-04-02 17:26:44 UTC (rev 1194)
@@ -17,7 +17,7 @@
* along with JASDL. If not, see <http://www.gnu.org/licenses/>.
*
*/
-package jasdl.bridge.alias;
+package jasdl.bridge.mapping.aliasing;
public interface MappingStrategy {
public String apply(String input);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-02 17:09:56
|
Revision: 1193
http://jason.svn.sourceforge.net/jason/?rev=1193&view=rev
Author: tomklapiscak
Date: 2008-04-02 10:09:55 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Structural Improvements.
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
trunk/applications/jasdl-owlapi/src/jasdl/architecture/IncomingPropContProcessingStrategy.java
trunk/applications/jasdl-owlapi/src/jasdl/architecture/OutgoingPropContProcessingStrategy.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/parsing/NSPrefixEntityChecker.java
trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlIncisionFunction.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralDataPropertyAssertion.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralPropertyAssertion.java
trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
Added Paths:
-----------
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AliasFactory.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java
trunk/applications/jasdl-owlapi/src/jasdl/util/xsd/
trunk/applications/jasdl-owlapi/src/jasdl/util/xsd/XSDDataType.java
trunk/applications/jasdl-owlapi/src/jasdl/util/xsd/XSDDataTypeUtils.java
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/src/jasdl/bridge/alias/
trunk/applications/jasdl-owlapi/src/jasdl/bridge/label/
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralFactory.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/xsd/
trunk/applications/jasdl-owlapi/src/jasdl/test/blank.asl
trunk/applications/jasdl-owlapi/src/jasdl/util/xsd/XSDDataType.java
trunk/applications/jasdl-owlapi/src/jasdl/util/xsd/XSDDataTypeUtils.java
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-04-02 17:09:55 UTC (rev 1193)
@@ -40,12 +40,12 @@
* jasdl_reasonerClass = "uk.ac.manchester.cs.factplusplus.owlapi.Reasoner",
*/
- jasdl_default_mapping_strategies="jasdl.bridge.alias.DecapitaliseMappingStrategy", // applied to incoming ontologies and those given no automapping
+ jasdl_default_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy", // applied to incoming ontologies and those given no automapping
jasdl_ontologies="travel",
jasdl_travel_uri="http://www.dur.ac.uk/t.g.klapiscak/onts/travel.owl",
- /*jasdl_travel_mapping_strategies="jasdl.bridge.alias.DecapitaliseMappingStrategy",*/ // defaults can be overriden per-ontology here
+ /*jasdl_travel_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy",*/ // defaults can be overriden per-ontology here
jasdl_travel_mapping_manual="small_beach=beach", // these manual mappings will override any automatic mappings made by strategies,
// static trust ratings, mainly for testing purposes - likely to change
@@ -61,17 +61,17 @@
customer
customer.asl
[
- /* jasdl_default_mapping_strategies="jasdl.bridge.alias.DecapitaliseMappingStrategy", */ // defaults to this
+ /* jasdl_default_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy", */ // defaults to this
jasdl_useBeliefRevision = "true",
jasdl_ontologies="holidays,places",
jasdl_holidays_uri="http://www.dur.ac.uk/t.g.klapiscak/onts/travel.owl",
- jasdl_holidays_mapping_strategies="jasdl.bridge.alias.DecapitaliseMappingStrategy",
+ jasdl_holidays_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy",
jasdl_holidays_mapping_manual="small_beach=beach, luxuriousHotel=LuxuryHotel", // for demonstration of arbitrary primitive mappings being handled correctly
jasdl_places_uri="http://www.dur.ac.uk/t.g.klapiscak/onts/places.owl",
- jasdl_places_mapping_strategies="jasdl.bridge.alias.DecapitaliseMappingStrategy"
+ jasdl_places_mapping_strategies="jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy"
]
agentArchClass jasdl.architecture.JasdlAgArch
agentClass jasdl.asSemantics.JasdlAgent
Modified: trunk/applications/jasdl-owlapi/src/jasdl/architecture/IncomingPropContProcessingStrategy.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/architecture/IncomingPropContProcessingStrategy.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/architecture/IncomingPropContProcessingStrategy.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -23,8 +23,8 @@
import static jasdl.architecture.JasdlAgArch.NAMED_ANNOTATION_FUNCTOR;
import static jasdl.util.Common.strip;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.bridge.alias.Alias;
-import jasdl.bridge.alias.AliasFactory;
+import jasdl.bridge.factory.AliasFactory;
+import jasdl.bridge.mapping.aliasing.Alias;
import jasdl.bridge.seliteral.SELiteral;
import jasdl.util.DuplicateMappingException;
import jasdl.util.JasdlException;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/architecture/OutgoingPropContProcessingStrategy.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/architecture/OutgoingPropContProcessingStrategy.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/architecture/OutgoingPropContProcessingStrategy.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -59,7 +59,7 @@
Literal result = l;
try{
- SELiteral sl = agent.getSELiteralFactory().create(l);
+ SELiteral sl = agent.getSELiteralFactory().construct(l);
// qualify o
sl.qualifyOntologyAnnotation();
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -9,18 +9,18 @@
import jasdl.bb.revision.JasdlIncisionFunction;
import jasdl.bb.revision.JasdlReasonerFactory;
import jasdl.bb.revision.TBoxAxiomKernelsetFilter;
-import jasdl.bridge.AllDifferentPlaceholder;
-import jasdl.bridge.ToAxiomConverter;
-import jasdl.bridge.ToSELiteralConverter;
-import jasdl.bridge.alias.Alias;
-import jasdl.bridge.alias.AliasFactory;
-import jasdl.bridge.alias.AliasManager;
-import jasdl.bridge.alias.DefinitionManager;
-import jasdl.bridge.alias.MappingStrategy;
-import jasdl.bridge.label.LabelManager;
-import jasdl.bridge.label.OntologyURIManager;
+import jasdl.bridge.factory.AliasFactory;
+import jasdl.bridge.factory.AxiomToSELiteralConverter;
+import jasdl.bridge.factory.SELiteralFactory;
+import jasdl.bridge.factory.SELiteralToAxiomConverter;
+import jasdl.bridge.mapping.aliasing.Alias;
+import jasdl.bridge.mapping.aliasing.AliasManager;
+import jasdl.bridge.mapping.aliasing.AllDifferentPlaceholder;
+import jasdl.bridge.mapping.aliasing.DefinitionManager;
+import jasdl.bridge.mapping.aliasing.MappingStrategy;
+import jasdl.bridge.mapping.label.LabelManager;
+import jasdl.bridge.mapping.label.OntologyURIManager;
import jasdl.bridge.seliteral.SELiteral;
-import jasdl.bridge.seliteral.SELiteralFactory;
import jasdl.util.DuplicateMappingException;
import jasdl.util.InvalidSELiteralException;
import jasdl.util.JasdlException;
@@ -57,6 +57,7 @@
import org.semanticweb.owl.inference.OWLReasonerException;
import org.semanticweb.owl.model.OWLAxiom;
import org.semanticweb.owl.model.OWLClass;
+import org.semanticweb.owl.model.OWLDataFactory;
import org.semanticweb.owl.model.OWLDescription;
import org.semanticweb.owl.model.OWLEntity;
import org.semanticweb.owl.model.OWLEquivalentClassesAxiom;
@@ -77,8 +78,8 @@
private AliasManager aliasManager;
private LabelManager labelManager;
private SELiteralFactory seLiteralFactory;
- private ToSELiteralConverter toSELiteralConverter;
- private ToAxiomConverter toAxiomConverter;
+ private AxiomToSELiteralConverter axiomToSELiteralConverter;
+ private SELiteralToAxiomConverter SELiteralToAxiomConverter;
private OntologyURIManager logicalURIManager;
private OntologyURIManager physicalURIManager;
private ManchesterOWLSyntaxOWLObjectRendererImpl manchesterObjectRenderer;
@@ -111,8 +112,8 @@
definitionManager = new DefinitionManager();
seLiteralFactory = new SELiteralFactory(this);
- toAxiomConverter = new ToAxiomConverter(this);
- toSELiteralConverter = new ToSELiteralConverter(this);
+ SELiteralToAxiomConverter = new SELiteralToAxiomConverter(this);
+ axiomToSELiteralConverter = new AxiomToSELiteralConverter(this);
knownAgentNames = new Vector<String>();
trustMap = new HashMap<Atom, Float>();
@@ -134,35 +135,8 @@
}
- public void setReasoner(OWLReasoner reasoner){
- this.reasoner = reasoner;
- }
- public void addKnownAgentName(String name){
- knownAgentNames.add(name);
- }
- public List<String> getKnownAgentNames(){
- return knownAgentNames;
- }
-
-
- public void setReasonerLogLevel(org.apache.log4j.Level level){
- if(reasoner instanceof org.mindswap.pellet.owlapi.Reasoner){
- org.mindswap.pellet.owlapi.Reasoner pellet = (org.mindswap.pellet.owlapi.Reasoner)reasoner;
- Log4JLogger abox_logger = (Log4JLogger)pellet.getKB().getABox().log;
- abox_logger.getLogger().setLevel(level);
-
- Log4JLogger taxonomy_logger = (Log4JLogger)pellet.getKB().getTaxonomy().log;
- taxonomy_logger.getLogger().setLevel(level);
-
- Log4JLogger kb_logger = (Log4JLogger)pellet.getKB().log;
- kb_logger.getLogger().setLevel(level);
- }
- }
-
-
-
@Override
public TransitionSystem initAg(AgArch arch, BeliefBase bb, String src, Settings stts) throws JasonException {
if(!(bb instanceof JasdlBeliefBase)){
@@ -192,7 +166,7 @@
List<Literal> bels = new Vector<Literal>();
for(OWLOntology ontology : ontologyManager.getOntologies()){
for(OWLIndividualAxiom axiom : ontology.getIndividualAxioms()){
- Literal l = toSELiteralConverter.convert(axiom).getLiteral();
+ Literal l = axiomToSELiteralConverter.convert(axiom).getLiteral();
bels.add(l);
}
}
@@ -236,7 +210,7 @@
}else if(beliefToAdd != null){
try{
getLogger().fine("Revise: +"+beliefToAdd);
- SELiteral sl = getSELiteralFactory().create(beliefToAdd);
+ SELiteral sl = getSELiteralFactory().construct(beliefToAdd);
OWLAxiom axiomToAdd = sl.createAxiom();
BeliefBaseSemiRevisor bbrev = new BeliefBaseSemiRevisor(axiomToAdd, getOntologyManager(), new JasdlReasonerFactory(), getLogger());
List<OWLAxiom> contractList = bbrev.revise(new TBoxAxiomKernelsetFilter(), new JasdlIncisionFunction(this, sl));
@@ -244,7 +218,7 @@
// will only have reached here if new belief is accepted.
addList.add(beliefToAdd);
for(OWLAxiom contract : contractList){
- removeList.add(toSELiteralConverter.convert((OWLIndividualAxiom)contract).getLiteral());
+ removeList.add(axiomToSELiteralConverter.convert((OWLIndividualAxiom)contract).getLiteral());
}
revisionApplied = true;
}catch(RevisionFailedException e){
@@ -579,6 +553,21 @@
}
}
+
+ public void setReasonerLogLevel(org.apache.log4j.Level level){
+ if(reasoner instanceof org.mindswap.pellet.owlapi.Reasoner){
+ org.mindswap.pellet.owlapi.Reasoner pellet = (org.mindswap.pellet.owlapi.Reasoner)reasoner;
+ Log4JLogger abox_logger = (Log4JLogger)pellet.getKB().getABox().log;
+ abox_logger.getLogger().setLevel(level);
+
+ Log4JLogger taxonomy_logger = (Log4JLogger)pellet.getKB().getTaxonomy().log;
+ taxonomy_logger.getLogger().setLevel(level);
+
+ Log4JLogger kb_logger = (Log4JLogger)pellet.getKB().log;
+ kb_logger.getLogger().setLevel(level);
+ }
+ }
+
/**
* *Must* be unique within society!
* @return
@@ -586,20 +575,15 @@
public String getAgentName(){
return getTS().getUserAgArch().getAgName();
}
-
public List<MappingStrategy> getDefaultMappingStrategies() {
return defaultMappingStrategies;
}
-
-
public void setDefaultMappingStrategies(List<MappingStrategy> defaultMappingStrategies) {
this.defaultMappingStrategies = defaultMappingStrategies;
}
-
-
public Atom getPersonalOntologyLabel(){
return new Atom("self");
}
@@ -612,7 +596,6 @@
return URI.create("http://www.dur.ac.uk/t.g.klapiscak/self"+label+".owl");
}
-
public AliasManager getAliasManager() {
return aliasManager;
}
@@ -637,8 +620,6 @@
return definitionManager;
}
-
-
public OWLReasoner getReasoner() {
return reasoner;
}
@@ -647,12 +628,12 @@
return seLiteralFactory;
}
- public ToAxiomConverter getToAxiomConverter() {
- return toAxiomConverter;
+ public SELiteralToAxiomConverter getSELiteralToAxiomConverter() {
+ return SELiteralToAxiomConverter;
}
- public ToSELiteralConverter getToSELiteralConverter() {
- return toSELiteralConverter;
+ public AxiomToSELiteralConverter getAxiomToSELiteralConverter() {
+ return axiomToSELiteralConverter;
}
public ManchesterOWLSyntaxOWLObjectRendererImpl getManchesterObjectRenderer() {
@@ -666,7 +647,31 @@
public ManchesterOWLSyntaxDescriptionParser getManchesterURIDescriptionParser() {
return manchesterURIDescriptionParser;
}
+
+ public boolean isBeliefRevisionEnabled() {
+ return beliefRevisionEnabled;
+ }
+ public void setBeliefRevisionEnabled(boolean beliefRevisionEnabled) {
+ this.beliefRevisionEnabled = beliefRevisionEnabled;
+ }
+
+ public OWLDataFactory getOWLDataFactory(){
+ return getOntologyManager().getOWLDataFactory();
+ }
+
+ public void setReasoner(OWLReasoner reasoner){
+ this.reasoner = reasoner;
+ }
+
+ public void addKnownAgentName(String name){
+ knownAgentNames.add(name);
+ }
+
+ public List<String> getKnownAgentNames(){
+ return knownAgentNames;
+ }
+
public void setTrustRating(Atom name, float trust){
trustMap.remove(name);
trustMap.put(name, trust);
@@ -676,19 +681,7 @@
return trustMap.get(name);
}
-
-
-
-
- public boolean isBeliefRevisionEnabled() {
- return beliefRevisionEnabled;
- }
-
- public void setBeliefRevisionEnabled(boolean beliefRevisionEnabled) {
- this.beliefRevisionEnabled = beliefRevisionEnabled;
- }
-
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -2,10 +2,10 @@
import static jasdl.util.Common.DELIM;
import static jasdl.util.Common.strip;
-import jasdl.bridge.alias.Alias;
-import jasdl.bridge.alias.AliasFactory;
-import jasdl.bridge.alias.DecapitaliseMappingStrategy;
-import jasdl.bridge.alias.MappingStrategy;
+import jasdl.bridge.factory.AliasFactory;
+import jasdl.bridge.mapping.aliasing.Alias;
+import jasdl.bridge.mapping.aliasing.DecapitaliseMappingStrategy;
+import jasdl.bridge.mapping.aliasing.MappingStrategy;
import jasdl.util.JasdlConfigurationException;
import jasdl.util.JasdlException;
import jason.asSyntax.Atom;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/parsing/NSPrefixEntityChecker.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/parsing/NSPrefixEntityChecker.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/parsing/NSPrefixEntityChecker.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -1,7 +1,7 @@
package jasdl.asSemantics.parsing;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.bridge.alias.Alias;
-import jasdl.bridge.alias.AliasFactory;
+import jasdl.bridge.factory.AliasFactory;
+import jasdl.bridge.mapping.aliasing.Alias;
import jason.asSyntax.Atom;
import org.semanticweb.owl.expression.OWLEntityChecker;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -53,7 +53,7 @@
@Override
public void add(Plan p) throws JasonException {
try{
- agent.getSELiteralFactory().create(p.getTrigger().getLiteral());
+ agent.getSELiteralFactory().construct(p.getTrigger().getLiteral());
super.add(new SEPlan(agent, p));
}catch(NotEnrichedException e){
super.add(p);
@@ -142,7 +142,7 @@
*/
public static List<Trigger> getMoreGeneralTriggers(JasdlAgent agent, Trigger te) throws JasdlException{
Literal l = te.getLiteral();
- SELiteral sl = agent.getSELiteralFactory().create(l);
+ SELiteral sl = agent.getSELiteralFactory().construct(l);
if(l.negated()){
throw new JasdlException("JASDL cannot generalise strongly negated triggers");
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -41,7 +41,7 @@
getLogger().fine("Adding "+l);
try{
- SELiteral sl = agent.getSELiteralFactory().create(l);
+ SELiteral sl = agent.getSELiteralFactory().construct(l);
OWLIndividualAxiom axiom = sl.createAxiom();
OWLOntology ontology = sl.getOntology();
@@ -92,7 +92,7 @@
getLogger().fine("Contracting "+l);
try{
- SELiteral sl = agent.getSELiteralFactory().create(l);
+ SELiteral sl = agent.getSELiteralFactory().construct(l);
OWLOntology ontology = sl.getOntology();
OWLIndividualAxiom axiom = sl.createAxiom();
@@ -157,8 +157,8 @@
}catch(NotEnrichedException e){
return super.remove(l); // semantically-naive, use standard Jason mechanisms
}catch(Exception e){
- getLogger().warning("Exception caught removing SELiteral "+l+" from belief base: ");
- e.printStackTrace();
+ getLogger().fine("Exception caught removing SELiteral "+l+" from belief base: ");
+ //e.printStackTrace();
return false;
}
}
@@ -167,7 +167,7 @@
public Literal contains(Literal l) {
agent.getLogger().fine("Contains: "+l);
try {
- SELiteral sl = agent.getSELiteralFactory().create(l);
+ SELiteral sl = agent.getSELiteralFactory().construct(l);
OWLIndividualAxiom axiom = sl.createAxiom();
if(sl.getOntology().containsAxiom(axiom)){
Iterator<Literal> it = getCandidateBeliefs(l, null);
@@ -184,6 +184,7 @@
}
}
+
@Override
@@ -195,10 +196,10 @@
Set<Literal> relevant = new HashSet<Literal>();
try{
- SELiteral sl = agent.getSELiteralFactory().create(l);
- Set<OWLIndividualAxiom> axioms = sl.getAxioms();
+ SELiteral sl = agent.getSELiteralFactory().construct(l);
+ Set<OWLIndividualAxiom> axioms = sl.getAxioms(); // <- really just a wrapper for this method
for(OWLIndividualAxiom axiom : axioms){
- SELiteral found = agent.getToSELiteralConverter().convert(axiom);
+ SELiteral found = agent.getAxiomToSELiteralConverter().convert(axiom);
// hack, gets around non-consistent ordering of OWLDifferentIndividualAxiom individuals
// -- just check list membership is equivalent (i.e. treat as sets)
@@ -211,10 +212,8 @@
}
}
- relevant.add(found.getLiteral());
+ relevant.add(found.getLiteral());
-
-
}
getLogger().fine("... found: "+relevant);
if(relevant.isEmpty()){
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlIncisionFunction.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlIncisionFunction.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlIncisionFunction.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -73,7 +73,7 @@
if(axiom.equals(toAddLiteral.createAxiom())){ // hack to get the annotations of the NOT YET ADDED toAdd axiom
sources = toAddLiteral.getLiteral().getSources();
}else{
- SELiteral sl = agent.getToSELiteralConverter().convert((OWLIndividualAxiom)axiom); // kernel filter ensures axiom is an OWLIndividualAxiom
+ SELiteral sl = agent.getAxiomToSELiteralConverter().convert((OWLIndividualAxiom)axiom); // kernel filter ensures axiom is an OWLIndividualAxiom
sources = sl.getLiteral().getSources();
}
agent.getLogger().finest("Sources of "+axiom+"="+sources);
Copied: trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AliasFactory.java (from rev 1190, trunk/applications/jasdl-owlapi/src/jasdl/bridge/alias/AliasFactory.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AliasFactory.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AliasFactory.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -0,0 +1,64 @@
+package jasdl.bridge.factory;
+
+import jasdl.bridge.mapping.aliasing.Alias;
+import jasdl.bridge.seliteral.SELiteral;
+import jasdl.util.JasdlException;
+import jason.asSyntax.Atom;
+
+/**
+ * A convenient singleton factory providing methods to create JASDL alias objects.
+ *
+ * @author Tom Klapiscak
+ *
+ */
+public class AliasFactory {
+ public static Atom OWL_NAMESPACE_LABEL = new Atom("owl");
+
+ /**
+ * A singleton alias mapped to the universal owl:thing concept
+ */
+ public static Alias OWL_THING = new Alias(new Atom("thing"), OWL_NAMESPACE_LABEL);
+
+ /**
+ * A singleton alias mapped to the universal owl:nothing concept
+ */
+ public static Alias OWL_NOTHING = new Alias(new Atom("nothing"), OWL_NAMESPACE_LABEL);
+
+
+ public static Atom OWL_NOTHING_FUNCTOR = new Atom("nothing");
+ public static Atom OWL_ALL_DIFFERENT_FUNCTOR = new Atom("all_different");
+
+
+ /**
+ * Singleton instance we should use.
+ */
+ public static AliasFactory INSTANCE = new AliasFactory();
+
+ private AliasFactory(){
+ }
+
+ /**
+ * Create an alias to represent an SELiteral. Literal functor becomes alias functor.
+ * Literal ontology label becomes alias label;
+ * If l is negated (and a unary class assertion) then functor is prefixed with "~".
+ * @param sl the SELiteral the alias will represent
+ * @return an alias representing the supplied SELiteral
+ */
+ public Alias create(SELiteral sl) throws JasdlException{
+ return new Alias( (sl.getLiteral().negated()?"~":"") + sl.getLiteral().getFunctor(), sl.getOntologyLabel());
+ }
+
+ /**
+ * Create an alias from an atomic functor and label
+ * @param functor
+ * @param label
+ * @return
+ */
+ public Alias create(Atom functor, Atom label){
+ return new Alias(functor, label);
+ }
+
+ public Alias all_different(Atom label){
+ return new Alias(OWL_ALL_DIFFERENT_FUNCTOR, label);
+ }
+}
Added: trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/AxiomToSELiteralConverter.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -0,0 +1,193 @@
+package jasdl.bridge.factory;
+
+import jasdl.asSemantics.JasdlAgent;
+import jasdl.bridge.mapping.aliasing.Alias;
+import jasdl.bridge.mapping.aliasing.AllDifferentPlaceholder;
+import jasdl.bridge.seliteral.SELiteral;
+import jasdl.util.InvalidSELiteralException;
+import jasdl.util.JasdlException;
+import jasdl.util.UnknownMappingException;
+import jasdl.util.xsd.XSDDataType;
+import jasdl.util.xsd.XSDDataTypeUtils;
+import jason.asSyntax.Atom;
+import jason.asSyntax.DefaultTerm;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Term;
+
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
+import org.semanticweb.owl.model.OWLAxiom;
+import org.semanticweb.owl.model.OWLAxiomAnnotationAxiom;
+import org.semanticweb.owl.model.OWLClassAssertionAxiom;
+import org.semanticweb.owl.model.OWLConstant;
+import org.semanticweb.owl.model.OWLDataPropertyAssertionAxiom;
+import org.semanticweb.owl.model.OWLDifferentIndividualsAxiom;
+import org.semanticweb.owl.model.OWLIndividual;
+import org.semanticweb.owl.model.OWLIndividualAxiom;
+import org.semanticweb.owl.model.OWLObjectPropertyAssertionAxiom;
+import org.semanticweb.owl.model.OWLOntology;
+import org.semanticweb.owl.model.OWLTypedConstant;
+
+
+/**
+ * Accepts an arbitrary OWLIndividualAxiom and, depending on its type, creates a SE-Literal encoding of it.
+ * Will always result in a ground SELiteral (since OWLIndividualAxioms must always be ground)<p>
+ * For example:
+ * <ul>
+ * <li>ClassAssertion(Hotel hilton) -> hotel(hilton)[o(travel)]</li>
+ * <li>ObjectPropertyAssertion(hasRating hilton ThreeStarRating) -> hasRating(hilton,threeStarRating)[o(travel)]</li>
+ * <li>DifferentIndividuals( fourSeasons hilton ) -> all_different([hilton,fourSeasons])[o(travel)]</li>
+ * </ul>
+ * @author Tom Klapiscak
+ *
+ */
+public class AxiomToSELiteralConverter {
+
+ /**
+ * The agent this converter is working on behalf of. Required for access to managers.
+ */
+ private JasdlAgent agent;
+
+ public AxiomToSELiteralConverter(JasdlAgent agent){
+ this.agent = agent;
+ }
+
+ /**
+ * Fetches and deseralises and returns all ASSERTED annotations of the supplied axiom.
+ * TODO: Shift to a factory?
+ * @param sl
+ */
+ public static List<Term> getAssertedAnnotations(OWLAxiom axiom, OWLOntology ontology){
+ List<Term> result = new Vector<Term>();
+ // get annotations
+ Set<OWLAxiomAnnotationAxiom> annotAxioms = axiom.getAnnotationAxioms(ontology);
+ for(OWLAxiomAnnotationAxiom annotAxiom : annotAxioms){ // remember, possibly semantically-naive payload!
+ Term annot = Literal.parse(annotAxiom.getAnnotation().getAnnotationValueAsConstant().getLiteral());
+ result.add(annot);
+ }
+ return result;
+ }
+
+
+ /**
+ * Polymorphically applies appropriate factory method depending on specialisation of axiom
+ * @param axiom
+ * @return
+ * @throws JasdlException if specialisation of axiom is not of an appropriate type for conversion to a SELiteral
+ */
+ public SELiteral convert(OWLIndividualAxiom axiom) throws JasdlException{
+ if(axiom instanceof OWLClassAssertionAxiom){
+ return convert((OWLClassAssertionAxiom)axiom);
+ }else if(axiom instanceof OWLObjectPropertyAssertionAxiom){
+ return convert((OWLObjectPropertyAssertionAxiom)axiom);
+ }else if(axiom instanceof OWLDataPropertyAssertionAxiom){
+ return convert((OWLDataPropertyAssertionAxiom)axiom);
+ }else if(axiom instanceof OWLDifferentIndividualsAxiom){
+ return convert((OWLDifferentIndividualsAxiom) axiom);
+ }else{
+ throw new JasdlException(axiom+" is not of an appropriate type for conversion to a SELiteral");
+ }
+ }
+
+
+ /**
+ * Convert an axiom asserting class membership to a unary SELiteral
+ * @param axiom the axiom to convert
+ * @return a unary SELiteral encoding of axiom
+ * @throws JasdlException
+ */
+ public SELiteral convert(OWLClassAssertionAxiom axiom) throws JasdlException{
+ Alias alias = agent.getAliasManager().getLeft(axiom.getDescription());
+ Atom individual = agent.getAliasManager().getLeft(axiom.getIndividual()).getFunctor(); // TODO: what if individual is previously undefined? possible?
+ return agent.getSELiteralFactory().construct(alias, individual, getAnnots(alias, axiom));
+ }
+
+ /**
+ * Convert an axiom asserting that two individuals are related by an object property to a binary SELiteral
+ * @param axiom the axiom to convert
+ * @return an binary SELiteral encoding of axiom
+ * @throws JasdlException
+ */
+ public SELiteral convert(OWLObjectPropertyAssertionAxiom axiom) throws JasdlException{
+ Alias alias = agent.getAliasManager().getLeft(axiom.getProperty().asOWLObjectProperty());
+ Atom subject = agent.getAliasManager().getLeft(axiom.getSubject()).getFunctor();
+ Atom object = agent.getAliasManager().getLeft(axiom.getObject()).getFunctor();
+ return agent.getSELiteralFactory().construct(alias, subject, object, getAnnots(alias, axiom));
+ }
+
+ /**
+ * Convert an axiom asserting that two individuals are related by a data property to a binary SELiteral
+ * @param axiom the axiom to convert
+ * @return a binary SELiteral encoding of axiom
+ * @throws JasdlException
+ */
+ public SELiteral convert(OWLDataPropertyAssertionAxiom axiom) throws JasdlException{
+ Alias alias = agent.getAliasManager().getLeft(axiom.getProperty().asOWLDataProperty());
+ Atom subject = agent.getAliasManager().getLeft(axiom.getSubject()).getFunctor();
+ Term object;
+ OWLConstant constant = axiom.getObject();
+ if(constant.isTyped()){
+ OWLTypedConstant ot = constant.asOWLTypedConstant();
+ XSDDataType xsd = XSDDataTypeUtils.get(ot.getDataType().toString());
+ // surround with quotes if necessary for representation in AgentSpeak syntax
+ if(XSDDataTypeUtils.isStringType(xsd)){
+ object = DefaultTerm.parse("\""+constant.getLiteral().toString()+"\"");
+ }else if(XSDDataTypeUtils.isBooleanType(xsd)){
+ if(Boolean.parseBoolean(ot.getLiteral().toString())){
+ object = Literal.LTrue;
+ }else{
+ object = Literal.LFalse;
+ }
+ }else{
+ object = DefaultTerm.parse(constant.getLiteral().toString());
+ }
+ }else{
+ throw new JasdlException("JASDL does not support untyped data ranges such as: "+axiom);
+ }
+ return agent.getSELiteralFactory().construct(alias, subject, object, getAnnots(alias, axiom));
+ }
+
+ /**
+ * Convert an axiom asserting that a set of individuals are distinct to a unary SELiteral (whose term is a list and functor is "all_different")
+ * @param axiom the axiom to convert
+ * @return a unary SELiteral (whose term is a list and functor is "all_different") encoding of axiom
+ * @throws JasdlException
+ */
+ public SELiteral convert(OWLDifferentIndividualsAxiom axiom) throws JasdlException{
+ Set<OWLIndividual> _is = axiom.getIndividuals();
+ if(_is.size() == 0){
+ throw new InvalidSELiteralException("All different assertion must contain some individuals! "+axiom);
+ }
+ Atom[] is = new Atom[_is.size()];
+ Atom label = null;
+ int j = 0;
+ for(OWLIndividual i : _is){
+ Alias iAlias = agent.getAliasManager().getLeft(i);
+ if(label == null){
+ // hack, get a reference back to ontology by examining one of the individuals
+ label = iAlias.getLabel();
+ }
+ is[j] = iAlias.getFunctor();
+ j++;
+ }
+ Alias alias = agent.getAliasManager().getLeft(new AllDifferentPlaceholder(label));
+ return agent.getSELiteralFactory().construct(alias, is, getAnnots(alias, axiom));
+ }
+
+ /**
+ * Utility method to get the annotations of an axiom as an array of terms within the ontology referenced by alias
+ * @param alias
+ * @param axiom
+ * @return
+ * @throws UnknownMappingException
+ */
+ private Term[] getAnnots(Alias alias, OWLAxiom axiom) throws UnknownMappingException{
+ OWLOntology ontology = agent.getLabelManager().getRight(alias.getLabel());
+ List<Term> collection = getAssertedAnnotations(axiom, ontology);
+ return (Term[])collection.toArray(new Term[collection.size()]);
+ }
+
+
+}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java (from rev 1190, trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralFactory.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralFactory.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -0,0 +1,147 @@
+package jasdl.bridge.factory;
+
+import static jasdl.util.Common.DOMAIN;
+
+import java.util.Arrays;
+
+import jasdl.asSemantics.JasdlAgent;
+import jasdl.bridge.mapping.aliasing.Alias;
+import jasdl.bridge.mapping.aliasing.AllDifferentPlaceholder;
+import jasdl.bridge.seliteral.SELiteral;
+import jasdl.util.InvalidSELiteralException;
+import jasdl.util.JasdlException;
+import jason.asSyntax.Atom;
+import jason.asSyntax.DefaultTerm;
+import jason.asSyntax.ListTerm;
+import jason.asSyntax.ListTermImpl;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Structure;
+import jason.asSyntax.Term;
+
+import org.semanticweb.owl.model.OWLDataProperty;
+import org.semanticweb.owl.model.OWLDescription;
+import org.semanticweb.owl.model.OWLObject;
+import org.semanticweb.owl.model.OWLObjectProperty;
+
+public class SELiteralFactory {
+
+ private JasdlAgent agent;
+
+ public SELiteralFactory(JasdlAgent agent){
+ this.agent = agent;
+ }
+
+ /**
+ * Polymorphically creates a specific type of SELiteral based on the properties of the supplied literal
+ * @param l
+ * @return
+ * @throws JasdlException
+ */
+ public SELiteral construct(Literal l) throws JasdlException{
+ SELiteral sl = new SELiteral(l, agent); // so we can use convenience methods on a processed seliteral
+ OWLObject entity = sl.toOWLObject();
+ if(sl.getLiteral().getArity() == 1){
+ if(entity instanceof OWLDescription){
+ return sl.asClassAssertion();
+ }else if(entity instanceof AllDifferentPlaceholder){
+ //if(!l.isGround()) throw new JasdlException("JASDL does not currently support unground all_different assertions such as "+l);
+ // TODO: can ensure this here (due to unground TG all_different literals), where should I? axiom converter?
+ if(l.negated()) throw new JasdlException("JASDL does not currently support negated all_different assertions such as "+l+", since OWL makes the UNA by default and JASDL doesn't allow this to be overridden");
+ return sl.asAllDifferentAssertion();
+ }else{
+ throw new InvalidSELiteralException(sl+" does not refer to a known class or an all_different assertion");
+ }
+ }else if(sl.getLiteral().getArity() == 2){
+ if(sl.getLiteral().negated()) throw new JasdlException("JASDL does not currently support negated property assertions such as "+sl);
+ if(!sl.getLiteral().getTerm(DOMAIN).isGround()) throw new JasdlException("JASDL cannot handle left-unground property assertions such as "+sl);
+ if(entity instanceof OWLObjectProperty){
+ return sl.asObjectPropertyAssertion();
+ }else if(entity instanceof OWLDataProperty){
+ return sl.asDataPropertyAssertion();
+ }else{
+ throw new InvalidSELiteralException(sl+" does not refer to a known object or data property");
+ }
+ }else{
+ throw new InvalidSELiteralException(sl+" must be either unary or binary");
+ }
+ }
+
+
+
+
+ public SELiteral construct(boolean sign, Atom functor, Term[] terms, Term[] annots, Atom label) throws JasdlException{
+ Literal l = new Literal(sign, functor);
+
+ // add "o"
+ Structure o = new Structure(SELiteral.ONTOLOGY_ANNOTATION_FUNCTOR);
+ o.addTerm(label);
+ l.addAnnot(o);
+
+ l.addTerms(Arrays.asList(terms));
+ if(annots!=null){
+ l.addAnnots(Arrays.asList(annots));
+ }
+ if(l.negated()){
+ if(
+ (l.getFunctor().equals("thing") || l.getFunctor().equals("nothing")) || // special case: reject ~thing and ~nothing
+ (l.getArity() == 2) || //special case: reject negated property assertions
+ (l.getFunctor().equals(AliasFactory.OWL_ALL_DIFFERENT_FUNCTOR.getFunctor())) // special case: reject ~all_different assertions
+ ){
+ throw new InvalidSELiteralException(l+" is invalid");
+ }
+ }
+ return construct(l);
+ }
+
+ public SELiteral construct(boolean sign, Atom functor, Atom individual, Term[] annots, Atom label) throws JasdlException{
+ return construct(sign, functor, new Term[] {individual}, annots, label);
+ }
+
+ public SELiteral construct(boolean sign, Atom functor, Atom subject, Term object, Term[] annots, Atom label) throws JasdlException{
+ return construct(sign, functor, new Term[] {subject, object}, annots, label);
+ }
+
+ public SELiteral construct(boolean sign, Atom[] _is, Term[] annots, Atom label) throws JasdlException{
+ ListTerm is = new ListTermImpl();// TODO: override this object's unify method to perform set, not list, unification + equality?
+ for(Atom i : _is){
+ is.add(i);
+ }
+ return construct(sign, AliasFactory.OWL_ALL_DIFFERENT_FUNCTOR, new Term[] {is}, annots, label);
+ }
+
+
+ /**
+ * Common SELiteral construction code: sets functor, negation (based on presence of "~" prefix) and ontology annotation.
+ * Results in a SELiteral with no arguments.
+ * @param alias the alias from which to construct this SELiteral
+ * @return an SELiteral corresponding to alias with no arguments
+ */
+ public SELiteral construct(Alias alias, Term[] terms, Term[] annots) throws JasdlException{
+ // construct a new literal (with no terms) based on alias
+ boolean sign = true;
+ String functor = alias.getFunctor().toString();
+ //~ might be present
+ if(functor.startsWith("~")){
+ functor = functor.substring(1);
+ sign = false;
+ }
+ return construct(sign, new Atom(functor), terms, annots, alias.getLabel());
+ }
+
+
+ public SELiteral construct(Alias alias, Atom individual, Term[] annots) throws JasdlException{
+ return construct(alias, new Term[] {individual}, annots);
+ }
+
+ public SELiteral construct(Alias alias, Atom subject, Term object, Term[] annots) throws JasdlException{
+ return construct(alias, new Term[] {subject, object}, annots);
+ }
+
+ public SELiteral construct(Alias alias, Atom[] _is, Term[] annots) throws JasdlException{
+ ListTerm is = new ListTermImpl();// TODO: override this object's unify method to perform set, not list, unification + equality?
+ for(Atom i : _is){
+ is.add(i);
+ }
+ return construct(alias, new Term[] {is}, annots);
+ }
+}
Added: trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/factory/SELiteralToAxiomConverter.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -0,0 +1,268 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.bridge.factory;
+
+import static jasdl.util.Common.RANGE;
+import jasdl.asSemantics.JasdlAgent;
+import jasdl.bb.revision.IndividualAxiomToDescriptionConverter;
+import jasdl.bridge.seliteral.SELiteral;
+import jasdl.bridge.seliteral.SELiteralAllDifferentAssertion;
+import jasdl.bridge.seliteral.SELiteralClassAssertion;
+import jasdl.bridge.seliteral.SELiteralDataPropertyAssertion;
+import jasdl.bridge.seliteral.SELiteralObjectPropertyAssertion;
+import jasdl.util.InvalidSELiteralException;
+import jasdl.util.JasdlException;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.semanticweb.owl.inference.OWLReasonerException;
+import org.semanticweb.owl.model.OWLConstant;
+import org.semanticweb.owl.model.OWLDataProperty;
+import org.semanticweb.owl.model.OWLDescription;
+import org.semanticweb.owl.model.OWLDifferentIndividualsAxiom;
+import org.semanticweb.owl.model.OWLIndividual;
+import org.semanticweb.owl.model.OWLIndividualAxiom;
+import org.semanticweb.owl.model.OWLObjectProperty;
+import org.semanticweb.owl.model.OWLTypedConstant;
+
+
+/**
+ * Accepts an arbitrary SEliteral and, depending on its type, creates an OWLIndividualAxiom encoding of it.
+ * This factory can be used in one of two ways: for <i>creation</i> or for <i>retrieval</i>.<p>
+ *
+ * Creation will always return a encoding regardless of whether the axiom is entailed by the ontology.
+ * In this case, the SELiteral must be ground and only a <b>single</b> SELiteral can be returned.<p>
+ *
+ * Retrieval, on the other hand, will result in an empty list if the axiom is not entailed by the ontology, otherwise
+ * a list containing SELiteral encodings of <b>all</b> entailments is returned. The retrieval operation can deal
+ * with unground SELiterals, in which case unground terms will be treated as "wildcards" that match any (suitable) resource.<p>
+ *
+ * Creation example:
+ * <ul>
+ * <li>hotel(hilton)[o(travel)] -> ClassAssertion(Hotel hilton)</li>
+ * <li>hasRating(hilton,threeStarRating)[o(travel)] -> ObjectPropertyAssertion(hasRating hilton ThreeStarRating)</li>
+ * <li>all_different([hilton,fourSeasons])[o(travel)] -> DifferentIndividuals( fourSeasons hilton )</li>
+ * </ul><p>
+ *
+ * Retrieval example:
+ * <ul>
+ * <li>hotel(hilton)[o(travel)] -> [ClassAssertion(Hotel hilton)]</li>
+ * <li>hasRating(hilton,X)[o(travel)] -> [ObjectPropertyAssertion(hasRating hilton OneStarRating), ObjectPropertyAssertion(hasRating hilton TwoStarRating), ObjectPropertyAssertion(hasRating hilton ThreeStarRating)]</li>
+ * <li>hotel(threeStarRating)[o(travel)] -> []</li>
+ * <li>~hotel(threeStarRating)[o(travel)] -> [ObjectComplementOf(ClassAssertion(Hotel threeStarRating))]</li>
+ * </ul>
+ * @author Tom Klapiscak
+ *
+ */
+public class SELiteralToAxiomConverter {
+
+ private JasdlAgent agent;
+
+ public SELiteralToAxiomConverter(JasdlAgent agent){
+ this.agent = agent;
+ }
+
+
+ public Set<OWLIndividualAxiom> retrieve(SELiteral sl) throws JasdlException{
+ return convert(sl, true);
+ }
+
+ /**
+ * <b>Create</b> an axiomatic encoding of sl. Specific type of axiom dependent on specific type of sl.
+ * sl must be <b>ground</b>
+ * @param sl the SE-Literal to encode
+ * @return a single encoding of sl - regardless of whether it is entailed or not
+ * @throws JasdlException
+ */
+ public OWLIndividualAxiom create(SELiteral sl) throws JasdlException{
+ if(!sl.getLiteral().isGround()){
+ throw new JasdlException("Cannot create an axiom from unground SELiteral "+sl);
+ }
+ Set<OWLIndividualAxiom> axioms = convert(sl, false);
+ if(axioms.isEmpty()){
+ throw new JasdlException("Error creating axiom from "+sl);
+ }
+ return (OWLIndividualAxiom)axioms.toArray()[0];
+ }
+
+ /**
+ * Polymorphically apply a factory method dependent on the specific type of sl
+ * @param sl the SE-Literal to encode
+ * @param checkForExistence if true, results will only be returned in they are entailed - if false, a successful encoding will guarantee a result
+ * @return a set of entailments matching sl
+ * @throws JasdlException
+ */
+ private Set<OWLIndividualAxiom> convert(SELiteral sl, boolean checkForExistence) throws JasdlException{
+ if(sl instanceof SELiteralClassAssertion){
+ return convert((SELiteralClassAssertion)sl, checkForExistence);
+ }else if(sl instanceof SELiteralObjectPropertyAssertion){
+ return create((SELiteralObjectPropertyAssertion)sl, checkForExistence);
+ }else if(sl instanceof SELiteralDataPropertyAssertion){
+ return create((SELiteralDataPropertyAssertion)sl, checkForExistence);
+ }else if(sl instanceof SELiteralAllDifferentAssertion){
+ return create((SELiteralAllDifferentAssertion)sl, checkForExistence);
+ }else{
+ throw new InvalidSELiteralException("JASDL does not know how to handle SELiterals like "+sl);
+ }
+ }
+
+ /**
+ * Convert a unary SELiteral (asserting a class membership of an individual) to its axiomatic encoding
+ * @param sl the SELiteral to convert
+ * @param checkForExistence if true, results will only be returned in they are entailed - if false, a successful encoding will guarantee a result
+ * @return an axiomatic encoding of sl
+ * @throws JasdlException
+ */
+ private Set<OWLIndividualAxiom> convert(SELiteralClassAssertion sl, boolean checkForExistence) throws JasdlException{
+ try {
+ Set<OWLIndividual> is = new HashSet<OWLIndividual>();
+ OWLDescription desc = sl.getOWLDescription();
+
+ if(sl.getLiteral().isGround()){
+ OWLIndividual i = sl.getOWLIndividual();
+ if(!checkForExistence || agent.getReasoner().hasType(i, desc, false)){
+ is.add(i);
+ }
+ }else{
+ is.addAll(agent.getReasoner().getIndividuals(desc, false));
+ }
+ Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
+ for(OWLIndividual i : is){
+ axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLClassAssertionAxiom(i, desc));
+ }
+ return axioms;
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
+ }
+ }
+
+ /**
+ * Convert a unary all_different SELiteral (asserting distinctness of a set of individuals) to its axiomatic encoding
+ * @param sl the SELiteral to convert
+ * @param checkForExistence if true, results will only be returned in they are entailed - if false, a successful encoding will guarantee a result
+ * @return an axiomatic encoding of sl
+ * @throws JasdlException
+ */
+ public Set<OWLIndividualAxiom> create(SELiteralAllDifferentAssertion sl, boolean checkForExistence) throws JasdlException{
+ try {
+ Set<OWLIndividual> _is = sl.getOWLIndividuals();
+ Object[] is = _is.toArray();
+ if(is.length == 0){
+ throw new JasdlException("All different assertion must contain some individuals! "+sl);
+ }
+ // check they are mutually distinct (if we are checking for existence)
+ boolean distinct = true;
+ if(checkForExistence){
+ for(int i=0; i<is.length; i++){
+ for(int j=i+1; j<is.length; j++){
+ // create a description that is satisfiable iff the two individuals are different. TODO: request in-built OWL-API support for this
+ OWLDifferentIndividualsAxiom axiom = agent.getOntologyManager().getOWLDataFactory().getOWLDifferentIndividualsAxiom(_is);
+ IndividualAxiomToDescriptionConverter conv = new IndividualAxiomToDescriptionConverter(agent.getOntologyManager().getOWLDataFactory());
+ axiom.accept(conv);
+ if(!agent.getReasoner().isSatisfiable(conv.getDescription())){//.isDifferentFrom((OWLIndividual)is[i], (OWLIndividual)is[j])){
+ distinct = false;
+ break;
+ }
+ }
+ if(!distinct) break;
+ }
+ }
+ Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
+ Set<OWLIndividual> different = new HashSet<OWLIndividual>();
+ if(!checkForExistence || distinct){
+ for(int i=0; i<is.length; i++){
+ different.add((OWLIndividual)is[i]);
+ }
+ OWLDifferentIndividualsAxiom axiom = agent.getOntologyManager().getOWLDataFactory().getOWLDifferentIndividualsAxiom(different);
+ axioms.add(axiom);
+ }
+ return axioms;
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
+ }
+ }
+
+ /**
+ * Convert a binary SELiteral (asserting that two individuals are related by an object property) to its axiomatic encoding
+ * @param sl the SELiteral to convert
+ * @param checkForExistence if true, results will only be returned in they are entailed - if false, a successful encoding will guarantee a result
+ * @return an axiomatic encoding of sl
+ * @throws JasdlException
+ */
+ public Set<OWLIndividualAxiom> create(SELiteralObjectPropertyAssertion sl, boolean checkForExistence) throws JasdlException{
+ try {
+ Set<OWLIndividual> os = new HashSet<OWLIndividual>();
+ OWLIndividual s = sl.getSubject();
+ OWLObjectProperty p = sl.getPredicate();
+ if(sl.getLiteral().getTerm(RANGE).isGround()){
+ OWLIndividual o = sl.getObject();
+ if(!checkForExistence || agent.getReasoner().hasObjectPropertyRelationship(s, p, o)){
+ os.add(o);
+ }
+ }else{
+ os.addAll(agent.getReasoner().getRelatedIndividuals(s, p));
+ }
+ Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
+ for(OWLIndividual o : os){
+ axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLObjectPropertyAssertionAxiom(s, p, o));
+ }
+ return axioms;
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
+ }
+ }
+
+ /**
+ * Convert a binary SELiteral (asserting that an individual is related to a datatype literal) to its axiomatic encoding
+ * @param sl the SELiteral to convert
+ * @param checkForExistence if true, results will only be returned in they are entailed - if false, a successful encoding will guarantee a result
+ * @return an axiomatic encoding of sl
+ * @throws JasdlException
+ */
+ public Set<OWLIndividualAxiom> create(SELiteralDataPropertyAssertion sl, boolean checkForExistence) throws JasdlException{
+ try {
+ Set<OWLConstant> os = new HashSet<OWLConstant>();
+ OWLIndividual s = sl.getSubject();
+ OWLDataProperty p = sl.getPredicate();
+ if(sl.getLiteral().getTerm(RANGE).isGround()){
+ OWLTypedConstant o = sl.getObject();
+ if(!checkForExistence || agent.getReasoner().hasDataPropertyRelationship(s, p, o)){
+ os.add(o);
+ }
+ }else{
+ os.addAll(agent.getReasoner().getRelatedValues(s, p));
+ }
+ Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
+ for(OWLConstant o : os){
+ axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLDataPropertyAssertionAxiom(s, p, o));
+ }
+ return axioms;
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
+ }
+ }
+
+
+
+
+
+
+}
\ No newline at end of file
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -1,8 +1,8 @@
package jasdl.bridge.seliteral;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.bridge.alias.Alias;
-import jasdl.bridge.alias.AliasFactory;
+import jasdl.bridge.factory.AliasFactory;
+import jasdl.bridge.mapping.aliasing.Alias;
import jasdl.util.InvalidSELiteralException;
import jasdl.util.JasdlException;
import jasdl.util.NotEnrichedException;
@@ -149,7 +149,7 @@
*/
public OWLIndividualAxiom createAxiom() throws JasdlException{
if(axiom == null || !USE_CACHING){
- axiom = agent.getToAxiomConverter().create(this);
+ axiom = agent.getSELiteralToAxiomConverter().create(this);
}
return axiom;
}
@@ -159,7 +159,7 @@
*/
public Set<OWLIndividualAxiom> getAxioms() throws JasdlException{
if(axioms == null || !USE_CACHING){
- axioms = agent.getToAxiomConverter().retrieve(this);
+ axioms = agent.getSELiteralToAxiomConverter().retrieve(this);
}
return axioms;
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralDataPropertyAssertion.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralDataPropertyAssertion.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralDataPropertyAssertion.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -4,10 +4,10 @@
import static jasdl.util.Common.strip;
import static jasdl.util.Common.surroundedBy;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.bridge.xsd.XSDDataType;
-import jasdl.bridge.xsd.XSDDataTypeUtils;
import jasdl.util.InvalidSELiteralException;
import jasdl.util.JasdlException;
+import jasdl.util.xsd.XSDDataType;
+import jasdl.util.xsd.XSDDataTypeUtils;
import jason.asSyntax.Literal;
import jason.asSyntax.Term;
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralFactory.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralFactory.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralFactory.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -1,57 +0,0 @@
-package jasdl.bridge.seliteral;
-
-import static jasdl.util.Common.DOMAIN;
-import jasdl.asSemantics.JasdlAgent;
-import jasdl.bridge.AllDifferentPlaceholder;
-import jasdl.util.InvalidSELiteralException;
-import jasdl.util.JasdlException;
-import jason.asSyntax.Literal;
-
-import org.semanticweb.owl.model.OWLDataProperty;
-import org.semanticweb.owl.model.OWLDescription;
-import org.semanticweb.owl.model.OWLObject;
-import org.semanticweb.owl.model.OWLObjectProperty;
-
-public class SELiteralFactory {
-
- private JasdlAgent agent;
-
- public SELiteralFactory(JasdlAgent agent){
- this.agent = agent;
- }
-
- /**
- * Polymorphically creates a specific type of SELiteral based on the properties of the supplied literal
- * @param l
- * @return
- * @throws JasdlException
- */
- public SELiteral create(Literal l) throws JasdlException{
- SELiteral sl = new SELiteral(l, agent); // so we can use convenience methods on a processed seliteral
- OWLObject entity = sl.toOWLObject();
- if(sl.getLiteral().getArity() == 1){
- if(entity instanceof OWLDescription){
- return sl.asClassAssertion();
- }else if(entity instanceof AllDifferentPlaceholder){
- //if(!l.isGround()) throw new JasdlException("JASDL does not currently support unground all_different assertions such as "+l);
- // TODO: can ensure this here (due to unground TG all_different literals), where should I? axiom converter?
- if(l.negated()) throw new JasdlException("JASDL does not currently support negated all_different assertions such as "+l+", since OWL makes the UNA by default and JASDL doesn't allow this to be overridden");
- return sl.asAllDifferentAssertion();
- }else{
- throw new InvalidSELiteralException(sl+" does not refer to a known class or an all_different assertion");
- }
- }else if(sl.getLiteral().getArity() == 2){
- if(sl.getLiteral().negated()) throw new JasdlException("JASDL does not currently support negated property assertions such as "+sl);
- if(!sl.getLiteral().getTerm(DOMAIN).isGround()) throw new JasdlException("JASDL cannot handle left-unground property assertions such as "+sl);
- if(entity instanceof OWLObjectProperty){
- return sl.asObjectPropertyAssertion();
- }else if(entity instanceof OWLDataProperty){
- return sl.asDataPropertyAssertion();
- }else{
- throw new InvalidSELiteralException(sl+" does not refer to a known object or data property");
- }
- }else{
- throw new InvalidSELiteralException(sl+" must be either unary or binary");
- }
- }
-}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralPropertyAssertion.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralPropertyAssertion.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteralPropertyAssertion.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -5,7 +5,7 @@
import org.semanticweb.owl.model.OWLIndividual;
import jasdl.asSemantics.JasdlAgent;
-import jasdl.bridge.alias.AliasFactory;
+import jasdl.bridge.factory.AliasFactory;
import jasdl.util.JasdlException;
import jason.asSyntax.Literal;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-02 17:05:13 UTC (rev 1192)
+++ trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-02 17:09:55 UTC (rev 1193)
@@ -7,29 +7,28 @@
import jasdl.architecture.JasdlAgArch;
import jasdl.asSemantics.JasdlAgent;
import jasdl.bb.JasdlBeliefBase;
-import jasdl.bridge.alias.Alias;
+import jasdl.bridge.factory.AliasFactory;
+import jasdl.bridge.mapping.aliasing.Alias;
import jasdl.bridge.seliteral.SELiteral;
-import jasdl.bridge.xsd.XSDDataType;
-import jasdl.bridge.xsd.XSDDataTypeUtils;
+import jasdl.util.JasdlException;
+import jasdl.util.xsd.XSDDataType;
+import jasdl.util.xsd.XSDDataTypeUtils;
import jason.architecture.AgArch;
import jason.architecture.AgArchInfraTier;
import jason.asSyntax.Atom;
-import jason.asSyntax.DefaultTerm;
+import jason.asSyntax.ListTerm;
+import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
-import jason.asSyntax.Structure;
+import jason.asSyntax.StringTermImpl;
import jason.asSyntax.Term;
-import jason.bb.BeliefBase;
import jason.bb.DefaultBeliefBase;
import jason.infra.centralised.CentralisedAgArch;
import jason.mas2j.ClassParameters;
import jason.runtime.Settings;
import java.lang.reflect.Constructor;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
import junit.framework.TestCase;
@@ -56,6 +55,7 @@
* A seperate test suite must be developed for belief bases employing the legacy rollback consistency assurance mechanism.
*
* TODO: contruct special testing ontology to better cover all test cases
+ * TODO: Perhaps we shouldn't be testing literal transation functionality here (i.e. in add)?
*
* @author Tom Klapiscak
*
@@ -66,7 +66,7 @@
public static String JASDL_AGENT_CLASS = "jasdl.asSemantics.JasdlAgent";
public static String JASDL_BELIEF_BASE_CLASS = "jasdl.bb.JasdlBeliefBase";
- public static String TEST_ONTOLOGY_LABEL = "test";
+ public static Atom TEST_ONTOLOGY_LABEL = new Atom("test");
public static String TEST_ONTOLOGY_URI = "http://www.dur.ac.uk/t.g.klapiscak/onts/travel.owl";
protected JasdlAgArch arch;
@@ -87,10 +87,9 @@
public void setUp() throws Exception {
// Use default manual mappings, mapping strategies and reasoner class. No known agents + trust ratings
Settings stts = new Settings();
- stts.addOption(MAS2J_PREFIX + MAS2J_ONTOLOGIES, TEST_ONTOLOGY_LABEL);
+ stts.addOption(MAS2J_PREFIX + MAS2J_ONTOLOGIES, TEST_ONTOLOGY_LABEL.getFunctor());
stts.addOption(MAS2J_PREFIX + "_" + TEST_ONTOLOGY_LABEL + MAS2J_URI, TEST_ONTOLOGY_URI);
stts.addOption(MAS2J_PREFIX + MAS2J_USEBELIEFREVISION, "true"); // Must be enabled (we don't want legacy consistency assurance!) - remember brf is skipped by this
- String aslFile = getClass().getResource("blank.asl").toExternalForm();
// load arch
Class cls = Class.forName(JASDL_AG_ARCH_CLASS);
@@ -98,7 +97,7 @@
AgArch arch = (AgArch)ct.newInstance(new Object[] {});
AgArchInfraTier archInfraTier = new CentralisedAgArch();
...
[truncated message content] |
|
From: <tom...@us...> - 2008-04-02 17:05:27
|
Revision: 1192
http://jason.svn.sourceforge.net/jason/?rev=1192&view=rev
Author: tomklapiscak
Date: 2008-04-02 10:05:13 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Structural improvements.
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/build.xml
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/src/jasdl/bridge/AllDifferentPlaceholder.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/MappingManager.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToAxiomConverter.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToSELiteralConverter.java
Modified: trunk/applications/jasdl-owlapi/build.xml
===================================================================
--- trunk/applications/jasdl-owlapi/build.xml 2008-04-02 17:00:03 UTC (rev 1191)
+++ trunk/applications/jasdl-owlapi/build.xml 2008-04-02 17:05:13 UTC (rev 1192)
@@ -1,13 +1,18 @@
<project basedir="." default="jar" name="jasdl">
- <property name="source.dir" value="${basedir}/src" />
- <property name="build.dir" value="${basedir}/bin" />
- <property name="apidocs.dir" value="${basedir}/doc/api" />
- <property name="jar.file" value="${basedir}/lib/jasdl.jar" />
+ <property name="jason.dir" value="../.."/>
+ <property name="apps.dir" value="${jason.dir}/applications"/>
+ <property name="jmca.dir" value="${apps.dir}/jmca"/>
+ <property name="asunit.dir" value="${apps.dir}/as-unit-test"/>
+ <property name="source.dir" value="${basedir}/src" />
+ <property name="build.dir" value="${basedir}/bin" />
+ <property name="apidocs.dir" value="${basedir}/doc/api" />
+ <property name="jar.file" value="${basedir}/lib/jasdl.jar" />
<path id="project.classpath">
- <pathelement location="../../lib/jason.jar"/>
- <pathelement location="../../applications/jmca/lib/jmca.jar"/>
+ <pathelement location="${jason.dir}/lib/jason.jar"/>
+ <pathelement location="${jmca.dir}/lib/jmca.jar"/>
+ <pathelement location="${asunit.dir}/lib/asunit.jar"/>
<fileset dir="./lib">
<include name="**/*.jar"/>
</fileset>
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/bridge/AllDifferentPlaceholder.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/AllDifferentPlaceholder.java 2008-04-02 17:00:03 UTC (rev 1191)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/AllDifferentPlaceholder.java 2008-04-02 17:05:13 UTC (rev 1192)
@@ -1,118 +0,0 @@
-package jasdl.bridge;
-
-import jason.asSyntax.Atom;
-
-import java.net.URI;
-import java.util.Set;
-
-import org.semanticweb.owl.model.OWLAnnotation;
-import org.semanticweb.owl.model.OWLAnnotationAxiom;
-import org.semanticweb.owl.model.OWLClass;
-import org.semanticweb.owl.model.OWLDataProperty;
-import org.semanticweb.owl.model.OWLDataType;
-import org.semanticweb.owl.model.OWLEntity;
-import org.semanticweb.owl.model.OWLEntityVisitor;
-import org.semanticweb.owl.model.OWLException;
-import org.semanticweb.owl.model.OWLIndividual;
-import org.semanticweb.owl.model.OWLNamedObjectVisitor;
-import org.semanticweb.owl.model.OWLObject;
-import org.semanticweb.owl.model.OWLObjectProperty;
-import org.semanticweb.owl.model.OWLObjectVisitor;
-import org.semanticweb.owl.model.OWLOntology;
-
-/**
- * Since the all_different has no concrete entity associated with it, we create a "placeholder" so that it remains consistent with
- * JASDL's mapping mechanisms. Entities of this type will be intercepted and dealt with differently.
- * Associated with an ontology label which determines hash-code - required since each ontology must have its own placeholder to reference
- * @author tom
- *
- */
-public class AllDifferentPlaceholder implements OWLEntity {
- private Atom label;
-
- public AllDifferentPlaceholder(Atom label){
- this.label = label;
- }
-
- public void accept(OWLEntityVisitor visitor) {
- }
-
- public Set<OWLAnnotationAxiom> getAnnotationAxioms(OWLOntology ontology) {
- return null;
- }
-
- public Set<OWLAnnotation> getAnnotations(OWLOntology ontology) {
- return null;
- }
-
- public Set<OWLAnnotation> getAnnotations(OWLOntology ontology, URI annotationURI) {
- return null;
- }
-
- public void accept(OWLObjectVisitor visitor) {
-
- }
-
- public void accept(OWLNamedObjectVisitor visitor) {
- }
-
- public URI getURI() {
- return null;
- }
-
- public boolean equals(Object other){
- if(!(other instanceof AllDifferentPlaceholder)){
- return false;
- }
- return label.equals(((AllDifferentPlaceholder)other).label);
- }
-
- public int hashCode(){
- return label.hashCode();
- }
-
- public OWLClass asOWLClass() {
- return null;
- }
-
- public OWLDataProperty asOWLDataProperty() {
- return null;
- }
-
- public OWLDataType asOWLDataType() {
- return null;
- }
-
- public OWLIndividual asOWLIndividual() {
- return null;
- }
-
- public OWLObjectProperty asOWLObjectProperty() {
- return null;
- }
-
- public boolean isOWLClass() {
- return false;
- }
-
- public boolean isOWLDataProperty() {
- return false;
- }
-
- public boolean isOWLDataType() {
- return false;
- }
-
- public boolean isOWLIndividual() {
- return false;
- }
-
- public boolean isOWLObjectProperty() {
- return false;
- }
-
- public int compareTo(OWLObject arg0) {
- return 0;
- }
-
-}
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/bridge/MappingManager.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/MappingManager.java 2008-04-02 17:00:03 UTC (rev 1191)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/MappingManager.java 2008-04-02 17:05:13 UTC (rev 1192)
@@ -1,105 +0,0 @@
-package jasdl.bridge;
-
-import jasdl.util.DuplicateMappingException;
-import jasdl.util.UnknownMappingException;
-
-import java.util.HashMap;
-import java.util.Set;
-import java.util.logging.Logger;
-
-/**
- * A bi-directional hash map that enforces 1 to 1 mappings.
- *
- * @author Tom Klapiscak
- *
- * @param <X>
- * @param <Y>
- */
-public class MappingManager<X extends Object, Y extends Object> {
- private Logger logger = Logger.getLogger(this.getClass().toString());
-
- private HashMap<X, Y> xToYMap;
-
- private HashMap<Y, X> yToXMap;
-
- public MappingManager(){
- xToYMap = new HashMap<X, Y>();
- yToXMap = new HashMap<Y, X>();
- }
-
- /**
- * Maps an x to a y and visa-versa.
- * 1 <-> 1 relationships enforced to prevent ambiguous mapping.
- * @param alias
- * @param entity
- * @throws DuplicateMappingException if either alias or entity is already mapped (thus breaking 1 <-> 1 constraint)
- */
- public void put(X x, Y y) throws DuplicateMappingException{
- logger.fine("mapping "+x+" <-> "+y);
-
- if(isKnownLeft(x)){
- throw new DuplicateMappingException("Duplicate mapping on "+x);
- }
- if(isKnownRight(y)){
- throw new DuplicateMappingException("Duplicate mapping on "+y);
- }
-
- xToYMap.put(x, y);
- yToXMap.put(y, x);
- }
-
- /**
- * Gets the alias associated with an entity
- * @param entity
- * @return
- * @throws UnknownMappingException if entity is unknown (not mapped)
- */
- public X getLeft(Y y) throws UnknownMappingException{
- X x = yToXMap.get(y);
- if(x == null){
- throw new UnknownMappingException("Unknown mapping "+y);
- }
- return x;
- }
-
- /**
- * Gets the entity associated with an alias
- * @param alias
- * @return
- * @throws UnknownMappingException if alias is unknown (not mapped)
- */
- public Y getRight(X x) throws UnknownMappingException{
- Y y = xToYMap.get(x);
- if(y == null){
- throw new UnknownMappingException("Unknown mapping "+x);
- }
- return y;
- }
-
-
- public boolean isKnownLeft(X x){
- return xToYMap.containsKey(x);
- }
-
- public boolean isKnownRight(Y y){
- return yToXMap.containsKey(y);
- }
-
- public Set<X> getLefts(){
- return xToYMap.keySet();
- }
-
- public Set<Y> getRights(){
- return yToXMap.keySet();
- }
-
- public void removeByLeft(X x){
- Y y = xToYMap.remove(x);
- yToXMap.remove(y);
- }
-
- public void removeByRight(Y y){
- X x = yToXMap.remove(y);
- xToYMap.remove(x);
- }
-}
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToAxiomConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToAxiomConverter.java 2008-04-02 17:00:03 UTC (rev 1191)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToAxiomConverter.java 2008-04-02 17:05:13 UTC (rev 1192)
@@ -1,268 +0,0 @@
-/*
- * 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/>.
- *
- */
-package jasdl.bridge;
-
-import static jasdl.util.Common.RANGE;
-import jasdl.asSemantics.JasdlAgent;
-import jasdl.bb.revision.IndividualAxiomToDescriptionConverter;
-import jasdl.bridge.seliteral.SELiteral;
-import jasdl.bridge.seliteral.SELiteralAllDifferentAssertion;
-import jasdl.bridge.seliteral.SELiteralClassAssertion;
-import jasdl.bridge.seliteral.SELiteralDataPropertyAssertion;
-import jasdl.bridge.seliteral.SELiteralObjectPropertyAssertion;
-import jasdl.util.InvalidSELiteralException;
-import jasdl.util.JasdlException;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.semanticweb.owl.inference.OWLReasonerException;
-import org.semanticweb.owl.model.OWLConstant;
-import org.semanticweb.owl.model.OWLDataProperty;
-import org.semanticweb.owl.model.OWLDescription;
-import org.semanticweb.owl.model.OWLDifferentIndividualsAxiom;
-import org.semanticweb.owl.model.OWLIndividual;
-import org.semanticweb.owl.model.OWLIndividualAxiom;
-import org.semanticweb.owl.model.OWLObjectProperty;
-import org.semanticweb.owl.model.OWLTypedConstant;
-
-
-/**
- * Accepts an arbitrary SEliteral and, depending on its type, creates an OWLIndividualAxiom encoding of it.
- * This factory can be used in one of two ways: for <i>creation</i> or for <i>retrieval</i>.<p>
- *
- * Creation will always return a encoding regardless of whether the axiom is entailed by the ontology.
- * In this case, the SELiteral must be ground and only a <b>single</b> SELiteral can be returned.<p>
- *
- * Retrieval, on the other hand, will result in an empty list if the axiom is not entailed by the ontology, otherwise
- * a list containing SELiteral encodings of <b>all</b> entailments is returned. The retrieval operation can deal
- * with unground SELiterals, in which case unground terms will be treated as "wildcards" that match any (suitable) resource.<p>
- *
- * Creation example:
- * <ul>
- * <li>hotel(hilton)[o(travel)] -> ClassAssertion(Hotel hilton)</li>
- * <li>hasRating(hilton,threeStarRating)[o(travel)] -> ObjectPropertyAssertion(hasRating hilton ThreeStarRating)</li>
- * <li>all_different([hilton,fourSeasons])[o(travel)] -> DifferentIndividuals( fourSeasons hilton )</li>
- * </ul><p>
- *
- * Retrieval example:
- * <ul>
- * <li>hotel(hilton)[o(travel)] -> [ClassAssertion(Hotel hilton)]</li>
- * <li>hasRating(hilton,X)[o(travel)] -> [ObjectPropertyAssertion(hasRating hilton OneStarRating), ObjectPropertyAssertion(hasRating hilton TwoStarRating), ObjectPropertyAssertion(hasRating hilton ThreeStarRating)]</li>
- * <li>hotel(threeStarRating)[o(travel)] -> []</li>
- * <li>~hotel(threeStarRating)[o(travel)] -> [ObjectComplementOf(ClassAssertion(Hotel threeStarRating))]</li>
- * </ul>
- * @author Tom Klapiscak
- *
- */
-public class ToAxiomConverter {
-
- private JasdlAgent agent;
-
- public ToAxiomConverter(JasdlAgent agent){
- this.agent = agent;
- }
-
-
- public Set<OWLIndividualAxiom> retrieve(SELiteral sl) throws JasdlException{
- return convert(sl, true);
- }
-
- /**
- * <b>Create</b> an axiomatic encoding of sl. Specific type of axiom dependent on specific type of sl.
- * sl must be <b>ground</b>
- * @param sl the SE-Literal to encode
- * @return a single encoding of sl - regardless of whether it is entailed or not
- * @throws JasdlException
- */
- public OWLIndividualAxiom create(SELiteral sl) throws JasdlException{
- if(!sl.getLiteral().isGround()){
- throw new JasdlException("Cannot create an axiom from unground SELiteral "+sl);
- }
- Set<OWLIndividualAxiom> axioms = convert(sl, false);
- if(axioms.isEmpty()){
- throw new JasdlException("Error creating axiom from "+sl);
- }
- return (OWLIndividualAxiom)axioms.toArray()[0];
- }
-
- /**
- * Polymorphically apply a factory method dependent on the specific type of sl
- * @param sl the SE-Literal to encode
- * @param checkForExistence if true, results will only be returned in they are entailed - if false, a successful encoding will guarantee a result
- * @return a set of entailments matching sl
- * @throws JasdlException
- */
- private Set<OWLIndividualAxiom> convert(SELiteral sl, boolean checkForExistence) throws JasdlException{
- if(sl instanceof SELiteralClassAssertion){
- return convert((SELiteralClassAssertion)sl, checkForExistence);
- }else if(sl instanceof SELiteralObjectPropertyAssertion){
- return create((SELiteralObjectPropertyAssertion)sl, checkForExistence);
- }else if(sl instanceof SELiteralDataPropertyAssertion){
- return create((SELiteralDataPropertyAssertion)sl, checkForExistence);
- }else if(sl instanceof SELiteralAllDifferentAssertion){
- return create((SELiteralAllDifferentAssertion)sl, checkForExistence);
- }else{
- throw new InvalidSELiteralException("JASDL does not know how to handle SELiterals like "+sl);
- }
- }
-
- /**
- * Convert a unary SELiteral (asserting a class membership of an individual) to its axiomatic encoding
- * @param sl the SELiteral to convert
- * @param checkForExistence if true, results will only be returned in they are entailed - if false, a successful encoding will guarantee a result
- * @return an axiomatic encoding of sl
- * @throws JasdlException
- */
- private Set<OWLIndividualAxiom> convert(SELiteralClassAssertion sl, boolean checkForExistence) throws JasdlException{
- try {
- Set<OWLIndividual> is = new HashSet<OWLIndividual>();
- OWLDescription desc = sl.getOWLDescription();
-
- if(sl.getLiteral().isGround()){
- OWLIndividual i = sl.getOWLIndividual();
- if(!checkForExistence || agent.getReasoner().hasType(i, desc, false)){
- is.add(i);
- }
- }else{
- is.addAll(agent.getReasoner().getIndividuals(desc, false));
- }
- Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
- for(OWLIndividual i : is){
- axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLClassAssertionAxiom(i, desc));
- }
- return axioms;
- } catch (OWLReasonerException e) {
- throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
- }
- }
-
- /**
- * Convert a unary all_different SELiteral (asserting distinctness of a set of individuals) to its axiomatic encoding
- * @param sl the SELiteral to convert
- * @param checkForExistence if true, results will only be returned in they are entailed - if false, a successful encoding will guarantee a result
- * @return an axiomatic encoding of sl
- * @throws JasdlException
- */
- public Set<OWLIndividualAxiom> create(SELiteralAllDifferentAssertion sl, boolean checkForExistence) throws JasdlException{
- try {
- Set<OWLIndividual> _is = sl.getOWLIndividuals();
- Object[] is = _is.toArray();
- if(is.length == 0){
- throw new JasdlException("All different assertion must contain some individuals! "+sl);
- }
- // check they are mutually distinct (if we are checking for existence)
- boolean distinct = true;
- if(checkForExistence){
- for(int i=0; i<is.length; i++){
- for(int j=i+1; j<is.length; j++){
- // create a description that is satisfiable iff the two individuals are different. TODO: request in-built OWL-API support for this
- OWLDifferentIndividualsAxiom axiom = agent.getOntologyManager().getOWLDataFactory().getOWLDifferentIndividualsAxiom(_is);
- IndividualAxiomToDescriptionConverter conv = new IndividualAxiomToDescriptionConverter(agent.getOntologyManager().getOWLDataFactory());
- axiom.accept(conv);
- if(!agent.getReasoner().isSatisfiable(conv.getDescription())){//.isDifferentFrom((OWLIndividual)is[i], (OWLIndividual)is[j])){
- distinct = false;
- break;
- }
- }
- if(!distinct) break;
- }
- }
- Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
- Set<OWLIndividual> different = new HashSet<OWLIndividual>();
- if(!checkForExistence || distinct){
- for(int i=0; i<is.length; i++){
- different.add((OWLIndividual)is[i]);
- }
- OWLDifferentIndividualsAxiom axiom = agent.getOntologyManager().getOWLDataFactory().getOWLDifferentIndividualsAxiom(different);
- axioms.add(axiom);
- }
- return axioms;
- } catch (OWLReasonerException e) {
- throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
- }
- }
-
- /**
- * Convert a binary SELiteral (asserting that two individuals are related by an object property) to its axiomatic encoding
- * @param sl the SELiteral to convert
- * @param checkForExistence if true, results will only be returned in they are entailed - if false, a successful encoding will guarantee a result
- * @return an axiomatic encoding of sl
- * @throws JasdlException
- */
- public Set<OWLIndividualAxiom> create(SELiteralObjectPropertyAssertion sl, boolean checkForExistence) throws JasdlException{
- try {
- Set<OWLIndividual> os = new HashSet<OWLIndividual>();
- OWLIndividual s = sl.getSubject();
- OWLObjectProperty p = sl.getPredicate();
- if(sl.getLiteral().getTerm(RANGE).isGround()){
- OWLIndividual o = sl.getObject();
- if(!checkForExistence || agent.getReasoner().hasObjectPropertyRelationship(s, p, o)){
- os.add(o);
- }
- }else{
- os.addAll(agent.getReasoner().getRelatedIndividuals(s, p));
- }
- Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
- for(OWLIndividual o : os){
- axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLObjectPropertyAssertionAxiom(s, p, o));
- }
- return axioms;
- } catch (OWLReasonerException e) {
- throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
- }
- }
-
- /**
- * Convert a binary SELiteral (asserting that an individual is related to a datatype literal) to its axiomatic encoding
- * @param sl the SELiteral to convert
- * @param checkForExistence if true, results will only be returned in they are entailed - if false, a successful encoding will guarantee a result
- * @return an axiomatic encoding of sl
- * @throws JasdlException
- */
- public Set<OWLIndividualAxiom> create(SELiteralDataPropertyAssertion sl, boolean checkForExistence) throws JasdlException{
- try {
- Set<OWLConstant> os = new HashSet<OWLConstant>();
- OWLIndividual s = sl.getSubject();
- OWLDataProperty p = sl.getPredicate();
- if(sl.getLiteral().getTerm(RANGE).isGround()){
- OWLTypedConstant o = sl.getObject();
- if(!checkForExistence || agent.getReasoner().hasDataPropertyRelationship(s, p, o)){
- os.add(o);
- }
- }else{
- os.addAll(agent.getReasoner().getRelatedValues(s, p));
- }
- Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
- for(OWLConstant o : os){
- axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLDataPropertyAssertionAxiom(s, p, o));
- }
- return axioms;
- } catch (OWLReasonerException e) {
- throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
- }
- }
-
-
-
-
-
-
-}
\ No newline at end of file
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToSELiteralConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToSELiteralConverter.java 2008-04-02 17:00:03 UTC (rev 1191)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToSELiteralConverter.java 2008-04-02 17:05:13 UTC (rev 1192)
@@ -1,224 +0,0 @@
-package jasdl.bridge;
-
-import jasdl.asSemantics.JasdlAgent;
-import jasdl.bridge.alias.Alias;
-import jasdl.bridge.seliteral.SELiteral;
-import jasdl.bridge.xsd.XSDDataType;
-import jasdl.bridge.xsd.XSDDataTypeUtils;
-import jasdl.util.JasdlException;
-import jason.asSyntax.Atom;
-import jason.asSyntax.DefaultTerm;
-import jason.asSyntax.ListTerm;
-import jason.asSyntax.ListTermImpl;
-import jason.asSyntax.Literal;
-import jason.asSyntax.Structure;
-import jason.asSyntax.Term;
-
-import java.util.List;
-import java.util.Set;
-import java.util.Vector;
-
-import org.semanticweb.owl.model.OWLAxiom;
-import org.semanticweb.owl.model.OWLAxiomAnnotationAxiom;
-import org.semanticweb.owl.model.OWLClassAssertionAxiom;
-import org.semanticweb.owl.model.OWLConstant;
-import org.semanticweb.owl.model.OWLDataPropertyAssertionAxiom;
-import org.semanticweb.owl.model.OWLDifferentIndividualsAxiom;
-import org.semanticweb.owl.model.OWLIndividual;
-import org.semanticweb.owl.model.OWLIndividualAxiom;
-import org.semanticweb.owl.model.OWLObjectPropertyAssertionAxiom;
-import org.semanticweb.owl.model.OWLOntology;
-import org.semanticweb.owl.model.OWLTypedConstant;
-
-
-/**
- * Accepts an arbitrary OWLIndividualAxiom and, depending on its type, creates a SE-Literal encoding of it.
- * Will always result in a ground SELiteral (since OWLIndividualAxioms must always be ground)<p>
- * For example:
- * <ul>
- * <li>ClassAssertion(Hotel hilton) -> hotel(hilton)[o(travel)]</li>
- * <li>ObjectPropertyAssertion(hasRating hilton ThreeStarRating) -> hasRating(hilton,threeStarRating)[o(travel)]</li>
- * <li>DifferentIndividuals( fourSeasons hilton ) -> all_different([hilton,fourSeasons])[o(travel)]</li>
- * </ul>
- * @author Tom Klapiscak
- *
- */
-public class ToSELiteralConverter {
-
- /**
- * The agent this converter is working on behalf of. Required for access to managers.
- */
- private JasdlAgent agent;
-
- public ToSELiteralConverter(JasdlAgent agent){
- this.agent = agent;
- }
-
- /**
- * Fetches and deseralises and returns all ASSERTED annotations of the supplied axiom.
- * TODO: Shift to a factory?
- * @param sl
- */
- public static List<Term> getAssertedAnnotations(OWLAxiom axiom, OWLOntology ontology){
- List<Term> result = new Vector<Term>();
- // get annotations
- Set<OWLAxiomAnnotationAxiom> annotAxioms = axiom.getAnnotationAxioms(ontology);
- for(OWLAxiomAnnotationAxiom annotAxiom : annotAxioms){ // remember, possibly semantically-naive payload!
- Term annot = Literal.parse(annotAxiom.getAnnotation().getAnnotationValueAsConstant().getLiteral());
- result.add(annot);
- }
- return result;
- }
-
-
- /**
- * Polymorphically applies appropriate factory method depending on specialisation of axiom
- * @param axiom
- * @return
- * @throws JasdlException if specialisation of axiom is not of an appropriate type for conversion to a SELiteral
- */
- public SELiteral convert(OWLIndividualAxiom axiom) throws JasdlException{
- if(axiom instanceof OWLClassAssertionAxiom){
- return convert((OWLClassAssertionAxiom)axiom);
- }else if(axiom instanceof OWLObjectPropertyAssertionAxiom){
- return convert((OWLObjectPropertyAssertionAxiom)axiom);
- }else if(axiom instanceof OWLDataPropertyAssertionAxiom){
- return convert((OWLDataPropertyAssertionAxiom)axiom);
- }else if(axiom instanceof OWLDifferentIndividualsAxiom){
- return convert((OWLDifferentIndividualsAxiom) axiom);
- }else{
- throw new JasdlException(axiom+" is not of an appropriate type for conversion to a SELiteral");
- }
- }
-
- /**
- * Convert an axiom asserting class membership to a unary SELiteral
- * @param axiom the axiom to convert
- * @return a unary SELiteral encoding of axiom
- * @throws JasdlException
- */
- public SELiteral convert(OWLClassAssertionAxiom axiom) throws JasdlException{
- Alias alias = agent.getAliasManager().getLeft(axiom.getDescription());
- Literal l = construct(alias);
- Atom i = agent.getAliasManager().getLeft(axiom.getIndividual()).getFunctor(); // TODO: what if individual is previously undefined? possible?
- l.addTerm(i);
-
- SELiteral sl = agent.getSELiteralFactory().create(l);
- sl.getLiteral().addAnnots(getAssertedAnnotations(axiom, sl.getOntology()));
- return sl;
- }
-
- /**
- * Convert an axiom asserting that two individuals are related by an object property to a binary SELiteral
- * @param axiom the axiom to convert
- * @return an binary SELiteral encoding of axiom
- * @throws JasdlException
- */
- public SELiteral convert(OWLObjectPropertyAssertionAxiom axiom) throws JasdlException{
- Alias alias = agent.getAliasManager().getLeft(axiom.getProperty().asOWLObjectProperty());
- Literal l = construct(alias);
- Atom s = agent.getAliasManager().getLeft(axiom.getSubject()).getFunctor();
- l.addTerm(s);
- Atom o = agent.getAliasManager().getLeft(axiom.getObject()).getFunctor();
- l.addTerm(o);
-
- SELiteral sl = agent.getSELiteralFactory().create(l);
- sl.getLiteral().addAnnots(getAssertedAnnotations(axiom, sl.getOntology()));
- return sl;
- }
-
- /**
- * Convert an axiom asserting that two individuals are related by a data property to a binary SELiteral
- * @param axiom the axiom to convert
- * @return a binary SELiteral encoding of axiom
- * @throws JasdlException
- */
- public SELiteral convert(OWLDataPropertyAssertionAxiom axiom) throws JasdlException{
- Alias alias = agent.getAliasManager().getLeft(axiom.getProperty().asOWLDataProperty());
- Literal l = construct(alias);
- Atom s = agent.getAliasManager().getLeft(axiom.getSubject()).getFunctor();
- l.addTerm(s);
-
- Term o;
- OWLConstant constant = axiom.getObject();
- if(constant.isTyped()){
- OWLTypedConstant ot = constant.asOWLTypedConstant();
- XSDDataType xsd = XSDDataTypeUtils.get(ot.getDataType().toString());
- // surround with quotes if necessary for representation in AgentSpeak syntax
- if(XSDDataTypeUtils.isStringType(xsd)){
- o = DefaultTerm.parse("\""+constant.getLiteral().toString()+"\"");
- }else if(XSDDataTypeUtils.isBooleanType(xsd)){
- if(Boolean.parseBoolean(ot.getLiteral().toString())){
- o = Literal.LTrue;
- }else{
- o = Literal.LFalse;
- }
- }else{
- o = DefaultTerm.parse(constant.getLiteral().toString());
- }
- }else{
- throw new JasdlException("JASDL does not support untyped data ranges such as: "+axiom);
- }
-
- l.addTerm(o);
-
- SELiteral sl = agent.getSELiteralFactory().create(l);
- sl.getLiteral().addAnnots(getAssertedAnnotations(axiom, sl.getOntology()));
- return sl;
- }
-
- /**
- * Convert an axiom asserting that a set of individuals are distinct to a unary SELiteral (whose term is a list and functor is "all_different")
- * @param axiom the axiom to convert
- * @return a unary SELiteral (whose term is a list and functor is "all_different") encoding of axiom
- * @throws JasdlException
- */
- public SELiteral convert(OWLDifferentIndividualsAxiom axiom) throws JasdlException{
- ListTerm list = new ListTermImpl(); // TODO: override this object's unify method to perform set, not list, unification?
- Set<OWLIndividual> is = axiom.getIndividuals();
- if(is.size() == 0){
- throw new JasdlException("All different assertion must contain some individuals! "+axiom);
- }
- Alias iAlias = null;
- for(OWLIndividual i : is){
- iAlias = agent.getAliasManager().getLeft(i);
- list.add(iAlias.getFunctor());
- }
- // hack, get a reference back to ontology by examining one of the individuals
- Alias alias = agent.getAliasManager().getLeft(new AllDifferentPlaceholder(iAlias.getLabel()));
- Literal l = construct(alias);
-
- l.addTerm(list);
-
- SELiteral sl = agent.getSELiteralFactory().create(l);
- sl.getLiteral().addAnnots(getAssertedAnnotations(axiom, sl.getOntology()));
- return sl;
- }
-
-
- /**
- * Common SELiteral construction code: sets functor, negation (based on presence of "~" prefix) and ontology annotation.
- * Results in a SELiteral with no arguments.
- * @param alias the alias from which to construct this SELiteral
- * @return an SELiteral corresponding to alias with no arguments
- */
- public Literal construct(Alias alias){
- // construct a new literal (with no terms) based on alias
- boolean sign = true;
- String functor = alias.getFunctor().toString();
- //~ might be present
- if(functor.startsWith("~")){
- functor = functor.substring(1);
- sign = false;
- }
- Literal l = new Literal(sign, functor);
-
- // add ontology annotation
- Structure o = new Structure(SELiteral.ONTOLOGY_ANNOTATION_FUNCTOR);
- o.addTerm(alias.getLabel());
- l.addAnnot(o);
-
- return l;
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-02 17:00:12
|
Revision: 1191
http://jason.svn.sourceforge.net/jason/?rev=1191&view=rev
Author: tomklapiscak
Date: 2008-04-02 10:00:03 -0700 (Wed, 02 Apr 2008)
Log Message:
-----------
Structural improvements.
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label/LabelManager.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label/OntologyURIManager.java
Added Paths:
-----------
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/MappingManager.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label/
Added: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/MappingManager.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/MappingManager.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/MappingManager.java 2008-04-02 17:00:03 UTC (rev 1191)
@@ -0,0 +1,105 @@
+package jasdl.bridge.mapping;
+
+import jasdl.util.DuplicateMappingException;
+import jasdl.util.UnknownMappingException;
+
+import java.util.HashMap;
+import java.util.Set;
+import java.util.logging.Logger;
+
+/**
+ * A bi-directional hash map that enforces 1 to 1 mappings.
+ *
+ * @author Tom Klapiscak
+ *
+ * @param <X>
+ * @param <Y>
+ */
+public class MappingManager<X extends Object, Y extends Object> {
+ private Logger logger = Logger.getLogger(this.getClass().toString());
+
+ private HashMap<X, Y> xToYMap;
+
+ private HashMap<Y, X> yToXMap;
+
+ public MappingManager(){
+ xToYMap = new HashMap<X, Y>();
+ yToXMap = new HashMap<Y, X>();
+ }
+
+ /**
+ * Maps an x to a y and visa-versa.
+ * 1 <-> 1 relationships enforced to prevent ambiguous mapping.
+ * @param alias
+ * @param entity
+ * @throws DuplicateMappingException if either alias or entity is already mapped (thus breaking 1 <-> 1 constraint)
+ */
+ public void put(X x, Y y) throws DuplicateMappingException{
+ logger.fine("mapping "+x+" <-> "+y);
+
+ if(isKnownLeft(x)){
+ throw new DuplicateMappingException("Duplicate mapping on "+x);
+ }
+ if(isKnownRight(y)){
+ throw new DuplicateMappingException("Duplicate mapping on "+y);
+ }
+
+ xToYMap.put(x, y);
+ yToXMap.put(y, x);
+ }
+
+ /**
+ * Gets the alias associated with an entity
+ * @param entity
+ * @return
+ * @throws UnknownMappingException if entity is unknown (not mapped)
+ */
+ public X getLeft(Y y) throws UnknownMappingException{
+ X x = yToXMap.get(y);
+ if(x == null){
+ throw new UnknownMappingException("Unknown mapping "+y);
+ }
+ return x;
+ }
+
+ /**
+ * Gets the entity associated with an alias
+ * @param alias
+ * @return
+ * @throws UnknownMappingException if alias is unknown (not mapped)
+ */
+ public Y getRight(X x) throws UnknownMappingException{
+ Y y = xToYMap.get(x);
+ if(y == null){
+ throw new UnknownMappingException("Unknown mapping "+x);
+ }
+ return y;
+ }
+
+
+ public boolean isKnownLeft(X x){
+ return xToYMap.containsKey(x);
+ }
+
+ public boolean isKnownRight(Y y){
+ return yToXMap.containsKey(y);
+ }
+
+ public Set<X> getLefts(){
+ return xToYMap.keySet();
+ }
+
+ public Set<Y> getRights(){
+ return yToXMap.keySet();
+ }
+
+ public void removeByLeft(X x){
+ Y y = xToYMap.remove(x);
+ yToXMap.remove(y);
+ }
+
+ public void removeByRight(Y y){
+ X x = yToXMap.remove(y);
+ xToYMap.remove(x);
+ }
+}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label (from rev 1190, trunk/applications/jasdl-owlapi/src/jasdl/bridge/label)
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label/LabelManager.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/label/LabelManager.java 2008-04-02 02:21:21 UTC (rev 1190)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label/LabelManager.java 2008-04-02 17:00:03 UTC (rev 1191)
@@ -1,6 +1,6 @@
-package jasdl.bridge.label;
+package jasdl.bridge.mapping.label;
-import jasdl.bridge.MappingManager;
+import jasdl.bridge.mapping.MappingManager;
import jasdl.util.DuplicateMappingException;
import jason.asSyntax.Atom;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label/OntologyURIManager.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/label/OntologyURIManager.java 2008-04-02 02:21:21 UTC (rev 1190)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/mapping/label/OntologyURIManager.java 2008-04-02 17:00:03 UTC (rev 1191)
@@ -1,6 +1,6 @@
-package jasdl.bridge.label;
+package jasdl.bridge.mapping.label;
-import jasdl.bridge.MappingManager;
+import jasdl.bridge.mapping.MappingManager;
import java.net.URI;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-02 02:21:30
|
Revision: 1190
http://jason.svn.sourceforge.net/jason/?rev=1190&view=rev
Author: tomklapiscak
Date: 2008-04-01 19:21:21 -0700 (Tue, 01 Apr 2008)
Log Message:
-----------
Improved JasdlBeliefBase test and added (incomplete) remove test. Fixed bugs in the annotation handling of the remove operation.
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl
trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl 2008-04-01 23:35:02 UTC (rev 1189)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl 2008-04-02 02:21:21 UTC (rev 1190)
@@ -46,7 +46,6 @@
<owl:ObjectProperty rdf:about="#hasAccommodation">
<rdfs:range rdf:resource="#Accommodation"/>
<rdfs:domain rdf:resource="#Destination"/>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -56,7 +55,6 @@
<owl:ObjectProperty rdf:about="#hasActivity">
<rdfs:range rdf:resource="#Activity"/>
<rdfs:domain rdf:resource="#Destination"/>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
<owl:inverseOf rdf:resource="#isOfferedAt"/>
</owl:ObjectProperty>
@@ -67,7 +65,6 @@
<owl:ObjectProperty rdf:about="#hasContact">
<rdfs:domain rdf:resource="#Activity"/>
<rdfs:range rdf:resource="#Contact"/>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -76,7 +73,6 @@
<owl:ObjectProperty rdf:about="#hasDestination">
<rdfs:range rdf:resource="#Destination"/>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -87,7 +83,6 @@
<rdf:type rdf:resource="&owl;TransitiveProperty"/>
<rdfs:domain rdf:resource="#Destination"/>
<rdfs:range rdf:resource="#Destination"/>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -98,24 +93,17 @@
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<rdfs:domain rdf:resource="#Accommodation"/>
<rdfs:range rdf:resource="#AccommodationRating"/>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
- <!-- http://www.owl-ontologies.com/travel.owl#hasThing -->
-
- <owl:ObjectProperty rdf:about="#hasThing"/>
-
-
-
<!-- http://www.owl-ontologies.com/travel.owl#isLocatedAt -->
<owl:ObjectProperty rdf:about="#isLocatedAt">
+ <rdf:type rdf:resource="&owl11;IrreflexiveProperty"/>
<rdfs:domain rdf:resource="#Accommodation"/>
<rdfs:range rdf:resource="#Destination"/>
<owl:inverseOf rdf:resource="#hasAccommodation"/>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -127,7 +115,6 @@
>Generalised to apply to accommodations as well</rdfs:comment>
<rdfs:domain rdf:resource="#Activity"/>
<rdfs:range rdf:resource="#Destination"/>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -138,7 +125,6 @@
<rdfs:domain rdf:resource="#Destination"/>
<rdfs:range rdf:resource="#Destination"/>
<owl:inverseOf rdf:resource="#hasPart"/>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -158,24 +144,32 @@
<owl:DatatypeProperty rdf:about="#hasCity">
<rdfs:domain rdf:resource="#Contact"/>
- <rdfs:subPropertyOf rdf:resource="#hasData"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
- <!-- http://www.owl-ontologies.com/travel.owl#hasData -->
+ <!-- http://www.owl-ontologies.com/travel.owl#hasDate -->
- <owl:DatatypeProperty rdf:about="#hasData"/>
+ <owl:DatatypeProperty rdf:about="#hasDate">
+ <rdfs:range rdf:resource="&xsd;date"/>
+ </owl:DatatypeProperty>
+ <!-- http://www.owl-ontologies.com/travel.owl#hasDateTime -->
+
+ <owl:DatatypeProperty rdf:about="#hasDateTime">
+ <rdfs:range rdf:resource="&xsd;dateTime"/>
+ </owl:DatatypeProperty>
+
+
+
<!-- http://www.owl-ontologies.com/travel.owl#hasEMail -->
<owl:DatatypeProperty rdf:about="#hasEMail">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<rdfs:domain rdf:resource="#Contact"/>
- <rdfs:subPropertyOf rdf:resource="#hasData"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
@@ -188,7 +182,6 @@
<rdfs:comment
>Stated in local currency</rdfs:comment>
<rdfs:domain rdf:resource="#Accommodation"/>
- <rdfs:subPropertyOf rdf:resource="#hasData"/>
<rdfs:range rdf:resource="&xsd;double"/>
</owl:DatatypeProperty>
@@ -198,18 +191,24 @@
<owl:DatatypeProperty rdf:about="#hasStreet">
<rdfs:domain rdf:resource="#Contact"/>
- <rdfs:subPropertyOf rdf:resource="#hasData"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
+ <!-- http://www.owl-ontologies.com/travel.owl#hasTime -->
+
+ <owl:DatatypeProperty rdf:about="#hasTime">
+ <rdfs:range rdf:resource="&xsd;time"/>
+ </owl:DatatypeProperty>
+
+
+
<!-- http://www.owl-ontologies.com/travel.owl#hasZipCode -->
<owl:DatatypeProperty rdf:about="#hasZipCode">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<rdfs:domain rdf:resource="#Contact"/>
- <rdfs:subPropertyOf rdf:resource="#hasData"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl 2008-04-01 23:35:02 UTC (rev 1189)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl 2008-04-02 02:21:21 UTC (rev 1190)
@@ -83,6 +83,9 @@
+ruralArea(somewhere)[o(travel), source(tom)];
?ruralArea(somewhere)[o(travel)];
+
+ +isLocatedAt(x, x)[o(travel)]; // rejected since isLocated at is irreflexive
+
.print("DL-based belief revision is enabled"); // without, the above test-goal will fail, since legacy mechanism simply removes incoming inconsistent beliefs
// since the classes destination and and contact are disjoint (and ruralArea is a subclass of destination),
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-01 23:35:02 UTC (rev 1189)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-02 02:21:21 UTC (rev 1190)
@@ -214,6 +214,10 @@
public List<Literal>[] brf(Literal beliefToAdd, Literal beliefToDel, Intention i) throws RevisionFailedException {
+ // TODO: what annotations should revision contractions contain? all! (or none? - same effect)
+ // No! the same. -a[x] only undermines assertions leading to a[x]!
+ // if we are performing belief-revision all annotations will be gathered (shortcut - use none?) ensuring axiom will be obliterated
+ // annotations never solely lead to conflicts.
if(!isBeliefRevisionEnabled()){ // if experimental feature is disabled
return super.brf(beliefToAdd, beliefToDel, i);
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-01 23:35:02 UTC (rev 1189)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-02 02:21:21 UTC (rev 1190)
@@ -14,8 +14,7 @@
import jason.asSyntax.Term;
import jason.bb.DefaultBeliefBase;
-import java.util.Collections;
-import java.util.Comparator;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -90,41 +89,68 @@
*/
@Override
public boolean remove(Literal l) {
+
getLogger().fine("Contracting "+l);
try{
SELiteral sl = agent.getSELiteralFactory().create(l);
OWLOntology ontology = sl.getOntology();
- OWLIndividualAxiom axiom = sl.createAxiom();
+ OWLIndividualAxiom axiom = sl.createAxiom();
+
boolean result = false; // -> at least *something* must be removed for this to be true!
BeliefBaseContractor contractor = new BeliefBaseContractor(agent.getOntologyManager(), new JasdlReasonerFactory(), agent.getLogger());
List<OWLAxiom> contractList = contractor.contract(axiom, new TBoxAxiomKernelsetFilter(), new JasdlIncisionFunction(agent, sl));
// NOTE: this technique only really makes sense with annotation gathering!
- for(OWLAxiom contract : contractList){ // removals corresponds to l and all l's whose removal will undermine it
+ for(OWLAxiom contract : contractList){ // removals correspond to l and all assertions whose removal will undermine l
+ //agent.refreshReasoner();
- // for each annotation to this axiom, remove it if l has it
- List<OWLAxiomAnnotationAxiom> annotationsToRemove = new Vector<OWLAxiomAnnotationAxiom>(); // to avoid concurrency issues
+ // fail if axiom not contained in ontology
+ if(!ontology.containsAxiom(contract)){
+ continue;
+ }
+
+ // construct annot axiom->term map (avoids unecessary parsing of terms)
+ HashMap<OWLAxiomAnnotationAxiom, Term> annotAxiomToTermMap = new HashMap<OWLAxiomAnnotationAxiom, Term>();
for(OWLAxiomAnnotationAxiom annotAxiom : contract.getAnnotationAxioms(ontology)){
- Term annot = Literal.parse(annotAxiom.getAnnotation().getAnnotationValueAsConstant().getLiteral());
- if(l.hasAnnot(annot)){
- annotationsToRemove.add(annotAxiom);
- result = true;
- }
+ Term annotTerm = Literal.parse(annotAxiom.getAnnotation().getAnnotationValueAsConstant().getLiteral());
+ annotAxiomToTermMap.put(annotAxiom, annotTerm);
}
- for(OWLAxiom annotationToRemove : annotationsToRemove){
- agent.getOntologyManager().applyChange(new RemoveAxiom(ontology, annotationToRemove));
+ // if l only has "o" annotations. Remember, "o" isn't stored in ontology
+ // note: literals without "o" are semantically-naive and so will be caught below
+ if(sl.getSemanticallyNaiveAnnotations().isEmpty()){
+ // remove axiom and all annotations
+ for(OWLAxiomAnnotationAxiom annotAxiom : annotAxiomToTermMap.keySet()){
+ agent.getOntologyManager().applyChange(new RemoveAxiom(ontology, annotAxiom));
+ }
+ agent.getOntologyManager().applyChange(new RemoveAxiom(ontology, contract));
+ result = true;
+ continue;
}
- // remove source(self) and source(percept). TODO: right thing to do?
- // remove assertion if no annotation axioms left
+
+ // first check axiom has all annotations of l except for "o" (otherwise fail)
+ if(!annotAxiomToTermMap.values().containsAll(sl.getSemanticallyNaiveAnnotations())){
+ continue;
+ }
+
+ result = true;
+
+ // remove all axiom annotations (implicitly possessed also by l)
+ for(OWLAxiomAnnotationAxiom annotAxiom : annotAxiomToTermMap.keySet()){
+ agent.getOntologyManager().applyChange(new RemoveAxiom(ontology, annotAxiom));
+ }
+
+ // remove source(self) and source(percept). TODO: right thing to do?
+
+ // if no annotation axioms left, remove assertion
Set<OWLAxiomAnnotationAxiom> remaining = contract.getAnnotationAxioms(ontology);
if(remaining.isEmpty()){
agent.getOntologyManager().applyChange(new RemoveAxiom(ontology, contract));
- result = true;
- }
+ }
+
}
agent.refreshReasoner();
return result;
Modified: trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-01 23:35:02 UTC (rev 1189)
+++ trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-02 02:21:21 UTC (rev 1190)
@@ -18,6 +18,7 @@
import jason.asSyntax.Literal;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
+import jason.bb.BeliefBase;
import jason.bb.DefaultBeliefBase;
import jason.infra.centralised.CentralisedAgArch;
import jason.mas2j.ClassParameters;
@@ -30,7 +31,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import java.util.Vector;
import junit.framework.TestCase;
@@ -55,6 +55,8 @@
* No thought it given to consistency of additions. This is dealt with by the brf before these methods are called.
* A seperate test suite must be developed for belief bases employing the legacy rollback consistency assurance mechanism.
*
+ * TODO: contruct special testing ontology to better cover all test cases
+ *
* @author Tom Klapiscak
*
*/
@@ -102,94 +104,184 @@
bb = (JasdlBeliefBase)agent.getBB();
testbb = new DefaultBeliefBase();
-
- /*
- // ensure initial state of testbb contained predefinitions from bb's ABox
- // Add in reverse order, so iterator ordering is identical
- List<Literal> state = new Vector<Literal>();
- Iterator<Literal> bbit = bb.iterator();
- while(bbit.hasNext()){
- state.add(bbit.next());
- }
- Collections.reverse(state);
- for(Literal l : state){
- testbb.add(l);
- }
- */
-
-
+
// we are not worrying about ordering of iterator anymore
Iterator<Literal> bbit = bb.iterator();
while(bbit.hasNext()){
testbb.add(bbit.next());
- }
+ }
-
-
-
}
@After
public void tearDown() throws Exception {
}
+
+
+ private Literal constructSELiteral(boolean sign, String functor, Term[] terms, Term[] annots, String label){
+ Literal l = new Literal(sign, functor);
+ addO(l, label);
+ l.addTerms(Arrays.asList(terms));
+ if(annots!=null){
+ l.addAnnots(Arrays.asList(annots));
+ }
+ return l;
+ }
+
+ private Literal constructSELiteral(boolean sign, String functor, Term[] terms, String[] _annots, String label){
+ Term[] annots = null;
+ if(_annots != null){
+ annots = new Term[_annots.length];
+ for(int i=0; i<_annots.length; i++){
+ annots[i] = DefaultTerm.parse(_annots[i]);
+ }
+ }
+ return constructSELiteral(sign, functor, terms, annots, label);
+ }
+
+ private Literal constructClass(boolean sign, String functor, String i, String[] annots, String label){
+ return constructSELiteral(sign, functor, new Term[] {new Atom(i)}, annots, label);
+ }
+
+ private Literal constructObjectProperty(boolean sign, String functor, String s, String o, String[] annots, String label){
+ return constructSELiteral(sign, functor, new Term[] {new Atom(s), new Atom(o)}, annots, label);
+ }
+
+ private Literal constructDataProperty(boolean sign, String functor, String s, String o, String[] annots, String label){
+ return constructSELiteral(sign, functor, new Term[] {new Atom(s), DefaultTerm.parse(o)}, annots, label);
+ }
+
+
+
+
+ private Literal constructSELiteral(boolean sign, String functor, Term[] terms, String label){
+ return constructSELiteral(sign, functor, terms, (Term[])null, label);
+ }
+
+ private Literal constructClass(boolean sign, String functor, String i, String label){
+ return constructSELiteral(sign, functor, new Term[] {new Atom(i)}, label);
+ }
+
+ private Literal constructObjectProperty(boolean sign, String functor, String s, String o, String label){
+ return constructSELiteral(sign, functor, new Term[] {new Atom(s), new Atom(o)}, label);
+ }
+
+ private Literal constructDataProperty(boolean sign, String functor, String s, String o, String label){
+ return constructSELiteral(sign, functor, new Term[] {new Atom(s), DefaultTerm.parse(o)}, label);
+ }
+
+ /**
+ * Adds the ontology annotation with the specified label to the supplied literal
+ * @param l
+ */
+ private void addO(Literal l, String label){
+ Structure o = new Structure(SELiteral.ONTOLOGY_ANNOTATION_FUNCTOR);
+ o.addTerm(new Atom(label));
+ l.addAnnot(o);
+ }
+
+ private static boolean[] signs = new boolean[] {true, false};
+
+
@Test
- public void testAddLiteral() throws Exception{
+ public void testRemoveLiteral() throws Exception{
+ // contractor is tested more thoroughly elsewhere
- boolean[] signs = new boolean[] {true, false};
+ /** Testing annotation handling */
+ //for(boolean sign : signs){
+ boolean sign = true;
+ Literal l = constructClass(sign, "hotel", "a", TEST_ONTOLOGY_LABEL);
+ Literal l_x = constructClass(sign, "hotel", "a", new String[] {"x"}, TEST_ONTOLOGY_LABEL);
+ Literal l_xy = constructClass(sign, "hotel", "a", new String[] {"x", "y"}, TEST_ONTOLOGY_LABEL);
+
+ testRemoveIndividualAssertion(l);
+ testRemoveIndividualAssertion(l_x);
+ testRemoveIndividualAssertion(l_xy);
+
+ testAddIndividualAssertion(l);
+ testRemoveIndividualAssertion(l);
+
+
+ testAddIndividualAssertion(l_x);
+ testRemoveIndividualAssertion(l);
+ testRemoveIndividualAssertion(l_x);
+
+ testAddIndividualAssertion(l_x);
+ testRemoveIndividualAssertion(l_x);
+ testRemoveIndividualAssertion(l);
+
+
+ testAddIndividualAssertion(l_x);
+ testRemoveIndividualAssertion(l_xy);
+ testRemoveIndividualAssertion(l);
+
+ testAddIndividualAssertion(l_x);
+ testRemoveIndividualAssertion(l);
+ testRemoveIndividualAssertion(l_xy);
+
+
+
+ //}
+
+ //l = constructClass();
+
+ }
+
+
+ //@Test
+ public void notestAddLiteral() throws Exception{
+ String[][] annotSets = new String[][] {new String[]{}, new String[] {"x"}, new String[] {"x", "y"} };
for(OWLOntology ontology : agent.getOntologyManager().getOntologies()){
for(int run=0; run<=1; run++){ // run twice to ensure duplicate additions are rejected
for(boolean sign : signs){
- for(OWLClass cls : ontology.getReferencedClasses()){
- Alias alias = agent.getAliasManager().getLeft(cls);
- String label = alias.getLabel().getFunctor();
- String functor = alias.getFunctor().getFunctor();
- assertAddClass(sign, functor, "a", label);
- assertAddClass(sign, functor, "b", label);
- }
- for(OWLObjectProperty oprop : ontology.getReferencedObjectProperties()){
- Alias alias = agent.getAliasManager().getLeft(oprop);
- String label = alias.getLabel().getFunctor();
- String functor = alias.getFunctor().getFunctor();
- assertAddObjectProperty(sign, functor, "a", "b", label);
- assertAddObjectProperty(sign, functor, "b", "a", label);
- assertAddObjectProperty(sign, functor, "a", "a", label); // irreflexive properties shouldn't be rejected at this stage
- }
-
- for(OWLDataProperty dprop : ontology.getReferencedDataProperties()){
- Alias alias = agent.getAliasManager().getLeft(dprop);
- String label = alias.getLabel().getFunctor();
- String functor = alias.getFunctor().getFunctor();
- XSDDataType typ = XSDDataTypeUtils.get(((OWLDataType)dprop.getRanges(ontology).toArray()[0]).toString());
- if(typ == XSDDataType.XSD_BOOLEAN){
- assertAddDataProperty(sign, functor, "a", "false", label);
- assertAddDataProperty(sign, functor, "a", "true", label);
- }else if(typ == XSDDataType.XSD_DATE){
- assertAddDataProperty(sign, functor, "a", "\"2007-12-20\"", label);
- }else if(typ == XSDDataType.XSD_DATETIME){
- assertAddDataProperty(sign, functor, "a", "\"2007-12-20T20:16:55\"", label);
- }else if(typ == XSDDataType.XSD_DOUBLE){
- assertAddDataProperty(sign, functor, "a", "22.0", label);
- }else if(typ == XSDDataType.XSD_FLOAT){
- assertAddDataProperty(sign, functor, "a", "0.5", label);
- }else if(typ == XSDDataType.XSD_INT){
- assertAddDataProperty(sign, functor, "a", "22", label);
- }else if(typ == XSDDataType.XSD_STRING){
- assertAddDataProperty(sign, functor, "a", "\"Winchester\"", label);
- }else if(typ == XSDDataType.XSD_TIME){
- assertAddDataProperty(sign, functor, "a", "\"20:16:57\"", label);
+ for(String[] annots : annotSets){
+ for(OWLClass cls : ontology.getReferencedClasses()){
+ Alias alias = agent.getAliasManager().getLeft(cls);
+ String label = alias.getLabel().getFunctor();
+ String functor = alias.getFunctor().getFunctor();
+ testAddIndividualAssertion(constructClass(sign, functor, "a", annots, label));
+ testAddIndividualAssertion(constructClass(sign, functor, "b", annots, label));
}
+ for(OWLObjectProperty oprop : ontology.getReferencedObjectProperties()){
+ Alias alias = agent.getAliasManager().getLeft(oprop);
+ String label = alias.getLabel().getFunctor();
+ String functor = alias.getFunctor().getFunctor();
+ testAddIndividualAssertion(constructObjectProperty(sign, functor, "a", "b", annots, label));
+ testAddIndividualAssertion(constructObjectProperty(sign, functor, "b", "a", annots, label));
+ testAddIndividualAssertion(constructObjectProperty(sign, functor, "a", "a", annots, label)); // irreflexive properties shouldn't be rejected at this stage
+ }
+
+ for(OWLDataProperty dprop : ontology.getReferencedDataProperties()){
+ Alias alias = agent.getAliasManager().getLeft(dprop);
+ String label = alias.getLabel().getFunctor();
+ String functor = alias.getFunctor().getFunctor();
+ XSDDataType typ = XSDDataTypeUtils.get(((OWLDataType)dprop.getRanges(ontology).toArray()[0]).toString());
+ if(typ == XSDDataType.XSD_BOOLEAN){
+ testAddIndividualAssertion(constructDataProperty(sign, functor, "a", "false", annots, label));
+ testAddIndividualAssertion(constructDataProperty(sign, functor, "a", "true", annots, label));
+ }else if(typ == XSDDataType.XSD_DATE){
+ testAddIndividualAssertion(constructDataProperty(sign, functor, "a", "\"2007-12-20\"", annots, label));
+ }else if(typ == XSDDataType.XSD_DATETIME){
+ testAddIndividualAssertion(constructDataProperty(sign, functor, "a", "\"2007-12-20T20:16:55\"", annots, label));
+ }else if(typ == XSDDataType.XSD_FLOAT){
+ testAddIndividualAssertion(constructDataProperty(sign, functor, "a", "0.5", annots, label));
+ }else if(typ == XSDDataType.XSD_INT){
+ testAddIndividualAssertion(constructDataProperty(sign, functor, "a", "22", annots, label));
+ }else if(typ == XSDDataType.XSD_STRING){
+ testAddIndividualAssertion(constructDataProperty(sign, functor, "a", "\"Winchester\"", annots, label));
+ }else if(typ == XSDDataType.XSD_TIME){
+ testAddIndividualAssertion(constructDataProperty(sign, functor, "a", "\"20:16:57\"", annots, label));
+ }
+ }
}
}
}
}
-
-
-
Set<Literal> expected = new HashSet<Literal>();
Iterator<Literal> testbbit = testbb.iterator();
@@ -201,111 +293,49 @@
Iterator<Literal> bbit = bb.iterator();
while(bbit.hasNext()){
actual.add(bbit.next());
- }
-
+ }
assertEquals(expected, actual);
}
-
- /**
- * Constructs functor and annotations (including ontology annotation) of a SE-Literal.
- * @param sign
- * @param functor
- * @param annots
- * @return
- */
- private Literal constructSELiteral(boolean sign, String functor, String label){
- Literal l = new Literal(sign, functor);
- addO(l, label);
- return l;
+
+
+ private void testAddIndividualAssertion(Literal l){
+ // special case: reject ~thing and ~nothing
+ if(l.negated() && (l.getFunctor().equals("thing") || l.getFunctor().equals("nothing"))){
+ assertFalse(bb.add(l));return;
+ }
+ //special case: reject negated property assertions
+ if(l.negated() && l.getArity() == 2){
+ assertFalse(bb.add(l));return;
+ }
+ System.out.print("Adding: "+l);
+ //cloning necessary since Jason's default bb.add affects l passed to it
+ boolean expected = testbb.add((Literal)l.clone());
+ boolean actual = bb.add((Literal)l.clone());
+ assertEquals(expected, actual);
+ System.out.println(" ... Result: "+actual);
}
- /**
- * Adds the ontology annotation with the specified label to the supplied literal
- * @param l
- */
- private void addO(Literal l, String label){
- Structure o = new Structure(SELiteral.ONTOLOGY_ANNOTATION_FUNCTOR);
- o.addTerm(new Atom(label));
- l.addAnnot(o);
- }
-
- /**
- * Constructs SE-Literal, adds terms
- * recognises special cases (i.e. negated properties)
- * otherwise, ensures behaviour is identical to Jason's BB.
- * Additionally, tries with "x", then "y" annots added.
- * @param sign
- * @param functor
- * @param annots
- * @param is
- * @param expected
- */
- private void assertAdd(boolean sign, String functor, List<Term> is, String label){
- Term[][] annotSets = new Term[][] {new Term[]{}, new Term[] {new Atom("x")}, new Term[] {new Atom("x"), new Atom("y")} };
- for(Term[] annots : annotSets){
- Literal l = constructSELiteral(sign, functor, label);
- l.addTerms(is);
- l.addAnnots(Arrays.asList(annots));
- // special case: reject ~thing and ~nothing
- if(!sign && (functor.equals("thing") || functor.equals("nothing"))){
- assertFalse(bb.add(l));return;
- }
- //special case: reject negated property assertions
- if(!sign && l.getArity() == 2){
- assertFalse(bb.add(l));return;
- }
- //System.out.println("Adding: "+l);
- assertEquals(testbb.add((Literal)l.clone()), bb.add((Literal)l.clone())); // cloning necessary since Jason's default bb.add affects l passed to it
+
+ private void testRemoveIndividualAssertion(Literal l){
+ // special case: reject ~thing and ~nothing
+ if(l.negated() && (l.getFunctor().equals("thing") || l.getFunctor().equals("nothing"))){
+ assertFalse(bb.remove(l));return;
}
- }
-
-
- /**
- * Convenience method for testing class assertion additions (unary literals)
- *
- * @param sign
- * @param functor
- * @param annots
- * @param i
- * @param expected
- */
- private void assertAddClass(boolean sign, String functor, String i, String label){
- assertAdd(sign, functor, Collections.singletonList((Term)new Atom(i)), label);
- }
-
- /**
- * Convenience method for testing class assertion additions (unary literals)
- *
- * @param sign
- * @param functor
- * @param annots
- * @param i
- * @param expected
- */
- private void assertAddDataProperty(boolean sign, String functor, String s, String o, String label){
- assertAdd(sign, functor, Arrays.asList(new Term[] {new Atom(s), DefaultTerm.parse(o)}), label);
+ //special case: reject negated property assertions
+ if(l.negated() && l.getArity() == 2){
+ assertFalse(bb.remove(l));return;
+ }
+ System.out.print("Removing: "+l);
+ boolean expected = testbb.remove((Literal)l.clone());
+ boolean actual = bb.remove((Literal)l.clone());
+ assertEquals(expected, actual);
+ System.out.println(" ... Result: "+actual);
}
- /**
- * Convenience method for testing class assertion additions (unary literals)
- *
- * @param sign
- * @param functor
- * @param annots
- * @param i
- * @param expected
- */
- private void assertAddObjectProperty(boolean sign, String functor, String s, String o, String label){
- assertAdd(sign, functor, Arrays.asList(new Term[] {new Atom(s), new Atom(o)}), label);
- }
@Test
- public void testRemoveLiteral() {
- }
-
- @Test
public void testContainsLiteral() {
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-01 23:35:05
|
Revision: 1189
http://jason.svn.sourceforge.net/jason/?rev=1189&view=rev
Author: tomklapiscak
Date: 2008-04-01 16:35:02 -0700 (Tue, 01 Apr 2008)
Log Message:
-----------
Started work on new jasdl.test package. Far more comprehensive JasdlBeliefBase implemented (matches behaviour against Jason's default).
Bug fixes.
Agent configuration improvement.
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
Modified: trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-01 23:33:22 UTC (rev 1188)
+++ trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-01 23:35:02 UTC (rev 1189)
@@ -203,27 +203,7 @@
actual.add(bbit.next());
}
- Set<Literal> actuallyLessDifference = new HashSet<Literal>();
- actuallyLessDifference.addAll(expected);
- actuallyLessDifference.removeAll(actual);
- if(!actuallyLessDifference.isEmpty()){
- System.out.println("\n\nexpected > actual. Difference: "+actuallyLessDifference+"\n\n");
- }
-
- Set<Literal> actuallyMoreDifference = new HashSet<Literal>();
- actuallyMoreDifference.addAll(actual);
- actuallyMoreDifference.removeAll(expected);
- if(!actuallyMoreDifference.isEmpty()){
- System.out.println("\n\nexpected < actual. Difference: "+actuallyMoreDifference+"\n\n");
- }
-
- //System.out.println("Terminal state: "+actual);
-
assertEquals(expected, actual);
- //System.out.println("Terminal state consistent? "+);
-
-
-
}
@@ -278,15 +258,6 @@
//System.out.println("Adding: "+l);
assertEquals(testbb.add((Literal)l.clone()), bb.add((Literal)l.clone())); // cloning necessary since Jason's default bb.add affects l passed to it
}
-
- // TODO: error in Jason's BB below? Rejects additions even though annots changed!
- // might be because deffault bb.add affects literals?
- //l.addAnnot(new Atom("x"));
- //System.out.println("Adding: "+l);
- //assertEquals(testbb.add(l), bb.add(l));
- //l.addAnnot(new Atom("y"));
- //System.out.println("Adding: "+l);
- //assertEquals(testbb.add(l), bb.add(l));
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-01 23:33:24
|
Revision: 1188
http://jason.svn.sourceforge.net/jason/?rev=1188&view=rev
Author: tomklapiscak
Date: 2008-04-01 16:33:22 -0700 (Tue, 01 Apr 2008)
Log Message:
-----------
Started work on new jasdl.test package. Far more comprehensive JasdlBeliefBase implemented (matches behaviour against Jason's default).
Bug fixes.
Agent configuration improvement.
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/build.xml
trunk/applications/jasdl-owlapi/lib/junit.jar
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
Added Paths:
-----------
trunk/applications/jasdl-owlapi/src/jasdl/test/
trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
trunk/applications/jasdl-owlapi/src/jasdl/test/blank.asl
trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlConfigurationException.java
Modified: trunk/applications/jasdl-owlapi/build.xml
===================================================================
--- trunk/applications/jasdl-owlapi/build.xml 2008-04-01 16:15:10 UTC (rev 1187)
+++ trunk/applications/jasdl-owlapi/build.xml 2008-04-01 23:33:22 UTC (rev 1188)
@@ -1,16 +1,16 @@
<project basedir="." default="jar" name="jasdl">
- <property name="source.dir" value="${basedir}/src" />
+ <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" />
<property name="jar.file" value="${basedir}/lib/jasdl.jar" />
-
- <path id="project.classpath">
+
+ <path id="project.classpath">
<pathelement location="../../lib/jason.jar"/>
<pathelement location="../../applications/jmca/lib/jmca.jar"/>
<fileset dir="./lib">
<include name="**/*.jar"/>
- </fileset>
+ </fileset>
</path>
<path id="test.classpath">
@@ -21,18 +21,18 @@
<target name="init">
<tstamp/>
<mkdir dir="${build.dir}"/>
- </target>
-
- <target name="compile" depends="init">
- <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>
- </target>
-
- <target name="jar" depends="compile">
- <jar destfile="${jar.file}" basedir="./bin" includes="**/*.class"/>
</target>
+ <target name="compile" depends="init">
+ <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>
+ </target>
+
+ <target name="jar" depends="compile">
+ <jar destfile="${jar.file}" basedir="./bin" includes="**/*.class"/>
+ </target>
+
<target name="clean">
<delete dir="${build.dir}"/>
<delete file="${jar.file}"/>
@@ -45,7 +45,7 @@
<classpath refid="test.classpath" />
<formatter type="plain" usefile="false" />
<batchtest>
- <fileset dir="${source.dir}/jasdl/test" includes="*Test.java" />
+ <fileset dir="${source.dir}" includes="jasdl/test/*Test.java" />
</batchtest>
</junit>
<fail message="test failed" if="test.failure" />
@@ -66,5 +66,5 @@
</javadoc>
</target>
-
+
</project>
Modified: trunk/applications/jasdl-owlapi/lib/junit.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-01 16:15:10 UTC (rev 1187)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-01 23:33:22 UTC (rev 1188)
@@ -15,7 +15,6 @@
import jasdl.bridge.alias.Alias;
import jasdl.bridge.alias.AliasFactory;
import jasdl.bridge.alias.AliasManager;
-import jasdl.bridge.alias.DecapitaliseMappingStrategy;
import jasdl.bridge.alias.DefinitionManager;
import jasdl.bridge.alias.MappingStrategy;
import jasdl.bridge.label.LabelManager;
@@ -41,7 +40,6 @@
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -51,6 +49,7 @@
import jmca.asSemantics.JmcaAgent;
+import org.apache.commons.logging.impl.Log4JLogger;
import org.coode.manchesterowlsyntax.ManchesterOWLSyntaxDescriptionParser;
import org.mindswap.pellet.owlapi.Reasoner;
import org.semanticweb.owl.apibinding.OWLManager;
@@ -71,9 +70,8 @@
import uk.ac.manchester.cs.owl.mansyntaxrenderer.ManchesterOWLSyntaxOWLObjectRendererImpl;
public class JasdlAgent extends JmcaAgent{
- public static List<MappingStrategy> DEFAULT_MAPPING_STRATEGIES = Arrays.asList( new MappingStrategy[] { new DecapitaliseMappingStrategy()} );
- public static String DEFAULT_REASONER_CLASS = "org.mindswap.pellet.owlapi.Reasoner";
+
private OWLOntologyManager ontologyManager;
private OWLReasoner reasoner;
private AliasManager aliasManager;
@@ -86,24 +84,23 @@
private ManchesterOWLSyntaxOWLObjectRendererImpl manchesterObjectRenderer;
private ManchesterOWLSyntaxDescriptionParser manchesterNsPrefixDescriptionParser;
- private ManchesterOWLSyntaxDescriptionParser manchesterURIDescriptionParser;
+ private ManchesterOWLSyntaxDescriptionParser manchesterURIDescriptionParser;
- private List<MappingStrategy> defaultMappingStrategies;
public static String ANON_LABEL_PREFIX = "anon_label_";
public static String ANON_ALIAS_PREFIX = "anon_alias_";
private DefinitionManager definitionManager;
+ private List<String> knownAgentNames;
private HashMap<Atom, Float> trustMap;
- private boolean beliefRevisionEnabled = true;
-
+ private boolean beliefRevisionEnabled;
+ private List<MappingStrategy> defaultMappingStrategies = JasdlConfigurator.DEFAULT_MAPPING_STRATEGIES;
public JasdlAgent(){
super();
- defaultMappingStrategies = DEFAULT_MAPPING_STRATEGIES;
// instantiate managers
aliasManager = new AliasManager();
@@ -117,6 +114,7 @@
toAxiomConverter = new ToAxiomConverter(this);
toSELiteralConverter = new ToSELiteralConverter(this);
+ knownAgentNames = new Vector<String>();
trustMap = new HashMap<Atom, Float>();
manchesterObjectRenderer = new ManchesterOWLSyntaxOWLObjectRendererImpl();
@@ -133,13 +131,38 @@
// override plan library
setPL( new JasdlPlanLibrary(this) );
+
}
public void setReasoner(OWLReasoner reasoner){
this.reasoner = reasoner;
}
+ public void addKnownAgentName(String name){
+ knownAgentNames.add(name);
+ }
+ public List<String> getKnownAgentNames(){
+ return knownAgentNames;
+ }
+
+
+ public void setReasonerLogLevel(org.apache.log4j.Level level){
+ if(reasoner instanceof org.mindswap.pellet.owlapi.Reasoner){
+ org.mindswap.pellet.owlapi.Reasoner pellet = (org.mindswap.pellet.owlapi.Reasoner)reasoner;
+ Log4JLogger abox_logger = (Log4JLogger)pellet.getKB().getABox().log;
+ abox_logger.getLogger().setLevel(level);
+
+ Log4JLogger taxonomy_logger = (Log4JLogger)pellet.getKB().getTaxonomy().log;
+ taxonomy_logger.getLogger().setLevel(level);
+
+ Log4JLogger kb_logger = (Log4JLogger)pellet.getKB().log;
+ kb_logger.getLogger().setLevel(level);
+ }
+ }
+
+
+
@Override
public TransitionSystem initAg(AgArch arch, BeliefBase bb, String src, Settings stts) throws JasonException {
if(!(bb instanceof JasdlBeliefBase)){
@@ -582,7 +605,7 @@
}
public URI getPersonalOntologyURI(Atom label) {
- return URI.create("http://www.dur.ac.uk/t.g.klapiscak/"+label+".owl");
+ return URI.create("http://www.dur.ac.uk/t.g.klapiscak/self"+label+".owl");
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-04-01 16:15:10 UTC (rev 1187)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-04-01 23:33:22 UTC (rev 1188)
@@ -4,7 +4,9 @@
import static jasdl.util.Common.strip;
import jasdl.bridge.alias.Alias;
import jasdl.bridge.alias.AliasFactory;
+import jasdl.bridge.alias.DecapitaliseMappingStrategy;
import jasdl.bridge.alias.MappingStrategy;
+import jasdl.util.JasdlConfigurationException;
import jasdl.util.JasdlException;
import jason.asSyntax.Atom;
import jason.runtime.Settings;
@@ -15,24 +17,29 @@
import java.util.List;
import java.util.Vector;
+import org.apache.log4j.Level;
import org.semanticweb.owl.inference.OWLReasoner;
import org.semanticweb.owl.model.OWLEntity;
import org.semanticweb.owl.model.OWLOntology;
import org.semanticweb.owl.model.OWLOntologyManager;
public class JasdlConfigurator {
- private static String MAS2J_PREFIX = "jasdl";
- private static String MAS2J_ONTOLOGIES = "_ontologies";
- private static String MAS2J_URI = "_uri";
- private static String MAS2J_MAPPING_STRATEGIES = "_mapping_strategies";
- private static String MAS2J_MAPPING_MANUAL = "_mapping_manual";
- private static String MAS2J_TRUSTRATING = "_trustRating";
- private static String MAS2J_KNOWNAGENTS = "_knownAgents";
- private static String MAS2J_USEBELIEFREVISION = "_useBeliefRevision";
- private static String MAS2J_REASONERCLASS = "_reasonerClass";
+ public static String MAS2J_PREFIX = "jasdl";
+ public static String MAS2J_ONTOLOGIES = "_ontologies";
+ public static String MAS2J_URI = "_uri";
+ public static String MAS2J_MAPPING_STRATEGIES = "_mapping_strategies";
+ public static String MAS2J_MAPPING_MANUAL = "_mapping_manual";
+ public static String MAS2J_TRUSTRATING = "_trustRating";
+ public static String MAS2J_KNOWNAGENTS = "_knownAgents";
+ public static String MAS2J_USEBELIEFREVISION = "_useBeliefRevision";
+ public static String MAS2J_REASONERCLASS = "_reasonerClass";
+ public static List<MappingStrategy> DEFAULT_MAPPING_STRATEGIES = Arrays.asList( new MappingStrategy[] { new DecapitaliseMappingStrategy()} );
+ public static String DEFAULT_REASONER_CLASS = "org.mindswap.pellet.owlapi.Reasoner";
+ public static boolean DEFAULT_USEBELIEFREVISION = false;
+
/**
* List of reserved ontology labels. Currently:
* <ul>
@@ -55,30 +62,25 @@
public void configure(Settings stts) throws JasdlException{
try{
loadReasoner(stts);
-
- // load default mapping strategies
- agent.setDefaultMappingStrategies(getMappingStrategies(stts, new Atom("default"))); //implication "default" is a reserved ontology label
-
- // set whether to use belief revision or not
- String useBeliefRevision = prepareUserParameter(stts, MAS2J_PREFIX + MAS2J_USEBELIEFREVISION);
- agent.setBeliefRevisionEnabled(Boolean.parseBoolean(useBeliefRevision));
-
+ loadDefaultMappingStrategies(stts);
+ setUseBeliefRevision(stts);
loadOntologies(stts);
- applyManualMappings(stts);
- loadTrustRatings(stts);
-
-
-
+ applyManualMappings(stts);
+ loadKnownAgents(stts);
+ loadTrustRatings(stts);
}catch(JasdlException e){
throw new JasdlException("JASDL agent encountered error during configuration. Reason: "+e);
}
}
+ @SuppressWarnings("unchecked")
private void loadReasoner(Settings stts) throws JasdlException{
- String reasonerClass = prepareUserParameter( stts, MAS2J_PREFIX + MAS2J_REASONERCLASS);
- if(reasonerClass.length() == 0){
- reasonerClass = JasdlAgent.DEFAULT_REASONER_CLASS;
- }
+ String reasonerClass;
+ try{
+ reasonerClass = prepareUserParameter( stts, MAS2J_PREFIX + MAS2J_REASONERCLASS);
+ }catch(JasdlConfigurationException e){
+ reasonerClass = DEFAULT_REASONER_CLASS;
+ }
try {
Class cls = Class.forName(reasonerClass);
Constructor ct = cls.getConstructor(new Class[] {OWLOntologyManager.class});
@@ -87,13 +89,28 @@
throw new JasdlException("Unknown reasoner class: "+reasonerClass);
}else{
agent.setReasoner(reasoner);
+ agent.setReasonerLogLevel(Level.WARN);
}
}catch (Throwable e) {
throw new JasdlException("Error instantiating reasoner "+reasonerClass+". Reason: "+e);
}
}
+ private void loadDefaultMappingStrategies(Settings stts) throws JasdlException{
+ agent.setDefaultMappingStrategies(getMappingStrategies(stts, new Atom("default"))); //implication "default" is a reserved ontology label
+ }
+ private void setUseBeliefRevision(Settings stts) throws JasdlException{
+ try{
+ // set whether to use belief revision or not
+ String useBeliefRevision = prepareUserParameter(stts, MAS2J_PREFIX + MAS2J_USEBELIEFREVISION);
+ agent.setBeliefRevisionEnabled(Boolean.parseBoolean(useBeliefRevision));
+ }catch(JasdlConfigurationException e){
+ agent.setBeliefRevisionEnabled(DEFAULT_USEBELIEFREVISION);
+ }
+ }
+
+
/**
* Load ontologies as specified in .mas2j settings
* @param stts .mas2j settings
@@ -105,12 +122,13 @@
if(reservedOntologyLabels.contains(label)){
throw new JasdlException(label+" is a reserved ontology label");
}
- URI physicalURI;
+ String _uri = prepareUserParameter( stts, MAS2J_PREFIX + "_" + label + MAS2J_URI );
+ URI uri = null;
try {
- physicalURI = new URI(prepareUserParameter( stts, MAS2J_PREFIX + "_" + label + MAS2J_URI ));
- agent.loadOntology(new Atom(label), physicalURI, getMappingStrategies(stts, new Atom(label)));
+ uri = new URI(_uri);
+ agent.loadOntology(new Atom(label), uri, getMappingStrategies(stts, new Atom(label)));
} catch (Exception e) {
- throw new JasdlException("Unable to instantiate ontology \""+label+"\". Reason: "+e);
+ throw new JasdlException("Unable to instantiate ontology "+_uri+" (\""+label+"\"). Reason: "+e);
}
}
}
@@ -122,42 +140,55 @@
*/
private void applyManualMappings(Settings stts) throws JasdlException{
for(Atom label : agent.getLabelManager().getLefts()){
- String[] mappings = splitUserParameter(stts, MAS2J_PREFIX + "_" + label + MAS2J_MAPPING_MANUAL);
- for(String mapping : mappings){
- OWLOntology ontology = agent.getLabelManager().getRight(label);
- String[] split = mapping.split("=");
- if(split.length == 2){
- Alias alias = AliasFactory.INSTANCE.create(new Atom(split[0].trim()), label);
- URI uri = URI.create(ontology.getURI() + "#" + split[1].trim());
- OWLEntity entity = agent.toEntity(uri);
-
- if(agent.getAliasManager().isKnownRight(entity)){ // manual mappings override automatic ones
- agent.getAliasManager().removeByRight(entity);
+ try{
+ String[] mappings = splitUserParameter(stts, MAS2J_PREFIX + "_" + label + MAS2J_MAPPING_MANUAL);
+ for(String mapping : mappings){
+ OWLOntology ontology = agent.getLabelManager().getRight(label);
+ String[] split = mapping.split("=");
+ if(split.length == 2){
+ Alias alias = AliasFactory.INSTANCE.create(new Atom(split[0].trim()), label);
+ URI uri = URI.create(ontology.getURI() + "#" + split[1].trim());
+ OWLEntity entity = agent.toEntity(uri);
+
+ if(agent.getAliasManager().isKnownRight(entity)){ // manual mappings override automatic ones
+ agent.getAliasManager().removeByRight(entity);
+ }
+
+ agent.getAliasManager().put(alias, entity);
}
-
- agent.getAliasManager().put(alias, entity);
}
+ }catch(JasdlConfigurationException e){
+ // manual mappings are optional
}
}
}
+ private void loadKnownAgents(Settings stts) throws JasdlException{
+ try{
+ String[] names = (splitUserParameter(stts, MAS2J_PREFIX + MAS2J_KNOWNAGENTS));
+ for(String name : names){
+ agent.addKnownAgentName(name);
+ }
+ }catch(JasdlConfigurationException e){
+ // optional parameter, default to empty
+ }
+ }
+
+
+ // TODO: set trust ratings for assertions predefined in ontology schema (maybe annotated with self)
private void loadTrustRatings(Settings stts) throws JasdlException{
// agent trusts itself completely!
- agent.setTrustRating(new Atom("self"), 1f);
-
- // load trust ratings
- String[] knownAgents = splitUserParameter(stts, MAS2J_PREFIX + MAS2J_KNOWNAGENTS);
- for(String knownAgent : knownAgents){
- if(knownAgent.length() > 0){
- String _trustRating = prepareUserParameter(stts, MAS2J_PREFIX + "_" + knownAgent + MAS2J_TRUSTRATING);
- Float trustRating;
- try{
- trustRating = Float.parseFloat(_trustRating);
- }catch(NumberFormatException e){
- throw new JasdlException("Invalid trust rating for "+knownAgent+". Reason: "+e);
- }
- agent.setTrustRating(new Atom(knownAgent), trustRating);
+ agent.setTrustRating(new Atom("self"), 1f);
+ for(String knownAgent : agent.getKnownAgentNames()){
+ // load trust ratings (mandatory for known agents)
+ String _trustRating = prepareUserParameter(stts, MAS2J_PREFIX + "_" + knownAgent + MAS2J_TRUSTRATING);
+ Float trustRating;
+ try{
+ trustRating = Float.parseFloat(_trustRating);
+ }catch(NumberFormatException e){
+ throw new JasdlException("Invalid trust rating for "+knownAgent+". Reason: "+e);
}
+ agent.setTrustRating(new Atom(knownAgent), trustRating);
}
}
@@ -169,11 +200,12 @@
* Applies mappings to all resources in an ontology according to composition of supplied strategies.
* @param stts .mas2j settings
*/
+ @SuppressWarnings("unchecked")
private List<MappingStrategy> getMappingStrategies(Settings stts, Atom label) throws JasdlException{
List<MappingStrategy> strategies = new Vector<MappingStrategy>();
- String[] strategyNames = splitUserParameter(stts, MAS2J_PREFIX + "_" + label + MAS2J_MAPPING_STRATEGIES);
- for(String strategyName : strategyNames){
- if(strategyName.length() > 0){
+ try{
+ String[] strategyNames = splitUserParameter(stts, MAS2J_PREFIX + "_" + label + MAS2J_MAPPING_STRATEGIES);
+ for(String strategyName : strategyNames){
try {
Class cls = Class.forName(strategyName);
Constructor ct = cls.getConstructor(new Class[] {});
@@ -187,10 +219,9 @@
throw new JasdlException("Error instantiating mapping strategy "+strategyName+". Reason: "+e);
}
}
+ }catch(JasdlConfigurationException e){
+ strategies = agent.getDefaultMappingStrategies(); // mapping strategies optional, use defaults if not set
}
- if(strategies.size() == 0){
- strategies = agent.getDefaultMappingStrategies();
- }
return strategies;
}
@@ -206,10 +237,10 @@
* @param name name of the setting to prepare
* @return
*/
- private String prepareUserParameter(Settings stts, String name){
+ private String prepareUserParameter(Settings stts, String name) throws JasdlConfigurationException{
String p = stts.getUserParameter(name);
if(p == null){
- return "";
+ throw new JasdlConfigurationException(name+" is not set!");
}else{
return strip(p, "\"").trim();
}
@@ -221,7 +252,7 @@
* @param name name of the setting to split
* @return
*/
- private String[] splitUserParameter(Settings stts, String name, String delim){
+ private String[] splitUserParameter(Settings stts, String name, String delim) throws JasdlConfigurationException{
String[] elems = prepareUserParameter(stts, name).split(delim);
for(int i=0; i<elems.length; i++){
elems[i] = strip(elems[i], "\"").trim();
@@ -235,7 +266,7 @@
* @param name name of the setting to split
* @return
*/
- private String[] splitUserParameter(Settings stts, String name){
+ private String[] splitUserParameter(Settings stts, String name) throws JasdlConfigurationException{
return splitUserParameter(stts, name, DELIM);
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-01 16:15:10 UTC (rev 1187)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-01 23:33:22 UTC (rev 1188)
@@ -14,6 +14,8 @@
import jason.asSyntax.Term;
import jason.bb.DefaultBeliefBase;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -77,8 +79,7 @@
getLogger().fine("... semantically-naive");
return super.add(l); // semantically-naive, use standard Jason mechanisms
}catch(Exception e){
- getLogger().warning("Exception caught adding SELiteral "+l+" to belief base: ");
- e.printStackTrace();
+ getLogger().fine("Exception caught adding SELiteral "+l+" to belief base: "+e);
return false;
}
}
@@ -207,6 +208,8 @@
/**
* TODO: Currently only returns asserted ABox axioms. Include option to also show inferences?
+ * Doesn't return beliefs in same order as Jason (could sort stricly alphabetically - but this would be costly
+ * isn't even exactly identical to Jason's behaviour - does it really matter anyway?)
*/
@Override
public Iterator<Literal> iterator() {
@@ -223,8 +226,10 @@
bels.addAll(agent.getABoxState());
}catch(JasdlException e){
getLogger().warning("Exception caught while retrieving ABox state: "+e);
- }
+ }
+ //Collections.sort(bels);
+
return bels.iterator();
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-04-01 16:15:10 UTC (rev 1187)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-04-01 23:33:22 UTC (rev 1188)
@@ -124,7 +124,10 @@
return agent.getAliasManager().getRight(this.toAlias());
}catch(UnknownMappingException e){
Alias alias = toAlias();
- if(alias.getFunctor().toString().startsWith("~")){
+ if(alias.getFunctor().toString().startsWith("~")){
+ if(literal.getArity() == 2){
+ throw new InvalidSELiteralException("JASDL does not currently support negated property assertions");
+ }
Atom negatedFunctor = new Atom(alias.getFunctor().toString().substring(1));
Alias negatedAlias = AliasFactory.INSTANCE.create( negatedFunctor, alias.getLabel());
if(negatedAlias.equals(AliasFactory.OWL_THING) || negatedAlias.equals(AliasFactory.OWL_NOTHING)){
Added: trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-01 23:33:22 UTC (rev 1188)
@@ -0,0 +1,349 @@
+package jasdl.test;
+
+import static jasdl.asSemantics.JasdlConfigurator.MAS2J_ONTOLOGIES;
+import static jasdl.asSemantics.JasdlConfigurator.MAS2J_PREFIX;
+import static jasdl.asSemantics.JasdlConfigurator.MAS2J_URI;
+import static jasdl.asSemantics.JasdlConfigurator.MAS2J_USEBELIEFREVISION;
+import jasdl.architecture.JasdlAgArch;
+import jasdl.asSemantics.JasdlAgent;
+import jasdl.bb.JasdlBeliefBase;
+import jasdl.bridge.alias.Alias;
+import jasdl.bridge.seliteral.SELiteral;
+import jasdl.bridge.xsd.XSDDataType;
+import jasdl.bridge.xsd.XSDDataTypeUtils;
+import jason.architecture.AgArch;
+import jason.architecture.AgArchInfraTier;
+import jason.asSyntax.Atom;
+import jason.asSyntax.DefaultTerm;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Structure;
+import jason.asSyntax.Term;
+import jason.bb.DefaultBeliefBase;
+import jason.infra.centralised.CentralisedAgArch;
+import jason.mas2j.ClassParameters;
+import jason.runtime.Settings;
+
+import java.lang.reflect.Constructor;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.semanticweb.owl.model.OWLClass;
+import org.semanticweb.owl.model.OWLDataProperty;
+import org.semanticweb.owl.model.OWLDataType;
+import org.semanticweb.owl.model.OWLObjectProperty;
+import org.semanticweb.owl.model.OWLOntology;
+
+
+/**
+ * Tests that behaviour of JASDL's BB is identical to that of Jason's default BB.
+ *
+ * Note that the ordering of JASDL's iterator function doesn't emulate Jason's exactly (Jason's is not strictly alphabetical and has a few odd quirks).
+ * As a result, we compare the results of the iterator functions using Sets.
+ *
+ * No thought it given to consistency of additions. This is dealt with by the brf before these methods are called.
+ * A seperate test suite must be developed for belief bases employing the legacy rollback consistency assurance mechanism.
+ *
+ * @author Tom Klapiscak
+ *
+ */
+public class JasdlBeliefBaseTest extends TestCase{
+
+ public static String JASDL_AG_ARCH_CLASS = "jasdl.architecture.JasdlAgArch";
+ public static String JASDL_AGENT_CLASS = "jasdl.asSemantics.JasdlAgent";
+ public static String JASDL_BELIEF_BASE_CLASS = "jasdl.bb.JasdlBeliefBase";
+
+ public static String TEST_ONTOLOGY_LABEL = "test";
+ public static String TEST_ONTOLOGY_URI = "http://www.dur.ac.uk/t.g.klapiscak/onts/travel.owl";
+
+ protected JasdlAgArch arch;
+ protected JasdlAgent agent;
+ protected JasdlBeliefBase bb;
+ protected DefaultBeliefBase testbb;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void setUp() throws Exception {
+ // Use default manual mappings, mapping strategies and reasoner class. No known agents + trust ratings
+ Settings stts = new Settings();
+ stts.addOption(MAS2J_PREFIX + MAS2J_ONTOLOGIES, TEST_ONTOLOGY_LABEL);
+ stts.addOption(MAS2J_PREFIX + "_" + TEST_ONTOLOGY_LABEL + MAS2J_URI, TEST_ONTOLOGY_URI);
+ stts.addOption(MAS2J_PREFIX + MAS2J_USEBELIEFREVISION, "true"); // Must be enabled (we don't want legacy consistency assurance!) - remember brf is skipped by this
+ String aslFile = getClass().getResource("blank.asl").toExternalForm();
+
+ // load arch
+ Class cls = Class.forName(JASDL_AG_ARCH_CLASS);
+ Constructor ct = cls.getConstructor(new Class[] {});
+ AgArch arch = (AgArch)ct.newInstance(new Object[] {});
+ AgArchInfraTier archInfraTier = new CentralisedAgArch();
+ arch.setArchInfraTier(archInfraTier);
+ arch.initAg(JASDL_AGENT_CLASS, new ClassParameters(JASDL_BELIEF_BASE_CLASS), aslFile, stts);
+
+ agent = (JasdlAgent)arch.getTS().getAg();
+ bb = (JasdlBeliefBase)agent.getBB();
+
+ testbb = new DefaultBeliefBase();
+
+ /*
+ // ensure initial state of testbb contained predefinitions from bb's ABox
+ // Add in reverse order, so iterator ordering is identical
+ List<Literal> state = new Vector<Literal>();
+ Iterator<Literal> bbit = bb.iterator();
+ while(bbit.hasNext()){
+ state.add(bbit.next());
+ }
+ Collections.reverse(state);
+ for(Literal l : state){
+ testbb.add(l);
+ }
+ */
+
+
+ // we are not worrying about ordering of iterator anymore
+ Iterator<Literal> bbit = bb.iterator();
+ while(bbit.hasNext()){
+ testbb.add(bbit.next());
+ }
+
+
+
+
+
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testAddLiteral() throws Exception{
+
+ boolean[] signs = new boolean[] {true, false};
+
+ for(OWLOntology ontology : agent.getOntologyManager().getOntologies()){
+ for(int run=0; run<=1; run++){ // run twice to ensure duplicate additions are rejected
+ for(boolean sign : signs){
+ for(OWLClass cls : ontology.getReferencedClasses()){
+ Alias alias = agent.getAliasManager().getLeft(cls);
+ String label = alias.getLabel().getFunctor();
+ String functor = alias.getFunctor().getFunctor();
+ assertAddClass(sign, functor, "a", label);
+ assertAddClass(sign, functor, "b", label);
+ }
+ for(OWLObjectProperty oprop : ontology.getReferencedObjectProperties()){
+ Alias alias = agent.getAliasManager().getLeft(oprop);
+ String label = alias.getLabel().getFunctor();
+ String functor = alias.getFunctor().getFunctor();
+ assertAddObjectProperty(sign, functor, "a", "b", label);
+ assertAddObjectProperty(sign, functor, "b", "a", label);
+ assertAddObjectProperty(sign, functor, "a", "a", label); // irreflexive properties shouldn't be rejected at this stage
+ }
+
+ for(OWLDataProperty dprop : ontology.getReferencedDataProperties()){
+ Alias alias = agent.getAliasManager().getLeft(dprop);
+ String label = alias.getLabel().getFunctor();
+ String functor = alias.getFunctor().getFunctor();
+ XSDDataType typ = XSDDataTypeUtils.get(((OWLDataType)dprop.getRanges(ontology).toArray()[0]).toString());
+ if(typ == XSDDataType.XSD_BOOLEAN){
+ assertAddDataProperty(sign, functor, "a", "false", label);
+ assertAddDataProperty(sign, functor, "a", "true", label);
+ }else if(typ == XSDDataType.XSD_DATE){
+ assertAddDataProperty(sign, functor, "a", "\"2007-12-20\"", label);
+ }else if(typ == XSDDataType.XSD_DATETIME){
+ assertAddDataProperty(sign, functor, "a", "\"2007-12-20T20:16:55\"", label);
+ }else if(typ == XSDDataType.XSD_DOUBLE){
+ assertAddDataProperty(sign, functor, "a", "22.0", label);
+ }else if(typ == XSDDataType.XSD_FLOAT){
+ assertAddDataProperty(sign, functor, "a", "0.5", label);
+ }else if(typ == XSDDataType.XSD_INT){
+ assertAddDataProperty(sign, functor, "a", "22", label);
+ }else if(typ == XSDDataType.XSD_STRING){
+ assertAddDataProperty(sign, functor, "a", "\"Winchester\"", label);
+ }else if(typ == XSDDataType.XSD_TIME){
+ assertAddDataProperty(sign, functor, "a", "\"20:16:57\"", label);
+ }
+ }
+
+ }
+ }
+ }
+
+
+
+
+ Set<Literal> expected = new HashSet<Literal>();
+ Iterator<Literal> testbbit = testbb.iterator();
+
+ while(testbbit.hasNext()){
+ expected.add(testbbit.next());
+ }
+
+ Set<Literal> actual = new HashSet<Literal>();
+ Iterator<Literal> bbit = bb.iterator();
+ while(bbit.hasNext()){
+ actual.add(bbit.next());
+ }
+
+ Set<Literal> actuallyLessDifference = new HashSet<Literal>();
+ actuallyLessDifference.addAll(expected);
+ actuallyLessDifference.removeAll(actual);
+ if(!actuallyLessDifference.isEmpty()){
+ System.out.println("\n\nexpected > actual. Difference: "+actuallyLessDifference+"\n\n");
+ }
+
+ Set<Literal> actuallyMoreDifference = new HashSet<Literal>();
+ actuallyMoreDifference.addAll(actual);
+ actuallyMoreDifference.removeAll(expected);
+ if(!actuallyMoreDifference.isEmpty()){
+ System.out.println("\n\nexpected < actual. Difference: "+actuallyMoreDifference+"\n\n");
+ }
+
+ //System.out.println("Terminal state: "+actual);
+
+ assertEquals(expected, actual);
+ //System.out.println("Terminal state consistent? "+);
+
+
+
+ }
+
+
+ /**
+ * Constructs functor and annotations (including ontology annotation) of a SE-Literal.
+ * @param sign
+ * @param functor
+ * @param annots
+ * @return
+ */
+ private Literal constructSELiteral(boolean sign, String functor, String label){
+ Literal l = new Literal(sign, functor);
+ addO(l, label);
+ return l;
+ }
+
+ /**
+ * Adds the ontology annotation with the specified label to the supplied literal
+ * @param l
+ */
+ private void addO(Literal l, String label){
+ Structure o = new Structure(SELiteral.ONTOLOGY_ANNOTATION_FUNCTOR);
+ o.addTerm(new Atom(label));
+ l.addAnnot(o);
+ }
+
+ /**
+ * Constructs SE-Literal, adds terms
+ * recognises special cases (i.e. negated properties)
+ * otherwise, ensures behaviour is identical to Jason's BB.
+ * Additionally, tries with "x", then "y" annots added.
+ * @param sign
+ * @param functor
+ * @param annots
+ * @param is
+ * @param expected
+ */
+ private void assertAdd(boolean sign, String functor, List<Term> is, String label){
+ Term[][] annotSets = new Term[][] {new Term[]{}, new Term[] {new Atom("x")}, new Term[] {new Atom("x"), new Atom("y")} };
+ for(Term[] annots : annotSets){
+ Literal l = constructSELiteral(sign, functor, label);
+ l.addTerms(is);
+ l.addAnnots(Arrays.asList(annots));
+ // special case: reject ~thing and ~nothing
+ if(!sign && (functor.equals("thing") || functor.equals("nothing"))){
+ assertFalse(bb.add(l));return;
+ }
+ //special case: reject negated property assertions
+ if(!sign && l.getArity() == 2){
+ assertFalse(bb.add(l));return;
+ }
+ //System.out.println("Adding: "+l);
+ assertEquals(testbb.add((Literal)l.clone()), bb.add((Literal)l.clone())); // cloning necessary since Jason's default bb.add affects l passed to it
+ }
+
+ // TODO: error in Jason's BB below? Rejects additions even though annots changed!
+ // might be because deffault bb.add affects literals?
+ //l.addAnnot(new Atom("x"));
+ //System.out.println("Adding: "+l);
+ //assertEquals(testbb.add(l), bb.add(l));
+ //l.addAnnot(new Atom("y"));
+ //System.out.println("Adding: "+l);
+ //assertEquals(testbb.add(l), bb.add(l));
+ }
+
+
+ /**
+ * Convenience method for testing class assertion additions (unary literals)
+ *
+ * @param sign
+ * @param functor
+ * @param annots
+ * @param i
+ * @param expected
+ */
+ private void assertAddClass(boolean sign, String functor, String i, String label){
+ assertAdd(sign, functor, Collections.singletonList((Term)new Atom(i)), label);
+ }
+
+ /**
+ * Convenience method for testing class assertion additions (unary literals)
+ *
+ * @param sign
+ * @param functor
+ * @param annots
+ * @param i
+ * @param expected
+ */
+ private void assertAddDataProperty(boolean sign, String functor, String s, String o, String label){
+ assertAdd(sign, functor, Arrays.asList(new Term[] {new Atom(s), DefaultTerm.parse(o)}), label);
+ }
+
+ /**
+ * Convenience method for testing class assertion additions (unary literals)
+ *
+ * @param sign
+ * @param functor
+ * @param annots
+ * @param i
+ * @param expected
+ */
+ private void assertAddObjectProperty(boolean sign, String functor, String s, String o, String label){
+ assertAdd(sign, functor, Arrays.asList(new Term[] {new Atom(s), new Atom(o)}), label);
+ }
+
+
+ @Test
+ public void testRemoveLiteral() {
+ }
+
+ @Test
+ public void testContainsLiteral() {
+ }
+
+ @Test
+ public void testGetCandidateBeliefsLiteralUnifier() {
+ }
+
+ @Test
+ public void testIterator() {
+ }
+
+}
Added: trunk/applications/jasdl-owlapi/src/jasdl/test/blank.asl
===================================================================
Added: trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlConfigurationException.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlConfigurationException.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/JasdlConfigurationException.java 2008-04-01 23:33:22 UTC (rev 1188)
@@ -0,0 +1,29 @@
+/*
+ * 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/>.
+ *
+ */
+package jasdl.util;
+
+import jason.JasonException;
+
+
+public class JasdlConfigurationException extends JasdlException {
+ public JasdlConfigurationException(String message){
+ super(message);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-01 16:15:18
|
Revision: 1187
http://jason.svn.sourceforge.net/jason/?rev=1187&view=rev
Author: tomklapiscak
Date: 2008-04-01 09:15:10 -0700 (Tue, 01 Apr 2008)
Log Message:
-----------
Deleted old tests
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/src/jasdl/test/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-04-01 00:59:37
|
Revision: 1186
http://jason.svn.sourceforge.net/jason/?rev=1186&view=rev
Author: tomklapiscak
Date: 2008-03-31 17:59:33 -0700 (Mon, 31 Mar 2008)
Log Message:
-----------
Generalised to support any DL-reasoner supported by the OWL-API (can be set using jasdl_reasonerClass="..."). FACT++ support very buggy (and seemingly no faster), will stick to Pellet for the time being.
Minor performance enhancements (SE-Literal caches results of operations and brf doesn't validate removals generated by the BB revisor).
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
trunk/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl
trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToAxiomConverter.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
Added Paths:
-----------
trunk/applications/jasdl-owlapi/lib/FaCTpp-OWLAPI-v1.1.11.jar
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-03-31 21:56:43 UTC (rev 1185)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-04-01 00:59:33 UTC (rev 1186)
@@ -33,6 +33,13 @@
[
jasdl_useBeliefRevision = "true", // use experimental DL-based belief revision mechanism
+ /*
+ * To use FaCT++, set the below. Must have libFaCTPlusPlusJNI.so in /usr/lib (or the equivalent for Mac or Windows)
+ * FaCT++ support is buggy and incomplete. Defaults to Pellet (org.mindswap.pellet.owlapi.Reasoner), which seems to work
+ * must better
+ * jasdl_reasonerClass = "uk.ac.manchester.cs.factplusplus.owlapi.Reasoner",
+ */
+
jasdl_default_mapping_strategies="jasdl.bridge.alias.DecapitaliseMappingStrategy", // applied to incoming ontologies and those given no automapping
jasdl_ontologies="travel",
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl 2008-03-31 21:56:43 UTC (rev 1185)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl 2008-04-01 00:59:33 UTC (rev 1186)
@@ -3,12 +3,10 @@
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
- <!ENTITY dc "http://purl.org/dc/elements/1.1/" >
<!ENTITY owl11 "http://www.w3.org/2006/12/owl11#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY owl11xml "http://www.w3.org/2006/12/owl11-xml#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
- <!ENTITY daml "http://www.daml.org/2001/03/daml+oil#" >
<!ENTITY travel "http://www.owl-ontologies.com/travel.owl#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
]>
@@ -16,15 +14,13 @@
<rdf:RDF xmlns="http://www.owl-ontologies.com/travel.owl#"
xml:base="http://www.owl-ontologies.com/travel.owl"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl11="http://www.w3.org/2006/12/owl11#"
xmlns:owl11xml="http://www.w3.org/2006/12/owl11-xml#"
+ xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:daml="http://www.daml.org/2001/03/daml+oil#"
- xmlns:travel="http://www.owl-ontologies.com/travel.owl#"
- xmlns:owl="http://www.w3.org/2002/07/owl#">
+ xmlns:travel="http://www.owl-ontologies.com/travel.owl#">
<owl:Ontology rdf:about="">
<owl:versionInfo rdf:datatype="&xsd;string"
>1.0 by Holger Knublauch (ho...@sm...)</owl:versionInfo>
@@ -58,9 +54,9 @@
<!-- http://www.owl-ontologies.com/travel.owl#hasActivity -->
<owl:ObjectProperty rdf:about="#hasActivity">
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
<rdfs:range rdf:resource="#Activity"/>
<rdfs:domain rdf:resource="#Destination"/>
+ <rdfs:subPropertyOf rdf:resource="#hasThing"/>
<owl:inverseOf rdf:resource="#isOfferedAt"/>
</owl:ObjectProperty>
@@ -69,9 +65,9 @@
<!-- http://www.owl-ontologies.com/travel.owl#hasContact -->
<owl:ObjectProperty rdf:about="#hasContact">
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
<rdfs:domain rdf:resource="#Activity"/>
<rdfs:range rdf:resource="#Contact"/>
+ <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -79,8 +75,8 @@
<!-- http://www.owl-ontologies.com/travel.owl#hasDestination -->
<owl:ObjectProperty rdf:about="#hasDestination">
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
<rdfs:range rdf:resource="#Destination"/>
+ <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -90,8 +86,8 @@
<owl:ObjectProperty rdf:about="#hasPart">
<rdf:type rdf:resource="&owl;TransitiveProperty"/>
<rdfs:domain rdf:resource="#Destination"/>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
<rdfs:range rdf:resource="#Destination"/>
+ <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -116,10 +112,10 @@
<!-- http://www.owl-ontologies.com/travel.owl#isLocatedAt -->
<owl:ObjectProperty rdf:about="#isLocatedAt">
- <owl:inverseOf rdf:resource="#hasAccommodation"/>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
<rdfs:domain rdf:resource="#Accommodation"/>
<rdfs:range rdf:resource="#Destination"/>
+ <owl:inverseOf rdf:resource="#hasAccommodation"/>
+ <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -127,11 +123,11 @@
<!-- http://www.owl-ontologies.com/travel.owl#isOfferedAt -->
<owl:ObjectProperty rdf:about="#isOfferedAt">
- <rdfs:range rdf:resource="#Destination"/>
<rdfs:comment
>Generalised to apply to accommodations as well</rdfs:comment>
- <rdfs:subPropertyOf rdf:resource="#hasThing"/>
<rdfs:domain rdf:resource="#Activity"/>
+ <rdfs:range rdf:resource="#Destination"/>
+ <rdfs:subPropertyOf rdf:resource="#hasThing"/>
</owl:ObjectProperty>
@@ -139,10 +135,10 @@
<!-- http://www.owl-ontologies.com/travel.owl#isPartOf -->
<owl:ObjectProperty rdf:about="#isPartOf">
- <owl:inverseOf rdf:resource="#hasPart"/>
+ <rdfs:domain rdf:resource="#Destination"/>
<rdfs:range rdf:resource="#Destination"/>
+ <owl:inverseOf rdf:resource="#hasPart"/>
<rdfs:subPropertyOf rdf:resource="#hasThing"/>
- <rdfs:domain rdf:resource="#Destination"/>
</owl:ObjectProperty>
@@ -161,9 +157,9 @@
<!-- http://www.owl-ontologies.com/travel.owl#hasCity -->
<owl:DatatypeProperty rdf:about="#hasCity">
+ <rdfs:domain rdf:resource="#Contact"/>
<rdfs:subPropertyOf rdf:resource="#hasData"/>
<rdfs:range rdf:resource="&xsd;string"/>
- <rdfs:domain rdf:resource="#Contact"/>
</owl:DatatypeProperty>
@@ -174,22 +170,13 @@
- <!-- http://www.owl-ontologies.com/travel.owl#hasDuration -->
-
- <owl:DatatypeProperty rdf:about="#hasDuration">
- <rdfs:range rdf:resource="&xsd;duration"/>
- <rdfs:subPropertyOf rdf:resource="#hasData"/>
- </owl:DatatypeProperty>
-
-
-
<!-- http://www.owl-ontologies.com/travel.owl#hasEMail -->
<owl:DatatypeProperty rdf:about="#hasEMail">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
+ <rdfs:domain rdf:resource="#Contact"/>
<rdfs:subPropertyOf rdf:resource="#hasData"/>
<rdfs:range rdf:resource="&xsd;string"/>
- <rdfs:domain rdf:resource="#Contact"/>
</owl:DatatypeProperty>
@@ -198,30 +185,21 @@
<owl:DatatypeProperty rdf:about="#hasPricePerNight">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
- <rdfs:subPropertyOf rdf:resource="#hasData"/>
<rdfs:comment
>Stated in local currency</rdfs:comment>
<rdfs:domain rdf:resource="#Accommodation"/>
+ <rdfs:subPropertyOf rdf:resource="#hasData"/>
<rdfs:range rdf:resource="&xsd;double"/>
</owl:DatatypeProperty>
- <!-- http://www.owl-ontologies.com/travel.owl#hasStartDate -->
-
- <owl:DatatypeProperty rdf:about="#hasStartDate">
- <rdfs:subPropertyOf rdf:resource="#hasData"/>
- <rdfs:range rdf:resource="&xsd;dateTime"/>
- </owl:DatatypeProperty>
-
-
-
<!-- http://www.owl-ontologies.com/travel.owl#hasStreet -->
<owl:DatatypeProperty rdf:about="#hasStreet">
<rdfs:domain rdf:resource="#Contact"/>
- <rdfs:range rdf:resource="&xsd;string"/>
<rdfs:subPropertyOf rdf:resource="#hasData"/>
+ <rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
@@ -231,8 +209,8 @@
<owl:DatatypeProperty rdf:about="#hasZipCode">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<rdfs:domain rdf:resource="#Contact"/>
- <rdfs:range rdf:resource="&xsd;string"/>
<rdfs:subPropertyOf rdf:resource="#hasData"/>
+ <rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
@@ -260,8 +238,10 @@
<!-- http://www.owl-ontologies.com/travel.owl#AccommodationRating -->
<owl:Class rdf:about="#AccommodationRating">
- <owl:disjointWith rdf:resource="#Destination"/>
<owl:disjointWith rdf:resource="#Accommodation"/>
+ <owl:disjointWith rdf:resource="#Activity"/>
+ <owl:disjointWith rdf:resource="#Contact"/>
+ <owl:disjointWith rdf:resource="#Destination"/>
<rdfs:comment rdf:datatype="&xsd;string"
>Consists of exactly three individuals.</rdfs:comment>
</owl:Class>
@@ -272,7 +252,6 @@
<owl:Class rdf:about="#Activity">
<owl:disjointWith rdf:resource="#Accommodation"/>
- <owl:disjointWith rdf:resource="#AccommodationRating"/>
</owl:Class>
@@ -281,7 +260,6 @@
<owl:Class rdf:about="#Adventure">
<rdfs:subClassOf rdf:resource="#Activity"/>
- <owl:disjointWith rdf:resource="#Sports"/>
</owl:Class>
@@ -297,17 +275,17 @@
<owl:someValuesFrom>
<owl:Class>
<owl:unionOf rdf:parseType="Collection">
- <rdf:Description rdf:about="#Adventure"/>
<rdf:Description rdf:about="#Sports"/>
+ <rdf:Description rdf:about="#Adventure"/>
</owl:unionOf>
</owl:Class>
</owl:someValuesFrom>
</owl:Restriction>
+ <rdf:Description rdf:about="#Destination"/>
<owl:Restriction>
<owl:onProperty rdf:resource="#hasAccommodation"/>
<owl:someValuesFrom rdf:resource="#BudgetAccommodation"/>
</owl:Restriction>
- <rdf:Description rdf:about="#Destination"/>
</owl:intersectionOf>
</owl:Class>
</owl:equivalentClass>
@@ -329,6 +307,7 @@
<owl:Class rdf:about="#BedAndBreakfast">
<rdfs:subClassOf rdf:resource="#Accommodation"/>
+ <owl:disjointWith rdf:resource="#Hotel"/>
</owl:Class>
@@ -343,11 +322,11 @@
<owl:unionOf rdf:parseType="Collection">
<owl:Restriction>
<owl:onProperty rdf:resource="#hasRating"/>
- <owl:hasValue rdf:resource="#OneStarRating"/>
+ <owl:hasValue rdf:resource="#TwoStarRating"/>
</owl:Restriction>
<owl:Restriction>
<owl:onProperty rdf:resource="#hasRating"/>
- <owl:hasValue rdf:resource="#TwoStarRating"/>
+ <owl:hasValue rdf:resource="#OneStarRating"/>
</owl:Restriction>
</owl:unionOf>
</owl:Class>
@@ -437,10 +416,8 @@
<!-- http://www.owl-ontologies.com/travel.owl#Contact -->
<owl:Class rdf:about="#Contact">
- <owl:disjointWith rdf:resource="#Activity"/>
<owl:disjointWith rdf:resource="#Accommodation"/>
- <owl:disjointWith rdf:resource="#Destination"/>
- <owl:disjointWith rdf:resource="#AccommodationRating"/>
+ <owl:disjointWith rdf:resource="#Activity"/>
</owl:Class>
@@ -457,7 +434,9 @@
<!-- http://www.owl-ontologies.com/travel.owl#Destination -->
- <owl:Class rdf:about="#Destination"/>
+ <owl:Class rdf:about="#Destination">
+ <owl:disjointWith rdf:resource="#Contact"/>
+ </owl:Class>
@@ -467,6 +446,7 @@
<owl:equivalentClass>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
+ <rdf:Description rdf:about="#Destination"/>
<owl:Restriction>
<owl:onProperty rdf:resource="#hasAccommodation"/>
<owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality>
@@ -475,7 +455,6 @@
<owl:onProperty rdf:resource="#hasActivity"/>
<owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">2</owl:minCardinality>
</owl:Restriction>
- <rdf:Description rdf:about="#Destination"/>
</owl:intersectionOf>
</owl:Class>
</owl:equivalentClass>
@@ -505,7 +484,6 @@
<owl:Class rdf:about="#Hotel">
<rdfs:subClassOf rdf:resource="#Accommodation"/>
- <owl:disjointWith rdf:resource="#BedAndBreakfast"/>
</owl:Class>
@@ -516,11 +494,11 @@
<owl:equivalentClass>
<owl:Class>
<owl:intersectionOf rdf:parseType="Collection">
- <rdf:Description rdf:about="#Hotel"/>
<owl:Restriction>
<owl:onProperty rdf:resource="#hasRating"/>
<owl:hasValue rdf:resource="#ThreeStarRating"/>
</owl:Restriction>
+ <rdf:Description rdf:about="#Hotel"/>
</owl:intersectionOf>
</owl:Class>
</owl:equivalentClass>
@@ -541,6 +519,7 @@
<!-- http://www.owl-ontologies.com/travel.owl#NationalPark -->
<owl:Class rdf:about="#NationalPark">
+ <rdfs:subClassOf rdf:resource="#Destination"/>
<rdfs:subClassOf rdf:resource="#RuralArea"/>
<rdfs:subClassOf>
<owl:Restriction>
@@ -554,7 +533,6 @@
<owl:someValuesFrom rdf:resource="#Hiking"/>
</owl:Restriction>
</rdfs:subClassOf>
- <rdfs:subClassOf rdf:resource="#Destination"/>
</owl:Class>
@@ -582,8 +560,6 @@
<owl:Class rdf:about="#Relaxation">
<rdfs:subClassOf rdf:resource="#Activity"/>
- <owl:disjointWith rdf:resource="#Sports"/>
- <owl:disjointWith rdf:resource="#Sightseeing"/>
<owl:disjointWith rdf:resource="#Adventure"/>
</owl:Class>
@@ -603,7 +579,6 @@
<owl:Class rdf:about="#RuralArea">
<rdfs:subClassOf rdf:resource="#Destination"/>
- <owl:disjointWith rdf:resource="#UrbanArea"/>
</owl:Class>
@@ -620,8 +595,8 @@
<owl:Class rdf:about="#Sightseeing">
<rdfs:subClassOf rdf:resource="#Activity"/>
- <owl:disjointWith rdf:resource="#Sports"/>
<owl:disjointWith rdf:resource="#Adventure"/>
+ <owl:disjointWith rdf:resource="#Relaxation"/>
</owl:Class>
@@ -630,6 +605,9 @@
<owl:Class rdf:about="#Sports">
<rdfs:subClassOf rdf:resource="#Activity"/>
+ <owl:disjointWith rdf:resource="#Adventure"/>
+ <owl:disjointWith rdf:resource="#Relaxation"/>
+ <owl:disjointWith rdf:resource="#Sightseeing"/>
</owl:Class>
@@ -662,6 +640,7 @@
<owl:Class rdf:about="#UrbanArea">
<rdfs:subClassOf rdf:resource="#Destination"/>
+ <owl:disjointWith rdf:resource="#RuralArea"/>
</owl:Class>
@@ -728,8 +707,8 @@
<rdf:Description>
<rdf:type rdf:resource="&owl;AllDifferent"/>
<owl:distinctMembers rdf:parseType="Collection">
+ <rdf:Description rdf:about="#OneStarRating"/>
<rdf:Description rdf:about="#ThreeStarRating"/>
- <rdf:Description rdf:about="#TwoStarRating"/>
</owl:distinctMembers>
</rdf:Description>
<rdf:Description>
@@ -743,7 +722,7 @@
<rdf:type rdf:resource="&owl;AllDifferent"/>
<owl:distinctMembers rdf:parseType="Collection">
<rdf:Description rdf:about="#ThreeStarRating"/>
- <rdf:Description rdf:about="#OneStarRating"/>
+ <rdf:Description rdf:about="#TwoStarRating"/>
</owl:distinctMembers>
</rdf:Description>
</rdf:RDF>
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl 2008-03-31 21:56:43 UTC (rev 1185)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl 2008-04-01 00:59:33 UTC (rev 1186)
@@ -18,15 +18,29 @@
*
*/
-!example_UBB_1.
-!example_UBB_2.
-!example_QBB.
-!example_RPP.
-!example_all_different.
+!start(total).
+!start(ubb1).!example_UBB_1.!end(ubb1).
+!start(ubb2).!example_UBB_2.!end(ubb2).
+!start(qbb).!example_QBB.!end(qbb).
+!start(rpp).!example_RPP.!end(rpp).
+!start(all_different).!example_all_different.!end(all_different).
//!example_annotation_gathering.
-!example_KSAA.
+!start(ksaa).!example_KSAA.!end(ksaa).
+//!end(total) is within example_KSAA_complete to allow inter-agent communication to finish
+@start[atomic]
++!start(A)
+ <-
+ +counter(A, system.time).
+@end[atomic]
++!end(A)
+ <-
+ ?counter(A, StartTime);
+ -counter(A, _);
+ TotalTime = (system.time - StartTime) / 1000;
+ .print("Execution time for counter ",A,": ",TotalTime,"s").
+
@example_ubb_1[atomic]
+!example_UBB_1
<-
@@ -130,10 +144,7 @@
?H;
?bundle(R).
-@example_KSAA_complete[atomic]
-+example_KSAA_complete
- <-
- .print("Completed: Knowledge Sharing Among Agents").
+
/**
@@ -181,6 +192,13 @@
?familyDestination(butlins)[o(travel), something];
.print("Complete: annotation gathering").
+
+
+@example_KSAA_complete[atomic]
++example_KSAA_complete
+ <-
+ .print("Completed: Knowledge Sharing Among Agents");
+ !end(total).
Added: trunk/applications/jasdl-owlapi/lib/FaCTpp-OWLAPI-v1.1.11.jar
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jasdl-owlapi/lib/FaCTpp-OWLAPI-v1.1.11.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-03-31 21:56:43 UTC (rev 1185)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-04-01 00:59:33 UTC (rev 1186)
@@ -52,9 +52,10 @@
import jmca.asSemantics.JmcaAgent;
import org.coode.manchesterowlsyntax.ManchesterOWLSyntaxDescriptionParser;
-import org.mindswap.pellet.PelletOptions;
import org.mindswap.pellet.owlapi.Reasoner;
import org.semanticweb.owl.apibinding.OWLManager;
+import org.semanticweb.owl.inference.OWLReasoner;
+import org.semanticweb.owl.inference.OWLReasonerException;
import org.semanticweb.owl.model.OWLAxiom;
import org.semanticweb.owl.model.OWLClass;
import org.semanticweb.owl.model.OWLDescription;
@@ -71,9 +72,10 @@
public class JasdlAgent extends JmcaAgent{
public static List<MappingStrategy> DEFAULT_MAPPING_STRATEGIES = Arrays.asList( new MappingStrategy[] { new DecapitaliseMappingStrategy()} );
+ public static String DEFAULT_REASONER_CLASS = "org.mindswap.pellet.owlapi.Reasoner";
private OWLOntologyManager ontologyManager;
- private Reasoner reasoner;
+ private OWLReasoner reasoner;
private AliasManager aliasManager;
private LabelManager labelManager;
private SELiteralFactory seLiteralFactory;
@@ -129,19 +131,15 @@
manchesterNsPrefixDescriptionParser = new ManchesterOWLSyntaxDescriptionParser(ontologyManager.getOWLDataFactory(), new NSPrefixEntityChecker(this));
manchesterURIDescriptionParser = new ManchesterOWLSyntaxDescriptionParser(ontologyManager.getOWLDataFactory(), new URIEntityChecker(this));
- // instantiate (Pellet) reasoner
- PelletOptions.USE_TRACING = true;
- reasoner = new Reasoner(ontologyManager);
- reasoner.getKB().setDoExplanation( true );
-
// override plan library
setPL( new JasdlPlanLibrary(this) );
}
+ public void setReasoner(OWLReasoner reasoner){
+ this.reasoner = reasoner;
+ }
-
-
@Override
public TransitionSystem initAg(AgArch arch, BeliefBase bb, String src, Settings stts) throws JasonException {
if(!(bb instanceof JasdlBeliefBase)){
@@ -201,6 +199,9 @@
List<Literal> addList = new Vector<Literal>();
List<Literal> removeList = new Vector<Literal>();
+ // For efficiency reasons: no need to check beliefs to be contracted if established by BB revisor (since they are implicitly grounded)
+ boolean revisionApplied = false;
+
// just accept beliefToDel. Assumption: Deletions never lead to inconsistencies?!
if(beliefToDel != null){
getLogger().finest("Revise: -"+beliefToDel);
@@ -218,6 +219,7 @@
for(OWLAxiom contract : contractList){
removeList.add(toSELiteralConverter.convert((OWLIndividualAxiom)contract).getLiteral());
}
+ revisionApplied = true;
}catch(RevisionFailedException e){
throw e; // propagate upwards
}catch(NotEnrichedException e){
@@ -235,23 +237,28 @@
// Need to perform removals before additions so our ontology instance never becomes inconsistent
for(Literal removed : removeList){
- // we need to ground unground removals
- Unifier u = null;
- try {
- u = i.peek().getUnif(); // get from current intention
- } catch (Exception e) {
- u = new Unifier();
- }
- if (believes(removed, u)) {
- removed.apply(u);
+ boolean ok = false;
+ if(revisionApplied){
+ ok = true;
+ }else{
+ // we need to ground unground removals
+ Unifier u = null;
+ try {
+ u = i.peek().getUnif(); // get from current intention
+ } catch (Exception e) {
+ u = new Unifier();
+ }
+ ok = believes(removed, u);
+ if(ok) removed.apply(u);
+ }
+ if(ok){
if(getBB().remove(removed)){
if(toReturn == null){
toReturn = new List[2];
toReturn[0] = new Vector<Literal>();
toReturn[1] = new Vector<Literal>();
}
- toReturn[1].add(removed);
-
+ toReturn[1].add(removed);
}
}
}
@@ -382,8 +389,12 @@
return alreadyKnown;
}catch(UnknownMappingException e){}
Set<OWLOntology> imports = ontologyManager.getImportsClosure(ontology);
- reasoner.loadOntologies(imports);
- reasoner.classify();
+ try {
+ reasoner.loadOntologies(imports);
+ reasoner.classify();
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to load "+uri+". Reason: "+e);
+ }
initOntology(ontology, label, uri, ontology.getURI(), false); // (successfully) loaded ontologies never personal
applyMappingStrategies(ontology, strategies);
getLogger().fine("Loaded ontology from "+uri+" and assigned label "+label);
@@ -409,7 +420,11 @@
public OWLOntology createOntology(Atom label, URI uri, boolean isPersonal) throws JasdlException{
try{
OWLOntology ontology = getOntologyManager().createOntology( uri );
- getReasoner().loadOntology(ontology);
+ try{
+ getReasoner().loadOntologies(Collections.singleton(ontology));
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to load "+uri+". Reason: "+e);
+ }
initOntology(ontology, label, uri, uri, isPersonal);
return ontology;
} catch (OWLOntologyCreationException e) {
@@ -513,14 +528,30 @@
} catch (OWLOntologyChangeException e) {
throw new JasdlException("Error adding "+uri+" naming of "+desc+" to "+label);
}
- reasoner.refresh();
getLogger().fine("Adding named class "+uri+" for "+desc+" in "+label);
getAliasManager().put(alias, naming); // consequence, we can no longer easily distinguish run-time defined classes from pre-defined - need to maintain a map
getDefinitionManager().put(naming, desc);
+
+ refreshReasoner();
+
getLogger().fine("Defined new class with alias "+alias);
return desc;
}
+ public void refreshReasoner() throws JasdlException{
+ try {
+ if(reasoner instanceof uk.ac.manchester.cs.factplusplus.owlapi.Reasoner){
+ ((uk.ac.manchester.cs.factplusplus.owlapi.Reasoner)reasoner).classify();
+ }else if(reasoner instanceof org.mindswap.pellet.owlapi.Reasoner){
+ ((org.mindswap.pellet.owlapi.Reasoner)reasoner).refresh();
+ }else{
+ reasoner.classify();
+ }
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to refresh reasoner. Reason: "+e);
+ }
+ }
+
/**
* *Must* be unique within society!
* @return
@@ -581,7 +612,7 @@
- public Reasoner getReasoner() {
+ public OWLReasoner getReasoner() {
return reasoner;
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-03-31 21:56:43 UTC (rev 1185)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlConfigurator.java 2008-04-01 00:59:33 UTC (rev 1186)
@@ -2,7 +2,6 @@
import static jasdl.util.Common.DELIM;
import static jasdl.util.Common.strip;
-import jasdl.bridge.AllDifferentPlaceholder;
import jasdl.bridge.alias.Alias;
import jasdl.bridge.alias.AliasFactory;
import jasdl.bridge.alias.MappingStrategy;
@@ -16,20 +15,24 @@
import java.util.List;
import java.util.Vector;
+import org.semanticweb.owl.inference.OWLReasoner;
import org.semanticweb.owl.model.OWLEntity;
import org.semanticweb.owl.model.OWLOntology;
+import org.semanticweb.owl.model.OWLOntologyManager;
public class JasdlConfigurator {
private static String MAS2J_PREFIX = "jasdl";
private static String MAS2J_ONTOLOGIES = "_ontologies";
private static String MAS2J_URI = "_uri";
private static String MAS2J_MAPPING_STRATEGIES = "_mapping_strategies";
- private static String MAS2J_MAPPING_MANUAL = "_mapping_manual";
- private static String MAS2J_AGENT_NAME = "_agent_name";
+ private static String MAS2J_MAPPING_MANUAL = "_mapping_manual";
private static String MAS2J_TRUSTRATING = "_trustRating";
private static String MAS2J_KNOWNAGENTS = "_knownAgents";
private static String MAS2J_USEBELIEFREVISION = "_useBeliefRevision";
+ private static String MAS2J_REASONERCLASS = "_reasonerClass";
+
+
/**
* List of reserved ontology labels. Currently:
* <ul>
@@ -41,6 +44,8 @@
public static List<Atom> reservedOntologyLabels = Arrays.asList( new Atom[] {new Atom("default"), new Atom("self")});
+
+
private JasdlAgent agent;
public JasdlConfigurator(JasdlAgent agent){
@@ -49,6 +54,8 @@
public void configure(Settings stts) throws JasdlException{
try{
+ loadReasoner(stts);
+
// load default mapping strategies
agent.setDefaultMappingStrategies(getMappingStrategies(stts, new Atom("default"))); //implication "default" is a reserved ontology label
@@ -67,6 +74,26 @@
}
}
+ private void loadReasoner(Settings stts) throws JasdlException{
+ String reasonerClass = prepareUserParameter( stts, MAS2J_PREFIX + MAS2J_REASONERCLASS);
+ if(reasonerClass.length() == 0){
+ reasonerClass = JasdlAgent.DEFAULT_REASONER_CLASS;
+ }
+ try {
+ Class cls = Class.forName(reasonerClass);
+ Constructor ct = cls.getConstructor(new Class[] {OWLOntologyManager.class});
+ OWLReasoner reasoner = (OWLReasoner)ct.newInstance(new Object[] {agent.getOntologyManager()});
+ if(reasoner == null){
+ throw new JasdlException("Unknown reasoner class: "+reasonerClass);
+ }else{
+ agent.setReasoner(reasoner);
+ }
+ }catch (Throwable e) {
+ throw new JasdlException("Error instantiating reasoner "+reasonerClass+". Reason: "+e);
+ }
+ }
+
+
/**
* Load ontologies as specified in .mas2j settings
* @param stts .mas2j settings
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java 2008-03-31 21:56:43 UTC (rev 1185)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java 2008-04-01 00:59:33 UTC (rev 1186)
@@ -36,6 +36,7 @@
import java.util.Vector;
import org.semanticweb.owl.inference.OWLReasonerAdapter;
+import org.semanticweb.owl.inference.OWLReasonerException;
import org.semanticweb.owl.model.OWLClass;
import org.semanticweb.owl.model.OWLDataProperty;
import org.semanticweb.owl.model.OWLObject;
@@ -123,7 +124,7 @@
List<Trigger> tes = getMoreGeneralTriggers(agent, te);
List<Plan> moreGeneral = new Vector<Plan>();
for(Trigger generalised : tes){
- List<Plan> relevant = super.getAllRelevant(generalised);
+ List<Plan> relevant = super.getCandidatePlans(generalised);
if(relevant != null){
moreGeneral.addAll(relevant);
}
@@ -174,15 +175,19 @@
* @throws JasdlException
*/
public static List<OWLObject> generalise(JasdlAgent agent, OWLObject o) throws JasdlException{
- List<OWLObject> os = new Vector<OWLObject>();
- if(o instanceof OWLClass){
- os.addAll(OWLReasonerAdapter.flattenSetOfSets(agent.getReasoner().getAncestorClasses((OWLClass)o)));
- }else if(o instanceof OWLObjectProperty){
- os.addAll(OWLReasonerAdapter.flattenSetOfSets(agent.getReasoner().getAncestorProperties((OWLObjectProperty)o)));
- }else if(o instanceof OWLDataProperty){
- os.addAll(OWLReasonerAdapter.flattenSetOfSets(agent.getReasoner().getAncestorProperties((OWLDataProperty)o)));
- }
- return os;
+ try {
+ List<OWLObject> os = new Vector<OWLObject>();
+ if(o instanceof OWLClass){
+ os.addAll(OWLReasonerAdapter.flattenSetOfSets(agent.getReasoner().getAncestorClasses((OWLClass)o)));
+ }else if(o instanceof OWLObjectProperty){
+ os.addAll(OWLReasonerAdapter.flattenSetOfSets(agent.getReasoner().getAncestorProperties((OWLObjectProperty)o)));
+ }else if(o instanceof OWLDataProperty){
+ os.addAll(OWLReasonerAdapter.flattenSetOfSets(agent.getReasoner().getAncestorProperties((OWLDataProperty)o)));
+ }
+ return os;
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to generalise "+o+". Reason: "+e);
+ }
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-03-31 21:56:43 UTC (rev 1185)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-04-01 00:59:33 UTC (rev 1186)
@@ -58,18 +58,17 @@
agent.getOntologyManager().applyChange(new AddAxiom(ontology, annotAxiom));
}
}
-
+
if(!containsAxiom || !containsAllAnnots){
- agent.getReasoner().refresh();
+ agent.refreshReasoner();
if(!agent.isBeliefRevisionEnabled()){ // if brf disabled, resort to legacy consistency maintenance mechanism
- if(!agent.getReasoner().isConsistent()){
+ if(!agent.getReasoner().isConsistent(ontology)){
RemoveAxiom rem = new RemoveAxiom(ontology, axiom);
agent.getOntologyManager().applyChange(rem);
- agent.getReasoner().refresh();
+ agent.refreshReasoner();
return false;
}
}
-
return true;
}else{
return false;
@@ -126,7 +125,7 @@
result = true;
}
}
- agent.getReasoner().refresh();
+ agent.refreshReasoner();
return result;
}catch(NotEnrichedException e){
return super.remove(l); // semantically-naive, use standard Jason mechanisms
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToAxiomConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToAxiomConverter.java 2008-03-31 21:56:43 UTC (rev 1185)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/ToAxiomConverter.java 2008-04-01 00:59:33 UTC (rev 1186)
@@ -21,6 +21,7 @@
import static jasdl.util.Common.RANGE;
import jasdl.asSemantics.JasdlAgent;
+import jasdl.bb.revision.IndividualAxiomToDescriptionConverter;
import jasdl.bridge.seliteral.SELiteral;
import jasdl.bridge.seliteral.SELiteralAllDifferentAssertion;
import jasdl.bridge.seliteral.SELiteralClassAssertion;
@@ -32,6 +33,7 @@
import java.util.HashSet;
import java.util.Set;
+import org.semanticweb.owl.inference.OWLReasonerException;
import org.semanticweb.owl.model.OWLConstant;
import org.semanticweb.owl.model.OWLDataProperty;
import org.semanticweb.owl.model.OWLDescription;
@@ -130,22 +132,26 @@
* @throws JasdlException
*/
private Set<OWLIndividualAxiom> convert(SELiteralClassAssertion sl, boolean checkForExistence) throws JasdlException{
- Set<OWLIndividual> is = new HashSet<OWLIndividual>();
- OWLDescription desc = sl.getOWLDescription();
-
- if(sl.getLiteral().isGround()){
- OWLIndividual i = sl.getOWLIndividual();
- if(!checkForExistence || agent.getReasoner().hasType(i, desc)){
- is.add(i);
+ try {
+ Set<OWLIndividual> is = new HashSet<OWLIndividual>();
+ OWLDescription desc = sl.getOWLDescription();
+
+ if(sl.getLiteral().isGround()){
+ OWLIndividual i = sl.getOWLIndividual();
+ if(!checkForExistence || agent.getReasoner().hasType(i, desc, false)){
+ is.add(i);
+ }
+ }else{
+ is.addAll(agent.getReasoner().getIndividuals(desc, false));
+ }
+ Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
+ for(OWLIndividual i : is){
+ axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLClassAssertionAxiom(i, desc));
}
- }else{
- is.addAll(agent.getReasoner().getIndividuals(desc, false));
- }
- Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
- for(OWLIndividual i : is){
- axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLClassAssertionAxiom(i, desc));
+ return axioms;
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
}
- return axioms;
}
/**
@@ -156,33 +162,42 @@
* @throws JasdlException
*/
public Set<OWLIndividualAxiom> create(SELiteralAllDifferentAssertion sl, boolean checkForExistence) throws JasdlException{
- Object[] is = sl.getOWLIndividuals().toArray();
- if(is.length == 0){
- throw new JasdlException("All different assertion must contain some individuals! "+sl);
+ try {
+ Set<OWLIndividual> _is = sl.getOWLIndividuals();
+ Object[] is = _is.toArray();
+ if(is.length == 0){
+ throw new JasdlException("All different assertion must contain some individuals! "+sl);
+ }
+ // check they are mutually distinct (if we are checking for existence)
+ boolean distinct = true;
+ if(checkForExistence){
+ for(int i=0; i<is.length; i++){
+ for(int j=i+1; j<is.length; j++){
+ // create a description that is satisfiable iff the two individuals are different. TODO: request in-built OWL-API support for this
+ OWLDifferentIndividualsAxiom axiom = agent.getOntologyManager().getOWLDataFactory().getOWLDifferentIndividualsAxiom(_is);
+ IndividualAxiomToDescriptionConverter conv = new IndividualAxiomToDescriptionConverter(agent.getOntologyManager().getOWLDataFactory());
+ axiom.accept(conv);
+ if(!agent.getReasoner().isSatisfiable(conv.getDescription())){//.isDifferentFrom((OWLIndividual)is[i], (OWLIndividual)is[j])){
+ distinct = false;
+ break;
+ }
+ }
+ if(!distinct) break;
+ }
+ }
+ Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
+ Set<OWLIndividual> different = new HashSet<OWLIndividual>();
+ if(!checkForExistence || distinct){
+ for(int i=0; i<is.length; i++){
+ different.add((OWLIndividual)is[i]);
+ }
+ OWLDifferentIndividualsAxiom axiom = agent.getOntologyManager().getOWLDataFactory().getOWLDifferentIndividualsAxiom(different);
+ axioms.add(axiom);
+ }
+ return axioms;
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
}
- // check they are mutually distinct (if we are checking for existence)
- boolean distinct = true;
- if(checkForExistence){
- for(int i=0; i<is.length; i++){
- for(int j=i+1; j<is.length; j++){
- if(!agent.getReasoner().isDifferentFrom((OWLIndividual)is[i], (OWLIndividual)is[j])){
- distinct = false;
- break;
- }
- }
- if(!distinct) break;
- }
- }
- Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
- Set<OWLIndividual> different = new HashSet<OWLIndividual>();
- if(!checkForExistence || distinct){
- for(int i=0; i<is.length; i++){
- different.add((OWLIndividual)is[i]);
- }
- OWLDifferentIndividualsAxiom axiom = agent.getOntologyManager().getOWLDataFactory().getOWLDifferentIndividualsAxiom(different);
- axioms.add(axiom);
- }
- return axioms;
}
/**
@@ -193,22 +208,26 @@
* @throws JasdlException
*/
public Set<OWLIndividualAxiom> create(SELiteralObjectPropertyAssertion sl, boolean checkForExistence) throws JasdlException{
- Set<OWLIndividual> os = new HashSet<OWLIndividual>();
- OWLIndividual s = sl.getSubject();
- OWLObjectProperty p = sl.getPredicate();
- if(sl.getLiteral().getTerm(RANGE).isGround()){
- OWLIndividual o = sl.getObject();
- if(!checkForExistence || agent.getReasoner().hasObjectPropertyRelationship(s, p, o)){
- os.add(o);
+ try {
+ Set<OWLIndividual> os = new HashSet<OWLIndividual>();
+ OWLIndividual s = sl.getSubject();
+ OWLObjectProperty p = sl.getPredicate();
+ if(sl.getLiteral().getTerm(RANGE).isGround()){
+ OWLIndividual o = sl.getObject();
+ if(!checkForExistence || agent.getReasoner().hasObjectPropertyRelationship(s, p, o)){
+ os.add(o);
+ }
+ }else{
+ os.addAll(agent.getReasoner().getRelatedIndividuals(s, p));
}
- }else{
- os.addAll(agent.getReasoner().getRelatedIndividuals(s, p));
+ Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
+ for(OWLIndividual o : os){
+ axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLObjectPropertyAssertionAxiom(s, p, o));
+ }
+ return axioms;
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
}
- Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
- for(OWLIndividual o : os){
- axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLObjectPropertyAssertionAxiom(s, p, o));
- }
- return axioms;
}
/**
@@ -219,22 +238,26 @@
* @throws JasdlException
*/
public Set<OWLIndividualAxiom> create(SELiteralDataPropertyAssertion sl, boolean checkForExistence) throws JasdlException{
- Set<OWLConstant> os = new HashSet<OWLConstant>();
- OWLIndividual s = sl.getSubject();
- OWLDataProperty p = sl.getPredicate();
- if(sl.getLiteral().getTerm(RANGE).isGround()){
- OWLTypedConstant o = sl.getObject();
- if(!checkForExistence || agent.getReasoner().hasDataPropertyRelationship(s, p, o)){
- os.add(o);
+ try {
+ Set<OWLConstant> os = new HashSet<OWLConstant>();
+ OWLIndividual s = sl.getSubject();
+ OWLDataProperty p = sl.getPredicate();
+ if(sl.getLiteral().getTerm(RANGE).isGround()){
+ OWLTypedConstant o = sl.getObject();
+ if(!checkForExistence || agent.getReasoner().hasDataPropertyRelationship(s, p, o)){
+ os.add(o);
+ }
+ }else{
+ os.addAll(agent.getReasoner().getRelatedValues(s, p));
}
- }else{
- os.addAll(agent.getReasoner().getRelatedValues(s, p));
+ Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
+ for(OWLConstant o : os){
+ axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLDataPropertyAssertionAxiom(s, p, o));
+ }
+ return axioms;
+ } catch (OWLReasonerException e) {
+ throw new JasdlException("Unable to convert "+sl+" to axiom. Reason: "+e);
}
- Set<OWLIndividualAxiom> axioms = new HashSet<OWLIndividualAxiom>();
- for(OWLConstant o : os){
- axioms.add(agent.getOntologyManager().getOWLDataFactory().getOWLDataPropertyAssertionAxiom(s, p, o));
- }
- return axioms;
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-03-31 21:56:43 UTC (rev 1185)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-04-01 00:59:33 UTC (rev 1186)
@@ -36,6 +36,18 @@
public class SELiteral{
public static String ONTOLOGY_ANNOTATION_FUNCTOR = "o";
+ /**
+ * Should results of various operations be cached for later usage?
+ * Tentatively, yes. May cause problems however;
+ */
+ private static boolean USE_CACHING = true;
+
+ protected Structure ontologyAnnotation = null;
+
+ protected OWLIndividualAxiom axiom = null;
+ protected Set<OWLIndividualAxiom> axioms = null;
+
+
protected JasdlAgent agent;
protected Literal literal;
@@ -54,27 +66,28 @@
}
private Structure getOntologyAnnotation() throws JasdlException{
- Structure annot = null;
- ListTerm os = literal.getAnnots(ONTOLOGY_ANNOTATION_FUNCTOR);
- if(os.size() == 0){
- throw new NotEnrichedException("Not semantically-enriched");
+ if(ontologyAnnotation == null || !USE_CACHING){
+ ListTerm os = literal.getAnnots(ONTOLOGY_ANNOTATION_FUNCTOR);
+ if(os.size() == 0){
+ throw new NotEnrichedException("Not semantically-enriched");
+ }
+ if(os.size() > 1){
+ throw new InvalidSELiteralException("Multiple ontology annotations present");
+ }
+ Term t = os.get(0);
+ if(!(t instanceof Structure)){
+ throw new InvalidSELiteralException("Invalid ontology annotation term");
+ }
+ ontologyAnnotation = (Structure)t;
+
+ if(ontologyAnnotation.getArity() != 1){
+ throw new InvalidSELiteralException("Invalid ontology annotation arity");
+ }
}
- if(os.size() > 1){
- throw new InvalidSELiteralException("Multiple ontology annotations present");
- }
- Term t = os.get(0);
- if(!(t instanceof Structure)){
- throw new InvalidSELiteralException("Invalid ontology annotation term");
- }
- annot = (Structure)t;
-
- if(annot.getArity() != 1){
- throw new InvalidSELiteralException("Invalid ontology annotation arity");
- }
- return annot;
+ return ontologyAnnotation;
}
- public OWLOntology getOntology() throws JasdlException{
+ public OWLOntology getOntology() throws JasdlException{
Structure o = getOntologyAnnotation();
if(o.getTerm(0).isStructure()){ // Checking for atomicity directly does not seem to work
return agent.getLabelManager().getRight((Atom)o.getTerm(0));
@@ -132,14 +145,20 @@
* @return
*/
public OWLIndividualAxiom createAxiom() throws JasdlException{
- return agent.getToAxiomConverter().create(this);
+ if(axiom == null || !USE_CACHING){
+ axiom = agent.getToAxiomConverter().create(this);
+ }
+ return axiom;
}
/**
* Convenience method, calls AxiomFactory
* @return
*/
public Set<OWLIndividualAxiom> getAxioms() throws JasdlException{
- return agent.getToAxiomConverter().retrieve(this);
+ if(axioms == null || !USE_CACHING){
+ axioms = agent.getToAxiomConverter().retrieve(this);
+ }
+ return axioms;
}
/**
@@ -157,20 +176,11 @@
* If not present, attempts to fetch from personal ontology.
* If not present, instantiates in personal ontology.
* Placed here for convenient (varying) usage by subclasses.
- * Validates since terms are mutable.
+ * Validates and doesn't cache since terms are mutable.
* @return
* @throws UnknownMappingException
*/
public OWLIndividual getOWLIndividual(Term term) throws JasdlException{
- //agent.getLogger().info("term: "+term);
- //if(term.isVar()){
- // term = ((VarTerm)term).getValue();
- //}
-
- //if(!(term.isAtom())){
- // throw new InvalidSELiteralException(term+" must be atomic in literal "+literal);
- //}
- //Atom atom = (Atom);
Atom atom = new Atom(term.toString());
OWLIndividual i;
try {
Modified: trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-03-31 21:56:43 UTC (rev 1185)
+++ trunk/applications/jasdl-owlapi/src/jasdl/test/JasdlBeliefBaseTest.java 2008-04-01 00:59:33 UTC (rev 1186)
@@ -41,6 +41,8 @@
import org.junit.Before;
import org.junit.Test;
+import org.semanticweb.owl.inference.OWLReasonerException;
+import org.semanticweb.owl.model.OWLOntology;
/**
* TODO: This is very out of date: needs tidying up and improving.
@@ -351,9 +353,15 @@
/* AUXILIARY METHODS */
public void checkConsistency(){
- if(!agent.getReasoner().isConsistent()){
- fail("Inconsistency detected");
- }
+ try {
+ for(OWLOntology ontology : agent.getReasoner().getLoadedOntologies()){
+ if(!agent.getReasoner().isConsistent(ontology)){
+ fail("Inconsistency detected");
+ }
+ }
+ } catch (OWLReasonerException e) {
+ e.printStackTrace();
+ }
}
public void addToBB(String functor, String params, boolean expected){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-03-31 21:56:53
|
Revision: 1185
http://jason.svn.sourceforge.net/jason/?rev=1185&view=rev
Author: tomklapiscak
Date: 2008-03-31 14:56:43 -0700 (Mon, 31 Mar 2008)
Log Message:
-----------
Belief Base removals are now implemented using the contraction operator and annotation removals handled correctly.
DL Belief Base semi-revision improved.
Implemented proper handling of physically disjoint but logically identical ontologies.
Made fully compatible with the latest release of Jason.
SE-Plan cloning handled correctly.
Improvements to Belief Base contains method.
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/build.xml
trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
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/bb/revision/IsolatedOntologyOperation.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlReasonerFactory.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/MappingManager.java
trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
Added Paths:
-----------
trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/BeliefBaseSemiRevisor.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/IndividualAxiomToDescriptionConverter.java
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/BeliefBaseRevisor.java
Property Changed:
----------------
trunk/applications/jasdl-owlapi/examples/
Modified: trunk/applications/jasdl-owlapi/build.xml
===================================================================
--- trunk/applications/jasdl-owlapi/build.xml 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/build.xml 2008-03-31 21:56:43 UTC (rev 1185)
@@ -39,12 +39,13 @@
<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="${basedir}/src" includes="**/junit/AllTests.java" />
+ <fileset dir="${source.dir}/jasdl/test" includes="*Test.java" />
</batchtest>
</junit>
<fail message="test failed" if="test.failure" />
Property changes on: trunk/applications/jasdl-owlapi/examples
___________________________________________________________________
Name: svn:ignore
+ testing
brf_test
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/config.mas2j 2008-03-31 21:56:43 UTC (rev 1185)
@@ -37,6 +37,7 @@
jasdl_ontologies="travel",
jasdl_travel_uri="http://www.dur.ac.uk/t.g.klapiscak/onts/travel.owl",
+
/*jasdl_travel_mapping_strategies="jasdl.bridge.alias.DecapitaliseMappingStrategy",*/ // defaults can be overriden per-ontology here
jasdl_travel_mapping_manual="small_beach=beach", // these manual mappings will override any automatic mappings made by strategies,
@@ -57,7 +58,6 @@
jasdl_useBeliefRevision = "true",
jasdl_ontologies="holidays,places",
- /*jasdl_holidays_uri="file:///home/tom/Desktop/Project/workspace/jason/applications/jasdl-owlapi/examples/travel_agent/ontologies/travel.owl", */
jasdl_holidays_uri="http://www.dur.ac.uk/t.g.klapiscak/onts/travel.owl",
jasdl_holidays_mapping_strategies="jasdl.bridge.alias.DecapitaliseMappingStrategy",
jasdl_holidays_mapping_manual="small_beach=beach, luxuriousHotel=LuxuryHotel", // for demonstration of arbitrary primitive mappings being handled correctly
Modified: trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/examples/travel_agent/travel_agent.asl 2008-03-31 21:56:43 UTC (rev 1185)
@@ -37,23 +37,31 @@
+city(london)[o(travel)]; // london is a city
+hasAccommodation(london, hilton)[o(travel)]; // hilton is in london
+country(england)[o(travel)]; // england is a country
- +urbanArea(windsor)[o(travel)]; // windsor is an urban area
- +isPartOf(windsor, london)[o(travel)]; // windsor is a part of london
+ +urbanArea(wembley)[o(travel)]; // wembley is an urban area
+ +isPartOf(wembley, london)[o(travel)]; // wembley is a part of london
+isPartOf(london, england)[o(travel)]; // london is a part of england
+hasPricePerNight(hilton, 22.0)[o(travel)]; // hilton costs £22 a night
+museums(scienceMuseum)[o(travel)];
+hasActivity(london, scienceMuseum)[o(travel)];
+hotel(travel_lodge)[o(travel)];
.print("Completed: Updating Belief Base 1").
-
+
@example_ubb_2[atomic]
+!example_UBB_2
- <-
- .print("Example: Updating Belief Base 2");
+ <-
+ .print("Example: Updating Belief Base 2");
+ jasdl.ia.define_class(tiny, "travel:urbanArea and travel:hasActivity max 1 travel:activity");
+ +tiny(newcastle)[o(self), source(tom)];
+ +hasActivity(newcastle, ax)[o(travel), source(tom)];
+ +hasActivity(newcastle, bx)[o(travel), source(ben)];
+ +all_different([ax, bx])[o(self), source(tom)];
+
+
+city(somewhere)[o(travel), source(ben)];
+town(somewhere)[o(travel), source(ben)];
+
// Despite the classes urbanArea and ruralArea being disjoint, the belief addition below will succeed,
// since tom's word is trusted over ben's (see config.mas2j)
// as a result, both (incompatible) assertions made above by ben will be contracted
@@ -66,16 +74,18 @@
// since the classes destination and and contact are disjoint (and ruralArea is a subclass of destination),
// and since we trust ben less than tom, the belief addition below will fail (and tom's assertion above will persist),
// thus failing the whole plan.
- +contact(somewhere)[o(travel), source(ben)].
+ +contact(somewhere)[o(travel), source(ben)];
+ .print("Failed: Updating Belief Base 2").
+
+@example_UBB_2_failure[atomic]
-!example_UBB_2
<-
// Notice this does not hold, since belief revision rejected the less trusted assertion made by ben.
?~contact(somewhere)[o(travel)];
.print("Completed: Updating Belief Base 2").
-
-@example_qbb[atomic]
+@example_qbb[atomic, breakpoint]
+!example_QBB
<-
.print("Example: Querying Belief Base");
@@ -83,13 +93,13 @@
/* 2 */ ?luxuryHotel(LuxuryHotel)[o(travel)];
/* 3 */ ?~budgetAccommodation(hilton)[o(travel)];
/* 4 */ .findall(Thing, thing(Thing)[o(owl)], E);
- /* 5 */ ?countryOf(windsor, Country);
+ /* 5 */ ?countryOf(wembley, Country);
/* 6 */ ?hasPricePerNight(hilton, Price)[o(travel)];
.print("Completed: Querying Belief Base").
-+?countryOf(Destination, Country) :
- isPartOf(Destination, Country)[o(travel)] &
- country(Country)[o(travel)].
++?countryOf(Destination, Country) : isPartOf(Destination, Country)[o(travel)] & country(Country)[o(travel)].
+
+
@example_rpp[atomic]
+!example_RPP
<-
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JasdlAgent.java 2008-03-31 21:56:43 UTC (rev 1185)
@@ -5,7 +5,7 @@
import jasdl.asSemantics.parsing.URIEntityChecker;
import jasdl.asSyntax.JasdlPlanLibrary;
import jasdl.bb.JasdlBeliefBase;
-import jasdl.bb.revision.BeliefBaseRevisor;
+import jasdl.bb.revision.BeliefBaseSemiRevisor;
import jasdl.bb.revision.JasdlIncisionFunction;
import jasdl.bb.revision.JasdlReasonerFactory;
import jasdl.bb.revision.TBoxAxiomKernelsetFilter;
@@ -30,6 +30,7 @@
import jason.JasonException;
import jason.RevisionFailedException;
import jason.architecture.AgArch;
+import jason.asSemantics.Event;
import jason.asSemantics.Intention;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
@@ -44,6 +45,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Queue;
import java.util.Set;
import java.util.Vector;
@@ -53,10 +55,7 @@
import org.mindswap.pellet.PelletOptions;
import org.mindswap.pellet.owlapi.Reasoner;
import org.semanticweb.owl.apibinding.OWLManager;
-import org.semanticweb.owl.model.AddAxiom;
-import org.semanticweb.owl.model.OWLAnnotation;
import org.semanticweb.owl.model.OWLAxiom;
-import org.semanticweb.owl.model.OWLAxiomAnnotationAxiom;
import org.semanticweb.owl.model.OWLClass;
import org.semanticweb.owl.model.OWLDescription;
import org.semanticweb.owl.model.OWLEntity;
@@ -183,6 +182,16 @@
+ @Override
+ public Event selectEvent(Queue<Event> events) {
+ getLogger().finest("Events: "+events);
+ return super.selectEvent(events);
+ }
+
+
+
+
+
public List<Literal>[] brf(Literal beliefToAdd, Literal beliefToDel, Intention i) throws RevisionFailedException {
if(!isBeliefRevisionEnabled()){ // if experimental feature is disabled
@@ -192,41 +201,23 @@
List<Literal> addList = new Vector<Literal>();
List<Literal> removeList = new Vector<Literal>();
-
// just accept beliefToDel. Assumption: Deletions never lead to inconsistencies?!
- if(beliefToDel != null){
+ if(beliefToDel != null){
+ getLogger().finest("Revise: -"+beliefToDel);
removeList.add(beliefToDel);
- }
-
- if(beliefToAdd != null){
- try{
-
-
+ }else if(beliefToAdd != null){
+ try{
+ getLogger().fine("Revise: +"+beliefToAdd);
SELiteral sl = getSELiteralFactory().create(beliefToAdd);
- OWLAxiom axiomToAdd = sl.createAxiom();
+ OWLAxiom axiomToAdd = sl.createAxiom();
+ BeliefBaseSemiRevisor bbrev = new BeliefBaseSemiRevisor(axiomToAdd, getOntologyManager(), new JasdlReasonerFactory(), getLogger());
+ List<OWLAxiom> contractList = bbrev.revise(new TBoxAxiomKernelsetFilter(), new JasdlIncisionFunction(this, sl));
- BeliefBaseRevisor bbrev = new BeliefBaseRevisor(axiomToAdd, getOntologyManager(), new JasdlReasonerFactory(), getLogger());
- List<OWLAxiom>[] result = bbrev.revise(new TBoxAxiomKernelsetFilter(), new JasdlIncisionFunction(this, sl));
-
- /*
- for(OWLAxiom added : result[0]){
- addList.add( getToSELiteralConverter().convert((OWLIndividualAxiom)added).getLiteral()); // safe type cast - Jasdl's incision function ensures only individual axioms are contracted
+ // will only have reached here if new belief is accepted.
+ addList.add(beliefToAdd);
+ for(OWLAxiom contract : contractList){
+ removeList.add(toSELiteralConverter.convert((OWLIndividualAxiom)contract).getLiteral());
}
- */
- // Simplication possible: only at most one addition (toAdd). Additionally, annotations required!
- if(result[0].contains(axiomToAdd)){
- addList.add(beliefToAdd);
-
- // there will only be axioms to remove if we accepted beliefToAdd
- for(OWLAxiom removed : result[1]){
- removeList.add( getToSELiteralConverter().convert((OWLIndividualAxiom)removed).getLiteral()); // safe type cast - Jasdl's incision function ensures only individual axioms are contracted
- }
- }else{
- // throw revision failed exception, since we didn't successfully add this belief
- throw new RevisionFailedException("Revision failed on "+beliefToAdd);
- }
-
-
}catch(RevisionFailedException e){
throw e; // propagate upwards
}catch(NotEnrichedException e){
@@ -236,22 +227,13 @@
getLogger().warning("Error performing belief revision. Reason:");
e.printStackTrace();
}
+ }else{
+ throw new RuntimeException("Unexpected behaviour, both beliefToAdd and beliefToDel are non-null...?");
}
List<Literal>[] toReturn = null;
-
- // affect BB
- for(Literal added : addList){
- if(getBB().add(added)){
- if(toReturn == null){
- toReturn = new List[2];
- toReturn[0] = new Vector<Literal>();
- toReturn[1] = new Vector<Literal>();
- }
- toReturn[0].add(added);
- }
- }
+ // Need to perform removals before additions so our ontology instance never becomes inconsistent
for(Literal removed : removeList){
// we need to ground unground removals
Unifier u = null;
@@ -261,21 +243,35 @@
u = new Unifier();
}
if (believes(removed, u)) {
- removed.apply(u); // TODO: should unground removals not result in removal of all unifications?
+ removed.apply(u);
if(getBB().remove(removed)){
if(toReturn == null){
- if(toReturn == null){
- toReturn = new List[2];
- toReturn[0] = new Vector<Literal>();
- toReturn[1] = new Vector<Literal>();
- }
- toReturn[1].add(removed);
+ toReturn = new List[2];
+ toReturn[0] = new Vector<Literal>();
+ toReturn[1] = new Vector<Literal>();
}
+ toReturn[1].add(removed);
}
- }
+ }
}
+
+
+ // affect BB
+ for(Literal added : addList){
+ if(getBB().add(added)){
+ if(toReturn == null){
+ toReturn = new List[2];
+ toReturn[0] = new Vector<Literal>();
+ toReturn[1] = new Vector<Literal>();
+ }
+ toReturn[0].add(added);
+ }
+ }
+
+
+
return toReturn;
}
@@ -381,19 +377,23 @@
public OWLOntology loadOntology(Atom label, URI uri, List<MappingStrategy> strategies) throws JasdlException{
try{
OWLOntology ontology = ontologyManager.loadOntologyFromPhysicalURI(uri);
+ try{
+ OWLOntology alreadyKnown = logicalURIManager.getLeft(ontology.getURI());
+ return alreadyKnown;
+ }catch(UnknownMappingException e){}
Set<OWLOntology> imports = ontologyManager.getImportsClosure(ontology);
reasoner.loadOntologies(imports);
- reasoner.classify();
+ reasoner.classify();
initOntology(ontology, label, uri, ontology.getURI(), false); // (successfully) loaded ontologies never personal
applyMappingStrategies(ontology, strategies);
- getLogger().fine("Loaded ontology from "+uri+" and assigned label "+label);
+ getLogger().fine("Loaded ontology from "+uri+" and assigned label "+label);
return ontology;
}catch(OWLOntologyCreationException e){
getLogger().warning("Placeholder personal ontology substituted for unreachable "+uri);
// can't load it, just create a blank (for unqualification of ontology annotations for example)
// personal by definition
return createOntology(label, uri, true);
- }
+ }
}
@@ -428,6 +428,7 @@
*/
private void initOntology(OWLOntology ontology, Atom label, URI physicalURI, URI logicalURI, boolean isPersonal) throws JasdlException{
labelManager.put(label, ontology, isPersonal);
+
physicalURIManager.put(ontology, physicalURI);
logicalURIManager.put(ontology, logicalURI);
// create the AllDifferent placeholder entity for this ontology
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JasdlPlanLibrary.java 2008-03-31 21:56:43 UTC (rev 1185)
@@ -67,8 +67,8 @@
* TODO: We are repeating work here: fetching more general triggers. Optimise by storing result for immedate use?
* Could store as part of plan, but wouldn't work correctly for run-time defined class
*/
- public List<Plan> getAllRelevant(Trigger te){
- List<Plan> relevant = super.getAllRelevant(te);
+ public List<Plan> getCandidatePlans(Trigger te){
+ List<Plan> relevant = super.getCandidatePlans(te);
if(!te.getLiteral().negated()){
try {
List<Plan> moreGeneral = getMoreGeneralPlans(te);
@@ -86,6 +86,28 @@
agent.getLogger().warning("JASDL plan relevancy check failed. Reason: "+e);
}
}
+
+ /*
+ * Alternative fix for issue discovered on 31/03/08
+ * (Subtle difference in JASDL's BB#getRelevant operation meaning context's must be unified first)
+ if(relevant != null){
+ List<Plan> clones = new Vector<Plan>();
+ for(Plan plan : relevant){
+ if(plan.getContext() != null){
+ Plan clone = (Plan)plan.clone();
+ Unifier un = new Unifier();
+ un.unifiesNoUndo(clone.getTrigger(), te);
+ clone.getTrigger().getLiteral().apply(un);
+ clones.add(clone);
+ }else{
+ clones.add(plan);
+ }
+
+ }
+ relevant = clones;
+ }
+ */
+
return relevant;
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java 2008-03-31 21:56:43 UTC (rev 1185)
@@ -43,6 +43,9 @@
this.agent = agent;
}
+
+
+ @Override
public Unifier isRelevant(Trigger te) {
Unifier un = super.isRelevant(te);
if(un != null){ // plan is specifically relevant to deal with the trigger
@@ -62,4 +65,9 @@
}
return null;
}
+
+ @Override
+ public Object clone(){
+ return new SEPlan(agent, (Plan)super.clone());
+ }
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JasdlBeliefBase.java 2008-03-31 21:56:43 UTC (rev 1185)
@@ -1,10 +1,15 @@
package jasdl.bb;
import jasdl.asSemantics.JasdlAgent;
+import jasdl.bb.revision.BeliefBaseContractor;
+import jasdl.bb.revision.JasdlIncisionFunction;
+import jasdl.bb.revision.JasdlReasonerFactory;
+import jasdl.bb.revision.TBoxAxiomKernelsetFilter;
import jasdl.bridge.seliteral.SELiteral;
import jasdl.bridge.seliteral.SELiteralAllDifferentAssertion;
import jasdl.util.JasdlException;
import jasdl.util.NotEnrichedException;
+import jason.asSemantics.Unifier;
import jason.asSyntax.Literal;
import jason.asSyntax.Term;
import jason.bb.DefaultBeliefBase;
@@ -18,6 +23,7 @@
import org.semanticweb.owl.model.AddAxiom;
import org.semanticweb.owl.model.OWLAnnotation;
+import org.semanticweb.owl.model.OWLAxiom;
import org.semanticweb.owl.model.OWLAxiomAnnotationAxiom;
import org.semanticweb.owl.model.OWLDifferentIndividualsAxiom;
import org.semanticweb.owl.model.OWLIndividual;
@@ -84,20 +90,44 @@
*/
@Override
public boolean remove(Literal l) {
- getLogger().fine("Removing "+l);
- try{
- // TODO: use contraction for belief base removal
- //BeliefBaseContractor contractor = new BeliefBaseContractor(agent.getOntologyManager(), new JasdlReasonerFactory(), agent.getLogger());
- //contractor.contract(axiom, kernelsetFilter, incisionFunction)
-
+ getLogger().fine("Contracting "+l);
+ try{
SELiteral sl = agent.getSELiteralFactory().create(l);
OWLOntology ontology = sl.getOntology();
- OWLIndividualAxiom axiom = sl.createAxiom();
- getLogger().fine("... as axiom: "+axiom);
- RemoveAxiom rem = new RemoveAxiom(ontology, axiom);
- agent.getOntologyManager().applyChange(rem);
+ OWLIndividualAxiom axiom = sl.createAxiom();
+
+ boolean result = false; // -> at least *something* must be removed for this to be true!
+
+ BeliefBaseContractor contractor = new BeliefBaseContractor(agent.getOntologyManager(), new JasdlReasonerFactory(), agent.getLogger());
+ List<OWLAxiom> contractList = contractor.contract(axiom, new TBoxAxiomKernelsetFilter(), new JasdlIncisionFunction(agent, sl));
+
+ // NOTE: this technique only really makes sense with annotation gathering!
+ for(OWLAxiom contract : contractList){ // removals corresponds to l and all l's whose removal will undermine it
+
+ // for each annotation to this axiom, remove it if l has it
+ List<OWLAxiomAnnotationAxiom> annotationsToRemove = new Vector<OWLAxiomAnnotationAxiom>(); // to avoid concurrency issues
+ for(OWLAxiomAnnotationAxiom annotAxiom : contract.getAnnotationAxioms(ontology)){
+ Term annot = Literal.parse(annotAxiom.getAnnotation().getAnnotationValueAsConstant().getLiteral());
+ if(l.hasAnnot(annot)){
+ annotationsToRemove.add(annotAxiom);
+ result = true;
+ }
+ }
+
+ for(OWLAxiom annotationToRemove : annotationsToRemove){
+ agent.getOntologyManager().applyChange(new RemoveAxiom(ontology, annotationToRemove));
+ }
+
+ // remove source(self) and source(percept). TODO: right thing to do?
+ // remove assertion if no annotation axioms left
+ Set<OWLAxiomAnnotationAxiom> remaining = contract.getAnnotationAxioms(ontology);
+ if(remaining.isEmpty()){
+ agent.getOntologyManager().applyChange(new RemoveAxiom(ontology, contract));
+ result = true;
+ }
+ }
agent.getReasoner().refresh();
- return true;
+ return result;
}catch(NotEnrichedException e){
return super.remove(l); // semantically-naive, use standard Jason mechanisms
}catch(Exception e){
@@ -108,22 +138,19 @@
}
@Override
- public Literal contains(Literal l) {
+ public Literal contains(Literal l) {
+ agent.getLogger().fine("Contains: "+l);
try {
- // TODO: use OWLOntology#contains
- SELiteral sl = agent.getSELiteralFactory().create(l); // <- currently just to establish if semantically-enriched
- //OWLIndividualAxiom axiom = sl.createAxiom();
- //OWLAnnotation annot = agent.getOntologyManager().getOWLDataFactory().getOWLLabelAnnotation(sl.getSemanticallyNaiveAnnotations().toString()); //TODO: more efficient way of serialising list terms?
- //OWLAxiomAnnotationAxiom annotAxiom = agent.getOntologyManager().getOWLDataFactory().getOWLAxiomAnnotationAxiom(axiom, annot);
-
-
- Iterator<Literal> it = getRelevant(l);
- if(it.hasNext()){
- return it.next();
- }else{
- return null;
+ SELiteral sl = agent.getSELiteralFactory().create(l);
+ OWLIndividualAxiom axiom = sl.createAxiom();
+ if(sl.getOntology().containsAxiom(axiom)){
+ Iterator<Literal> it = getCandidateBeliefs(l, null);
+ if(it.hasNext()){
+ return it.next();
+ }
}
- }catch(NotEnrichedException e){
+ return null;
+ }catch(NotEnrichedException e){
return super.contains(l); // semantically-naive, use standard Jason mechanisms
}catch(Exception e){
getLogger().warning("Exception caught while checking if bb contains SELiteral "+l+". Reason: "+e);
@@ -134,8 +161,12 @@
@Override
- public Iterator<Literal> getRelevant(Literal l) {
+ public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier un) {
+ l = (Literal)l.clone();
+ l.apply(un);
+
getLogger().fine("Getting relevancies for "+l);
+
Set<Literal> relevant = new HashSet<Literal>();
try{
SELiteral sl = agent.getSELiteralFactory().create(l);
@@ -160,8 +191,13 @@
}
getLogger().fine("... found: "+relevant);
+ if(relevant.isEmpty()){
+ return null;
+ }
+
+
}catch(NotEnrichedException e){
- return super.getRelevant(l); // semantically-naive, use standard Jason mechanisms
+ return super.getCandidateBeliefs(l, un); // semantically-naive, use standard Jason mechanisms
}catch(Exception e){
getLogger().warning("Exception caught getting relevancies for SELiteral "+l+" to belief base: ");
e.printStackTrace();
Deleted: trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/BeliefBaseRevisor.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/BeliefBaseRevisor.java 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/BeliefBaseRevisor.java 2008-03-31 21:56:43 UTC (rev 1185)
@@ -1,92 +0,0 @@
-package jasdl.bb.revision;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Set;
-import java.util.Vector;
-import java.util.logging.Logger;
-
-import org.semanticweb.owl.inference.OWLReasoner;
-import org.semanticweb.owl.inference.OWLReasonerException;
-import org.semanticweb.owl.model.AddAxiom;
-import org.semanticweb.owl.model.OWLAxiom;
-import org.semanticweb.owl.model.OWLDescription;
-import org.semanticweb.owl.model.OWLOntology;
-import org.semanticweb.owl.model.OWLOntologyChange;
-import org.semanticweb.owl.model.OWLOntologyChangeException;
-import org.semanticweb.owl.model.OWLOntologyCreationException;
-import org.semanticweb.owl.model.OWLOntologyManager;
-import org.semanticweb.owl.model.UnknownOWLOntologyException;
-
-import com.clarkparsia.explanation.BlackBoxExplanation;
-import com.clarkparsia.explanation.HSTExplanationGenerator;
-import com.clarkparsia.explanation.ReasonerFactory;
-import com.clarkparsia.explanation.SatisfiabilityConverter;
-
-public class BeliefBaseRevisor extends IsolatedOntologyOperation {
-
- private Logger logger;
- private OWLAxiom toAdd;
-
- public BeliefBaseRevisor(OWLAxiom toAdd, OWLOntologyManager originalManager, ReasonerFactory reasonerFactory, Logger logger) throws UnknownOWLOntologyException, OWLOntologyCreationException, OWLOntologyChangeException, OWLReasonerException{
- super(originalManager, reasonerFactory);
- this.logger = logger;
- // unfortunately, this needs to be done here (not in .revise)
- // since JASDL (specifically) needs to annotate this axiom
- this.toAdd = toAdd;
- isolatedOntologyManager.applyChange(new AddAxiom(isolatedOntology, toAdd));
- }
-
- public List<OWLAxiom>[] revise(KernelsetFilter kernelsetFilter, IncisionFunction incisionFunction){
- List<OWLAxiom> addList = new Vector<OWLAxiom>();
- List<OWLAxiom> delList = new Vector<OWLAxiom>();
- try {
- isolatedReasoner.classify();
-
- if(isolatedReasoner.isConsistent(isolatedOntology)){
- addList.add(toAdd);
- }else{
- Set<Set<OWLAxiom>> kernelset = applyKernelOperator(toAdd, isolatedOntologyManager, isolatedOntology, isolatedReasoner, reasonerFactory);
- kernelset = kernelsetFilter.apply(kernelset);
- log("Explanation of inconsistency: "+kernelset);
- BeliefBaseContractor contractor = new BeliefBaseContractor(isolatedOntologyManager, reasonerFactory, logger);
- List<OWLAxiom> contracted = contractor.contract(incisionFunction.apply(kernelset), kernelsetFilter, incisionFunction);
-
-
- if(!contracted.contains(toAdd)){
- addList.add(toAdd); // remember, toAdd is not in original ontology so need to remove if it has been contracted
- }
- delList.addAll(contracted);
- }
-
-
- } catch (Exception e) {
- logger.warning("Revision failed. Reason: ");
- e.printStackTrace();
- }
-
- return new List[] {addList, delList};
- }
-
-
- private Set<Set<OWLAxiom>> applyKernelOperator(OWLAxiom a, OWLOntologyManager ontologyManager, OWLOntology ontology, OWLReasoner reasoner, ReasonerFactory reasonerFactory){
- SatisfiabilityConverter satcon = new SatisfiabilityConverter(ontologyManager.getOWLDataFactory());
- OWLDescription description = ontologyManager.getOWLDataFactory().getOWLObjectComplementOf(satcon.convert(a));
- BlackBoxExplanation bbgen = new BlackBoxExplanation(ontologyManager);
- HSTExplanationGenerator hstgen = new HSTExplanationGenerator(bbgen);
- hstgen.setOntology(ontology);
- hstgen.setReasoner(reasoner);
- hstgen.setReasonerFactory(reasonerFactory);
- return hstgen.getExplanations(description);
- }
-
-
- private void log(String msg){
- if(logger != null){
- logger.fine(msg);
- }
- }
-
-
-
-}
Copied: trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/BeliefBaseSemiRevisor.java (from rev 1172, trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/BeliefBaseRevisor.java)
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/BeliefBaseSemiRevisor.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/BeliefBaseSemiRevisor.java 2008-03-31 21:56:43 UTC (rev 1185)
@@ -0,0 +1,92 @@
+package jasdl.bb.revision;
+
+import jason.RevisionFailedException;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+import java.util.logging.Logger;
+
+import org.semanticweb.owl.inference.OWLReasonerException;
+import org.semanticweb.owl.model.AddAxiom;
+import org.semanticweb.owl.model.OWLAxiom;
+import org.semanticweb.owl.model.OWLException;
+import org.semanticweb.owl.model.OWLOntologyChangeException;
+import org.semanticweb.owl.model.OWLOntologyCreationException;
+import org.semanticweb.owl.model.OWLOntologyManager;
+import org.semanticweb.owl.model.UnknownOWLOntologyException;
+
+import com.clarkparsia.explanation.BlackBoxExplanation;
+import com.clarkparsia.explanation.HSTExplanationGenerator;
+import com.clarkparsia.explanation.ReasonerFactory;
+import com.clarkparsia.explanation.io.ConciseExplanationRenderer;
+
+public class BeliefBaseSemiRevisor extends IsolatedOntologyOperation {
+
+ private Logger logger;
+ private OWLAxiom toAdd;
+
+
+ public BeliefBaseSemiRevisor(OWLAxiom toAdd, OWLOntologyManager originalManager, ReasonerFactory reasonerFactory, Logger logger) throws UnknownOWLOntologyException, OWLOntologyCreationException, OWLOntologyChangeException, OWLReasonerException{
+ super(originalManager, reasonerFactory);
+ this.logger = logger;
+ this.toAdd = toAdd;
+ }
+
+ public List<OWLAxiom> revise(KernelsetFilter kernelsetFilter, IncisionFunction incisionFunction) throws RevisionFailedException, OWLReasonerException, OWLOntologyChangeException{
+ isolatedOntologyManager.applyChange(new AddAxiom(isolatedOntology, toAdd));
+ isolatedReasoner.classify();
+ List<OWLAxiom> delList = new Vector<OWLAxiom>();
+ if(!isolatedReasoner.isConsistent(isolatedOntology)){
+ Set<Set<OWLAxiom>> kernelset = applyKernelOperator();
+ kernelset = kernelsetFilter.apply(kernelset);
+ logger.fine("Explanation of inconsistency due to "+toAdd+": "+kernelset);
+ Set<OWLAxiom> toContract = incisionFunction.apply(kernelset);
+ logger.fine("... chosen to contract: "+toContract);
+ if(toContract.contains(toAdd)){
+ throw new RevisionFailedException(toAdd+" rejected");
+ }
+
+ delList.addAll(toContract);
+ }
+ return delList;
+ }
+
+ private void render(Set<Set<OWLAxiom>> kernelset){
+ ConciseExplanationRenderer renderer = new ConciseExplanationRenderer();
+ renderer.startRendering(new PrintWriter(System.out));
+ try {
+ renderer.render(toAdd, kernelset);
+ } catch (OWLException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ renderer.endRendering();
+ }
+
+
+ private Set<Set<OWLAxiom>> applyKernelOperator(){
+ BlackBoxExplanation bbgen = new BlackBoxExplanation(isolatedOntologyManager);
+ HSTExplanationGenerator hstgen = new HSTExplanationGenerator(bbgen);
+ hstgen.setOntology(isolatedOntology);
+ hstgen.setReasoner(isolatedReasoner);
+ hstgen.setReasonerFactory(reasonerFactory);
+ IndividualAxiomToDescriptionConverter conv = new IndividualAxiomToDescriptionConverter(isolatedOntologyManager.getOWLDataFactory());
+ toAdd.accept(conv);
+ Set<Set<OWLAxiom>> kernelset = hstgen.getExplanations(conv.getDescription());
+
+ // since we are dealing with semi-revision, ensure the axiom toAdd is a possible justification in each a-kernel that can be retracted
+ // doesn't seem to be adding when toAdd is a class assertion?? TODO: Is this a bug??
+ for(Set<OWLAxiom> akernel : kernelset){
+ akernel.add(toAdd);
+ }
+
+ return kernelset;
+ }
+
+
+
+}
Added: trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/IndividualAxiomToDescriptionConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/IndividualAxiomToDescriptionConverter.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/IndividualAxiomToDescriptionConverter.java 2008-03-31 21:56:43 UTC (rev 1185)
@@ -0,0 +1,228 @@
+package jasdl.bb.revision;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.semanticweb.owl.model.OWLAntiSymmetricObjectPropertyAxiom;
+import org.semanticweb.owl.model.OWLAxiomAnnotationAxiom;
+import org.semanticweb.owl.model.OWLAxiomVisitor;
+import org.semanticweb.owl.model.OWLClassAssertionAxiom;
+import org.semanticweb.owl.model.OWLDataFactory;
+import org.semanticweb.owl.model.OWLDataPropertyAssertionAxiom;
+import org.semanticweb.owl.model.OWLDataPropertyDomainAxiom;
+import org.semanticweb.owl.model.OWLDataPropertyRangeAxiom;
+import org.semanticweb.owl.model.OWLDataSubPropertyAxiom;
+import org.semanticweb.owl.model.OWLDeclarationAxiom;
+import org.semanticweb.owl.model.OWLDescription;
+import org.semanticweb.owl.model.OWLDifferentIndividualsAxiom;
+import org.semanticweb.owl.model.OWLDisjointClassesAxiom;
+import org.semanticweb.owl.model.OWLDisjointDataPropertiesAxiom;
+import org.semanticweb.owl.model.OWLDisjointObjectPropertiesAxiom;
+import org.semanticweb.owl.model.OWLDisjointUnionAxiom;
+import org.semanticweb.owl.model.OWLEntityAnnotationAxiom;
+import org.semanticweb.owl.model.OWLEquivalentClassesAxiom;
+import org.semanticweb.owl.model.OWLEquivalentDataPropertiesAxiom;
+import org.semanticweb.owl.model.OWLEquivalentObjectPropertiesAxiom;
+import org.semanticweb.owl.model.OWLFunctionalDataPropertyAxiom;
+import org.semanticweb.owl.model.OWLFunctionalObjectPropertyAxiom;
+import org.semanticweb.owl.model.OWLImportsDeclaration;
+import org.semanticweb.owl.model.OWLIndividual;
+import org.semanticweb.owl.model.OWLInverseFunctionalObjectPropertyAxiom;
+import org.semanticweb.owl.model.OWLInverseObjectPropertiesAxiom;
+import org.semanticweb.owl.model.OWLIrreflexiveObjectPropertyAxiom;
+import org.semanticweb.owl.model.OWLNegativeDataPropertyAssertionAxiom;
+import org.semanticweb.owl.model.OWLNegativeObjectPropertyAssertionAxiom;
+import org.semanticweb.owl.model.OWLObjectPropertyAssertionAxiom;
+import org.semanticweb.owl.model.OWLObjectPropertyChainSubPropertyAxiom;
+import org.semanticweb.owl.model.OWLObjectPropertyDomainAxiom;
+import org.semanticweb.owl.model.OWLObjectPropertyRangeAxiom;
+import org.semanticweb.owl.model.OWLObjectSubPropertyAxiom;
+import org.semanticweb.owl.model.OWLOntologyAnnotationAxiom;
+import org.semanticweb.owl.model.OWLReflexiveObjectPropertyAxiom;
+import org.semanticweb.owl.model.OWLRuntimeException;
+import org.semanticweb.owl.model.OWLSameIndividualsAxiom;
+import org.semanticweb.owl.model.OWLSubClassAxiom;
+import org.semanticweb.owl.model.OWLSymmetricObjectPropertyAxiom;
+import org.semanticweb.owl.model.OWLTransitiveObjectPropertyAxiom;
+import org.semanticweb.owl.model.SWRLRule;
+
+/**
+ * Converts an axiom asserting something about an individual into a description that expresses the same information.
+ * i.e. axiom entailed <-> description satisfiable.
+ * Works only for class, object property, data property and all_different assertions (since these are the only types of assertions that can be made using SE-Literals).
+ * Attempting to visit any other type of axiom will throw a runtime exception.
+ * @author Tom Klapiscak
+ *
+ */
+public class IndividualAxiomToDescriptionConverter implements OWLAxiomVisitor{
+
+ private OWLDataFactory factory;
+ private OWLDescription desc;
+
+ public IndividualAxiomToDescriptionConverter(OWLDataFactory factory){
+ this.factory = factory;
+ }
+
+ public OWLDescription getDescription(){
+ return desc;
+ }
+
+
+ public void visit(OWLClassAssertionAxiom axiom) {
+ desc = factory.getOWLObjectIntersectionOf(new OWLDescription[] {axiom.getDescription(), factory.getOWLObjectOneOf(Collections.singleton(axiom.getIndividual()))});
+ }
+
+
+ public void visit(OWLObjectPropertyAssertionAxiom axiom) {
+ desc = factory.getOWLObjectIntersectionOf(new OWLDescription[] {factory.getOWLObjectValueRestriction(axiom.getProperty(), axiom.getObject()), factory.getOWLObjectOneOf(Collections.singleton(axiom.getSubject()))});
+ }
+
+
+ public void visit(OWLDataPropertyAssertionAxiom axiom) {
+ desc = factory.getOWLObjectIntersectionOf(new OWLDescription[] {factory.getOWLDataValueRestriction(axiom.getProperty(), axiom.getObject()), factory.getOWLObjectOneOf(Collections.singleton(axiom.getSubject()))});
+ }
+
+ public void visit(OWLDifferentIndividualsAxiom axiom) {
+ Set<OWLDescription> nominals = new HashSet<OWLDescription>();
+ for(OWLIndividual individual : axiom.getIndividuals()){
+ nominals.add(factory.getOWLObjectComplementOf(factory.getOWLObjectOneOf(individual)));
+ }
+ desc = factory.getOWLObjectIntersectionOf(nominals);
+ }
+
+
+
+ public void visit(OWLSubClassAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLAntiSymmetricObjectPropertyAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLReflexiveObjectPropertyAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLDisjointClassesAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLDataPropertyDomainAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLImportsDeclaration axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLAxiomAnnotationAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLObjectPropertyDomainAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLEquivalentObjectPropertiesAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLDisjointDataPropertiesAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLDisjointObjectPropertiesAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLObjectPropertyRangeAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLFunctionalObjectPropertyAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLObjectSubPropertyAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLDisjointUnionAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLDeclarationAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLEntityAnnotationAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLOntologyAnnotationAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLSymmetricObjectPropertyAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLDataPropertyRangeAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLFunctionalDataPropertyAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLEquivalentDataPropertiesAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLEquivalentClassesAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLTransitiveObjectPropertyAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLDataSubPropertyAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLSameIndividualsAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLObjectPropertyChainSubPropertyAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(OWLInverseObjectPropertiesAxiom axiom) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+ public void visit(SWRLRule rule) {
+ throw new OWLRuntimeException("Unimplemented");
+ }
+
+}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/IsolatedOntologyOperation.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/IsolatedOntologyOperation.java 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/IsolatedOntologyOperation.java 2008-03-31 21:56:43 UTC (rev 1185)
@@ -26,12 +26,14 @@
protected OWLReasoner isolatedReasoner;
- public IsolatedOntologyOperation(OWLOntologyManager originalManager, ReasonerFactory reasonerFactory) throws OWLOntologyCreationException, OWLOntologyChangeException, UnknownOWLOntologyException, OWLReasonerException{
+ public IsolatedOntologyOperation(OWLOntologyManager originalOntologyManager, ReasonerFactory reasonerFactory) throws OWLOntologyCreationException, OWLOntologyChangeException, UnknownOWLOntologyException, OWLReasonerException{
+ //long start = System.currentTimeMillis();
this.isolatedOntologyManager = OWLManager.createOWLOntologyManager();
- this.isolatedOntology = createDebuggingOntology(originalManager, isolatedOntologyManager);
+ this.isolatedOntology = createDebuggingOntology(originalOntologyManager, isolatedOntologyManager);
this.reasonerFactory = new JasdlReasonerFactory();
this.isolatedReasoner = reasonerFactory.createReasoner(isolatedOntologyManager);
this.isolatedReasoner.loadOntologies(isolatedOntologyManager.getImportsClosure(isolatedOntology));
+ //System.out.println("Duration: "+(System.currentTimeMillis() - start) / 1000.0);
}
private OWLOntology createDebuggingOntology(OWLOntologyManager from, OWLOntologyManager to) throws OWLOntologyCreationException, OWLOntologyChangeException{
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlReasonerFactory.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlReasonerFactory.java 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/revision/JasdlReasonerFactory.java 2008-03-31 21:56:43 UTC (rev 1185)
@@ -1,5 +1,6 @@
package jasdl.bb.revision;
+import org.mindswap.pellet.PelletOptions;
import org.mindswap.pellet.owlapi.Reasoner;
import org.semanticweb.owl.inference.OWLReasoner;
import org.semanticweb.owl.model.OWLOntologyManager;
@@ -17,7 +18,8 @@
}
public OWLReasoner createReasoner(OWLOntologyManager manager) {
- return new Reasoner(manager);
+ Reasoner pellet = new Reasoner(manager);
+ return pellet;
}
public String getReasonerName() {
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/MappingManager.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/MappingManager.java 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/MappingManager.java 2008-03-31 21:56:43 UTC (rev 1185)
@@ -43,9 +43,7 @@
if(isKnownRight(y)){
throw new DuplicateMappingException("Duplicate mapping on "+y);
}
-
- logger.fine("Mapped: "+x+" to "+y);
-
+
xToYMap.put(x, y);
yToXMap.put(y, x);
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-03-31 21:10:53 UTC (rev 1184)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bridge/seliteral/SELiteral.java 2008-03-31 21:56:43 UTC (rev 1185)
@@ -260,7 +260,9 @@
+ public String toString(){
+ return literal.toString();
+ }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-03-31 21:10:55
|
Revision: 1184
http://jason.svn.sourceforge.net/jason/?rev=1184&view=rev
Author: jomifred
Date: 2008-03-31 14:10:53 -0700 (Mon, 31 Mar 2008)
Log Message:
-----------
add PlanBody* classes in svn
Modified Paths:
--------------
trunk/src/jason/asSyntax/BodyLiteral.java
Added Paths:
-----------
trunk/src/jason/asSyntax/PlanBody.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
Modified: trunk/src/jason/asSyntax/BodyLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/BodyLiteral.java 2008-03-31 20:04:20 UTC (rev 1183)
+++ trunk/src/jason/asSyntax/BodyLiteral.java 2008-03-31 21:10:53 UTC (rev 1184)
@@ -25,7 +25,6 @@
}
private static PlanBody.BodyType oldToNew(BodyType old) {
- // TODO: implement it!
switch (old) {
case action: return PlanBody.BodyType.action;
case internalAction: return PlanBody.BodyType.internalAction;
Added: trunk/src/jason/asSyntax/PlanBody.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBody.java (rev 0)
+++ trunk/src/jason/asSyntax/PlanBody.java 2008-03-31 21:10:53 UTC (rev 1184)
@@ -0,0 +1,33 @@
+package jason.asSyntax;
+
+public interface PlanBody extends Term {
+
+ public enum BodyType {
+ none { public String toString() { return ""; }},
+ action { public String toString() { return ""; }},
+ internalAction { public String toString() { return ""; }},
+ achieve { public String toString() { return "!"; }},
+ test { public String toString() { return "?"; }},
+ addBel { public String toString() { return "+"; }},
+ delBel { public String toString() { return "-"; }},
+ delAddBel { public String toString() { return "-+"; }},
+ achieveNF { public String toString() { return "!!"; }},
+ constraint { public String toString() { return ""; }}
+ }
+
+ public BodyType getBodyType();
+ public Term getBodyTerm();
+ public PlanBody getBodyNext();
+
+ public boolean isEmptyBody();
+ public int getPlanSize();
+
+ public void setBodyType(BodyType bt);
+ public void setBodyTerm(Term t);
+ public void setBodyNext(PlanBody bl);
+
+
+ public boolean add(PlanBody bl);
+ public boolean add(int index, PlanBody bl);
+ public Term removeBody(int index);
+}
\ No newline at end of file
Added: trunk/src/jason/asSyntax/PlanBodyImpl.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBodyImpl.java (rev 0)
+++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-03-31 21:10:53 UTC (rev 1184)
@@ -0,0 +1,236 @@
+package jason.asSyntax;
+
+import jason.asSemantics.Unifier;
+
+import java.util.Iterator;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Represents a plan body item (achieve, test, action, ...) and its successors.
+ *
+ * A plan body like <code>a1; ?t; !g</code> is represented by the following structure
+ * <code>(a1, (?t, (!g)))</code>.
+ *
+ * @author Jomi
+ */
+public class PlanBodyImpl extends Structure implements PlanBody, Iterable<PlanBody> {
+
+ public static final String BODY_PLAN_FUNCTOR = ";";
+
+ private Term term = null;
+ private PlanBody next = null;
+ private BodyType formType = BodyType.none;
+
+ /** constructor for empty plan body */
+ public PlanBodyImpl() {
+ super(BODY_PLAN_FUNCTOR, 0);
+ }
+
+ public PlanBodyImpl(BodyType t, Term b) {
+ super(BODY_PLAN_FUNCTOR, 0);
+ term = b;
+ formType = t;
+ setSrc(b);
+ }
+
+ public void setBodyNext(PlanBody next) {
+ this.next = next;
+ }
+ public PlanBody getBodyNext() {
+ return next;
+ }
+
+ public boolean isEmptyBody() {
+ return term == null;
+ }
+
+ public BodyType getBodyType() {
+ return formType;
+ }
+ public void setBodyType(BodyType bt) {
+ formType = bt;
+ }
+
+ public Term getBodyTerm() {
+ return term;
+ }
+ public void setBodyTerm(Term t) {
+ term = t;
+ }
+
+ @Override
+ public boolean isPlanBody() {
+ return true;
+ }
+
+ public Iterator<PlanBody> iterator() {
+ return new Iterator<PlanBody>() {
+ PlanBody current = PlanBodyImpl.this;
+ public boolean hasNext() {
+ return current != null && current.getBodyTerm() != null;
+ }
+ public PlanBody next() {
+ PlanBody r = current;
+ if (current != null)
+ current = current.getBodyNext();
+ return r;
+ }
+ public void remove() { }
+ };
+ }
+
+ // Override some structure methods to work with unification/equals
+ @Override
+ public int getArity() {
+ if (term == null)
+ return 0;
+ else if (next == null)
+ return 1;
+ else
+ return 2;
+ }
+
+ @Override
+ public Term getTerm(int i) {
+ if (i == 0)
+ return term;
+ if (i == 1) {
+ if (next != null && next.getBodyTerm().isVar() && next.getBodyNext() == null)
+ // if next is the last VAR, return that var
+ return next.getBodyTerm();
+ else
+ return next;
+ }
+ return null;
+ }
+
+ @Override
+ public void setTerm(int i, Term t) {
+ if (i == 0) term = t;
+ if (i == 1) System.out.println("Should not set next of body literal!");
+ }
+
+ @Override
+ public boolean apply(Unifier u) {
+ // do not apply in next!
+ resetHashCodeCache();
+ if (term != null && term.apply(u)) {
+ if (term.isPlanBody()) { // we can not have "inner" body literals
+ formType = ((PlanBody)term).getBodyType();
+ term = ((PlanBody)term).getBodyTerm();
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null) return false;
+ if (o == this) return true;
+
+ if (o instanceof PlanBody) {
+ PlanBody b = (PlanBody)o;
+ return formType == b.getBodyType() && super.equals(o);
+ }
+ return false;
+ }
+
+ @Override
+ public int calcHashCode() {
+ return formType.hashCode() + super.calcHashCode();
+ }
+
+ public boolean add(PlanBody bl) {
+ if (term == null)
+ swap(bl);
+ else if (next == null)
+ next = bl;
+ else
+ next.add(bl);
+ return true;
+ }
+
+ public boolean add(int index, PlanBody bl) {
+ if (index == 0) {
+ swap(bl);
+ this.next = bl;
+ } else {
+ next.add(index - 1, bl);
+ }
+ return true;
+ }
+
+ public Term removeBody(int index) {
+ if (index == 0) {
+ if (next == null) {
+ term = null; // becomes an empty
+ } else {
+ Term oldvalue = term;
+ swap(next); // get values of text
+ next = next.getBodyNext();
+ return oldvalue;
+ }
+ return this;
+ } else {
+ return next.removeBody(index - 1);
+ }
+ }
+
+ public int getPlanSize() {
+ if (term == null)
+ return 0;
+ else if (next == null)
+ return 1;
+ else
+ return next.getPlanSize() + 1;
+ }
+
+ private void swap(PlanBody bl) {
+ BodyType bt = this.formType;
+ this.formType = bl.getBodyType();
+ bl.setBodyType(bt);
+
+ Term l = this.term;
+ this.term = bl.getBodyTerm();
+ bl.setBodyTerm(l);
+ }
+
+ public Object clone() {
+ if (term == null) // empty
+ return new PlanBodyImpl();
+
+ PlanBodyImpl c = new PlanBodyImpl(formType, (Term)term.clone());
+ if (next != null)
+ c.setBodyNext((PlanBody)getBodyNext().clone());
+ return c;
+ }
+
+ public String toString() {
+ if (term == null)
+ return "";
+ else if (next == null)
+ return formType.toString() + term;
+ else
+ return formType.toString() + term + "; " + next;
+ }
+
+ /** get as XML */
+ public Element getAsDOM(Document document) {
+ Element eb = (Element) document.createElement("body");
+ PlanBody bl = this;
+ while (bl != null && !bl.isEmptyBody()) {
+ Element u = (Element) document.createElement("body-literal");
+ if (bl.getBodyType().toString().length() > 0) {
+ u.setAttribute("type", bl.getBodyType().toString());
+ }
+ u.appendChild( ((Structure)bl.getBodyTerm()).getAsDOM(document));
+ eb.appendChild(u);
+
+ bl = bl.getBodyNext();
+ }
+ return eb;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-03-31 20:04:25
|
Revision: 1183
http://jason.svn.sourceforge.net/jason/?rev=1183&view=rev
Author: jomifred
Date: 2008-03-31 13:04:20 -0700 (Mon, 31 Mar 2008)
Log Message:
-----------
rename BodyLiteral to BodyPlan (old class is still there, but deprecated)
Modified Paths:
--------------
trunk/demos/directives/myp/LoggerDirective.java
trunk/src/jason/asSemantics/IntendedMeans.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/BodyLiteral.java
trunk/src/jason/asSyntax/Plan.java
trunk/src/jason/asSyntax/PlanLibrary.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
trunk/src/jason/asSyntax/parser/as2jTokenManager.java
trunk/src/jason/asSyntax/patterns/goal/DG.java
trunk/src/jason/asSyntax/patterns/goal/EBDG.java
trunk/src/jason/stdlib/remove_plan.java
trunk/src/jason/stdlib/wait.java
trunk/src/test/ASParserTest.java
trunk/src/test/PlanTest.java
Removed Paths:
-------------
trunk/src/jason/asSyntax/BodyLiteralImpl.java
trunk/src/jason/stdlib/myName.java
Modified: trunk/demos/directives/myp/LoggerDirective.java
===================================================================
--- trunk/demos/directives/myp/LoggerDirective.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/demos/directives/myp/LoggerDirective.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -2,12 +2,12 @@
package myp;
import jason.asSemantics.Agent;
-import jason.asSyntax.BodyLiteral;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.Plan;
import jason.asSyntax.Pred;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.directives.Directive;
import java.util.logging.Level;
@@ -28,11 +28,11 @@
// add .print(te) in the begin and end of the plan
for (Plan p: innerContent.getPL()) {
Literal print1 = Literal.parseLiteral(".print(\"Entering \","+p.getTrigger().getLiteral()+")");
- BodyLiteral b1 = new BodyLiteralImpl(BodyType.internalAction, print1);
+ PlanBody b1 = new PlanBodyImpl(BodyType.internalAction, print1);
p.getBody().add(0,b1);
Literal print2 = Literal.parseLiteral(".print(\"Leaving \","+p.getTrigger().getLiteral()+")");
- BodyLiteral b2 = new BodyLiteralImpl(BodyType.internalAction, print2);
+ PlanBody b2 = new PlanBodyImpl(BodyType.internalAction, print2);
p.getBody().add(b2);
newAg.getPL().add(p);
Modified: trunk/src/jason/asSemantics/IntendedMeans.java
===================================================================
--- trunk/src/jason/asSemantics/IntendedMeans.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSemantics/IntendedMeans.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -24,8 +24,8 @@
package jason.asSemantics;
-import jason.asSyntax.BodyLiteral;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
import jason.asSyntax.Literal;
@@ -73,7 +73,7 @@
/** removes the current action of the IM and returns the term of the body */
public Term removeCurrentStep() {
- BodyLiteral current = plan.getBody();
+ PlanBody current = plan.getBody();
if (current.isEmptyBody()) {
return null;
} else {
@@ -81,7 +81,7 @@
}
}
- public BodyLiteral getCurrentStep() {
+ public PlanBody getCurrentStep() {
return plan.getBody();
}
@@ -129,10 +129,10 @@
public Term getAsTerm() {
Structure im = new Structure("im");
im.addTerm(new StringTermImpl(plan.getLabel().toString()));
- if (plan.getBody() instanceof BodyLiteralImpl) {
+ if (plan.getBody() instanceof PlanBodyImpl) {
ListTerm lt = new ListTermImpl();
- for (BodyLiteral bd: (BodyLiteralImpl)plan.getBody()) {
- BodyLiteral c = (BodyLiteral)bd.clone();
+ for (PlanBody bd: (PlanBodyImpl)plan.getBody()) {
+ PlanBody c = (PlanBody)bd.clone();
c.apply(unif);
lt.add(new StringTermImpl(c.getBodyType().toString()+c.getBodyTerm()));
}
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -27,7 +27,7 @@
import jason.RevisionFailedException;
import jason.architecture.AgArch;
import jason.asSyntax.Atom;
-import jason.asSyntax.BodyLiteral;
+import jason.asSyntax.PlanBody;
import jason.asSyntax.DefaultTerm;
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.ListTermImpl;
@@ -286,11 +286,11 @@
}
/**
- * This step is new in Jason 1.0.2 and replaces the steps RelPl->ApplPl->SelAppl when the user
+ * This step is new in Jason 1.1 and replaces the steps RelPl->ApplPl->SelAppl when the user
* does not customise selectOption. This version does not create the RP and AP lists and thus
* optimise the reasoning cycle. It searches for the first option and automatically selects it.
*
- * @since 1.0.2
+ * @since 1.1
*/
private void applyFindOp() throws JasonException {
confP.step = State.AddIM; // default next step
@@ -402,7 +402,7 @@
return;
}
Unifier u = im.unif;
- BodyLiteral h = im.getCurrentStep();
+ PlanBody h = im.getCurrentStep();
h.apply(u);
Literal body = null;
Modified: trunk/src/jason/asSyntax/BodyLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/BodyLiteral.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/BodyLiteral.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -1,7 +1,12 @@
package jason.asSyntax;
-public interface BodyLiteral extends Term {
+/**
+ * @deprecated use PlanBodyImpl instead.
+ */
+public class BodyLiteral extends PlanBodyImpl {
+
+ /** @deprecated Use BodyType of PlanBody instead */
public enum BodyType {
none { public String toString() { return ""; }},
action { public String toString() { return ""; }},
@@ -15,19 +20,24 @@
constraint { public String toString() { return ""; }}
}
- public BodyType getBodyType();
- public Term getBodyTerm();
- public BodyLiteral getBodyNext();
+ public BodyLiteral(BodyType t, Term b) {
+ super(oldToNew(t),b);
+ }
+
+ private static PlanBody.BodyType oldToNew(BodyType old) {
+ // TODO: implement it!
+ switch (old) {
+ case action: return PlanBody.BodyType.action;
+ case internalAction: return PlanBody.BodyType.internalAction;
+ case achieve: return PlanBody.BodyType.achieve;
+ case test: return PlanBody.BodyType.test;
+ case addBel: return PlanBody.BodyType.addBel;
+ case delBel: return PlanBody.BodyType.delBel;
+ case delAddBel: return PlanBody.BodyType.delAddBel;
+ case achieveNF: return PlanBody.BodyType.achieveNF;
+ case constraint: return PlanBody.BodyType.constraint;
+ }
+ return PlanBody.BodyType.none;
+ }
- public boolean isEmptyBody();
- public int getPlanSize();
-
- public void setBodyType(BodyType bt);
- public void setBodyTerm(Term t);
- public void setBodyNext(BodyLiteral bl);
-
-
- public boolean add(BodyLiteral bl);
- public boolean add(int index, BodyLiteral bl);
- public Term removeBody(int index);
-}
\ No newline at end of file
+}
Deleted: trunk/src/jason/asSyntax/BodyLiteralImpl.java
===================================================================
--- trunk/src/jason/asSyntax/BodyLiteralImpl.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/BodyLiteralImpl.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -1,236 +0,0 @@
-package jason.asSyntax;
-
-import jason.asSemantics.Unifier;
-
-import java.util.Iterator;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Represents a plan body item (achieve, test, action, ...) and its successors.
- *
- * A plan body like <code>a1; ?t; !g</code> is represented by the following structure
- * <code>(a1, (?t, (!g)))</code>.
- *
- * @author Jomi
- */
-public class BodyLiteralImpl extends Structure implements BodyLiteral, Iterable<BodyLiteral> {
-
- public static final String BODY_PLAN_FUNCTOR = ";";
-
- private Term term = null;
- private BodyLiteral next = null;
- private BodyType formType = BodyType.none;
-
- /** constructor for empty plan body */
- public BodyLiteralImpl() {
- super(BODY_PLAN_FUNCTOR, 0);
- }
-
- public BodyLiteralImpl(BodyType t, Term b) {
- super(BODY_PLAN_FUNCTOR, 0);
- term = b;
- formType = t;
- setSrc(b);
- }
-
- public void setBodyNext(BodyLiteral next) {
- this.next = next;
- }
- public BodyLiteral getBodyNext() {
- return next;
- }
-
- public boolean isEmptyBody() {
- return term == null;
- }
-
- public BodyType getBodyType() {
- return formType;
- }
- public void setBodyType(BodyType bt) {
- formType = bt;
- }
-
- public Term getBodyTerm() {
- return term;
- }
- public void setBodyTerm(Term t) {
- term = t;
- }
-
- @Override
- public boolean isPlanBody() {
- return true;
- }
-
- public Iterator<BodyLiteral> iterator() {
- return new Iterator<BodyLiteral>() {
- BodyLiteral current = BodyLiteralImpl.this;
- public boolean hasNext() {
- return current != null && current.getBodyTerm() != null;
- }
- public BodyLiteral next() {
- BodyLiteral r = current;
- if (current != null)
- current = current.getBodyNext();
- return r;
- }
- public void remove() { }
- };
- }
-
- // Override some structure methods to work with unification/equals
- @Override
- public int getArity() {
- if (term == null)
- return 0;
- else if (next == null)
- return 1;
- else
- return 2;
- }
-
- @Override
- public Term getTerm(int i) {
- if (i == 0)
- return term;
- if (i == 1) {
- if (next != null && next.getBodyTerm().isVar() && next.getBodyNext() == null)
- // if next is the last VAR, return that var
- return next.getBodyTerm();
- else
- return next;
- }
- return null;
- }
-
- @Override
- public void setTerm(int i, Term t) {
- if (i == 0) term = t;
- if (i == 1) System.out.println("Should not set next of body literal!");
- }
-
- @Override
- public boolean apply(Unifier u) {
- // do not apply in next!
- resetHashCodeCache();
- if (term != null && term.apply(u)) {
- if (term.isPlanBody()) { // we can not have "inner" body literals
- formType = ((BodyLiteral)term).getBodyType();
- term = ((BodyLiteral)term).getBodyTerm();
- }
- return true;
- }
- return false;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == null) return false;
- if (o == this) return true;
-
- if (o instanceof BodyLiteral) {
- BodyLiteral b = (BodyLiteral)o;
- return formType == b.getBodyType() && super.equals(o);
- }
- return false;
- }
-
- @Override
- public int calcHashCode() {
- return formType.hashCode() + super.calcHashCode();
- }
-
- public boolean add(BodyLiteral bl) {
- if (term == null)
- swap(bl);
- else if (next == null)
- next = bl;
- else
- next.add(bl);
- return true;
- }
-
- public boolean add(int index, BodyLiteral bl) {
- if (index == 0) {
- swap(bl);
- this.next = bl;
- } else {
- next.add(index - 1, bl);
- }
- return true;
- }
-
- public Term removeBody(int index) {
- if (index == 0) {
- if (next == null) {
- term = null; // becomes an empty
- } else {
- Term oldvalue = term;
- swap(next); // get values of text
- next = next.getBodyNext();
- return oldvalue;
- }
- return this;
- } else {
- return next.removeBody(index - 1);
- }
- }
-
- public int getPlanSize() {
- if (term == null)
- return 0;
- else if (next == null)
- return 1;
- else
- return next.getPlanSize() + 1;
- }
-
- private void swap(BodyLiteral bl) {
- BodyType bt = this.formType;
- this.formType = bl.getBodyType();
- bl.setBodyType(bt);
-
- Term l = this.term;
- this.term = bl.getBodyTerm();
- bl.setBodyTerm(l);
- }
-
- public Object clone() {
- if (term == null) // empty
- return new BodyLiteralImpl();
-
- BodyLiteralImpl c = new BodyLiteralImpl(formType, (Term)term.clone());
- if (next != null)
- c.setBodyNext((BodyLiteral)getBodyNext().clone());
- return c;
- }
-
- public String toString() {
- if (term == null)
- return "";
- else if (next == null)
- return formType.toString() + term;
- else
- return formType.toString() + term + "; " + next;
- }
-
- /** get as XML */
- public Element getAsDOM(Document document) {
- Element eb = (Element) document.createElement("body");
- BodyLiteral bl = this;
- while (bl != null && !bl.isEmptyBody()) {
- Element u = (Element) document.createElement("body-literal");
- if (bl.getBodyType().toString().length() > 0) {
- u.setAttribute("type", bl.getBodyType().toString());
- }
- u.appendChild( ((Structure)bl.getBodyTerm()).getAsDOM(document));
- eb.appendChild(u);
-
- bl = bl.getBodyNext();
- }
- return eb;
- }
-}
Modified: trunk/src/jason/asSyntax/Plan.java
===================================================================
--- trunk/src/jason/asSyntax/Plan.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/Plan.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -51,7 +51,7 @@
private Pred label = null;
private Trigger tevent = null;
private LogicalFormula context;
- private BodyLiteral body;
+ private PlanBody body;
private boolean isAtomic = false;
@@ -63,12 +63,12 @@
}
// used by parser
- public Plan(Pred label, Trigger te, LogicalFormula ct, BodyLiteral bd) {
+ public Plan(Pred label, Trigger te, LogicalFormula ct, PlanBody bd) {
tevent = te;
setLabel(label);
setContext(ct);
if (bd == null)
- body = new BodyLiteralImpl();
+ body = new PlanBodyImpl();
else
body = bd;
}
@@ -121,7 +121,7 @@
return context;
}
- public BodyLiteral getBody() {
+ public PlanBody getBody() {
return body;
}
@@ -201,7 +201,7 @@
if (context != null)
p.context = (LogicalFormula)context.clone();
- p.body = (BodyLiteral)body.clone();
+ p.body = (PlanBody)body.clone();
p.setSrc(this);
@@ -219,7 +219,7 @@
p.tevent = (Trigger)tevent.clone();
p.context = context;
- p.body = (BodyLiteral)body.clone();
+ p.body = (PlanBody)body.clone();
p.setSrc(this);
Modified: trunk/src/jason/asSyntax/PlanLibrary.java
===================================================================
--- trunk/src/jason/asSyntax/PlanLibrary.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/PlanLibrary.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -195,7 +195,7 @@
* Remove a plan represented by the label <i>pLabel</i>.
* In case the plan has many sources, only the plan's source is removed.
*/
- public boolean removePlan(Structure pLabel, Structure source) {
+ public boolean remove(Structure pLabel, Structure source) {
// find the plan
Plan p = get(pLabel.getFunctor());
if (p != null) {
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -46,7 +46,7 @@
*
* @author jomi
*/
-public class VarTerm extends Literal implements NumberTerm, ListTerm, StringTerm, ObjectTerm, BodyLiteral {
+public class VarTerm extends Literal implements NumberTerm, ListTerm, StringTerm, ObjectTerm, PlanBody {
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(VarTerm.class.getName());
@@ -873,72 +873,72 @@
// -----------------------
public BodyType getBodyType() {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).getBodyType();
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).getBodyType();
else
return BodyType.none;
}
public Term getBodyTerm() {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).getBodyTerm();
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).getBodyTerm();
else
return null;
}
- public BodyLiteral getBodyNext() {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).getBodyNext();
+ public PlanBody getBodyNext() {
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).getBodyNext();
else
return null;
}
public boolean isEmptyBody() {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).isEmptyBody();
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).isEmptyBody();
else
return true;
}
public int getPlanSize() {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).getPlanSize();
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).getPlanSize();
else
return 0;
}
public void setBodyType(BodyType bt) {
- if (value != null && getValue() instanceof BodyLiteral)
- ((BodyLiteral) getValue()).setBodyType(bt);
+ if (value != null && getValue() instanceof PlanBody)
+ ((PlanBody) getValue()).setBodyType(bt);
}
public void setBodyTerm(Term t) {
- if (value != null && getValue() instanceof BodyLiteral)
- ((BodyLiteral) getValue()).setBodyTerm(t);
+ if (value != null && getValue() instanceof PlanBody)
+ ((PlanBody) getValue()).setBodyTerm(t);
}
- public void setBodyNext(BodyLiteral bl) {
- if (value != null && getValue() instanceof BodyLiteral)
- ((BodyLiteral) getValue()).setBodyNext(bl);
+ public void setBodyNext(PlanBody bl) {
+ if (value != null && getValue() instanceof PlanBody)
+ ((PlanBody) getValue()).setBodyNext(bl);
}
- public boolean add(BodyLiteral bl) {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).add(bl);
+ public boolean add(PlanBody bl) {
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).add(bl);
else
return false;
}
- public boolean add(int index, BodyLiteral bl) {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).add(index, bl);
+ public boolean add(int index, PlanBody bl) {
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).add(index, bl);
else
return false;
}
public Term removeBody(int index) {
- if (value != null && getValue() instanceof BodyLiteral)
- return ((BodyLiteral) getValue()).removeBody(index);
+ if (value != null && getValue() instanceof PlanBody)
+ return ((PlanBody) getValue()).removeBody(index);
else
return null;
}
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-03-31 20:04:20 UTC (rev 1183)
@@ -43,7 +43,7 @@
import jason.asSyntax.ArithExpr.ArithmeticOp;
import jason.asSyntax.LogExpr.LogicalOp;
import jason.asSyntax.RelExpr.RelationalOp;
- import jason.asSyntax.BodyLiteral.BodyType;
+ import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
import jason.jeditplugin.*;
@@ -289,7 +289,7 @@
/* Plan */
Plan plan() : { Token k; Pred L = null;
Trigger T;
- Object C = null; BodyLiteral bl = null;
+ Object C = null; PlanBody bl = null;
Object B = null;
int start = -1, end;}
{
@@ -304,11 +304,11 @@
if (ial != null)
throw new ParseException(getSourceRef(ial)+" The internal action '"+ial+"' can not be used in plan's context!");
if (B != null) {
- if (!(B instanceof BodyLiteral))
+ if (!(B instanceof PlanBody))
throw new ParseException(getSourceRef(B)+" Unknown body formula:"+B);
- bl = (BodyLiteral)B;
+ bl = (PlanBody)B;
if (bl.getBodyTerm().equals(Literal.LTrue))
- bl = (BodyLiteral)bl.getBodyNext();
+ bl = (PlanBody)bl.getBodyNext();
}
Plan p = new Plan(L,T,(LogicalFormula)C, bl);
p.setSrcLines(start,end);
@@ -366,11 +366,11 @@
{
F = body_formula()
- [ ";" { if (!(F instanceof BodyLiteral)) throw new ParseException(getSourceRef(F)+" "+F+" is not a body literal!"); }
- R = plan_body() { if (!(R instanceof BodyLiteral)) throw new ParseException(getSourceRef(R)+" "+R+" is not a body literal!"); }
+ [ ";" { if (!(F instanceof PlanBody)) throw new ParseException(getSourceRef(F)+" "+F+" is not a body literal!"); }
+ R = plan_body() { if (!(R instanceof PlanBody)) throw new ParseException(getSourceRef(R)+" "+R+" is not a body literal!"); }
]
- { if (F instanceof BodyLiteral && R instanceof BodyLiteral) {
- ((BodyLiteral)F).setBodyNext( (BodyLiteral)R );
+ { if (F instanceof PlanBody && R instanceof PlanBody) {
+ ((PlanBody)F).setBodyNext( (PlanBody)R );
}
return F;
}
@@ -394,13 +394,13 @@
{ if (B instanceof Literal) {
if ( ((Literal)B).isInternalAction() )
formType = BodyType.internalAction;
- return new BodyLiteralImpl(formType, (Literal)B);
+ return new PlanBodyImpl(formType, (Literal)B);
} else if (formType == BodyType.action && B instanceof RelExpr) {
- return new BodyLiteralImpl(BodyType.constraint, (RelExpr)B); // constraint
+ return new PlanBodyImpl(BodyType.constraint, (RelExpr)B); // constraint
} else {
if (formType == BodyType.test) {
if (B instanceof LogicalFormula)
- return new BodyLiteralImpl(BodyType.test, (Term)B); // used in ?(a & b)
+ return new PlanBodyImpl(BodyType.test, (Term)B); // used in ?(a & b)
else
throw new ParseException(getSourceRef(B)+" The argument for ? is not a logical formula.");
} else {
@@ -451,9 +451,9 @@
( o=list()
| o=log_expr() //plan_body() // plan_body includes literals/atoms/structures
)
- { // if the result is a BodyLiteral action with size = 1, it is indeed a literal and not a body literal
- /*if (o instanceof BodyLiteral) {
- BodyLiteral bl = (BodyLiteral)o;
+ { // if the result is a PlanBody action with size = 1, it is indeed a literal and not a body literal
+ /*if (o instanceof PlanBody) {
+ PlanBody bl = (PlanBody)o;
if (bl.getBodyType() == BodyType.action && bl.getPlanSize() == 1) {
o = bl.getBodyTerm();
}
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -13,7 +13,7 @@
import jason.asSyntax.ArithExpr.ArithmeticOp;
import jason.asSyntax.LogExpr.LogicalOp;
import jason.asSyntax.RelExpr.RelationalOp;
- import jason.asSyntax.BodyLiteral.BodyType;
+ import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
import jason.jeditplugin.*;
@@ -316,7 +316,7 @@
final public Plan plan() throws ParseException {
Token k; Pred L = null;
Trigger T;
- Object C = null; BodyLiteral bl = null;
+ Object C = null; PlanBody bl = null;
Object B = null;
int start = -1, end;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -358,11 +358,11 @@
if (ial != null)
{if (true) throw new ParseException(getSourceRef(ial)+" The internal action '"+ial+"' can not be used in plan's context!");}
if (B != null) {
- if (!(B instanceof BodyLiteral))
+ if (!(B instanceof PlanBody))
{if (true) throw new ParseException(getSourceRef(B)+" Unknown body formula:"+B);}
- bl = (BodyLiteral)B;
+ bl = (PlanBody)B;
if (bl.getBodyTerm().equals(Literal.LTrue))
- bl = (BodyLiteral)bl.getBodyNext();
+ bl = (PlanBody)bl.getBodyNext();
}
Plan p = new Plan(L,T,(LogicalFormula)C, bl);
p.setSrcLines(start,end);
@@ -485,16 +485,16 @@
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case 37:
jj_consume_token(37);
- if (!(F instanceof BodyLiteral)) {if (true) throw new ParseException(getSourceRef(F)+" "+F+" is not a body literal!");}
+ if (!(F instanceof PlanBody)) {if (true) throw new ParseException(getSourceRef(F)+" "+F+" is not a body literal!");}
R = plan_body();
- if (!(R instanceof BodyLiteral)) {if (true) throw new ParseException(getSourceRef(R)+" "+R+" is not a body literal!");}
+ if (!(R instanceof PlanBody)) {if (true) throw new ParseException(getSourceRef(R)+" "+R+" is not a body literal!");}
break;
default:
jj_la1[19] = jj_gen;
;
}
- if (F instanceof BodyLiteral && R instanceof BodyLiteral) {
- ((BodyLiteral)F).setBodyNext( (BodyLiteral)R );
+ if (F instanceof PlanBody && R instanceof PlanBody) {
+ ((PlanBody)F).setBodyNext( (PlanBody)R );
}
{if (true) return F;}
throw new Error("Missing return statement in function");
@@ -552,13 +552,13 @@
if (B instanceof Literal) {
if ( ((Literal)B).isInternalAction() )
formType = BodyType.internalAction;
- {if (true) return new BodyLiteralImpl(formType, (Literal)B);}
+ {if (true) return new PlanBodyImpl(formType, (Literal)B);}
} else if (formType == BodyType.action && B instanceof RelExpr) {
- {if (true) return new BodyLiteralImpl(BodyType.constraint, (RelExpr)B);} // constraint
+ {if (true) return new PlanBodyImpl(BodyType.constraint, (RelExpr)B);} // constraint
} else {
if (formType == BodyType.test) {
if (B instanceof LogicalFormula)
- {if (true) return new BodyLiteralImpl(BodyType.test, (Term)B);} // used in ?(a & b)
+ {if (true) return new PlanBodyImpl(BodyType.test, (Term)B);} // used in ?(a & b)
else
{if (true) throw new ParseException(getSourceRef(B)+" The argument for ? is not a logical formula.");}
} else {
@@ -662,9 +662,9 @@
jj_consume_token(-1);
throw new ParseException();
}
- // if the result is a BodyLiteral action with size = 1, it is indeed a literal and not a body literal
- /*if (o instanceof BodyLiteral) {
- BodyLiteral bl = (BodyLiteral)o;
+ // if the result is a PlanBody action with size = 1, it is indeed a literal and not a body literal
+ /*if (o instanceof PlanBody) {
+ PlanBody bl = (PlanBody)o;
if (bl.getBodyType() == BodyType.action && bl.getPlanSize() == 1) {
o = bl.getBodyTerm();
}
Modified: trunk/src/jason/asSyntax/parser/as2jTokenManager.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2jTokenManager.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/parser/as2jTokenManager.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -11,7 +11,7 @@
import jason.asSyntax.ArithExpr.ArithmeticOp;
import jason.asSyntax.LogExpr.LogicalOp;
import jason.asSyntax.RelExpr.RelationalOp;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
import jason.jeditplugin.*;
Modified: trunk/src/jason/asSyntax/patterns/goal/DG.java
===================================================================
--- trunk/src/jason/asSyntax/patterns/goal/DG.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/patterns/goal/DG.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -1,12 +1,12 @@
package jason.asSyntax.patterns.goal;
import jason.asSemantics.Agent;
-import jason.asSyntax.BodyLiteral;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.Plan;
import jason.asSyntax.Pred;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.directives.Directive;
import java.util.logging.Level;
@@ -32,7 +32,7 @@
// add ?g in the end of all inner plans
for (Plan p: innerContent.getPL()) {
- BodyLiteral b = new BodyLiteralImpl(BodyType.test, (Literal)goal.clone());
+ PlanBody b = new PlanBodyImpl(BodyType.test, (Literal)goal.clone());
p.getBody().add(b);
newAg.getPL().add(p);
}
Modified: trunk/src/jason/asSyntax/patterns/goal/EBDG.java
===================================================================
--- trunk/src/jason/asSyntax/patterns/goal/EBDG.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/asSyntax/patterns/goal/EBDG.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -1,15 +1,15 @@
package jason.asSyntax.patterns.goal;
import jason.asSemantics.Agent;
-import jason.asSyntax.BodyLiteral;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.LogExpr;
import jason.asSyntax.LogicalFormula;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.Plan;
import jason.asSyntax.Pred;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.LogExpr.LogicalOp;
import jason.asSyntax.directives.Directive;
@@ -53,10 +53,10 @@
// change body
// add +p__f(i,g)
- BodyLiteral b1 = new BodyLiteralImpl(BodyType.addBel, pi);
+ PlanBody b1 = new PlanBodyImpl(BodyType.addBel, pi);
p.getBody().add(0, b1);
// add ?g
- BodyLiteral b2 = new BodyLiteralImpl(BodyType.test, (Literal)goal.clone());
+ PlanBody b2 = new PlanBodyImpl(BodyType.test, (Literal)goal.clone());
p.getBody().add(b2);
newAg.getPL().add(p);
}
Deleted: trunk/src/jason/stdlib/myName.java
===================================================================
--- trunk/src/jason/stdlib/myName.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/stdlib/myName.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -1,73 +0,0 @@
-//----------------------------------------------------------------------------
-// Copyright (C) 2003 Rafael H. Bordini, Jomi F. Hubner, et al.
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library 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 GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// To contact the authors:
-// http://www.dur.ac.uk/r.bordini
-// http://www.inf.furb.br/~jomi
-//
-//----------------------------------------------------------------------------
-
-package jason.stdlib;
-
-import jason.JasonException;
-import jason.asSemantics.DefaultInternalAction;
-import jason.asSemantics.TransitionSystem;
-import jason.asSemantics.Unifier;
-import jason.asSyntax.Structure;
-import jason.asSyntax.Term;
-
-/**
- <p>Internal action: <b><code>.myName</code></b>.
-
- <p>Description: gets the agent unique identification in the
- multi-agent system. This identification is given by the runtime
- infrastructure of the system (centralised, saci, jade, ...).
-
- <p>Parameters:<ul>
-
- <li>+/- arg[0] (variable or atom): if this is a variable, unifies the agent
- name and the variable; if is is an atom, succeeds if the atom is equal to
- the agent's name.<br/>
-
- </ul>
-
- <p>Example:<ul>
-
- <li> <code>.myName(N)</code>: unifies <code>N</code> with the
- agent's name.</li>
-
- </ul>
-
-
- @see jason.stdlib.send
- @see jason.stdlib.broadcast
-
- @deprecated use .my_name instead
-
- */
-public class myName extends DefaultInternalAction {
-
- @Override
- public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- try {
- ts.getLogger().info("Deprecated: use .my_name instead of .myName.");
- return un.unifies(args[0], new Structure(ts.getUserAgArch().getAgName()));
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The internal action 'myName' has not received the required argument.");
- }
- }
-}
Modified: trunk/src/jason/stdlib/remove_plan.java
===================================================================
--- trunk/src/jason/stdlib/remove_plan.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/stdlib/remove_plan.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -91,11 +91,11 @@
boolean r = true;
ListTerm lt = (ListTerm)args[0];
for (Term t: lt) {
- r = r && ts.getAg().getPL().removePlan((Structure)t, source);
+ r = r && ts.getAg().getPL().remove((Structure)t, source);
}
return r;
} else { // args[0] is a plan label
- return ts.getAg().getPL().removePlan((Structure)label, source);
+ return ts.getAg().getPL().remove((Structure)label, source);
}
} catch (ArrayIndexOutOfBoundsException e) {
throw new JasonException("The internal action 'remove_plan' has not received the required argument (a plan label or list of labels).");
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/jason/stdlib/wait.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -31,12 +31,12 @@
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.Atom;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.NumberTerm;
import jason.asSyntax.StringTerm;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import java.util.ArrayList;
import java.util.Collections;
@@ -176,7 +176,7 @@
si.peek().removeCurrentStep();
if (stopByTimeout && te != null) {
// fail the .wait
- si.peek().getPlan().getBody().add(0, new BodyLiteralImpl(BodyType.internalAction, new Atom(".fail")));
+ si.peek().getPlan().getBody().add(0, new PlanBodyImpl(BodyType.internalAction, new Atom(".fail")));
}
if (si.isSuspended()) { // if the intention was suspended by .suspend
String k = suspend.SUSPENDED_INT+si.getId();
Modified: trunk/src/test/ASParserTest.java
===================================================================
--- trunk/src/test/ASParserTest.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/test/ASParserTest.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -4,7 +4,7 @@
import jason.asSemantics.Agent;
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
-import jason.asSyntax.BodyLiteral;
+import jason.asSyntax.PlanBody;
import jason.asSyntax.LogExpr;
import jason.asSyntax.LogicalFormula;
import jason.asSyntax.NumberTerm;
@@ -40,7 +40,7 @@
assertTrue(ag.parseAS("examples/auction/ag1.asl"));
Plan p = ag.getPL().get("l__0");
assertEquals(p.getBody().getPlanSize(), 1);
- assertEquals(((BodyLiteral)p.getBody()).getBodyType(), BodyLiteral.BodyType.internalAction);
+ assertEquals(((PlanBody)p.getBody()).getBodyType(), PlanBody.BodyType.internalAction);
assertTrue(ag.parseAS("examples/auction/ag2.asl"));
assertTrue(ag.parseAS("examples/auction/ag3.asl"));
}
Modified: trunk/src/test/PlanTest.java
===================================================================
--- trunk/src/test/PlanTest.java 2008-03-31 19:25:02 UTC (rev 1182)
+++ trunk/src/test/PlanTest.java 2008-03-31 20:04:20 UTC (rev 1183)
@@ -2,14 +2,14 @@
import jason.JasonException;
import jason.asSemantics.Unifier;
-import jason.asSyntax.BodyLiteral;
-import jason.asSyntax.BodyLiteralImpl;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Literal;
import jason.asSyntax.Plan;
import jason.asSyntax.PlanLibrary;
import jason.asSyntax.Trigger;
import jason.asSyntax.VarTerm;
-import jason.asSyntax.BodyLiteral.BodyType;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.parser.ParseException;
import java.util.Iterator;
@@ -58,18 +58,18 @@
public void testParser1() {
Plan p = Plan.parse("+te : a & b <- a1; a2; .print(a); !g1; !!g2; ?test1; 10 > 3; +b1; -b2; -+b3.");
p = (Plan)p.clone();
- Iterator<BodyLiteral> i = ((BodyLiteralImpl)p.getBody()).iterator();
- assertEquals( BodyLiteral.BodyType.action, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.action, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.internalAction, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.achieve, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.achieveNF, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.test, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.constraint, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.addBel, ((BodyLiteral)i.next()).getBodyType());
- assertEquals( BodyLiteral.BodyType.delBel, ((BodyLiteral)i.next()).getBodyType());
+ Iterator<PlanBody> i = ((PlanBodyImpl)p.getBody()).iterator();
+ assertEquals( PlanBody.BodyType.action, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.action, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.internalAction, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.achieve, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.achieveNF, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.test, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.constraint, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.addBel, ((PlanBody)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.delBel, ((PlanBody)i.next()).getBodyType());
assertTrue(i.hasNext());
- assertEquals( BodyLiteral.BodyType.delAddBel, ((BodyLiteral)i.next()).getBodyType());
+ assertEquals( PlanBody.BodyType.delAddBel, ((PlanBody)i.next()).getBodyType());
assertFalse(i.hasNext());
}
@@ -78,7 +78,7 @@
assertEquals(4, p.getBody().getPlanSize());
p.getBody().removeBody(0);
assertEquals(3, p.getBody().getPlanSize());
- assertEquals(BodyLiteral.BodyType.test, p.getBody().getBodyType());
+ assertEquals(PlanBody.BodyType.test, p.getBody().getBodyType());
p.getBody().removeBody(0); // 2
p.getBody().removeBody(0); // 1
assertEquals(1, p.getBody().getPlanSize());
@@ -87,7 +87,7 @@
}
public void testEqualsBodyLiteral() {
- BodyLiteral bl = new BodyLiteralImpl(BodyType.achieve, new Literal("g1"));
+ PlanBody bl = new PlanBodyImpl(BodyType.achieve, new Literal("g1"));
VarTerm v = new VarTerm("X");
Unifier u = new Unifier();
// X = !g1
@@ -101,9 +101,9 @@
public void testUnifyBody() {
Plan p1 = Plan.parse("+te : a & b <- !a1; ?a2; .print(a); !g1.");
- BodyLiteral bl = new BodyLiteralImpl(BodyType.action, new VarTerm("A1"));
- bl.add(new BodyLiteralImpl(BodyType.action, new VarTerm("A2")));
- bl.add(new BodyLiteralImpl(BodyType.action, new VarTerm("A3")));
+ PlanBody bl = new PlanBodyImpl(BodyType.action, new VarTerm("A1"));
+ bl.add(new PlanBodyImpl(BodyType.action, new VarTerm("A2")));
+ bl.add(new PlanBodyImpl(BodyType.action, new VarTerm("A3")));
//assertEquals(p1.getBody().getArity(), bl.getArity());
Unifier u = new Unifier();
assertTrue(u.unifies(p1.getBody(), bl));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-03-31 19:25:04
|
Revision: 1182
http://jason.svn.sourceforge.net/jason/?rev=1182&view=rev
Author: jomifred
Date: 2008-03-31 12:25:02 -0700 (Mon, 31 Mar 2008)
Log Message:
-----------
rename some methods:
BB: getRelevant(Literal l) -> getCandidateBeliefs(Literal l, Unifier u)
PL: isRelevant(Trigger te) -> hasCandidatePlan(Trigger te)
getAllRelevant(Trigger te) -> getCandidatePlans(Trigger te)
Modified Paths:
--------------
trunk/demos/persistent-belief-base/VoidBB.java
trunk/demos/tell-rule/rules/get_rules.java
trunk/examples/gold-miners-II/agent/UniqueBelsBB.java
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/PlanLibrary.java
trunk/src/jason/bb/BeliefBase.java
trunk/src/jason/bb/DefaultBeliefBase.java
trunk/src/jason/bb/JDBCPersistentBB.java
trunk/src/test/BeliefBaseTest.java
trunk/src/test/PlanTest.java
trunk/src/test/RuleTest.java
trunk/src/test/VarTermTest.java
Modified: trunk/demos/persistent-belief-base/VoidBB.java
===================================================================
--- trunk/demos/persistent-belief-base/VoidBB.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/demos/persistent-belief-base/VoidBB.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -55,6 +55,10 @@
return true;
}
+ public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u) {
+ return new ArrayList<Literal>().iterator();
+ }
+
public Iterator<Literal> getRelevant(Literal l) {
return new ArrayList<Literal>().iterator();
}
Modified: trunk/demos/tell-rule/rules/get_rules.java
===================================================================
--- trunk/demos/tell-rule/rules/get_rules.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/demos/tell-rule/rules/get_rules.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -22,7 +22,7 @@
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
Literal pattern = (Literal)args[0];
- Iterator<Literal> i = ts.getAg().getBB().getRelevant(pattern);
+ Iterator<Literal> i = ts.getAg().getBB().getCandidateBeliefs(pattern, un);
ListTerm result = new ListTermImpl();
while (i.hasNext()) {
Literal l = i.next();
Modified: trunk/examples/gold-miners-II/agent/UniqueBelsBB.java
===================================================================
--- trunk/examples/gold-miners-II/agent/UniqueBelsBB.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/examples/gold-miners-II/agent/UniqueBelsBB.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -44,7 +44,7 @@
Literal linbb = null;
boolean remove = false;
- Iterator<Literal> relevant = getRelevant(bel);
+ Iterator<Literal> relevant = getCandidateBeliefs(bel, null);
if (relevant != null) {
while (relevant.hasNext() && !remove) {
linbb = relevant.next();
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/src/jason/asSemantics/Agent.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -457,7 +457,7 @@
perceptsInBB.remove(); // remove l as perception from BB
Trigger te = new Trigger(TEOperator.del, TEType.belief, l);
- if (ts.getC().hasListener() || pl.isRelevant(te)) {
+ if (ts.getC().hasListener() || pl.hasCandidatePlan(te)) {
l = (Literal)l.clone();
l.clearAnnots();
l.addAnnot(BeliefBase.TPercept);
@@ -519,7 +519,7 @@
* The unifier <i>un</i> is updated by the method.
*/
public Literal findBel(Literal bel, Unifier un) {
- Iterator<Literal> relB = bb.getRelevant(bel);
+ Iterator<Literal> relB = bb.getCandidateBeliefs(bel, un);
if (relB != null) {
while (relB.hasNext()) {
Literal b = relB.next();
@@ -628,7 +628,7 @@
public void abolish(Literal bel, Unifier un) throws RevisionFailedException {
List<Literal> toDel = new ArrayList<Literal>();
- Iterator<Literal> il = getBB().getRelevant(bel);
+ Iterator<Literal> il = getBB().getCandidateBeliefs(bel, un);
if (il != null) {
while (il.hasNext()) {
Literal inBB = il.next();
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -297,7 +297,7 @@
// get all relevant plans for the selected event
//Trigger te = (Trigger) conf.C.SE.trigger.clone();
- List<Plan> candidateRPs = conf.ag.pl.getAllRelevant(conf.C.SE.trigger);
+ List<Plan> candidateRPs = conf.ag.pl.getCandidatePlans(conf.C.SE.trigger);
if (candidateRPs != null) {
for (Plan pl : candidateRPs) {
Unifier relUn = pl.isRelevant(conf.C.SE.trigger);
@@ -486,7 +486,7 @@
if (body.isLiteral()) { // in case body is a var with content that is not a literal (note the VarTerm pass in the instanceof Literal)
body.makeVarsAnnon();
Trigger te = new Trigger(TEOperator.add, TEType.test, body);
- if (ag.getPL().isRelevant(te)) {
+ if (ag.getPL().hasCandidatePlan(te)) {
Event evt = new Event(te, conf.C.SI);
if (logger.isLoggable(Level.FINE)) logger.fine("Test Goal '" + h + "' failed as simple query. Generating internal event for it: "+te);
conf.C.addEvent(evt);
@@ -655,7 +655,7 @@
public List<Option> relevantPlans(Trigger teP) throws JasonException {
Trigger te = (Trigger) teP.clone();
List<Option> rp = null;
- List<Plan> candidateRPs = conf.ag.pl.getAllRelevant(te);
+ List<Plan> candidateRPs = conf.ag.pl.getCandidatePlans(te);
if (candidateRPs != null) {
for (Plan pl : candidateRPs) {
Unifier relUn = pl.isRelevant(te);
@@ -707,10 +707,12 @@
for (Literal ladd: result[0]) {
Trigger te = new Trigger(TEOperator.add, TEType.belief, ladd);
updateEvents(new Event(te, focus));
+ focus = Intention.EmptyInt;
}
for (Literal lrem: result[1]) {
Trigger te = new Trigger(TEOperator.del, TEType.belief, lrem);
updateEvents(new Event(te, focus));
+ focus = Intention.EmptyInt;
}
}
@@ -719,7 +721,7 @@
// Note: we have to add events even if they are not relevant to
// a) allow the user to override selectOption and then provide an "unknown" plan; or then
// b) create the failure event (it is done by SelRelPlan)
- if (e.isInternal() || C.hasListener() || ag.getPL().isRelevant(e.trigger)) {
+ if (e.isInternal() || C.hasListener() || ag.getPL().hasCandidatePlan(e.trigger)) {
C.addEvent(e);
if (logger.isLoggable(Level.FINE)) logger.fine("Added event " + e);
}
@@ -794,14 +796,14 @@
Trigger failTrigger = new Trigger(TEOperator.del, tevent.getType(), tevent.getLiteral());
if (i != Intention.EmptyInt) {
ListIterator<IntendedMeans> ii = i.iterator();
- while (!getAg().getPL().isRelevant(failTrigger) && ii.hasPrevious()) {
+ while (!getAg().getPL().hasCandidatePlan(failTrigger) && ii.hasPrevious()) {
IntendedMeans im = ii.previous();
tevent = im.getTrigger();
failTrigger = new Trigger(TEOperator.del, tevent.getType(), tevent.getLiteral());
}
}
// if some failure handling plan is found
- if (tevent.isGoal() && getAg().getPL().isRelevant(failTrigger)) {
+ if (tevent.isGoal() && getAg().getPL().hasCandidatePlan(failTrigger)) {
return new Event(failTrigger, i);
}
return null;
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/src/jason/asSyntax/Literal.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -126,7 +126,7 @@
* Returns an iterator for all unifiers that are logCons.
*/
public Iterator<Unifier> logicalConsequence(final Agent ag, final Unifier un) {
- final Iterator<Literal> il = ag.getBB().getRelevant(this);
+ final Iterator<Literal> il = ag.getBB().getCandidateBeliefs(this, un);
if (il == null) // no relevant bels
return LogExpr.EMPTY_UNIF_LIST.iterator();
Modified: trunk/src/jason/asSyntax/PlanLibrary.java
===================================================================
--- trunk/src/jason/asSyntax/PlanLibrary.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/src/jason/asSyntax/PlanLibrary.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -233,12 +233,23 @@
return p;
}
+ /** @deprecated use hasCandidatePlan(te) instead */
public boolean isRelevant(Trigger te) {
- List<Plan> l = getAllRelevant(te);
+ return hasCandidatePlan(te);
+ }
+
+ public boolean hasCandidatePlan(Trigger te) {
+ List<Plan> l = getCandidatePlans(te);
return l != null && ! l.isEmpty();
}
+
+ /** @deprecated use getCandidatePlans(te) instead */
public List<Plan> getAllRelevant(Trigger te) {
+ return getCandidatePlans(te);
+ }
+
+ public List<Plan> getCandidatePlans(Trigger te) {
List<Plan> l = relPlans.get(te.getPredicateIndicator());
if ((l == null || l.isEmpty()) && !varPlans.isEmpty()) { // no rel plan, try varPlan
l = new ArrayList<Plan>();
Modified: trunk/src/jason/bb/BeliefBase.java
===================================================================
--- trunk/src/jason/bb/BeliefBase.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/src/jason/bb/BeliefBase.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -24,10 +24,11 @@
package jason.bb;
import jason.asSemantics.Agent;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.DefaultTerm;
import jason.asSyntax.Literal;
import jason.asSyntax.PredicateIndicator;
import jason.asSyntax.Term;
-import jason.asSyntax.DefaultTerm;
import java.util.Iterator;
@@ -76,12 +77,18 @@
/**
* Returns an iterator for all literals relevant for l's predicate
* indicator, if l is a var, returns all beliefs.<br>
+ *
+ * The unifier <i>u</i> may contain values for variables in <i>l</i>.
*
* Example, if BB={a(10),a(20),a(2,1),b(f)}, then
- * <code>getRelevant(a(5))</code> = {{a(10),a(20)}.<br>
- * if BB={a(10),a(20)}, then <code>getRelevant(X)</code> =
- * {{a(10),a(20)}.
+ * <code>getCandidateBeliefs(a(5), {})</code> = {{a(10),a(20)}.<br>
+ * if BB={a(10),a(20)}, then <code>getCandidateBeliefs(X)</code> =
+ * {{a(10),a(20)}. The <code>getCandidateBeliefs(a(X), {X -> 5})</code>
+ * should also return {{a(10),a(20)}.<br>
*/
+ public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u);
+
+ /** @deprecated use getCandidateBeliefs(l,null) instead */
public Iterator<Literal> getRelevant(Literal l);
/**
Modified: trunk/src/jason/bb/DefaultBeliefBase.java
===================================================================
--- trunk/src/jason/bb/DefaultBeliefBase.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/src/jason/bb/DefaultBeliefBase.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -24,6 +24,7 @@
package jason.bb;
import jason.asSemantics.Agent;
+import jason.asSemantics.Unifier;
import jason.asSyntax.Literal;
import jason.asSyntax.PredicateIndicator;
@@ -222,7 +223,7 @@
}
}
- public Iterator<Literal> getRelevant(Literal l) {
+ public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u) {
if (l.isVar()) {
// all bels are relevant
return iterator();
@@ -235,6 +236,11 @@
}
}
}
+
+ /** @deprecated use getCandidateBeliefs(l,null) instead */
+ public Iterator<Literal> getRelevant(Literal l) {
+ return getCandidateBeliefs(l, null);
+ }
public String toString() {
return belsMap.toString();
Modified: trunk/src/jason/bb/JDBCPersistentBB.java
===================================================================
--- trunk/src/jason/bb/JDBCPersistentBB.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/src/jason/bb/JDBCPersistentBB.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -1,6 +1,7 @@
package jason.bb;
import jason.asSemantics.Agent;
+import jason.asSemantics.Unifier;
import jason.asSyntax.DefaultTerm;
import jason.asSyntax.ListTerm;
import jason.asSyntax.ListTermImpl;
@@ -318,10 +319,10 @@
@Override
- public Iterator<Literal> getRelevant(Literal l) {
+ public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u) {
final PredicateIndicator pi = l.getPredicateIndicator();
if (belsDB.get(pi) == null)
- return super.getRelevant(l);
+ return super.getCandidateBeliefs(l, u);
if (l.isVar()) {
// all bels are relevant
Modified: trunk/src/test/BeliefBaseTest.java
===================================================================
--- trunk/src/test/BeliefBaseTest.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/src/test/BeliefBaseTest.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -119,7 +119,7 @@
l5 = new Literal(true, new Pred("garb"));
l5.addTerm(new Structure("r1"));
assertTrue(bb.remove(l5));
- assertEquals(bb.getRelevant(l5), null);
+ assertEquals(bb.getCandidateBeliefs(l5, null), null);
assertEquals(bb.size(), 3);
l4 = new Literal(true, new Pred("pos"));
@@ -127,7 +127,7 @@
l4.addTerm(new Structure("6"));
l4.addAnnot(BeliefBase.TPercept);
assertTrue(bb.remove(l4));
- assertEquals(iteratorSize(bb.getRelevant(l4)), 1);
+ assertEquals(iteratorSize(bb.getCandidateBeliefs(l4, null)), 1);
assertEquals(bb.size(), 2);
assertEquals(iteratorSize(bb.iterator()), 2);
@@ -141,7 +141,7 @@
l4.addTerm(new Structure("2"));
l4.addAnnot(BeliefBase.TPercept);
assertTrue(bb.remove(l4));
- assertEquals(bb.getRelevant(l4), null);
+ assertEquals(bb.getCandidateBeliefs(l4, null), null);
assertEquals(bb.size(), 1);
assertEquals(iteratorSize(bb.getPercepts()), 1);
@@ -513,7 +513,7 @@
//while (ir.hasNext()) {
// System.out.println(ir.next());
//}
- assertEquals(iteratorSize(bb.getRelevant(Literal.parseLiteral("book_author(_,_)"))),5);
+ assertEquals(iteratorSize(bb.getCandidateBeliefs(Literal.parseLiteral("book_author(_,_)"),null)),5);
bb.stop();
}
Modified: trunk/src/test/PlanTest.java
===================================================================
--- trunk/src/test/PlanTest.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/src/test/PlanTest.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -42,16 +42,16 @@
pl.add(Plan.parse("+!X <- .print(a)."));
- List<Plan> pls = pl.getAllRelevant(Trigger.parseTrigger("+p(3)"));
+ List<Plan> pls = pl.getCandidatePlans(Trigger.parseTrigger("+p(3)"));
assertEquals(2, pls.size());
- pls = pl.getAllRelevant(Trigger.parseTrigger("+!p(3)"));
+ pls = pl.getCandidatePlans(Trigger.parseTrigger("+!p(3)"));
assertEquals(3, pls.size());
- pls = pl.getAllRelevant(Trigger.parseTrigger("+!bla"));
+ pls = pl.getCandidatePlans(Trigger.parseTrigger("+!bla"));
assertEquals(1, pls.size());
- pls = pl.getAllRelevant(Trigger.parseTrigger("+bla"));
+ pls = pl.getCandidatePlans(Trigger.parseTrigger("+bla"));
assertEquals(0, pls.size());
}
Modified: trunk/src/test/RuleTest.java
===================================================================
--- trunk/src/test/RuleTest.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/src/test/RuleTest.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -119,7 +119,7 @@
assertEquals(u.get("M").toString(),"20");
Literal cons = Literal.parseLiteral("min([op(5),op(3),op(8),op(1),op(40)],op(1000),op(M))");
- Iterator<Literal> il = ag.getBB().getRelevant(cons);
+ Iterator<Literal> il = ag.getBB().getCandidateBeliefs(cons, null);
assertEquals(3,iteratorSize(il));
iun = cons.logicalConsequence(ag, new Unifier());
Modified: trunk/src/test/VarTermTest.java
===================================================================
--- trunk/src/test/VarTermTest.java 2008-03-30 20:41:40 UTC (rev 1181)
+++ trunk/src/test/VarTermTest.java 2008-03-31 19:25:02 UTC (rev 1182)
@@ -336,7 +336,7 @@
Unifier u = new Unifier();
VarTerm v1 = VarTerm.parseVar("P[d]");
- assertEquals(2, iteratorSize(ag.getBB().getRelevant(v1)));
+ assertEquals(2, iteratorSize(ag.getBB().getCandidateBeliefs(v1, null)));
Iterator<Unifier> i = v1.logicalConsequence(ag, u);
assertTrue(i.hasNext());
u = i.next(); // u = {P[d]=b2}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|