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-08-19 09:19:18
|
Revision: 1356
http://jason.svn.sourceforge.net/jason/?rev=1356&view=rev
Author: jomifred
Date: 2008-08-19 09:19:09 +0000 (Tue, 19 Aug 2008)
Log Message:
-----------
fix minor issue in Jade/saci infra related to source path
Modified Paths:
--------------
trunk/applications/jason-team/src/asl/exploration.asl
trunk/applications/jason-team/src/asl/gaucho.asl
trunk/applications/jason-team/src/asl/herding.asl
trunk/demos/suspend-resume/test.asl
trunk/doc/index.html
trunk/examples/auction/AuctioneerGUI.java
trunk/examples/cleaning-robots/MarsEnv.java
trunk/examples/food-simulation/FoodSimulation.mas2j
trunk/examples/food-simulation/src/java/FoodEnvironment.java
trunk/src/jason/asSyntax/NumberTermImpl.java
trunk/src/jason/asSyntax/Pred.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/asSyntax/directives/Include.java
trunk/src/jason/infra/jade/JadeAgArch.java
trunk/src/jason/infra/saci/SaciAgArch.java
trunk/src/jason/mas2j/MAS2JProject.java
Modified: trunk/applications/jason-team/src/asl/exploration.asl
===================================================================
--- trunk/applications/jason-team/src/asl/exploration.asl 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/applications/jason-team/src/asl/exploration.asl 2008-08-19 09:19:09 UTC (rev 1356)
@@ -142,7 +142,7 @@
+!change_to_herding[scheme(Sch),mission(Mission)]
: cow(_,_,_)
<- .print("ooo I see some cows, create the herding group");
- // check these cows are being herded by other group
+ // check whether the seen cows are being herded by other group
.findall(L, group_leader(_,L),Leaders);
!ask_all_cows(Leaders,LCows);
.findall(cow(ID,X,Y), cow(ID,X,Y), MyCows);
Modified: trunk/applications/jason-team/src/asl/gaucho.asl
===================================================================
--- trunk/applications/jason-team/src/asl/gaucho.asl 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/applications/jason-team/src/asl/gaucho.asl 2008-08-19 09:19:09 UTC (rev 1356)
@@ -58,7 +58,7 @@
!create_exploration_gr.
+!restart
<- .print("*** restart -- even ***");
- !quite_all_missions_roles;
+ !quit_all_missions_roles;
.my_name(Me);
// try to adopt scouter in some exploration
@@ -66,10 +66,10 @@
!try_adopt(scouter,LGE);
// if I still have no role, try herdboy
- if ( not play(Me,_,_) ) {
+ if ( not play(Me,_,_) ) {
.findall(GH, group(herding_grp,GH), LGH);
!try_adopt(herdboy,LGH)
- }.
+ }.
+!try_adopt(_Role,[]).
+!try_adopt(Role,[G|_])
@@ -135,7 +135,7 @@
.findall(Boy,play(Boy,herdboy,G),HerdBoys);
.send(HerdBoys, achieve, change_role(herdboy,GT))
};
- !quite_all_missions_roles;
+ !quit_all_missions_roles;
jmoise.adopt_role(NewRole,GT).
// causes a loop:
@@ -148,7 +148,7 @@
<- .print("ooo Adopting role ",Role," in group ",Group,", as asked by ",Ag);
jmoise.adopt_role(Role, Group).
-+!quite_all_missions_roles
++!quit_all_missions_roles
<- .my_name(Me);
// give up all missions
Modified: trunk/applications/jason-team/src/asl/herding.asl
===================================================================
--- trunk/applications/jason-team/src/asl/herding.asl 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/applications/jason-team/src/asl/herding.asl 2008-08-19 09:19:09 UTC (rev 1356)
@@ -98,6 +98,7 @@
.send(gaucho5,achieve,create_exploration_gr);
.send(gaucho6,achieve,restart).
*/
+// TODO: find a nice solution for this plan!
+!release_boys[scheme(Sch),mission(Mission),group(Gr)]
: .count(play(_,herdboy,Gr),N) &
(N > 3 | (N > 1 & current_cluster(CAsList) & .length(CAsList) < 5))
Modified: trunk/demos/suspend-resume/test.asl
===================================================================
--- trunk/demos/suspend-resume/test.asl 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/demos/suspend-resume/test.asl 2008-08-19 09:19:09 UTC (rev 1356)
@@ -12,7 +12,7 @@
<- .print(".");
!!dots.
-// another loop that resumes and suspend the start
+// another loop that resumes and suspend the "dops" goal
+!control
<- .wait(30);
.suspend(dots); // suspend the intention with goal dots
Modified: trunk/doc/index.html
===================================================================
--- trunk/doc/index.html 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/doc/index.html 2008-08-19 09:19:09 UTC (rev 1356)
@@ -40,7 +40,8 @@
<li><a href="http://sourceforge.net/mail/?group_id=98417">Mailing lists</a>
<li><a href="http://jason.sourceforge.net/JasonWebSite/Examples/Examples.html">Examples</a>
<li><a href="http://jason.sourceforge.net/JasonWebSite/Demos.html">Demos</a>
- <li><a href="http://jason.sourceforge.net/JasonWebSite/Publications.html">Publications</a>
+ <li><a href="http://jason.sourceforge.net/JasonWebSite/Documents.html">Publications</a>
+ <li><a href="http://jason.sourceforge.net/JasonWebSite/Related%20Projects.html">Related projects</a>
</ul>
</li>
<br/>
Modified: trunk/examples/auction/AuctioneerGUI.java
===================================================================
--- trunk/examples/auction/AuctioneerGUI.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/examples/auction/AuctioneerGUI.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -41,9 +41,13 @@
if (action.getActionTerm().getFunctor().startsWith("show_winner")) {
jt.append("Winner of auction " + action.getActionTerm().getTerm(0));
jt.append(" is " + action.getActionTerm().getTerm(1) + "\n");
- auction.setEnabled(true);
+ action.setResult(true);
+ feedback.add(action);
+
+ auction.setEnabled(true); // enable GUI button
+ } else {
+ super.act(action,feedback); // send the action to the environment to be performed.
}
- super.act(action,feedback); // send the action to the environment to be performed.
}
public void stopAg() {
Modified: trunk/examples/cleaning-robots/MarsEnv.java
===================================================================
--- trunk/examples/cleaning-robots/MarsEnv.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/examples/cleaning-robots/MarsEnv.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -37,6 +37,7 @@
@Override
public boolean executeAction(String ag, Structure action) {
+ logger.info(ag+" doing: "+ action);
try {
if (action.equals(ns)) {
model.nextSlot();
Modified: trunk/examples/food-simulation/FoodSimulation.mas2j
===================================================================
--- trunk/examples/food-simulation/FoodSimulation.mas2j 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/examples/food-simulation/FoodSimulation.mas2j 2008-08-19 09:19:09 UTC (rev 1356)
@@ -53,6 +53,8 @@
MAS normative_simulation {
+ infrastructure: Centralised
+
// the class that implements the environment is FoodEnvironment
// parameters are: grid size, number of agents, number of food units
environment: FoodEnvironment(10,50,25)
Modified: trunk/examples/food-simulation/src/java/FoodEnvironment.java
===================================================================
--- trunk/examples/food-simulation/src/java/FoodEnvironment.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/examples/food-simulation/src/java/FoodEnvironment.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -165,7 +165,7 @@
if (name != null) {
updateAgPercept(name, ag);
} else {
- logger.warning("Can not give perception to "+ag+" bacause it is no registered!");
+ logger.warning("Can not give perception to "+ag+" because it is no registered!");
}
}
Modified: trunk/src/jason/asSyntax/NumberTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/NumberTermImpl.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/asSyntax/NumberTermImpl.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -77,14 +77,11 @@
public boolean equals(Object o) {
if (o == this) return true;
- if (o != null && o instanceof Term && ((Term)o).isNumeric()) {
+ if (o != null && o instanceof Term && ((Term)o).isNumeric() && !((Term)o).isArithExpr()) {
NumberTerm st = (NumberTerm)o;
- if (st.isVar() || st.isArithExpr())
- return false;
- else
- try {
- return solve() == st.solve();
- } catch (Exception e) { }
+ try {
+ return solve() == st.solve();
+ } catch (Exception e) { }
}
return false;
}
Modified: trunk/src/jason/asSyntax/Pred.java
===================================================================
--- trunk/src/jason/asSyntax/Pred.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/asSyntax/Pred.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -426,7 +426,7 @@
if (ta.isVar() && !ta.isUnnamedVar()) {
// replace ta to an unnamed var
- VarTerm vt = un == null ? (VarTerm)ta : un.deref((VarTerm)ta);
+ VarTerm vt = un.deref((VarTerm)ta);
UnnamedVar uv;
if (vt.isUnnamedVar()) {
uv = (UnnamedVar)vt;
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/asSyntax/Structure.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -320,8 +320,8 @@
Term ti = getTerm(i);
if (ti.isVar() && !ti.isUnnamedVar()) {
// replace ti to an unnamed var
- VarTerm vt = un == null ? (VarTerm)ti : un.deref((VarTerm)ti);
- UnnamedVar uv = null;
+ VarTerm vt = un.deref((VarTerm)ti);
+ UnnamedVar uv;
if (vt.isUnnamedVar()) {
uv = (UnnamedVar)vt;
} else {
Modified: trunk/src/jason/asSyntax/directives/Include.java
===================================================================
--- trunk/src/jason/asSyntax/directives/Include.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/asSyntax/directives/Include.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -90,13 +90,13 @@
return f;
} else if (srcpath != null) {
for (String path: srcpath) {
- File newname = new File(path + "/" + f.toString());
- if (newname.exists()) {
- try {
+ try {
+ File newname = new File(path + "/" + f.toString());
+ if (newname.exists()) {
return newname.getCanonicalFile().toString();
- } catch (IOException e) {
- e.printStackTrace();
- }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
}
}
}
Modified: trunk/src/jason/infra/jade/JadeAgArch.java
===================================================================
--- trunk/src/jason/infra/jade/JadeAgArch.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/infra/jade/JadeAgArch.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -382,7 +382,7 @@
try {
Term acTerm = action.getActionTerm();
- logger.info("doing: " + acTerm);
+ logger.fine("doing: " + acTerm);
rwid++;
String rw = "id"+rwid;
Modified: trunk/src/jason/infra/saci/SaciAgArch.java
===================================================================
--- trunk/src/jason/infra/saci/SaciAgArch.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/infra/saci/SaciAgArch.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -422,7 +422,7 @@
TransitionSystem ts = userAgArch.getTS();
try {
Term acTerm = action.getActionTerm();
- logger.info("doing: " + acTerm);
+ logger.fine("doing: " + acTerm);
String rw = mboxPercept.getRW();
saci.Message m = new saci.Message("(ask :receiver environment :ontology AS-Action :content execute)");
Modified: trunk/src/jason/mas2j/MAS2JProject.java
===================================================================
--- trunk/src/jason/mas2j/MAS2JProject.java 2008-08-16 10:13:14 UTC (rev 1355)
+++ trunk/src/jason/mas2j/MAS2JProject.java 2008-08-19 09:19:09 UTC (rev 1356)
@@ -89,10 +89,6 @@
}
}
- public boolean isDefaultDirectory() {
- return projectDir.equals(".");
- }
-
public String getDirectory() {
return projectDir;
}
@@ -198,10 +194,11 @@
r.add(getDirectory());
}
for (String p: sourcepaths) {
- if (getDirectory().startsWith(".") || getDirectory().startsWith("/") || getDirectory().charAt(1) == ':') {
+ //if (getDirectory().startsWith(".") || getDirectory().startsWith("/") || getDirectory().charAt(1) == ':') {
+ if (p.startsWith(".") || p.startsWith("/") || p.charAt(1) == ':') {
r.add(p);
} else {
- r.add(getDirectory()+File.separator+p);
+ r.add(getDirectory()+"/"+p);
}
}
return r;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-08-16 10:13:20
|
Revision: 1355
http://jason.svn.sourceforge.net/jason/?rev=1355&view=rev
Author: jomifred
Date: 2008-08-16 10:13:14 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
use the classical "deref" for vars binding instead of VarsCluster
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSemantics/Unifier.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/ObjectTermImpl.java
trunk/src/jason/asSyntax/PlanBodyImpl.java
trunk/src/jason/asSyntax/Pred.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/asSyntax/UnnamedVar.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/test/TermTest.java
trunk/src/test/VarTermTest.java
Removed Paths:
-------------
trunk/src/jason/asSemantics/VarsCluster.java
Modified: trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -20,12 +20,19 @@
"test_rule(A,a(A)). "+
"ml0(L,L). "+
"ml(V1,V2,R) :- ml0([V1,V2],R). "+
+
+ "append([], L, L). "+
+ "append([H|T], L1, [H|L2]) :- append(T, L1, L2). "+
+
"+!test1 <- ?test_rule(T,A); A = a(V); T=45; jason.asunit.print(V). "+
- "+!test2 <- ?ml(A,B,L); A=1; B=2; jason.asunit.print(L). "
+ "+!test2 <- ?ml(A,B,L); A=1; B=2; jason.asunit.print(L). "+
+ "+!test3 <- L=[X,Y]; ?append(L, [Z], L2); Z=a; X=f; Y=i; jason.asunit.print(L2). "
);
}
- @Test
+
+
+ @Test
public void testRule1() {
ag.addGoal("test1");
ag.assertPrint("45", 5);
@@ -36,4 +43,10 @@
ag.addGoal("test2");
ag.assertPrint("[1,2]", 5);
}
+
+ @Test
+ public void testRule3() {
+ ag.addGoal("test3");
+ ag.assertPrint("[f,i,a]", 10);
+ }
}
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSemantics/Agent.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -367,7 +367,7 @@
public void addInitialGoalsInTS() {
for (Literal g: initialGoals) {
- g.makeVarsAnnon(null);
+ g.makeVarsAnnon();
if (! g.hasSource())
g.addAnnot(BeliefBase.TSelf);
getTS().getC().addAchvGoal(g,Intention.EmptyInt);
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -403,7 +403,7 @@
return;
}
Unifier u = im.unif;
- PlanBody h = im.getCurrentStep();
+ PlanBody h = im.getCurrentStep();
h.apply(u);
Literal body = null;
@@ -466,8 +466,8 @@
body.addAnnot(BeliefBase.TSelf);
}
// free variables in an event cannot conflict with those in the plan
- body = (Literal)body.clone();
- body.makeVarsAnnon(null);
+ body = body.copy();
+ body.makeVarsAnnon(u);
conf.C.addAchvGoal(body, conf.C.SI);
confP.step = State.StartRC;
break;
@@ -479,8 +479,8 @@
// programmer set some annotation
body.addAnnot(BeliefBase.TSelf);
}
- body = (Literal)body.clone();
- body.makeVarsAnnon();
+ body = body.copy();
+ body.makeVarsAnnon(u);
conf.C.addAchvGoal(body, Intention.EmptyInt);
updateIntention();
break;
@@ -495,7 +495,7 @@
if (f instanceof Literal) { // generate event when using literal in the test (no events for log. expr. like ?(a & b))
body = (Literal)f.clone();
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();
+ body.makeVarsAnnon(u);
Trigger te = new Trigger(TEOperator.add, TEType.test, body);
if (ag.getPL().hasCandidatePlan(te)) {
Event evt = new Event(te, conf.C.SI);
@@ -553,7 +553,7 @@
newfocus = conf.C.SI;
// rename free vars
- body.makeVarsAnnon();
+ body.makeVarsAnnon(u);
// call BRF
try {
Modified: trunk/src/jason/asSemantics/Unifier.java
===================================================================
--- trunk/src/jason/asSemantics/Unifier.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSemantics/Unifier.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -70,16 +70,22 @@
* other's value
*/
public Term get(VarTerm vtp) {
- return function.get(vtp);
+ Term vl = function.get(vtp);
+ if (vl != null && vl.isVar()) { // optimised deref
+ return get((VarTerm)vl);
+ }
+ return vl;
}
+ /*
public Term get(Term t) {
if (t.isVar()) {
- return function.get((VarTerm) t);
+ return function.get( deref((VarTerm) t));
} else {
return null;
}
}
+ */
public boolean unifies(Trigger te1, Trigger te2) {
return te1.sameType(te2) && unifies(te1.getLiteral(), te2.getLiteral());
@@ -143,19 +149,21 @@
// X = p(1), An = a, R=[b]
if (ok && np1 != null) { // they are predicates
if (np1.isVar() && np1.hasAnnot()) {
- Term np1vl = function.get((VarTerm) np1);
- if (np1vl.isPred()) {
- Pred pvl = (Pred)np1vl.clone();
+ np1 = deref( (VarTerm)np1);
+ Term np1vl = function.get( (VarTerm) np1);
+ if (np1vl != null && np1vl.isPred()) {
+ Pred pvl = (Pred)np1vl.clone();
pvl.clearAnnots();
- function.put((VarTerm) np1, pvl);
+ bind((VarTerm) np1, pvl);
}
}
if (np2.isVar() && np2.hasAnnot()) {
+ np2 = deref( (VarTerm)np2);
Term np2vl = function.get((VarTerm) np2);
- if (np2vl.isPred()) {
+ if (np2vl != null && np2vl.isPred()) {
Pred pvl = (Pred)np2vl.clone();
pvl.clearAnnots();
- function.put((VarTerm) np2, pvl);
+ bind((VarTerm) np2, pvl);
}
}
}
@@ -179,74 +187,31 @@
final boolean t1gisvar = t1g.isVar();
final boolean t2gisvar = t2g.isVar();
- // both are vars
- if (t1gisvar && t2gisvar) {
- VarTerm t1gv = (VarTerm) t1g;
- VarTerm t2gv = (VarTerm) t2g;
-
- // get their values
- Term t1vl = function.get(t1gv);
- Term t2vl = function.get(t2gv);
+ // one of the args is a var
+ if (t1gisvar || t2gisvar) {
- // if the variable value is a var cluster, it means it has no value
- if (t1vl instanceof VarsCluster)
- t1vl = null;
- if (t2vl instanceof VarsCluster)
- t2vl = null;
+ // deref vars
+ final VarTerm t1gv = t1gisvar ? deref((VarTerm)t1g) : null;
+ final VarTerm t2gv = t2gisvar ? deref((VarTerm)t2g) : null;
- // both has value, their values should unify
- if (t1vl != null && t2vl != null)
- return unifiesNoUndo(t1vl, t2vl);
+ // get their values
+ final Term t1vl = t1gisvar ? function.get(t1gv) : t1g;
+ final Term t2vl = t2gisvar ? function.get(t2gv) : t2g;
- // only t1 has value, t1's value should unify with var t2
- if (t1vl != null)
- return unifiesNoUndo(t2gv, t1vl);
-
- // only t2 has value, t2's value should unify with var t1
- if (t2vl != null)
- return unifiesNoUndo(t1gv, t2vl);
-
- // both are var with no value, like X=Y
- // we must ensure that these vars will form a cluster
- //if (! t1gv.isUnnamedVar() && ! t2gv.isUnnamedVar()) {
- VarTerm t1c = (VarTerm) t1gv.clone();
- VarTerm t2c = (VarTerm) t2gv.clone();
- VarsCluster cluster = new VarsCluster(t1c, t2c, this);
- if (cluster.hasValue()) {
- // all vars of the cluster should have the same value
- for (VarTerm vtc : cluster)
- function.put(vtc, cluster);
+ if (t1vl != null && t2vl != null) {
+ // unifies the two values of the vars
+ return unifiesNoUndo(t1vl, t2vl);
+ } else if (t1vl != null) {
+ bind(t2gv, t1vl);
+ } else if (t2vl != null) {
+ bind(t1gv, t2vl);
+ } else { //if (t1gv != null && t2gv != null) {
+ // unify two vars
+ bind(t1gv, t2gv);
}
- //}
return true;
- }
-
- // t1 is var that doesn't occur in t2
- if (t1gisvar) {
- VarTerm t1gv = (VarTerm) t1g;
- // if t1g is not free, must unify values
- Term t1vl = function.get(t1gv);
- if (t1vl != null && !(t1vl instanceof VarsCluster))
- return unifiesNoUndo(t1vl,t2g);
- else if (!t2g.hasVar(t1gv))
- return setVarValue(t1gv, t2g);
- else
- return false;
- }
-
- // t2 is var that doesn't occur in t1
- if (t2gisvar) {
- VarTerm t2gv = (VarTerm) t2g;
- // if t1g is not free, must unify values
- Term t2vl = function.get(t2gv);
- if (t2vl != null && !(t2vl instanceof VarsCluster))
- return unifiesNoUndo(t2vl,t1g);
- else if (!t1g.hasVar(t2gv))
- return setVarValue(t2gv, t1g);
- else
- return false;
- }
-
+ }
+
// both terms are not vars
// if any of the terms is not a structure (is a number or a
@@ -300,21 +265,40 @@
return true;
}
-
- protected boolean setVarValue(VarTerm vt, Term value) {
- // if the var has a cluster, set value for all cluster
- Term currentVl = function.get(vt);
- if (currentVl != null && currentVl instanceof VarsCluster) {
- VarsCluster cluster = (VarsCluster) currentVl;
- for (VarTerm cvt : cluster)
- function.put(cvt, value); //(Term) value.clone()); // the clone is done in apply
- } else {
- // no value in cluster
- function.put((VarTerm) vt.clone(), value); //(Term) value.clone()); // the clone is done in apply
+
+ public VarTerm deref(VarTerm v) {
+ Term vl = function.get(v);
+ // original def (before optimise)
+ // if (vl != null && vl.isVar())
+ // return deref(vl);
+ // return v;
+
+ VarTerm first = v;
+ while (vl != null && vl.isVar()) {
+ v = (VarTerm)vl;
+ vl = function.get(v);
}
- return true;
+ if (first != v) {
+ function.put(first, v); // optimise map
+ }
+ return v;
}
-
+
+
+
+ public void bind(VarTerm vt1, VarTerm vt2) {
+ final int comp = vt1.compareTo(vt2);
+ if (comp < 0) {
+ function.put((VarTerm)vt1.clone(), vt2);
+ } else if (comp > 0){
+ function.put((VarTerm)vt2.clone(), vt1);
+ } // if they are the same (comp == 0), do not bind
+ }
+
+ private void bind(VarTerm vt, Term vl) {
+ function.put((VarTerm) vt.clone(), vl);
+ }
+
public void clear() {
function.clear();
}
Deleted: trunk/src/jason/asSemantics/VarsCluster.java
===================================================================
--- trunk/src/jason/asSemantics/VarsCluster.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSemantics/VarsCluster.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -1,130 +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.asSemantics;
-
-import jason.asSyntax.DefaultTerm;
-import jason.asSyntax.Term;
-import jason.asSyntax.VarTerm;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.logging.Logger;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- Stores a set of vars that were unified.
-
- E.g.: when X = Y = W = Z the unifier function maps
- X -> { X, Y, W, Z }
- Y -> { X, Y, W, Z }
- W -> { X, Y, W, Z }
- Z -> { X, Y, W, Z }
- where { X, Y, W, Z } is a VarsCluster instance.
-
- So when one var is assigned to a value, all vars in the
- cluster receive this same value.
-
- @author Jomi
-*/
-public class VarsCluster extends DefaultTerm implements Iterable<VarTerm> {
-
- private static final long serialVersionUID = 1L;
- private static Logger logger = Logger.getLogger(VarsCluster.class.getName());
-
- private static int idCount = 0;
-
- private int id = 0;
- private Set<VarTerm> vars = null;
- private Unifier u;
-
- // used in clone
- protected VarsCluster(Unifier u) {
- this.u = u;
- }
-
- public VarsCluster(VarTerm v1, VarTerm v2, Unifier u) {
- id = ++idCount;
- this.u = u;
- add(v1);
- add(v2);
- }
-
- private void add(VarTerm vt) {
- Term vl = u.get(vt);
- if (vl == null) { // vt is not in a VarsCluster
- if (vars == null)
- vars = new TreeSet<VarTerm>();
- vars.add(vt);
- } else if (vl instanceof VarsCluster) {
- // since vt is in a VarsCluster, join the two sets here
- if (vars == null)
- vars = ((VarsCluster) vl).vars;
- else
- vars.addAll(((VarsCluster) vl).vars);
- } else {
- logger.warning("joining var that has value!");
- }
- }
-
- public Iterator<VarTerm> iterator() {
- return vars.iterator();
- }
-
- public boolean equals(Object o) {
- if (o == null) return false;
- if (o == this) return true;
- if (o instanceof VarsCluster) return vars.equals(((VarsCluster) o).vars);
- return false;
- }
-
- public boolean hasValue() {
- return vars != null && !vars.isEmpty();
- }
-
- public Object clone() {
- VarsCluster c = new VarsCluster(u);
- c.vars = new HashSet<VarTerm>();
- for (VarTerm vt : this.vars) {
- c.vars.add((VarTerm) vt.clone());
- }
- return c;
- }
-
- protected int calcHashCode() {
- return vars.hashCode();
- }
-
- public Element getAsDOM(Document document) {
- return null;
- }
-
- public String toString() {
- return "_VC" + id;
- }
-}
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/Literal.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -185,9 +185,9 @@
// it is used to define what will be the unifier used
// inside the rule.
if (cloneAnnon == null) {
- cloneAnnon = (Literal)Literal.this.clone();
+ cloneAnnon = Literal.this.copy();
cloneAnnon.apply(un);
- cloneAnnon.makeVarsAnnon(null);
+ cloneAnnon.makeVarsAnnon(un);
}
Unifier ruleUn = new Unifier();
if (ruleUn.unifiesNoUndo(cloneAnnon, rule)) { // the rule head unifies with the literal
@@ -198,7 +198,7 @@
}
}
} else {
- Unifier u = (Unifier) un.clone();
+ Unifier u = un.copy();
if (u.unifiesNoUndo(Literal.this, b)) {
current = u;
return;
Modified: trunk/src/jason/asSyntax/ObjectTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/ObjectTermImpl.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/ObjectTermImpl.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -6,7 +6,8 @@
import org.w3c.dom.Element;
public class ObjectTermImpl extends DefaultTerm implements ObjectTerm {
-
+ private static final long serialVersionUID = 1L;
+
private final Object o;
private Method mclone;
private boolean hasTestedClone = false;
Modified: trunk/src/jason/asSyntax/PlanBodyImpl.java
===================================================================
--- trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -17,6 +17,8 @@
*/
public class PlanBodyImpl extends Structure implements PlanBody, Iterable<PlanBody> {
+ private static final long serialVersionUID = 1L;
+
public static final String BODY_PLAN_FUNCTOR = ";";
private Term term = null;
Modified: trunk/src/jason/asSyntax/Pred.java
===================================================================
--- trunk/src/jason/asSyntax/Pred.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/Pred.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -417,27 +417,30 @@
* @param changes is the map of replacements
*/
@Override
- protected void makeVarsAnnon(Unifier un, Map<VarTerm,UnnamedVar> changes) {
+ public void makeVarsAnnon(Unifier un) {
if (annots != null) {
Iterator<ListTerm> i = annots.listTermIterator();
while (i.hasNext()) {
ListTerm lt = i.next();
Term ta = lt.getTerm();
- if (ta.isVar()) {
- // replace ta to an unnamed var
- UnnamedVar uv = changes.get(ta);
- if (uv == null) {
- VarTerm vt = (VarTerm)ta;
- uv = vt.preferredUnnamedVar(un);
- changes.put((VarTerm)ta, uv);
- }
- lt.setTerm(uv);
+
+ if (ta.isVar() && !ta.isUnnamedVar()) {
+ // replace ta to an unnamed var
+ VarTerm vt = un == null ? (VarTerm)ta : un.deref((VarTerm)ta);
+ UnnamedVar uv;
+ if (vt.isUnnamedVar()) {
+ uv = (UnnamedVar)vt;
+ } else {
+ uv = new UnnamedVar();
+ un.bind(vt, uv);
+ }
+ lt.setTerm(uv);
} else if (ta.isStructure()) {
- ((Structure)ta).makeVarsAnnon(un,changes);
+ ((Structure)ta).makeVarsAnnon(un);
}
}
}
- super.makeVarsAnnon(un, changes);
+ super.makeVarsAnnon(un);
}
@Override
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/Structure.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -308,35 +308,31 @@
return true;
}
- /** Replaces all variables of the term for unnamed variables (_). */
+ /** Replaces all variables by unnamed variables (_). */
public void makeVarsAnnon() {
- makeVarsAnnon(null, new HashMap<VarTerm,UnnamedVar>());
+ makeVarsAnnon(new Unifier());
}
- /** Replaces all variables of the term for unnamed variables (_).
- if un != null, unnamed vars unified to the var are preferred */
- public void makeVarsAnnon(Unifier un) {
- makeVarsAnnon(un, new HashMap<VarTerm,UnnamedVar>());
- }
-
- /** change all vars by unnamed vars, if un != null, unnamed vars unified to the var are preferred */
- protected void makeVarsAnnon(Unifier un, Map<VarTerm,UnnamedVar> changes) {
+ /** change all vars by unnamed vars, the unifier un is used to consistently replace vars. */
+ public void makeVarsAnnon(Unifier un) {
final int size = getArity();
for (int i=0; i<size; i++) {
Term ti = getTerm(i);
- if (ti.isVar()) {
+ if (ti.isVar() && !ti.isUnnamedVar()) {
// replace ti to an unnamed var
- UnnamedVar uv = changes.get(ti);
- if (uv == null) {
- VarTerm vt = (VarTerm)ti;
- uv = vt.preferredUnnamedVar(un);
- changes.put((VarTerm)ti, uv);
- }
- setTerm(i,uv);
+ VarTerm vt = un == null ? (VarTerm)ti : un.deref((VarTerm)ti);
+ UnnamedVar uv = null;
+ if (vt.isUnnamedVar()) {
+ uv = (UnnamedVar)vt;
+ } else {
+ uv = new UnnamedVar();
+ un.bind(vt, uv);
+ }
+ setTerm(i,uv);
} else if (ti.isStructure()) {
Structure tis = (Structure)ti;
if (tis.hasTerm()) {
- tis.makeVarsAnnon(un, changes);
+ tis.makeVarsAnnon(un);
}
}
}
Modified: trunk/src/jason/asSyntax/UnnamedVar.java
===================================================================
--- trunk/src/jason/asSyntax/UnnamedVar.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/UnnamedVar.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -67,11 +67,13 @@
return super.compareTo(t);
} else if (t instanceof UnnamedVar) {
if (myId > ((UnnamedVar)t).myId)
+ return -1;
+ else if (myId < ((UnnamedVar)t).myId)
return 1;
- else if (myId < ((UnnamedVar)t).myId)
- return -1;
else
return 0;
+ } else if (t instanceof VarTerm) {
+ return 1;
} else {
return super.compareTo(t);
}
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -25,7 +25,6 @@
import jason.asSemantics.Agent;
import jason.asSemantics.Unifier;
-import jason.asSemantics.VarsCluster;
import jason.asSyntax.parser.as2j;
import java.io.StringReader;
@@ -141,7 +140,7 @@
if (value == null) {
Term vl = u.get(this);
//System.out.println("applying "+this+"="+vl+" un="+u);
- if (vl != null && !(vl instanceof VarsCluster)) {
+ if (vl != null) { // && !(vl instanceof VarsCluster)) {
setValue(vl);
value.apply(u); // in case t has var args
return true;
@@ -151,20 +150,6 @@
}
return false;
}
-
- protected UnnamedVar preferredUnnamedVar(Unifier un) {
- if (un != null) {
- // check if I am in a var cluster with another unnamed var,
- // i.e. I am unified with an unnamed var,
- // then prefer that unnamed var instead of a new one
- Term vl = un.get(this);
- if (vl != null && vl instanceof VarsCluster)
- for (VarTerm v: (VarsCluster)vl)
- if (v.isUnnamedVar())
- return (UnnamedVar)v;
- }
- return new UnnamedVar();
- }
/**
* returns the value of this var.
@@ -200,6 +185,8 @@
public int compareTo(Term t) {
if (value != null)
return value.compareTo(t);
+ else if (t.isUnnamedVar())
+ return -1;
else
return super.compareTo(t);
}
Modified: trunk/src/test/TermTest.java
===================================================================
--- trunk/src/test/TermTest.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/test/TermTest.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -12,6 +12,7 @@
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
+import jason.asSyntax.UnnamedVar;
import jason.asSyntax.VarTerm;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
@@ -578,9 +579,9 @@
u.clear();
assertTrue(u.unifies(l1, l2));
l2.apply(u);
- assertEquals(l2.toString(), "calc(32,33,33)");
+ assertEquals("calc(32,33,33)", l2.toString());
l1.apply(u);
- assertEquals(l1.toString(), "calc(32,33,33)");
+ assertEquals("calc(32,33,33)", l1.toString());
}
public void testMakeVarAnnon3() {
@@ -591,7 +592,35 @@
assertEquals(3, v.size());
assertEquals("vl("+l1.getTerm(1)+")",l1.getAnnots("vl").get(0).toString());
}
+
+ public void testMakeVarAnnon4() {
+ Literal l = Literal.parseLiteral("p(X)");
+ Unifier u = new Unifier();
+ u.unifies(new UnnamedVar(4), new VarTerm("X"));
+ u.unifies(new VarTerm("X"), new UnnamedVar(2));
+ u.unifies(new UnnamedVar(2), new VarTerm("Y"));
+ u.unifies(new UnnamedVar(10), new VarTerm("Y"));
+ u.unifies(new VarTerm("X"), new VarTerm("Z"));
+ /*
+ Iterator<VarTerm> i = u.binds(new VarTerm("X"));
+ while (i.hasNext()) {
+ System.out.println(i.next());
+ }
+ */
+ l.makeVarsAnnon(u);
+ //System.out.println(u+ " "+l);
+ assertEquals("p(_2)", l.toString());
+ }
+ public void testMakeVarAnnon5() {
+ Literal l = Literal.parseLiteral("p(X,Y)[s(Y)]");
+ Unifier u = new Unifier();
+ u.unifies(new VarTerm("X"), new VarTerm("Y"));
+ l.makeVarsAnnon(u);
+ assertEquals(l.getTerm(0), l.getTerm(1));
+ assertEquals("[s("+l.getTerm(0)+")]", l.getAnnots().toString());
+ }
+
public void testAddAnnots() {
Literal p1 = Literal.parseLiteral("p1");
Literal p2 = Literal.parseLiteral("p2[a1,a2]");
Modified: trunk/src/test/VarTermTest.java
===================================================================
--- trunk/src/test/VarTermTest.java 2008-08-11 09:41:14 UTC (rev 1354)
+++ trunk/src/test/VarTermTest.java 2008-08-16 10:13:14 UTC (rev 1355)
@@ -74,7 +74,6 @@
u.unifies(x9,x8);
u.unifies(x7,x4);
-
u.unifies(x3,new Structure("a"));
assertEquals(u.get(x1).toString(),"a");
assertEquals(u.get(x2).toString(),"a");
@@ -493,11 +492,14 @@
public void testUnnamedvarsorder() {
// the order is important for the "return" of plans/rules (where makeVarAnnon is used)
// the most recently created unnamed vars should come first
- List<UnnamedVar> l = new ArrayList<UnnamedVar>();
+ List<VarTerm> l = new ArrayList<VarTerm>();
l.add(new UnnamedVar(5));
+ l.add(new VarTerm("F"));
l.add(new UnnamedVar(6));
l.add(new UnnamedVar(11));
+ l.add(new VarTerm("B"));
Collections.sort(l);
- assertEquals("[_5, _6, _11]", l.toString());
+ assertEquals("[B, F, _11, _6, _5]", l.toString()); // this order is VERY important for unification!
}
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-08-11 09:41:20
|
Revision: 1354
http://jason.svn.sourceforge.net/jason/?rev=1354&view=rev
Author: jomifred
Date: 2008-08-11 09:41:14 +0000 (Mon, 11 Aug 2008)
Log Message:
-----------
fix equals of NumberTermImpl when the arg is Var.
Modified Paths:
--------------
trunk/src/jason/asSyntax/NumberTermImpl.java
trunk/src/jason/asSyntax/VarTerm.java
Modified: trunk/src/jason/asSyntax/NumberTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/NumberTermImpl.java 2008-08-10 11:06:39 UTC (rev 1353)
+++ trunk/src/jason/asSyntax/NumberTermImpl.java 2008-08-11 09:41:14 UTC (rev 1354)
@@ -77,7 +77,7 @@
public boolean equals(Object o) {
if (o == this) return true;
- if (o != null && o instanceof NumberTerm) {
+ if (o != null && o instanceof Term && ((Term)o).isNumeric()) {
NumberTerm st = (NumberTerm)o;
if (st.isVar() || st.isArithExpr())
return false;
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-08-10 11:06:39 UTC (rev 1353)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-08-11 09:41:14 UTC (rev 1354)
@@ -601,9 +601,9 @@
if (value != null && value.isNumeric())
return ((NumberTerm) value).solve();
else if (hasValue())
- logger.log(Level.SEVERE, "Error getting numerical value of VarTerm " + super.getFunctor() + ", the variable value ("+value+") is not a number.", new Exception());
+ logger.log(Level.SEVERE, getErrorMsg()+" Error getting numerical value of VarTerm " + super.getFunctor() + ", the variable value ("+value+") is not a number.", new Exception());
else
- logger.log(Level.SEVERE, "Error getting numerical value of VarTerm " + super.getFunctor() + ", the variable hasn't a value.", new Exception());
+ logger.log(Level.SEVERE, getErrorMsg()+" Error getting numerical value of VarTerm " + super.getFunctor() + ", the variable hasn't a value.", new Exception());
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-08-10 11:06:43
|
Revision: 1353
http://jason.svn.sourceforge.net/jason/?rev=1353&view=rev
Author: jomifred
Date: 2008-08-10 11:06:39 +0000 (Sun, 10 Aug 2008)
Log Message:
-----------
automatically add source(self) in del bel (-) operator when no other source is provided.
previously, it is added only no annotation is provided.
Modified Paths:
--------------
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/Atom.java
trunk/src/jason/bb/DefaultBeliefBase.java
trunk/src/jason/stdlib/package.html
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-07-17 09:16:19 UTC (rev 1352)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-08-10 11:06:39 UTC (rev 1353)
@@ -517,9 +517,8 @@
case delAddBel:
// -+a(1,X) ===> remove a(_,_), add a(1,X)
// change all vars to anon vars to remove it
- if (!body.hasAnnot()) {
- // do not add source(self) in case the
- // programmer set some annotation
+ if (!body.hasSource()) {
+ // do not add source(self) in case the programmer set a source
body.addAnnot(BeliefBase.TSelf);
}
Literal bc = (Literal)body.clone();
@@ -574,9 +573,8 @@
break;
case delBel:
- if (!body.hasAnnot()) {
- // do not add source(self) in case the
- // programmer set some annotation
+ if (!body.hasSource()) {
+ // do not add source(self) in case the programmer set a source
body.addAnnot(BeliefBase.TSelf);
}
Modified: trunk/src/jason/asSyntax/Atom.java
===================================================================
--- trunk/src/jason/asSyntax/Atom.java 2008-07-17 09:16:19 UTC (rev 1352)
+++ trunk/src/jason/asSyntax/Atom.java 2008-08-10 11:06:39 UTC (rev 1353)
@@ -35,7 +35,7 @@
/**
* Represents an atom (a structure with no arguments, e.g. "tell", "a"), it is an
* immutable object. It extends Literal, so can be used in place of a
- * Literal, but does not allow operations on terms/atoms and can not be negated.
+ * Literal, but does not allow operations on terms/annots and can not be negated.
*/
public final class Atom extends Literal {
Modified: trunk/src/jason/bb/DefaultBeliefBase.java
===================================================================
--- trunk/src/jason/bb/DefaultBeliefBase.java 2008-07-17 09:16:19 UTC (rev 1352)
+++ trunk/src/jason/bb/DefaultBeliefBase.java 2008-08-10 11:06:39 UTC (rev 1353)
@@ -163,7 +163,9 @@
}
private boolean removeFromEntry(Literal l) {
- if (!l.hasSource()) {
+ if (l.hasSource()) {
+ return false;
+ } else {
PredicateIndicator key = l.getPredicateIndicator();
BelEntry entry = belsMap.get(key);
entry.remove(l);
@@ -172,8 +174,6 @@
}
size--;
return true;
- } else {
- return false;
}
}
Modified: trunk/src/jason/stdlib/package.html
===================================================================
--- trunk/src/jason/stdlib/package.html 2008-07-17 09:16:19 UTC (rev 1352)
+++ trunk/src/jason/stdlib/package.html 2008-08-10 11:06:39 UTC (rev 1353)
@@ -96,12 +96,13 @@
<h2>Meta programming</h2>
<ul>
- <li>{@link jason.stdlib.atom}: check whether an argument is an atom.</li>
+ <li>{@link jason.stdlib.atom}: check whether an argument is an atom (p).</li>
+ <li>{@link jason.stdlib.structure}: check whether an argument is a structure (p(t1,t2), [a,b]).</li>
+ <li>{@link jason.stdlib.literal}: check whether an argument is a literal (p(t1,t2), ~p(t1,t2), p(t1,t2)[a1,a2]).</li>
+ <li>{@link jason.stdlib.list}: check whether an argument is a list ([a,b]).</li>
<li>{@link jason.stdlib.ground}: check whether an argument is ground.</li>
- <li>{@link jason.stdlib.literal}: check whether an argument is a literal.</li>
- <li>{@link jason.stdlib.list}: check whether an argument is a list.</li>
- <li>{@link jason.stdlib.number}: check whether an argument is a number.</li>
- <li>{@link jason.stdlib.string}: check whether an argument is a string.</li>
+ <li>{@link jason.stdlib.number}: check whether an argument is a number (1, 2.3).</li>
+ <li>{@link jason.stdlib.string}: check whether an argument is a string ("s").</li>
<li>{@link jason.stdlib.ground}: check whether an argument is ground.</li>
<li>{@link jason.stdlib.add_annot}: add an annotation in a literal.</li>
<li>{@link jason.stdlib.add_nested_source}: add a source in a literal.</li>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-07-17 09:16:31
|
Revision: 1352
http://jason.svn.sourceforge.net/jason/?rev=1352&view=rev
Author: jomifred
Date: 2008-07-17 09:16:19 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
copy var annots to its value (see TestVarInContext example)
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestVarInContext.java
trunk/build.xml
trunk/src/jason/asSemantics/Unifier.java
trunk/src/jason/asSemantics/VarsCluster.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/jason/asSyntax/directives/Include.java
trunk/src/jason/bb/DefaultBeliefBase.java
trunk/src/jason/jeditplugin/AboutGUI.java
trunk/src/test/VarTermTest.java
Modified: trunk/applications/as-unit-test/src/jason/tests/TestVarInContext.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestVarInContext.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/applications/as-unit-test/src/jason/tests/TestVarInContext.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -17,13 +17,17 @@
// defines the agent's AgentSpeak code
ag.parseAScode(
- "b1[b]. b2[c]. b3[d]. b4[a,d]. "+
+ "b1[b]. b2[c]. b3[d]. b4[a,d]. step(5). b(8)[step(3)]. b(9)[step(0)]."+
"+!test1 : P[e] | P[c] <- jason.asunit.print(P). " +
"+!test2 : P[e] & P[c] <- jason.asunit.print(P). " +
"-!test2 <- jason.asunit.print(\"error\"). " +
- "+!test3 : P[a] & P[d] <- jason.asunit.print(P). "
+ "+!test3 : P[a] & P[d] <- jason.asunit.print(P). " +
+
+ "is_old(P) :- (not P | (step(Current) & P[step(N)] & Current - N > 3)). " +
+ "+!test4(X) : is_old(X) <- jason.asunit.print(1). "+
+ "+!test4(_) <- jason.asunit.print(2). "
);
}
@@ -39,6 +43,12 @@
ag.addGoal("test3");
ag.assertPrint("b4", 5);
+
+ ag.addGoal("test4(b(8))");
+ ag.assertPrint("2", 5);
+
+ ag.addGoal("test4(b(9))");
+ ag.assertPrint("1", 5);
}
}
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/build.xml 2008-07-17 09:16:19 UTC (rev 1352)
@@ -146,6 +146,14 @@
</target>
<target name="plugin" depends="compile, jar">
+ <propertyfile file="${dist.properties}">
+ <entry key="version" value="${version}" />
+ <entry key="release" value="${release}" />
+ <!-- entry default="0" key="build" operation="+" type="int" /-->
+ <entry key="build.date" type="date" value="now" />
+ </propertyfile>
+ <property file="${dist.properties}" />
+
<jar jarfile="${jedit.install.dir}/jars/${plugin.jar.name}">
<fileset dir="${basedir}/src/jeditPlugin">
<include name="Jason.props" />
@@ -221,16 +229,6 @@
<echo message="Generating Jason ${version}.${release}" />
- <propertyfile file="${dist.properties}">
- <entry key="version" value="${version}" />
- <entry key="release" value="${release}" />
- <!-- entry default="0" key="build" operation="+" type="int" /-->
- <entry key="build.date" type="date" value="now" />
- </propertyfile>
- <property file="${dist.properties}" />
-
- <antcall target="plugin" />
-
<fixcrlf eol="crlf" includes="**/*.txt,**/*.bat" srcdir="${basedir}" />
<delete failonerror="no" includeEmptyDirs="true">
Modified: trunk/src/jason/asSemantics/Unifier.java
===================================================================
--- trunk/src/jason/asSemantics/Unifier.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/asSemantics/Unifier.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -195,30 +195,28 @@
t2vl = null;
// both has value, their values should unify
- if (t1vl != null && t2vl != null) {
+ if (t1vl != null && t2vl != null)
return unifiesNoUndo(t1vl, t2vl);
- }
+
// only t1 has value, t1's value should unify with var t2
- if (t1vl != null) {
+ if (t1vl != null)
return unifiesNoUndo(t2gv, t1vl);
- }
+
// only t2 has value, t2's value should unify with var t1
- if (t2vl != null) {
+ if (t2vl != null)
return unifiesNoUndo(t1gv, t2vl);
- }
// both are var with no value, like X=Y
// we must ensure that these vars will form a cluster
//if (! t1gv.isUnnamedVar() && ! t2gv.isUnnamedVar()) {
- VarTerm t1c = (VarTerm) t1gv.clone();
- VarTerm t2c = (VarTerm) t2gv.clone();
- VarsCluster cluster = new VarsCluster(t1c, t2c, this);
- if (cluster.hasValue()) {
- // all vars of the cluster should have the same value
- for (VarTerm vtc : cluster) {
- function.put(vtc, cluster);
- }
- }
+ VarTerm t1c = (VarTerm) t1gv.clone();
+ VarTerm t2c = (VarTerm) t2gv.clone();
+ VarsCluster cluster = new VarsCluster(t1c, t2c, this);
+ if (cluster.hasValue()) {
+ // all vars of the cluster should have the same value
+ for (VarTerm vtc : cluster)
+ function.put(vtc, cluster);
+ }
//}
return true;
}
Modified: trunk/src/jason/asSemantics/VarsCluster.java
===================================================================
--- trunk/src/jason/asSemantics/VarsCluster.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/asSemantics/VarsCluster.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -77,18 +77,16 @@
private void add(VarTerm vt) {
Term vl = u.get(vt);
- if (vl == null) {
- // v1 has no value
- if (vars == null) {
+ if (vl == null) { // vt is not in a VarsCluster
+ if (vars == null)
vars = new TreeSet<VarTerm>();
- }
vars.add(vt);
} else if (vl instanceof VarsCluster) {
- if (vars == null) {
+ // since vt is in a VarsCluster, join the two sets here
+ if (vars == null)
vars = ((VarsCluster) vl).vars;
- } else {
+ else
vars.addAll(((VarsCluster) vl).vars);
- }
} else {
logger.warning("joining var that has value!");
}
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -42,7 +42,12 @@
/**
* Represents a variable Term: like X (starts with upper case). It may have a
- * value, after {@link Unifier}.apply.
+ * value, after {@link VarTerm}.apply.
+ *
+ * An object of this class can be used in place of a
+ * Literal, Number, List, String, .... It behaves like a
+ * Literal, Number, .... just in case its value is a Literal,
+ * Number, ...
*
* @author jomi
*/
@@ -110,15 +115,17 @@
}
vl = (Term)vl.clone(); // should clone here, since there is no cloning in unify
- // TODO: decide whether to use var annots in apply
+ // decide whether to use var annots in apply
// X = p[a]
// !X[b]
// what's the event:
// +!p[a]
// or
// +!p[a,b]
- //if (vl.isPred() && this.hasAnnot()) // if this var has annots, add them in the value's annots (Experimental)
- // ((Pred)vl).addAnnots(this.getAnnots());
+ // Answer: use annots of var, useful for meta-programming like
+ // P[step(N)]
+ if (vl.isPred() && this.hasAnnot()) // if this var has annots, add them in the value's annots (Experimental)
+ ((Pred)vl).addAnnots(this.getAnnots());
value = vl;
resetHashCodeCache();
@@ -147,8 +154,9 @@
protected UnnamedVar preferredUnnamedVar(Unifier un) {
if (un != null) {
- // check if I have a var cluster with another unnamed var there
- // and then prefer that unnamed var instead of a new one
+ // check if I am in a var cluster with another unnamed var,
+ // i.e. I am unified with an unnamed var,
+ // then prefer that unnamed var instead of a new one
Term vl = un.get(this);
if (vl != null && vl instanceof VarsCluster)
for (VarTerm v: (VarsCluster)vl)
Modified: trunk/src/jason/asSyntax/directives/Include.java
===================================================================
--- trunk/src/jason/asSyntax/directives/Include.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/asSyntax/directives/Include.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -56,7 +56,8 @@
// or in the source paths
List<String> newpath = new ArrayList<String>();
newpath.add(new File(outerPrefix).getAbsoluteFile().getParent());
- newpath.addAll(aslSourcePath);
+ if (aslSourcePath != null)
+ newpath.addAll(aslSourcePath);
file = checkPathAndFixWithSourcePath(file, newpath, null);
in = new FileInputStream(file);
}
Modified: trunk/src/jason/bb/DefaultBeliefBase.java
===================================================================
--- trunk/src/jason/bb/DefaultBeliefBase.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/bb/DefaultBeliefBase.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -62,7 +62,9 @@
protected Set<Literal> percepts = new HashSet<Literal>();
public void init(Agent ag, String[] args) {
- logger = Logger.getLogger(ag.getTS().getUserAgArch().getAgName() + "-"+DefaultBeliefBase.class.getSimpleName());
+ if (ag != null) {
+ logger = Logger.getLogger(ag.getTS().getUserAgArch().getAgName() + "-"+DefaultBeliefBase.class.getSimpleName());
+ }
}
public void stop() {
Modified: trunk/src/jason/jeditplugin/AboutGUI.java
===================================================================
--- trunk/src/jason/jeditplugin/AboutGUI.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/jason/jeditplugin/AboutGUI.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -18,12 +18,12 @@
Properties p = new Properties();
p.load(JasonID.class.getResource("/dist.properties").openStream());
version = "Jason " + p.get("version") + "." + p.get("release");
- build = " build " + p.get("build") + " on " + p.get("build.date") + "\n\n";
+ build = " build on " + p.get("build.date") + "\n\n";
} catch (Exception ex) { }
JOptionPane.showMessageDialog(parent,
version + build+
- "Copyright (C) 2003-2005 Rafael H. Bordini, Jomi F. Hubner, et al.\n\n"+
+ "Copyright (C) 2003-2008 Rafael H. Bordini, Jomi F. Hubner, et al.\n\n"+
"This library is free software; you can redistribute it and/or\n"+
"modify it under the terms of the GNU Lesser General Public\n"+
"License as published by the Free Software Foundation; either\n"+
@@ -40,7 +40,7 @@
"Musees Nationaux, France). Photograph by Herve Lewandowski.\n\n"+
"To contact the authors:\n"+
"http://www.dur.ac.uk/r.bordini\n"+
- "http://www.inf.furb.br/~jomi",
+ "http://www.emse.fr/~hubner",
"JasonID - About",
JOptionPane.INFORMATION_MESSAGE,
new ImageIcon(JasonID.class.getResource("/images/Jason-GMoreau-Small.jpg")));
Modified: trunk/src/test/VarTermTest.java
===================================================================
--- trunk/src/test/VarTermTest.java 2008-07-11 12:37:27 UTC (rev 1351)
+++ trunk/src/test/VarTermTest.java 2008-07-17 09:16:19 UTC (rev 1352)
@@ -261,7 +261,7 @@
assertTrue(u.unifies(v1, p1));
assertEquals(u.get("X").toString(), "p(t1,t2)");
v1.apply(u);
- assertEquals("p(t1,t2)",v1.toString());
+ assertEquals("p(t1,t2)[a,b,c]",v1.toString());
}
public void testVarWithAnnots2() {
@@ -280,7 +280,7 @@
assertTrue(u.unifies(v1, v2));
assertTrue(u.unifies(new Literal("vvv"), v1));
v1.apply(u);
- assertEquals("vvv", v1.toString());
+ assertEquals("vvv[a]", v1.toString());
}
public void testVarWithAnnots3() {
@@ -315,7 +315,7 @@
assertEquals("a", u.get("A").toString());
assertEquals("p(1)", u.get(v).toString());
v.apply(u);
- assertEquals("p(1)", v.toString());
+ assertEquals("p(1)[a]", v.toString());
}
/*
@@ -348,7 +348,7 @@
assertTrue(i.hasNext());
u = i.next(); // u = {P[d]=b2}
v1.apply(u);
- assertEquals("b2",v1.toString());
+ assertEquals("b2[d]",v1.toString());
}
@SuppressWarnings("unchecked")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-07-11 12:37:29
|
Revision: 1351
http://jason.svn.sourceforge.net/jason/?rev=1351&view=rev
Author: jomifred
Date: 2008-07-11 05:37:27 -0700 (Fri, 11 Jul 2008)
Log Message:
-----------
changes for jason-moise 1.1.2
Modified Paths:
--------------
trunk/applications/jason-moise/build.xml
trunk/applications/jason-moise/example/writePaper/wp-os.xml
trunk/applications/jason-moise/lib/moise.jar
trunk/applications/jason-moise/readme.txt
trunk/applications/jason-moise/src/asl/moise-common.asl
trunk/applications/jason-moise/src/jmoise/create_group.java
Modified: trunk/applications/jason-moise/build.xml
===================================================================
--- trunk/applications/jason-moise/build.xml 2008-07-10 15:52:25 UTC (rev 1350)
+++ trunk/applications/jason-moise/build.xml 2008-07-11 12:37:27 UTC (rev 1351)
@@ -8,8 +8,8 @@
<property environment="env"/>
<property name="version" value="1"/>
- <property name="release" value="1"/>
- <property name="moiseDir" value="${env.HOME}/Moise/Moise-svn" />
+ <property name="release" value="1.2"/>
+ <property name="moiseDir" value="${env.HOME}/svn-moise" />
<property name="distDir" value="${env.HOME}/tmp/jmoise-${version}.${release}" />
<property name="distFile" value="${env.HOME}/jason-moise-${version}.${release}" />
<property name="doc-src-dir" value="${env.HOME}/programming/Moise-doc" />
Modified: trunk/applications/jason-moise/example/writePaper/wp-os.xml
===================================================================
--- trunk/applications/jason-moise/example/writePaper/wp-os.xml 2008-07-10 15:52:25 UTC (rev 1350)
+++ trunk/applications/jason-moise/example/writePaper/wp-os.xml 2008-07-11 12:37:27 UTC (rev 1351)
@@ -5,7 +5,7 @@
<organisational-specification
id="wp"
- os-version="0.4"
+ os-version="0.6"
xmlns='http://moise.sourceforge.net/os'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
Modified: trunk/applications/jason-moise/lib/moise.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jason-moise/readme.txt
===================================================================
--- trunk/applications/jason-moise/readme.txt 2008-07-10 15:52:25 UTC (rev 1350)
+++ trunk/applications/jason-moise/readme.txt 2008-07-11 12:37:27 UTC (rev 1351)
@@ -9,4 +9,4 @@
and start it. The chapter 4 of doc/tutorial.pdf explains in details
the examples.
-Note: Jason 1.1 is required.
+Note: Jason 1.1.2 is required.
Modified: trunk/applications/jason-moise/src/asl/moise-common.asl
===================================================================
--- trunk/applications/jason-moise/src/asl/moise-common.asl 2008-07-10 15:52:25 UTC (rev 1350)
+++ trunk/applications/jason-moise/src/asl/moise-common.asl 2008-07-11 12:37:27 UTC (rev 1351)
@@ -33,15 +33,9 @@
+obligation(Sch, Mission)
: scheme(SchSpec,Sch) & desired_mission(SchSpec, Mission)
<- jmoise.commit_mission(Mission,Sch).
-+obligation(Sch, Mission)
- : not scheme(_,Sch)
- <- .println("I do not understand why I have an obligation for a scheme I do not know! Scheme:",Sch," Mission:", Mission).
+permission(Sch, Mission)
: scheme(SchSpec,Sch) & desired_mission(SchSpec, Mission)
<- jmoise.commit_mission(Mission,Sch).
-+permission(Sch, Mission)
- : not scheme(_,Sch)
- <- .println("I do not understand why I have a permission for a scheme I do not know! Scheme:",Sch," Mission:", Mission).
// when the root goal of the scheme is achieved,
// remove my missions
Modified: trunk/applications/jason-moise/src/jmoise/create_group.java
===================================================================
--- trunk/applications/jason-moise/src/jmoise/create_group.java 2008-07-10 15:52:25 UTC (rev 1350)
+++ trunk/applications/jason-moise/src/jmoise/create_group.java 2008-07-11 12:37:27 UTC (rev 1351)
@@ -6,11 +6,14 @@
/**
-<p>Organisational action: <b><code>jmoise.create_group( GrSpecId [, SuperGrId] )</code></b>:
- used by an agent to create a new group based on GrSpecId specification.
- GrSpecId is the name of the group in the structural specification, and
- SuperGrId is the identification of the super group instance. The second parameter
- is used in case a sub-groups is being created.
+<p>Organisational action: <b><code>jmoise.create_group( GrSpecId [,
+ SuperGrId] [, newGroupId] )</code></b>: used by an agent to create
+ a new group based on GrSpecId specification. GrSpecId is the name
+ of the group in the structural specification, and SuperGrId is the
+ identification of the super group instance. The second parameter is
+ used in case a sub-groups is being created. If the last argument is
+ a variable, it unifies with the unique identification given to the
+ new group.
<p>Conditions to succeed (just in case of creation of sub-groups):
<ul>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-07-10 15:52:27
|
Revision: 1350
http://jason.svn.sourceforge.net/jason/?rev=1350&view=rev
Author: jomifred
Date: 2008-07-10 08:52:25 -0700 (Thu, 10 Jul 2008)
Log Message:
-----------
add two new functions: sum and average
one new IA: term2string
Modified Paths:
--------------
trunk/applications/jason-team/src/team-os.xml
trunk/release-notes.txt
trunk/src/jason/asSyntax/directives/FunctionRegister.java
trunk/src/jason/stdlib/package.html
Added Paths:
-----------
trunk/src/jason/functions/Average.java
trunk/src/jason/functions/Sum.java
trunk/src/jason/stdlib/term2string.java
Modified: trunk/applications/jason-team/src/team-os.xml
===================================================================
--- trunk/applications/jason-team/src/team-os.xml 2008-07-06 18:04:48 UTC (rev 1349)
+++ trunk/applications/jason-team/src/team-os.xml 2008-07-10 15:52:25 UTC (rev 1350)
@@ -85,7 +85,7 @@
</goal>
<goal id="goto_near_unvisited" ds="go to the near unvisited location inside the area of the group" type="maintenance"/>
<goal id="share_seen_cows" ds="share seen cows with other agents in the scheme" type="maintenance"/>
- <goal id="follow_leader" ds="follows the leader of the scheme/group" type="maintenance"/>
+ <goal id="follow_leader" ds="follow the leader of the scheme/group" type="maintenance"/>
</plan>
</goal>
@@ -105,11 +105,12 @@
<goal id="herd_cows" >
<plan operator="parallel">
<goal id="recruit" ds="recruit more herdboys depending on the size of the cows cluster" type="maintenance"/>
- <goal id="release_boys" ds="if the number of agents too much, release some boyd" type="maintenance"/>
+ <goal id="release_boys" ds="if the group has
+ too much boys, release some" type="maintenance"/>
<goal id="define_formation" ds="compute the ideal location of each member of the group and share this information with them" type="maintenance"/>
<goal id="be_in_formation" ds="go to the place allocated to the agent in the formation" type="maintenance"/>
<goal id="share_seen_cows" ds="share seen cows with other agents in the scheme" type="maintenance"/>
- <goal id="change_to_exploring" ds="verify if necessary to finish the herding group and create the exploring groups" type="maintenance"/>
+ <goal id="change_to_exploring" ds="verify if it is necessary to finish the herding group and create the exploring group" type="maintenance"/>
</plan>
</goal>
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-07-06 18:04:48 UTC (rev 1349)
+++ trunk/release-notes.txt 2008-07-10 15:52:25 UTC (rev 1350)
@@ -1,4 +1,18 @@
-------------
+version 1.1.3
+-------------
+
+New internal actions
+. .term2string: transform term into strings and vice-versa.
+
+
+New functions
+. .math.sum: sums a list of numbers
+. .math.average: returns the average of a list of numbers
+
+
+
+-------------
version 1.1.2
-------------
Modified: trunk/src/jason/asSyntax/directives/FunctionRegister.java
===================================================================
--- trunk/src/jason/asSyntax/directives/FunctionRegister.java 2008-07-06 18:04:48 UTC (rev 1349)
+++ trunk/src/jason/asSyntax/directives/FunctionRegister.java 2008-07-10 15:52:25 UTC (rev 1350)
@@ -6,12 +6,14 @@
import jason.asSyntax.Pred;
import jason.asSyntax.StringTerm;
import jason.functions.Abs;
+import jason.functions.Average;
import jason.functions.Length;
import jason.functions.Max;
import jason.functions.Min;
import jason.functions.Random;
import jason.functions.Round;
import jason.functions.Sqrt;
+import jason.functions.Sum;
import jason.functions.ceil;
import jason.functions.e;
import jason.functions.floor;
@@ -39,6 +41,8 @@
addFunction(Abs.class);
addFunction(Max.class);
addFunction(Min.class);
+ addFunction(Sum.class);
+ addFunction(Average.class);
addFunction(Length.class);
addFunction(Random.class);
addFunction(Round.class);
Added: trunk/src/jason/functions/Average.java
===================================================================
--- trunk/src/jason/functions/Average.java (rev 0)
+++ trunk/src/jason/functions/Average.java 2008-07-10 15:52:25 UTC (rev 1350)
@@ -0,0 +1,50 @@
+package jason.functions;
+
+import jason.JasonException;
+import jason.asSemantics.DefaultArithFunction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSyntax.ListTerm;
+import jason.asSyntax.NumberTerm;
+import jason.asSyntax.Term;
+
+/**
+<p>Function: <b><code>math.average(L)</code></b>: returns the average of all values of L.
+
+<p>Examples:<ul>
+<li> <code>math.average([1,3])</code>: returns 2.</li>
+<li> <code>math.average([])</code>: fail.</li>
+</ul>
+
+@author Jomi
+
+@see jason.functions.Min
+@see jason.functions.Max
+@see jason.functions.Sum
+
+*/
+public class Average extends DefaultArithFunction {
+
+ public String getName() {
+ return "math.average";
+ }
+
+ @Override
+ public double evaluate(TransitionSystem ts, Term[] args) throws Exception {
+ if (args[0].isList()) {
+ double sum = 0;
+ int n = 0;
+ for (Term t: (ListTerm)args[0])
+ if (t.isNumeric()) {
+ sum += ((NumberTerm)t).solve();
+ n++;
+ }
+ return sum / n;
+ }
+ throw new JasonException(getName()+" is not implemented for type '"+args[0]+"'.");
+ }
+
+ @Override
+ public boolean checkArity(int a) {
+ return a == 1;
+ }
+}
Added: trunk/src/jason/functions/Sum.java
===================================================================
--- trunk/src/jason/functions/Sum.java (rev 0)
+++ trunk/src/jason/functions/Sum.java 2008-07-10 15:52:25 UTC (rev 1350)
@@ -0,0 +1,48 @@
+package jason.functions;
+
+import jason.JasonException;
+import jason.asSemantics.DefaultArithFunction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSyntax.ListTerm;
+import jason.asSyntax.NumberTerm;
+import jason.asSyntax.Term;
+
+/**
+<p>Function: <b><code>math.sum(L)</code></b>: sums all values of L.
+
+<p>Examples:<ul>
+<li> <code>math.sum([1,3])</code>: returns 4.</li>
+<li> <code>math.sum([3,a,"s",5])</code>: returns 8.</li>
+<li> <code>math.sum([])</code>: returns 0.</li>
+</ul>
+
+@author Jomi
+
+@see jason.functions.Min
+@see jason.functions.Max
+@see jason.functions.Average
+
+*/
+public class Sum extends DefaultArithFunction {
+
+ public String getName() {
+ return "math.sum";
+ }
+
+ @Override
+ public double evaluate(TransitionSystem ts, Term[] args) throws Exception {
+ if (args[0].isList()) {
+ double sum = 0;
+ for (Term t: (ListTerm)args[0])
+ if (t.isNumeric())
+ sum += ((NumberTerm)t).solve();
+ return sum;
+ }
+ throw new JasonException(getName()+" is not implemented for type '"+args[0]+"'.");
+ }
+
+ @Override
+ public boolean checkArity(int a) {
+ return a == 1;
+ }
+}
Modified: trunk/src/jason/stdlib/package.html
===================================================================
--- trunk/src/jason/stdlib/package.html 2008-07-06 18:04:48 UTC (rev 1349)
+++ trunk/src/jason/stdlib/package.html 2008-07-10 15:52:25 UTC (rev 1350)
@@ -83,6 +83,7 @@
<li>{@link jason.stdlib.reverse}: reverse strings. </li>
<li>{@link jason.stdlib.substring}: test substrings of strings. </li>
<li>{@link jason.stdlib.string}: check whether an argument is a string.</li>
+ <li>{@link jason.stdlib.term2string}: convert terms to strings and vice-versa.</li>
</ul>
<h2>Execution control</h2>
Added: trunk/src/jason/stdlib/term2string.java
===================================================================
--- trunk/src/jason/stdlib/term2string.java (rev 0)
+++ trunk/src/jason/stdlib/term2string.java 2008-07-10 15:52:25 UTC (rev 1350)
@@ -0,0 +1,73 @@
+
+package jason.stdlib;
+
+import jason.JasonException;
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.InternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.DefaultTerm;
+import jason.asSyntax.StringTerm;
+import jason.asSyntax.StringTermImpl;
+import jason.asSyntax.Term;
+
+/**
+ <p>Internal action: <b><code>.term2string(T,S)</code></b>.
+
+ <p>Description: converts the term T into a string S and vice-versa.
+
+ <p>Parameters:<ul>
+ <li>-/+ T (any term).<br/>
+ <li>-/+ S (a string).<br/>
+ </ul>
+
+ <p>Examples:<ul>
+ <li> <code>.substring(b,"b")</code>: true.
+ <li> <code>.substring(b,X)</code>: unifies X to "b".
+ <li> <code>.substring(X,"b")</code>: unified X to b.
+ </ul>
+
+ @see jason.stdlib.concat
+ @see jason.stdlib.delete
+ @see jason.stdlib.length
+ @see jason.stdlib.reverse
+
+*/
+public class term2string extends DefaultInternalAction {
+
+ private static InternalAction singleton = null;
+ public static InternalAction create() {
+ if (singleton == null)
+ singleton = new term2string();
+ return singleton;
+ }
+
+ @Override
+ public Object execute(TransitionSystem ts, final Unifier un, final Term[] args) throws Exception {
+ try {
+ // case 1, no vars
+ if (!args[0].isVar() && args[1].isString()) {
+ return args[0].toString().equals( ((StringTerm)args[1]).getString() );
+ }
+
+ // case 2, second is var
+ if (!args[0].isVar() && args[1].isVar()) {
+ return un.unifies(new StringTermImpl(args[0].toString()), args[1]);
+ }
+
+ // case 3, first is var
+ if (args[0].isVar() && args[1].isString()) {
+ return un.unifies(args[0], DefaultTerm.parse( ((StringTerm)args[1]).getString() ));
+ }
+
+ throw new JasonException("invalid case of term2string");
+ } catch (ArrayIndexOutOfBoundsException e) {
+ throw new JasonException("The internal action 'term2string' has not received two arguments.");
+ } catch (JasonException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JasonException("Error in internal action 'term2string': " + e, e);
+ }
+ }
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-07-06 18:04:51
|
Revision: 1349
http://jason.svn.sourceforge.net/jason/?rev=1349&view=rev
Author: jomifred
Date: 2008-07-06 11:04:48 -0700 (Sun, 06 Jul 2008)
Log Message:
-----------
update eclipse-plugin for 1.1.2
Modified Paths:
--------------
trunk/applications/jason-eclipse-plugin/build.xml
trunk/build.xml
Modified: trunk/applications/jason-eclipse-plugin/build.xml
===================================================================
--- trunk/applications/jason-eclipse-plugin/build.xml 2008-07-06 15:58:16 UTC (rev 1348)
+++ trunk/applications/jason-eclipse-plugin/build.xml 2008-07-06 18:04:48 UTC (rev 1349)
@@ -12,12 +12,12 @@
<property name="dist.properties" value="${basedir}/bin/dist.properties" />
<property name="version" value="1" />
- <property name="release" value="1.1" />
+ <property name="release" value="1.2" />
<property name="distDir" value="${basedir}/dist" />
<property name="distDirPlugins" value="${distDir}/plugins" />
<property name="pluginJar" value="${distDirPlugins}/net.sourceforge.jasonide_${version}.${release}.jar" />
- <property name="pluginZip" value="${distDir}/jason-eclipse-plugin-${version}.${release}.zip" />
+ <property name="pluginZip" value="${env.HOME}/jason-eclipse-plugin-${version}.${release}.zip" />
<path id="project.classpath">
<pathelement location="${regexpJar}" />
@@ -35,12 +35,8 @@
</javac>
</target>
- <target name="initJar">
- <mkdir dir="${distDir}" />
- <mkdir dir="${distDirPlugins}" />
- </target>
-
- <target name="jar" depends="compile,initJar">
+ <target name="jar" depends="compile">
+ <mkdir dir="${distDirPlugins}" />
<jar jarfile="${pluginJar}" manifest="${basedir}/META-INF/MANIFEST.MF">
<fileset dir="${build.dir}">
<include name="**/*.class" />
@@ -52,7 +48,13 @@
<include name="plugin.xml" />
</fileset>
</jar>
-
+ </target>
+
+ <target name="dist">
+ <delete failonerror="no" includeEmptyDirs="true">
+ <fileset dir="${distDir}" />
+ </delete>
+ <antcall target="jar" />
<zip destfile="${pluginZip}" basedir="${distDir}" />
</target>
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2008-07-06 15:58:16 UTC (rev 1348)
+++ trunk/build.xml 2008-07-06 18:04:48 UTC (rev 1349)
@@ -15,7 +15,7 @@
<property name="dist.properties" value="${basedir}/bin/dist.properties" />
<property name="version" value="1" />
- <property name="release" value="1.2" />
+ <property name="release" value="1.3" />
<property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" />
<property name="distFile" value="${env.HOME}/Jason-${version}.${release}" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-07-06 15:58:22
|
Revision: 1348
http://jason.svn.sourceforge.net/jason/?rev=1348&view=rev
Author: jomifred
Date: 2008-07-06 08:58:16 -0700 (Sun, 06 Jul 2008)
Log Message:
-----------
small changes for 1.1.2
Modified Paths:
--------------
trunk/applications/jason-team/readme.txt
trunk/applications/jason-team/screenshots/s1b.txt
trunk/applications/jason-team/screenshots/s1c ag against their curral.txt
trunk/demos/gui/readme.txt
trunk/release-notes.txt
trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
trunk/src/jason/asSyntax/parser/as2j.java
Added Paths:
-----------
trunk/src/jason/stdlib/if_then_else.java
Removed Paths:
-------------
trunk/src/jason/stdlib/conditional.java
Modified: trunk/applications/jason-team/readme.txt
===================================================================
--- trunk/applications/jason-team/readme.txt 2008-07-05 09:37:52 UTC (rev 1347)
+++ trunk/applications/jason-team/readme.txt 2008-07-06 15:58:16 UTC (rev 1348)
@@ -10,8 +10,8 @@
*/
-To run this team Jason 1.1.2 is required.
-
+To run this team Jason 1.1.2 is required.
+
Steps:
1. run massim-server
Modified: trunk/applications/jason-team/screenshots/s1b.txt
===================================================================
--- trunk/applications/jason-team/screenshots/s1b.txt 2008-07-05 09:37:52 UTC (rev 1347)
+++ trunk/applications/jason-team/screenshots/s1b.txt 2008-07-06 15:58:16 UTC (rev 1348)
@@ -1,79 +1,79 @@
-|---------------------------------------------------------------------------------|
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| X XXXXXXXXX X |
-| X XXX XXX X |
-| XX XXX XXX XX |
-| XX XXX XXX XX |
-| XXX XXX XXX XXX |
-| XXXX XXX XXX XXXX |
-| XXXXXX XXXXXX |
-| X X |
-| XXXXXX X X XXXXXX |
-| X XXXXX XX XX XXXXX X |
-| XX XXXXXXXX XXXXXXXX XX |
-| X ------ XXXXXX X |
-| X ------ XXXXXX X |
-| X ------ XXXXXX X |
-| X c ------ XXXXXX X |
-| XX cc ------ XXXXXX XX |
-| XX ------ XXXXXX XX |
-| XX 1 XXX ------ XXXXXX XXX XX |
-| XX X ------ XXXXXX X XX |
-| X X |
-| X X |
-| c X X |
-| c X X 32 |
-| X X |
-| XX XX 6 |
-| c X X 4 |
-| X X |
-| XX XX |
-| X X |
-| XX XX |
-| X X |
-| XX X X XX |
-| X X X X |
-| XX XX XX XX |
-| X XXX XXX X |
-| X XXXX XXXX X |
-| X XXX XXX X |
-| X XX XX X |
-| XX XX |
-| X X X X |
-| X X |
-| XXX XXX XXX XXX |
-| X X |
-| XXXX XXXX |
-| X XXXXXXXXXX XX X |
-| XX X X XX |
-| XX XX |
-| XX XX X |
-| XXXX |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-| |
-|---------------------------------------------------------------------------------|
+|---------------------------------------------------------------------------------|
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| X XXXXXXXXX X |
+| X XXX XXX X |
+| XX XXX XXX XX |
+| XX XXX XXX XX |
+| XXX XXX XXX XXX |
+| XXXX XXX XXX XXXX |
+| XXXXXX XXXXXX |
+| X X |
+| XXXXXX X X XXXXXX |
+| X XXXXX XX XX XXXXX X |
+| XX XXXXXXXX XXXXXXXX XX |
+| X ------ XXXXXX X |
+| X ------ XXXXXX X |
+| X ------ XXXXXX X |
+| X c ------ XXXXXX X |
+| XX cc ------ XXXXXX XX |
+| XX ------ XXXXXX XX |
+| XX 1 XXX ------ XXXXXX XXX XX |
+| XX X ------ XXXXXX X XX |
+| X X |
+| X X |
+| c X X |
+| c X X 32 |
+| X X |
+| XX XX 6 |
+| c X X 4 |
+| X X |
+| XX XX |
+| X X |
+| XX XX |
+| X X |
+| XX X X XX |
+| X X X X |
+| XX XX XX XX |
+| X XXX XXX X |
+| X XXXX XXXX X |
+| X XXX XXX X |
+| X XX XX X |
+| XX XX |
+| X X X X |
+| X X |
+| XXX XXX XXX XXX |
+| X X |
+| XXXX XXXX |
+| X XXXXXXXXXX XX X |
+| XX X X XX |
+| XX XX |
+| XX XX X |
+| XXXX |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+| |
+|---------------------------------------------------------------------------------|
Modified: trunk/applications/jason-team/screenshots/s1c ag against their curral.txt
===================================================================
--- trunk/applications/jason-team/screenshots/s1c ag against their curral.txt 2008-07-05 09:37:52 UTC (rev 1347)
+++ trunk/applications/jason-team/screenshots/s1c ag against their curral.txt 2008-07-06 15:58:16 UTC (rev 1348)
@@ -1,64 +1,64 @@
-| |
-| |
-| |
-| |
-| |
-| XXXXXXXXX |
-| XXX XXX |
-| X XXX XXX |
-| XX XXX XXX XX |
-| XXX XXX XXX XXX |
-| XXXX XXX XXX XXXX |
-| XXXXXX XXXXXX |
-| X X |
-| XXXXXX X X c XXXXXX |
-| X XXXXX XX XX c XXXXX X |
-| X XXXXXXXX XXXXXXXX XX |
-| X ------ XXXXXX X |
-| X ------ XXXXXX c X |
-| X ------ XXXXXX X |
-| X ------ XXXXXX X |
-| XX ------ XXXXXX 1 4 XX |
-| XX ------ XXXXXX E cE XX |
-| XX XXX ------ XXXXXX XXX 3 XX |
-| XX X ------ XXXXXX X XX |
-| X X |
-| X X c |
-| X X E |
-| X X |
-| X X |
-| XX XX |
-| X X |
-| X X |
-| X X |
-| X X |
-| X X |
-| XX XX |
-| XX XX |
-| X X |
-| XX XX |
-| X 2 X |
-| XX X X XX |
-| X X X X |
-| XX XX XX XX |
-| X XX XXX X |
-| X XXXX X |
-| X XXX X |
-| X XX X |
-| XX XX |
-| X X X X |
-| X X |
-| XXX XXX XXX |
-| X |
-| XXXX |
-| XXXXXXXXXX X |
-| X XX5 |
-| XX |
-| XXXX XX 6 |
-| XXXX |
-| |
-| |
-| |
-| |
-| |
-| |
+| |
+| |
+| |
+| |
+| |
+| XXXXXXXXX |
+| XXX XXX |
+| X XXX XXX |
+| XX XXX XXX XX |
+| XXX XXX XXX XXX |
+| XXXX XXX XXX XXXX |
+| XXXXXX XXXXXX |
+| X X |
+| XXXXXX X X c XXXXXX |
+| X XXXXX XX XX c XXXXX X |
+| X XXXXXXXX XXXXXXXX XX |
+| X ------ XXXXXX X |
+| X ------ XXXXXX c X |
+| X ------ XXXXXX X |
+| X ------ XXXXXX X |
+| XX ------ XXXXXX 1 4 XX |
+| XX ------ XXXXXX E cE XX |
+| XX XXX ------ XXXXXX XXX 3 XX |
+| XX X ------ XXXXXX X XX |
+| X X |
+| X X c |
+| X X E |
+| X X |
+| X X |
+| XX XX |
+| X X |
+| X X |
+| X X |
+| X X |
+| X X |
+| XX XX |
+| XX XX |
+| X X |
+| XX XX |
+| X 2 X |
+| XX X X XX |
+| X X X X |
+| XX XX XX XX |
+| X XX XXX X |
+| X XXXX X |
+| X XXX X |
+| X XX X |
+| XX XX |
+| X X X X |
+| X X |
+| XXX XXX XXX |
+| X |
+| XXXX |
+| XXXXXXXXXX X |
+| X XX5 |
+| XX |
+| XXXX XX 6 |
+| XXXX |
+| |
+| |
+| |
+| |
+| |
+| |
Modified: trunk/demos/gui/readme.txt
===================================================================
--- trunk/demos/gui/readme.txt 2008-07-05 09:37:52 UTC (rev 1347)
+++ trunk/demos/gui/readme.txt 2008-07-06 15:58:16 UTC (rev 1348)
@@ -1,18 +1,18 @@
-There are many ways of creating GUI for Jason agents.
-All of them relies on Java.
-
-This directory contains the following examples:
-
-gui1: uses and internal action to ask something to the user
-
-gui2: creates a window with buttons that, when pressed,
- produce events the agent can react to.
-
-
-Some examples of Jason also use GUI:
-
-auction: uses a customised agent architecture that provides special
- actions to show information in a GUI
-
-domestic-robot, iterated-prisoners-dilemma, and many others: the GUI
- is implemented and maintained by the environment.
\ No newline at end of file
+There are many ways of creating GUI for Jason agents.
+All of them relies on Java.
+
+This directory contains the following examples:
+
+gui1: uses and internal action to ask something to the user
+
+gui2: creates a window with buttons that, when pressed,
+ produce events the agent can react to.
+
+
+Some examples of Jason also use GUI:
+
+auction: uses a customised agent architecture that provides special
+ actions to show information in a GUI
+
+domestic-robot, iterated-prisoners-dilemma, and many others: the GUI
+ is implemented and maintained by the environment.
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-07-05 09:37:52 UTC (rev 1347)
+++ trunk/release-notes.txt 2008-07-06 15:58:16 UTC (rev 1348)
@@ -3,7 +3,7 @@
-------------
New features
-. (experimental) control of the execution in plan's body with if, while
+. (experimental) control of the execution in plan bodies with if, while,
and for.
--- if ----
@@ -17,8 +17,9 @@
if <logical formula> holds, <plan_body1> is executed; otherwise,
<plan_body2> is executed.
- e.g.: if (vl(X) & X > 10) { // where vl(X) is a belief
- .print("value > 10")
+ e.g.: if (vl(X) & X > 10 & X < 20) { // where vl(X) is a belief
+ .print("value > 10 and ");
+ .print("value < 20")
}
--- while ---
@@ -41,7 +42,7 @@
<plan_body>
};
- for all unifications of <logical formula> the <plan_body> is executed.
+ the <plan_body> is executed for all unifications of <logical formula>.
e.g.: for ( vl(X) ) {
.print(X)
@@ -55,19 +56,19 @@
New examples and demos:
-. demos/gui: two simple examples of how to make a GUI for agents
+. demos/gui: two simple examples of how to make a GUI for individual agents
. example/food-simulation: implementation of the scenario of simulation
presented in http://jasss.soc.surrey.ac.uk/1/3/3.html
Bugs fixed:
-. BUF doesn't add annotation "source(percept)" in the perception deletion event
-. drop_desire does not remove desires in Circumstance.Event correctly
+. BUF didn't add annotation "source(percept)" in the perception deletion event
+. drop_desire did not remove desires in Circumstance.Event correctly
when annotations are used
-. print works like println
-. =.. with atoms
-. unbound vars as arguments for rules (as identified by Stephen Cranefield)
+. print worked like println
+. problem in =.. with atoms
+. problem in unification whe unbound vars were used as arguments
+ for rules (as identified by Stephen Cranefield)
-
-------------
version 1.1.1
-------------
Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc
===================================================================
--- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-07-05 09:37:52 UTC (rev 1347)
+++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2008-07-06 15:58:16 UTC (rev 1348)
@@ -403,7 +403,7 @@
]
F=pred() {
if (F.getFunctor().equals("if")) {
- Pred c = new Pred(".conditional");
+ Pred c = new Pred(".if_then_else");
c.setTerms(F.getTerms());
F = c;
} else if (F.getFunctor().equals("while")) {
Modified: trunk/src/jason/asSyntax/parser/as2j.java
===================================================================
--- trunk/src/jason/asSyntax/parser/as2j.java 2008-07-05 09:37:52 UTC (rev 1347)
+++ trunk/src/jason/asSyntax/parser/as2j.java 2008-07-06 15:58:16 UTC (rev 1348)
@@ -548,7 +548,7 @@
}
F = pred();
if (F.getFunctor().equals("if")) {
- Pred c = new Pred(".conditional");
+ Pred c = new Pred(".if_then_else");
c.setTerms(F.getTerms());
F = c;
} else if (F.getFunctor().equals("while")) {
Deleted: trunk/src/jason/stdlib/conditional.java
===================================================================
--- trunk/src/jason/stdlib/conditional.java 2008-07-05 09:37:52 UTC (rev 1347)
+++ trunk/src/jason/stdlib/conditional.java 2008-07-06 15:58:16 UTC (rev 1348)
@@ -1,111 +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 java.util.Iterator;
-
-import jason.JasonException;
-import jason.asSemantics.DefaultInternalAction;
-import jason.asSemantics.IntendedMeans;
-import jason.asSemantics.InternalAction;
-import jason.asSemantics.TransitionSystem;
-import jason.asSemantics.Unifier;
-import jason.asSyntax.LogicalFormula;
-import jason.asSyntax.PlanBody;
-import jason.asSyntax.Term;
-
-/**
-Implementation of <b>if</b>.
-
-<p>Syntax:
-<pre>
- if ( <i>logical formula</i> ) {
- <i>plan_body1</i>
- [ } else { <i>plan_body2</i> ]
- };
-</pre>
-</p>
-
-<p>if <i>logical formula</i> holds, <i>plan_body1</i> is executed;
-otherwise, <i>plan_body2</i> is executed.</p>
-
-<p>Example:
-<pre>
-+event : context
- <- ....
- if (vl(X) & X > 10) { // where vl(X) is a belief
- .print("value > 10")
- };
- ....
-</pre>
-The unification is changed by the evaluation of the logical formula, i.e., X might have a value after if.
-</p>
-
-*/
-public class conditional extends DefaultInternalAction {
-
- private static InternalAction singleton = null;
- public static InternalAction create() {
- if (singleton == null)
- singleton = new conditional();
- return singleton;
- }
-
- @Override
- public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
- try {
- if ( !(args[0] instanceof LogicalFormula))
- throw new JasonException("The first argument of if must be a logical formula.");
-
- LogicalFormula logExpr = (LogicalFormula)args[0];
- PlanBody whattoadd = null;
-
- Iterator<Unifier> iu = logExpr.logicalConsequence(ts.getAg(), un);
- if (iu.hasNext()) { // .if THEN
- if ( !args[1].isPlanBody())
- throw new JasonException("The second argument of if must be a plan body term.");
- whattoadd = (PlanBody)args[1];
- un.compose(iu.next());
- } else if (args.length == 3) { // .if ELSE
- if ( !args[2].isPlanBody())
- throw new JasonException("The third argument of if must be a plan body term.");
- whattoadd = (PlanBody)args[2];
- }
-
- if (whattoadd != null) {
- IntendedMeans im = ts.getC().getSelectedIntention().peek();
- PlanBody ifia = im.getCurrentStep();
- whattoadd.setAsBodyTerm(false);
- ifia.add(1,whattoadd);
- }
- return true;
- } catch (ArrayIndexOutOfBoundsException e) {
- throw new JasonException("The 'if' has not received the required arguments.");
- } catch (JasonException e) {
- throw e;
- } catch (Exception e) {
- throw new JasonException("Error in 'if': " + e, e);
- }
- }
-}
Added: trunk/src/jason/stdlib/if_then_else.java
===================================================================
--- trunk/src/jason/stdlib/if_then_else.java (rev 0)
+++ trunk/src/jason/stdlib/if_then_else.java 2008-07-06 15:58:16 UTC (rev 1348)
@@ -0,0 +1,111 @@
+//----------------------------------------------------------------------------
+// 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 java.util.Iterator;
+
+import jason.JasonException;
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.IntendedMeans;
+import jason.asSemantics.InternalAction;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.LogicalFormula;
+import jason.asSyntax.PlanBody;
+import jason.asSyntax.Term;
+
+/**
+Implementation of <b>if</b>.
+
+<p>Syntax:
+<pre>
+ if ( <i>logical formula</i> ) {
+ <i>plan_body1</i>
+ [ } else { <i>plan_body2</i> ]
+ };
+</pre>
+</p>
+
+<p>if <i>logical formula</i> holds, <i>plan_body1</i> is executed;
+otherwise, <i>plan_body2</i> is executed.</p>
+
+<p>Example:
+<pre>
++event : context
+ <- ....
+ if (vl(X) & X > 10) { // where vl(X) is a belief
+ .print("value > 10")
+ };
+ ....
+</pre>
+The unification is changed by the evaluation of the logical formula, i.e., X might have a value after if.
+</p>
+
+*/
+public class if_then_else extends DefaultInternalAction {
+
+ private static InternalAction singleton = null;
+ public static InternalAction create() {
+ if (singleton == null)
+ singleton = new if_then_else();
+ return singleton;
+ }
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ try {
+ if ( !(args[0] instanceof LogicalFormula))
+ throw new JasonException("The first argument of if must be a logical formula.");
+
+ LogicalFormula logExpr = (LogicalFormula)args[0];
+ PlanBody whattoadd = null;
+
+ Iterator<Unifier> iu = logExpr.logicalConsequence(ts.getAg(), un);
+ if (iu.hasNext()) { // .if THEN
+ if ( !args[1].isPlanBody())
+ throw new JasonException("The second argument of if must be a plan body term.");
+ whattoadd = (PlanBody)args[1];
+ un.compose(iu.next());
+ } else if (args.length == 3) { // .if ELSE
+ if ( !args[2].isPlanBody())
+ throw new JasonException("The third argument of if must be a plan body term.");
+ whattoadd = (PlanBody)args[2];
+ }
+
+ if (whattoadd != null) {
+ IntendedMeans im = ts.getC().getSelectedIntention().peek();
+ PlanBody ifia = im.getCurrentStep();
+ whattoadd.setAsBodyTerm(false);
+ ifia.add(1,whattoadd);
+ }
+ return true;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ throw new JasonException("The 'if' has not received the required arguments.");
+ } catch (JasonException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JasonException("Error in 'if': " + e, e);
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-07-05 09:37:56
|
Revision: 1347
http://jason.svn.sourceforge.net/jason/?rev=1347&view=rev
Author: jomifred
Date: 2008-07-05 02:37:52 -0700 (Sat, 05 Jul 2008)
Log Message:
-----------
test all exampels/demos and fix some minor issues
Modified Paths:
--------------
trunk/demos/function/a.asl
trunk/demos/persistent-belief-base/VoidBB.java
trunk/demos/persistent-belief-base/bookstore.properties
trunk/examples/gold-miners-II/arch/MinerArch.java
trunk/src/jason/asSemantics/SuspendInternalAction.java
trunk/src/jason/infra/centralised/CentralisedAgArch.java
trunk/src/jason/jeditplugin/JasonID.java
trunk/src/jason/mas2j/MAS2JProject.java
trunk/src/jeditPlugin/Jason.props
trunk/src/jeditPlugin/actions.xml
Modified: trunk/demos/function/a.asl
===================================================================
--- trunk/demos/function/a.asl 2008-07-02 10:13:59 UTC (rev 1346)
+++ trunk/demos/function/a.asl 2008-07-05 09:37:52 UTC (rev 1347)
@@ -32,7 +32,7 @@
/* Initial goals */
-//!show_predef_funtion.
+!show_predef_funtion.
!show_userdef_funtion.
/* Plans */
Modified: trunk/demos/persistent-belief-base/VoidBB.java
===================================================================
--- trunk/demos/persistent-belief-base/VoidBB.java 2008-07-02 10:13:59 UTC (rev 1346)
+++ trunk/demos/persistent-belief-base/VoidBB.java 2008-07-05 09:37:52 UTC (rev 1347)
@@ -43,6 +43,7 @@
return new ArrayList<Literal>().iterator();
}
+ @Deprecated
public Iterator<Literal> getAll() {
return iterator();
}
@@ -59,6 +60,7 @@
return new ArrayList<Literal>().iterator();
}
+ @Deprecated
public Iterator<Literal> getRelevant(Literal l) {
return new ArrayList<Literal>().iterator();
}
Modified: trunk/demos/persistent-belief-base/bookstore.properties
===================================================================
--- trunk/demos/persistent-belief-base/bookstore.properties 2008-07-02 10:13:59 UTC (rev 1346)
+++ trunk/demos/persistent-belief-base/bookstore.properties 2008-07-05 09:37:52 UTC (rev 1347)
@@ -1,5 +1,5 @@
#HSQL Database Engine
-#Tue Jan 08 10:15:50 CET 2008
+#Sat Jul 05 11:30:42 CEST 2008
hsqldb.script_format=0
runtime.gc_interval=0
sql.enforce_strict_size=false
Modified: trunk/examples/gold-miners-II/arch/MinerArch.java
===================================================================
--- trunk/examples/gold-miners-II/arch/MinerArch.java 2008-07-02 10:13:59 UTC (rev 1346)
+++ trunk/examples/gold-miners-II/arch/MinerArch.java 2008-07-05 09:37:52 UTC (rev 1347)
@@ -4,7 +4,6 @@
import jason.RevisionFailedException;
import jason.architecture.AgArch;
import jason.asSemantics.Message;
-import jason.asSyntax.Atom;
import jason.asSyntax.Literal;
import jason.asSyntax.NumberTerm;
import jason.asSyntax.PredicateIndicator;
Modified: trunk/src/jason/asSemantics/SuspendInternalAction.java
===================================================================
--- trunk/src/jason/asSemantics/SuspendInternalAction.java 2008-07-02 10:13:59 UTC (rev 1346)
+++ trunk/src/jason/asSemantics/SuspendInternalAction.java 2008-07-05 09:37:52 UTC (rev 1347)
@@ -3,6 +3,7 @@
import jason.asSyntax.InternalActionLiteral;
import jason.asSyntax.PlanBody;
import jason.asSyntax.PlanBodyImpl;
+import jason.asSyntax.Term;
import jason.asSyntax.PlanBody.BodyType;
import java.util.concurrent.TimeUnit;
@@ -31,6 +32,10 @@
return true;
}
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ return false;
+ }
+
/**
* Suspend the current intention, put it in the PendingIntention (PI) structure and assigns it to a key.
*
Modified: trunk/src/jason/infra/centralised/CentralisedAgArch.java
===================================================================
--- trunk/src/jason/infra/centralised/CentralisedAgArch.java 2008-07-02 10:13:59 UTC (rev 1346)
+++ trunk/src/jason/infra/centralised/CentralisedAgArch.java 2008-07-05 09:37:52 UTC (rev 1347)
@@ -233,6 +233,8 @@
// this is used by the .send internal action in stdlib
public void sendMsg(Message m) throws ReceiverNotFoundException {
// actually send the message
+ if (m.getSender() == null) m.setSender(getAgName());
+
CentralisedAgArch rec = masRunner.getAg(m.getReceiver());
if (rec == null) {
Modified: trunk/src/jason/jeditplugin/JasonID.java
===================================================================
--- trunk/src/jason/jeditplugin/JasonID.java 2008-07-02 10:13:59 UTC (rev 1346)
+++ trunk/src/jason/jeditplugin/JasonID.java 2008-07-05 09:37:52 UTC (rev 1347)
@@ -627,8 +627,8 @@
ex.printStackTrace();
}
}
-
- public void createJar() {
+
+ public void runAntTask(String task) {
final Buffer b = getProjectBuffer();
if (b == null) {
textArea.setText("There is no Jason project opened!");
@@ -636,28 +636,12 @@
}
MAS2JProject project = parseProject(b);
if (project == null) // || !parseProjectAS(project)) {
- return;
- CentralisedMASLauncherAnt script = new CentralisedMASLauncherAnt("jar");
- script.setProject(project);
- if (script.writeScripts(false)) {
- new Thread(script, "Ant-Task").start();
- }
- }
-
- public void createJnlp() {
- final Buffer b = getProjectBuffer();
- if (b == null) {
- textArea.setText("There is no Jason project opened!");
return;
- }
- MAS2JProject project = parseProject(b);
- if (project == null) // || !parseProjectAS(project)) {
- return;
- CentralisedMASLauncherAnt script = new CentralisedMASLauncherAnt("jnlp");
+ CentralisedMASLauncherAnt script = new CentralisedMASLauncherAnt(task);
script.setProject(project);
if (script.writeScripts(false)) {
new Thread(script, "Ant-Task").start();
}
- }
-
+
+ }
}
Modified: trunk/src/jason/mas2j/MAS2JProject.java
===================================================================
--- trunk/src/jason/mas2j/MAS2JProject.java 2008-07-02 10:13:59 UTC (rev 1346)
+++ trunk/src/jason/mas2j/MAS2JProject.java 2008-07-05 09:37:52 UTC (rev 1347)
@@ -198,7 +198,7 @@
r.add(getDirectory());
}
for (String p: sourcepaths) {
- if (isDefaultDirectory()) {
+ if (getDirectory().startsWith(".") || getDirectory().startsWith("/") || getDirectory().charAt(1) == ':') {
r.add(p);
} else {
r.add(getDirectory()+File.separator+p);
Modified: trunk/src/jeditPlugin/Jason.props
===================================================================
--- trunk/src/jeditPlugin/Jason.props 2008-07-02 10:13:59 UTC (rev 1346)
+++ trunk/src/jeditPlugin/Jason.props 2008-07-05 09:37:52 UTC (rev 1347)
@@ -14,7 +14,7 @@
# application menu items
plugin.jason.jeditplugin.JasonIDPlugin.menu=jason - \
- jason.run-project jason.debug-project jason.stop-mas \
+ jason.run-project jason.debug-project jason.stop-mas jason.clean-project \
- \
jason.new-project \
jason.new-ag \
@@ -36,6 +36,7 @@
jason.new-ag.label=New Agent
jason.create-env.label=Create project environment
jason.new-ia.label=New internal action
+jason.clean-project.label=Clean Project
jason.edit-log.label=Edit log parameters
jason.asl2html.label=ASL to HTML
jason.asl2tex.label=ASL to LaTeX
Modified: trunk/src/jeditPlugin/actions.xml
===================================================================
--- trunk/src/jeditPlugin/actions.xml 2008-07-02 10:13:59 UTC (rev 1346)
+++ trunk/src/jeditPlugin/actions.xml 2008-07-05 09:37:52 UTC (rev 1347)
@@ -27,6 +27,12 @@
wm.getDockable(jason.jeditplugin.JasonIDPlugin.NAME).newProject();
</CODE>
</ACTION>
+ <ACTION NAME="jason.clean-project">
+ <CODE>
+ wm.addDockableWindow(jason.jeditplugin.JasonIDPlugin.NAME);
+ wm.getDockable(jason.jeditplugin.JasonIDPlugin.NAME).runAntTask("clean");
+ </CODE>
+ </ACTION>
<ACTION NAME="jason.new-ag">
<CODE>
wm.addDockableWindow(jason.jeditplugin.JasonIDPlugin.NAME);
@@ -66,13 +72,13 @@
<ACTION NAME="jason.create-jar">
<CODE>
wm.addDockableWindow(jason.jeditplugin.JasonIDPlugin.NAME);
- wm.getDockable(jason.jeditplugin.JasonIDPlugin.NAME).createJar();
+ wm.getDockable(jason.jeditplugin.JasonIDPlugin.NAME).runAntTask("jar");
</CODE>
</ACTION>
<ACTION NAME="jason.create-jnlp">
<CODE>
wm.addDockableWindow(jason.jeditplugin.JasonIDPlugin.NAME);
- wm.getDockable(jason.jeditplugin.JasonIDPlugin.NAME).createJnlp();
+ wm.getDockable(jason.jeditplugin.JasonIDPlugin.NAME).runAntTask("jnlp");
</CODE>
</ACTION>
</ACTIONS>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-07-02 10:14:00
|
Revision: 1346
http://jason.svn.sourceforge.net/jason/?rev=1346&view=rev
Author: jomifred
Date: 2008-07-02 03:13:59 -0700 (Wed, 02 Jul 2008)
Log Message:
-----------
set sender of messages in .send and .broadcast
Modified Paths:
--------------
trunk/src/jason/asSemantics/Message.java
trunk/src/jason/infra/centralised/CentralisedAgArch.java
trunk/src/jason/stdlib/broadcast.java
trunk/src/jason/stdlib/send.java
Modified: trunk/src/jason/asSemantics/Message.java
===================================================================
--- trunk/src/jason/asSemantics/Message.java 2008-06-26 15:02:50 UTC (rev 1345)
+++ trunk/src/jason/asSemantics/Message.java 2008-07-02 10:13:59 UTC (rev 1346)
@@ -119,9 +119,12 @@
this.inReplyTo = inReplyTo;
}
- public Object clone() {
+ public Message copy() {
return new Message(this);
}
+ public Object clone() {
+ return new Message(this);
+ }
public String toString() {
String irt = (inReplyTo == null ? "" : "->"+inReplyTo);
Modified: trunk/src/jason/infra/centralised/CentralisedAgArch.java
===================================================================
--- trunk/src/jason/infra/centralised/CentralisedAgArch.java 2008-06-26 15:02:50 UTC (rev 1345)
+++ trunk/src/jason/infra/centralised/CentralisedAgArch.java 2008-07-02 10:13:59 UTC (rev 1346)
@@ -233,7 +233,6 @@
// this is used by the .send internal action in stdlib
public void sendMsg(Message m) throws ReceiverNotFoundException {
// actually send the message
- m.setSender(getAgName());
CentralisedAgArch rec = masRunner.getAg(m.getReceiver());
if (rec == null) {
@@ -242,14 +241,12 @@
else
return;
}
- rec.receiveMsg(new Message(m)); // send a cloned message
+ rec.receiveMsg(m.copy()); // send a cloned message
// notify listeners
- if (msgListeners != null) {
- for (MsgListener l: msgListeners) {
+ if (msgListeners != null)
+ for (MsgListener l: msgListeners)
l.msgSent(m);
- }
- }
}
public void receiveMsg(Message m) {
Modified: trunk/src/jason/stdlib/broadcast.java
===================================================================
--- trunk/src/jason/stdlib/broadcast.java 2008-06-26 15:02:50 UTC (rev 1345)
+++ trunk/src/jason/stdlib/broadcast.java 2008-07-02 10:13:59 UTC (rev 1346)
@@ -77,7 +77,7 @@
} catch (ArrayIndexOutOfBoundsException e) {
throw new JasonException("The internal action 'broadcast' has not received two arguments.");
}
- Message m = new Message(ilf.toString(), null, null, pcnt);
+ Message m = new Message(ilf.toString(), ts.getUserAgArch().getAgName(), null, pcnt);
try {
ts.getUserAgArch().broadcast(m);
Modified: trunk/src/jason/stdlib/send.java
===================================================================
--- trunk/src/jason/stdlib/send.java 2008-06-26 15:02:50 UTC (rev 1345)
+++ trunk/src/jason/stdlib/send.java 2008-07-02 10:13:59 UTC (rev 1346)
@@ -148,7 +148,7 @@
} catch (ArrayIndexOutOfBoundsException e) {
throw new JasonException("The internal action 'send' to '"+to+"' has not received three arguments.");
}
- Message m = new Message(ilf.toString(), null, null, pcnt);
+ Message m = new Message(ilf.toString(), ts.getUserAgArch().getAgName(), null, pcnt);
// async ask has a fourth argument and should suspend the intention
lastSendWasSynAsk = m.isAsk() && args.length > 3;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-06-26 15:02:53
|
Revision: 1345
http://jason.svn.sourceforge.net/jason/?rev=1345&view=rev
Author: jomifred
Date: 2008-06-26 08:02:50 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
add a new setupLogger in RunCentMAS
Modified Paths:
--------------
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSyntax/UnnamedVar.java
trunk/src/jason/functions/Random.java
trunk/src/jason/infra/centralised/RunCentralisedMAS.java
trunk/src/jason/stdlib/nth.java
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-06-24 16:19:11 UTC (rev 1344)
+++ trunk/src/jason/asSemantics/Agent.java 2008-06-26 15:02:50 UTC (rev 1345)
@@ -146,15 +146,22 @@
}
}
}
-
- // kqml Plans at the end of the ag PS
- setASLSrc("kqmlPlans.asl");
- parseAS(JasonException.class.getResource("/asl/kqmlPlans.asl"));
- setASLSrc(asSrc);
+
if (parsingOk) {
addInitialBelsInBB();
addInitialGoalsInTS();
}
+
+ // kqml Plans at the end of the ag PS
+ if (JasonException.class.getResource("/asl/kqmlPlans.asl") != null) {
+ setASLSrc("kqmlPlans.asl");
+ parseAS(JasonException.class.getResource("/asl/kqmlPlans.asl"));
+ setASLSrc(asSrc);
+ } else {
+ logger.warning("The kqmlPlans.asl was not found!");
+ }
+
+
return ts;
} catch (Exception e) {
logger.log(Level.SEVERE, "Error creating the agent class!", e);
Modified: trunk/src/jason/asSyntax/UnnamedVar.java
===================================================================
--- trunk/src/jason/asSyntax/UnnamedVar.java 2008-06-24 16:19:11 UTC (rev 1344)
+++ trunk/src/jason/asSyntax/UnnamedVar.java 2008-06-26 15:02:50 UTC (rev 1345)
@@ -42,7 +42,7 @@
public UnnamedVar(String name) {
super( name.length() == 1 ? "_" + (varCont++) : name);
- myId = varCont;
+ myId = varCont++;
}
public UnnamedVar(int id) {
Modified: trunk/src/jason/functions/Random.java
===================================================================
--- trunk/src/jason/functions/Random.java 2008-06-24 16:19:11 UTC (rev 1344)
+++ trunk/src/jason/functions/Random.java 2008-06-26 15:02:50 UTC (rev 1345)
@@ -12,7 +12,7 @@
<p>Examples:<ul>
<li> <code>math.random</code>: returns the random number between 0 and 1.</li>
- <li> <code>math.random(10)</code>: returns the random number between 0 and 10.</li>
+ <li> <code>math.random(10)</code>: returns the random number between 0 and 9.9999.</li>
</ul>
@author Jomi
Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java
===================================================================
--- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2008-06-24 16:19:11 UTC (rev 1344)
+++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2008-06-26 15:02:50 UTC (rev 1345)
@@ -52,6 +52,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
@@ -212,10 +213,22 @@
LogManager.getLogManager().readConfiguration(RunCentralisedMAS.class.getResource("/templates/" + logPropFile).openStream());
} catch (Exception e) {
System.err.println("Error setting up logger:" + e);
+ e.printStackTrace();
}
}
}
}
+
+ public static void setupDefaultConsoleLogger() {
+ Handler[] hs = Logger.getLogger("").getHandlers();
+ for (int i = 0; i < hs.length; i++) {
+ Logger.getLogger("").removeHandler(hs[i]);
+ }
+ Handler h = new ConsoleHandler();
+ h.setFormatter(new MASConsoleLogFormatter());
+ Logger.getLogger("").addHandler(h);
+ Logger.getLogger("").setLevel(Level.INFO);
+ }
protected void createButtons() {
createStopButton();
Modified: trunk/src/jason/stdlib/nth.java
===================================================================
--- trunk/src/jason/stdlib/nth.java 2008-06-24 16:19:11 UTC (rev 1344)
+++ trunk/src/jason/stdlib/nth.java 2008-06-26 15:02:50 UTC (rev 1345)
@@ -51,12 +51,12 @@
public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
try {
if (!args[0].isNumeric()) {
- throw new JasonException("nth: the first argument should be numeric!");
+ throw new JasonException("nth: the first argument should be numeric and not '"+args[0]+"'.");
}
int index = (int)((NumberTerm)args[0]).solve();
if (!args[1].isList()) {
- throw new JasonException("nth: the second argument should be a list!");
+ throw new JasonException("nth: the second argument should be a list and not '"+args[1]+"'.");
}
ListTerm list = (ListTerm)args[1];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-06-24 16:19:18
|
Revision: 1344
http://jason.svn.sourceforge.net/jason/?rev=1344&view=rev
Author: jomifred
Date: 2008-06-24 09:19:11 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
add order in the unnamed vars based on their ids.
Modified Paths:
--------------
trunk/release-notes.txt
trunk/src/jason/asSyntax/UnnamedVar.java
trunk/src/test/VarTermTest.java
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-06-24 15:20:36 UTC (rev 1343)
+++ trunk/release-notes.txt 2008-06-24 16:19:11 UTC (rev 1344)
@@ -65,6 +65,7 @@
when annotations are used
. print works like println
. =.. with atoms
+. unbound vars as arguments for rules (as identified by Stephen Cranefield)
-------------
Modified: trunk/src/jason/asSyntax/UnnamedVar.java
===================================================================
--- trunk/src/jason/asSyntax/UnnamedVar.java 2008-06-24 15:20:36 UTC (rev 1343)
+++ trunk/src/jason/asSyntax/UnnamedVar.java 2008-06-24 16:19:11 UTC (rev 1344)
@@ -33,17 +33,21 @@
private static final long serialVersionUID = 1L;
private static int varCont = 1;
-
+ private int myId;
+
public UnnamedVar() {
- super(createNewName());
+ super("_" + (varCont++));
+ myId = varCont;
}
public UnnamedVar(String name) {
super( name.length() == 1 ? "_" + (varCont++) : name);
+ myId = varCont;
}
-
- public static String createNewName() {
- return "_" + (varCont++);
+
+ public UnnamedVar(int id) {
+ super("_" + id);
+ myId = id;
}
public Object clone() {
@@ -51,11 +55,27 @@
return getValue().clone();
} else {
UnnamedVar newv = new UnnamedVar(getFunctor());
+ newv.myId = this.myId;
if (hasAnnot())
newv.addAnnots((ListTerm)this.getAnnots().clone());
return newv;
}
}
+
+ public int compareTo(Term t) {
+ if (hasValue()) {
+ return super.compareTo(t);
+ } else if (t instanceof UnnamedVar) {
+ if (myId > ((UnnamedVar)t).myId)
+ return 1;
+ else if (myId < ((UnnamedVar)t).myId)
+ return -1;
+ else
+ return 0;
+ } else {
+ return super.compareTo(t);
+ }
+ }
@Override
public boolean isUnnamedVar() {
Modified: trunk/src/test/VarTermTest.java
===================================================================
--- trunk/src/test/VarTermTest.java 2008-06-24 15:20:36 UTC (rev 1343)
+++ trunk/src/test/VarTermTest.java 2008-06-24 16:19:11 UTC (rev 1344)
@@ -15,6 +15,7 @@
import jason.asSyntax.Pred;
import jason.asSyntax.Structure;
import jason.asSyntax.Term;
+import jason.asSyntax.UnnamedVar;
import jason.asSyntax.VarTerm;
import jason.asSyntax.ArithExpr.ArithmeticOp;
import jason.asSyntax.parser.SimpleCharStream;
@@ -23,8 +24,11 @@
import jason.infra.centralised.CentralisedAgArch;
import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
@@ -484,5 +488,16 @@
x.apply(u);
assertEquals(x.toString(), "10");
- }
+ }
+
+ public void testUnnamedvarsorder() {
+ // the order is important for the "return" of plans/rules (where makeVarAnnon is used)
+ // the most recently created unnamed vars should come first
+ List<UnnamedVar> l = new ArrayList<UnnamedVar>();
+ l.add(new UnnamedVar(5));
+ l.add(new UnnamedVar(6));
+ l.add(new UnnamedVar(11));
+ Collections.sort(l);
+ assertEquals("[_5, _6, _11]", l.toString());
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-06-24 15:44:49
|
Revision: 1343
http://jason.svn.sourceforge.net/jason/?rev=1343&view=rev
Author: jomifred
Date: 2008-06-24 08:20:36 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
fix the bug with return variables in "call" rules/plans
Modified Paths:
--------------
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSemantics/VarsCluster.java
trunk/src/jason/asSyntax/Atom.java
trunk/src/jason/asSyntax/DefaultTerm.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/Pred.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/asSyntax/Term.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/test/VarTermTest.java
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2008-06-24 13:15:06 UTC (rev 1342)
+++ trunk/src/jason/asSemantics/Agent.java 2008-06-24 15:20:36 UTC (rev 1343)
@@ -360,7 +360,7 @@
public void addInitialGoalsInTS() {
for (Literal g: initialGoals) {
- g.makeVarsAnnon();
+ g.makeVarsAnnon(null);
if (! g.hasSource())
g.addAnnot(BeliefBase.TSelf);
getTS().getC().addAchvGoal(g,Intention.EmptyInt);
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-06-24 13:15:06 UTC (rev 1342)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-06-24 15:20:36 UTC (rev 1343)
@@ -467,7 +467,7 @@
}
// free variables in an event cannot conflict with those in the plan
body = (Literal)body.clone();
- body.makeVarsAnnon();
+ body.makeVarsAnnon(null);
conf.C.addAchvGoal(body, conf.C.SI);
confP.step = State.StartRC;
break;
@@ -658,7 +658,7 @@
// they are anonymous)
Literal tel = topIM.getPlan().getTrigger().getLiteral();
tel.apply(topIM.unif);
- tel.makeVarsAnnon();
+ tel.makeVarsAnnon(topIM.unif);
im.unif.unifies(tel, g);
}
}
Modified: trunk/src/jason/asSemantics/VarsCluster.java
===================================================================
--- trunk/src/jason/asSemantics/VarsCluster.java 2008-06-24 13:15:06 UTC (rev 1342)
+++ trunk/src/jason/asSemantics/VarsCluster.java 2008-06-24 15:20:36 UTC (rev 1343)
@@ -30,6 +30,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import java.util.TreeSet;
import java.util.logging.Logger;
import org.w3c.dom.Document;
@@ -79,7 +80,7 @@
if (vl == null) {
// v1 has no value
if (vars == null) {
- vars = new HashSet<VarTerm>();
+ vars = new TreeSet<VarTerm>();
}
vars.add(vt);
} else if (vl instanceof VarsCluster) {
Modified: trunk/src/jason/asSyntax/Atom.java
===================================================================
--- trunk/src/jason/asSyntax/Atom.java 2008-06-24 13:15:06 UTC (rev 1342)
+++ trunk/src/jason/asSyntax/Atom.java 2008-06-24 15:20:36 UTC (rev 1343)
@@ -155,6 +155,7 @@
@Override public void makeTermsAnnon() { }
@Override public void makeVarsAnnon() { }
+ @Override public void makeVarsAnnon(Unifier un) { }
@Override
protected int calcHashCode() {
Modified: trunk/src/jason/asSyntax/DefaultTerm.java
===================================================================
--- trunk/src/jason/asSyntax/DefaultTerm.java 2008-06-24 13:15:06 UTC (rev 1342)
+++ trunk/src/jason/asSyntax/DefaultTerm.java 2008-06-24 15:20:36 UTC (rev 1343)
@@ -53,6 +53,7 @@
}
public boolean isVar() { return false; }
+ public boolean isUnnamedVar() { return false; }
public boolean isLiteral() { return false; }
public boolean isRule() { return false; }
public boolean isList() { return false; }
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-06-24 13:15:06 UTC (rev 1342)
+++ trunk/src/jason/asSyntax/Literal.java 2008-06-24 15:20:36 UTC (rev 1343)
@@ -165,7 +165,7 @@
Unifier ruleUn = ruleIt.next(); // evaluation result
Literal rhead = rule.headClone();
rhead.apply(ruleUn);
- rhead.makeVarsAnnon();
+ rhead.makeVarsAnnon(ruleUn);
Unifier unC = un.copy();
if (unC.unifiesNoUndo(Literal.this, rhead)) {
@@ -187,7 +187,7 @@
if (cloneAnnon == null) {
cloneAnnon = (Literal)Literal.this.clone();
cloneAnnon.apply(un);
- cloneAnnon.makeVarsAnnon();
+ cloneAnnon.makeVarsAnnon(null);
}
Unifier ruleUn = new Unifier();
if (ruleUn.unifiesNoUndo(cloneAnnon, rule)) { // the rule head unifies with the literal
Modified: trunk/src/jason/asSyntax/Pred.java
===================================================================
--- trunk/src/jason/asSyntax/Pred.java 2008-06-24 13:15:06 UTC (rev 1342)
+++ trunk/src/jason/asSyntax/Pred.java 2008-06-24 15:20:36 UTC (rev 1343)
@@ -417,7 +417,7 @@
* @param changes is the map of replacements
*/
@Override
- protected void makeVarsAnnon(Map<VarTerm,UnnamedVar> changes) {
+ protected void makeVarsAnnon(Unifier un, Map<VarTerm,UnnamedVar> changes) {
if (annots != null) {
Iterator<ListTerm> i = annots.listTermIterator();
while (i.hasNext()) {
@@ -427,16 +427,17 @@
// replace ta to an unnamed var
UnnamedVar uv = changes.get(ta);
if (uv == null) {
- uv = new UnnamedVar();
+ VarTerm vt = (VarTerm)ta;
+ uv = vt.preferredUnnamedVar(un);
changes.put((VarTerm)ta, uv);
}
lt.setTerm(uv);
} else if (ta.isStructure()) {
- ((Structure)ta).makeVarsAnnon(changes);
+ ((Structure)ta).makeVarsAnnon(un,changes);
}
}
}
- super.makeVarsAnnon(changes);
+ super.makeVarsAnnon(un, changes);
}
@Override
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-06-24 13:15:06 UTC (rev 1342)
+++ trunk/src/jason/asSyntax/Structure.java 2008-06-24 15:20:36 UTC (rev 1343)
@@ -310,15 +310,17 @@
/** Replaces all variables of the term for unnamed variables (_). */
public void makeVarsAnnon() {
- makeVarsAnnon(new HashMap<VarTerm,UnnamedVar>());
+ makeVarsAnnon(null, new HashMap<VarTerm,UnnamedVar>());
}
- /**
- * Replaces all variables of the term for unnamed variables (_).
- *
- * @param changes is the map of replacements
- */
- protected void makeVarsAnnon(Map<VarTerm,UnnamedVar> changes) {
+ /** Replaces all variables of the term for unnamed variables (_).
+ if un != null, unnamed vars unified to the var are preferred */
+ public void makeVarsAnnon(Unifier un) {
+ makeVarsAnnon(un, new HashMap<VarTerm,UnnamedVar>());
+ }
+
+ /** change all vars by unnamed vars, if un != null, unnamed vars unified to the var are preferred */
+ protected void makeVarsAnnon(Unifier un, Map<VarTerm,UnnamedVar> changes) {
final int size = getArity();
for (int i=0; i<size; i++) {
Term ti = getTerm(i);
@@ -326,14 +328,15 @@
// replace ti to an unnamed var
UnnamedVar uv = changes.get(ti);
if (uv == null) {
- uv = new UnnamedVar();
+ VarTerm vt = (VarTerm)ti;
+ uv = vt.preferredUnnamedVar(un);
changes.put((VarTerm)ti, uv);
}
setTerm(i,uv);
} else if (ti.isStructure()) {
Structure tis = (Structure)ti;
if (tis.hasTerm()) {
- tis.makeVarsAnnon(changes);
+ tis.makeVarsAnnon(un, changes);
}
}
}
Modified: trunk/src/jason/asSyntax/Term.java
===================================================================
--- trunk/src/jason/asSyntax/Term.java 2008-06-24 13:15:06 UTC (rev 1342)
+++ trunk/src/jason/asSyntax/Term.java 2008-06-24 15:20:36 UTC (rev 1343)
@@ -12,6 +12,7 @@
public interface Term extends Cloneable, Comparable<Term>, Serializable, ToDOM {
public boolean isVar();
+ public boolean isUnnamedVar();
public boolean isLiteral();
public boolean isRule();
public boolean isList();
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-06-24 13:15:06 UTC (rev 1342)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-06-24 15:20:36 UTC (rev 1343)
@@ -53,8 +53,6 @@
private Term value = null;
- private String unnamedId = null; // set when transformed in unnamed var
-
public VarTerm(String s) {
super(s);
if (s != null && Character.isLowerCase(s.charAt(0))) {
@@ -81,7 +79,6 @@
// do not call constructor with term parameter!
VarTerm t = new VarTerm(super.getFunctor());
t.setSrc(this);
- t.unnamedId = this.unnamedId;
if (hasAnnot())
t.setAnnots((ListTerm) getAnnots().clone());
return t;
@@ -94,22 +91,9 @@
}
public boolean isUnnamedVar() {
- return unnamedId != null;
+ return false;
}
- /** change the functor of the var to _ */
- public void setUnnamed() {
- unnamedId = UnnamedVar.createNewName();
- }
- public void setUnnamed(String id) {
- unnamedId = id;
- }
-
- /** undo the setUnanamed() */
- public void setNamed() {
- unnamedId = null;
- }
-
@Override
public boolean isGround() {
return value != null && value.isGround();
@@ -161,6 +145,19 @@
return false;
}
+ protected UnnamedVar preferredUnnamedVar(Unifier un) {
+ if (un != null) {
+ // check if I have a var cluster with another unnamed var there
+ // and then prefer that unnamed var instead of a new one
+ Term vl = un.get(this);
+ if (vl != null && vl instanceof VarsCluster)
+ for (VarTerm v: (VarsCluster)vl)
+ if (v.isUnnamedVar())
+ return (UnnamedVar)v;
+ }
+ return new UnnamedVar();
+ }
+
/**
* returns the value of this var.
*/
@@ -208,10 +205,7 @@
@Override
public String getFunctor() {
if (value == null) {
- if (unnamedId != null)
- return unnamedId;
- else
- return super.getFunctor();
+ return super.getFunctor();
} else if (value.isStructure()) {
return ((Structure)getValue()).getFunctor();
} else {
Modified: trunk/src/test/VarTermTest.java
===================================================================
--- trunk/src/test/VarTermTest.java 2008-06-24 13:15:06 UTC (rev 1342)
+++ trunk/src/test/VarTermTest.java 2008-06-24 15:20:36 UTC (rev 1343)
@@ -484,15 +484,5 @@
x.apply(u);
assertEquals(x.toString(), "10");
- }
-
- public void testTransformUnnamed() {
- VarTerm x = new VarTerm("X");
- assertFalse(x.isUnnamedVar());
- x.setUnnamed();
- assertTrue(x.isUnnamedVar());
- assertFalse("X".equals(x.toString()));
- x.setNamed();
- assertTrue("X".equals(x.toString()));
- }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-06-24 13:15:08
|
Revision: 1342
http://jason.svn.sourceforge.net/jason/?rev=1342&view=rev
Author: jomifred
Date: 2008-06-24 06:15:06 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
fix bug in =..
start fixing the bug reported by Sthepen
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/TestAll.java
trunk/release-notes.txt
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSemantics/Unifier.java
trunk/src/jason/asSyntax/Atom.java
trunk/src/jason/asSyntax/ListTermImpl.java
trunk/src/jason/asSyntax/Literal.java
trunk/src/jason/asSyntax/Structure.java
trunk/src/jason/asSyntax/UnnamedVar.java
trunk/src/jason/asSyntax/VarTerm.java
trunk/src/jason/environment/Environment.java
trunk/src/test/VarTermTest.java
Added Paths:
-----------
trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java
Added: trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java (rev 0)
+++ trunk/applications/as-unit-test/src/jason/tests/BugVarsAsArg.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -0,0 +1,39 @@
+package jason.tests;
+
+import jason.asunit.TestAgent;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/** based on bug found by Stephen Cranefield -- see jason list */
+public class BugVarsAsArg {
+
+ TestAgent ag;
+
+ // initialisation of the agent test
+ @Before
+ public void setupAg() {
+ ag = new TestAgent();
+
+ // defines the agent's AgentSpeak code
+ ag.parseAScode(
+ "test_rule(A,a(A)). "+
+ "ml0(L,L). "+
+ "ml(V1,V2,R) :- ml0([V1,V2],R). "+
+ "+!test1 <- ?test_rule(T,A); A = a(V); T=45; jason.asunit.print(V). "+
+ "+!test2 <- ?ml(A,B,L); A=1; B=2; jason.asunit.print(L). "
+ );
+ }
+
+ @Test
+ public void testRule1() {
+ ag.addGoal("test1");
+ ag.assertPrint("45", 5);
+ }
+
+ @Test
+ public void testRule2() {
+ ag.addGoal("test2");
+ ag.assertPrint("[1,2]", 5);
+ }
+}
Modified: trunk/applications/as-unit-test/src/jason/tests/TestAll.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/TestAll.java 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/applications/as-unit-test/src/jason/tests/TestAll.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -8,6 +8,7 @@
@SuiteClasses({
BugListReturnUnification.class,
BugVarsInInitBels.class,
+ BugVarsAsArg.class,
TestAddLogExprInBB.class,
TestGoalSource.class,
TestIF.class,
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/release-notes.txt 2008-06-24 13:15:06 UTC (rev 1342)
@@ -64,6 +64,7 @@
. drop_desire does not remove desires in Circumstance.Event correctly
when annotations are used
. print works like println
+. =.. with atoms
-------------
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -658,6 +658,7 @@
// they are anonymous)
Literal tel = topIM.getPlan().getTrigger().getLiteral();
tel.apply(topIM.unif);
+ tel.makeVarsAnnon();
im.unif.unifies(tel, g);
}
}
Modified: trunk/src/jason/asSemantics/Unifier.java
===================================================================
--- trunk/src/jason/asSemantics/Unifier.java 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/src/jason/asSemantics/Unifier.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -207,9 +207,9 @@
return unifiesNoUndo(t1gv, t2vl);
}
- // both are var (not unnamedvar) with no value, like X=Y
+ // both are var with no value, like X=Y
// we must ensure that these vars will form a cluster
- if (! t1gv.isUnnamedVar() && ! t2gv.isUnnamedVar()) {
+ //if (! t1gv.isUnnamedVar() && ! t2gv.isUnnamedVar()) {
VarTerm t1c = (VarTerm) t1gv.clone();
VarTerm t2c = (VarTerm) t2gv.clone();
VarsCluster cluster = new VarsCluster(t1c, t2c, this);
@@ -219,7 +219,7 @@
function.put(vtc, cluster);
}
}
- }
+ //}
return true;
}
Modified: trunk/src/jason/asSyntax/Atom.java
===================================================================
--- trunk/src/jason/asSyntax/Atom.java 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/src/jason/asSyntax/Atom.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -115,6 +115,11 @@
}
@Override
+ public List<Term> getTerms() {
+ return emptyTermList;
+ }
+
+ @Override
public Term[] getTermsArray() {
return emptyTermArray;
}
Modified: trunk/src/jason/asSyntax/ListTermImpl.java
===================================================================
--- trunk/src/jason/asSyntax/ListTermImpl.java 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/src/jason/asSyntax/ListTermImpl.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -436,6 +436,7 @@
@SuppressWarnings("unchecked")
public boolean addAll(Collection c) {
+ if (c == null) return false;
ListTerm lt = this; // where to add
Iterator i = c.iterator();
while (i.hasNext()) {
Modified: trunk/src/jason/asSyntax/Literal.java
===================================================================
--- trunk/src/jason/asSyntax/Literal.java 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/src/jason/asSyntax/Literal.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -165,6 +165,7 @@
Unifier ruleUn = ruleIt.next(); // evaluation result
Literal rhead = rule.headClone();
rhead.apply(ruleUn);
+ rhead.makeVarsAnnon();
Unifier unC = un.copy();
if (unC.unifiesNoUndo(Literal.this, rhead)) {
Modified: trunk/src/jason/asSyntax/Structure.java
===================================================================
--- trunk/src/jason/asSyntax/Structure.java 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/src/jason/asSyntax/Structure.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -48,7 +48,9 @@
private static final long serialVersionUID = 1L;
private static Logger logger = Logger.getLogger(Structure.class.getName());
- protected static final Term[] emptyTermArray = new Term[0]; // just to have a type for toArray in the getTermsArray method
+
+ protected static final List<Term> emptyTermList = new ArrayList<Term>(0);
+ protected static final Term[] emptyTermArray = new Term[0]; // just to have a type for toArray in the getTermsArray method
private final String functor; // immutable field
Modified: trunk/src/jason/asSyntax/UnnamedVar.java
===================================================================
--- trunk/src/jason/asSyntax/UnnamedVar.java 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/src/jason/asSyntax/UnnamedVar.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -35,12 +35,16 @@
private static int varCont = 1;
public UnnamedVar() {
- super("_" + (varCont++));
+ super(createNewName());
}
public UnnamedVar(String name) {
super( name.length() == 1 ? "_" + (varCont++) : name);
}
+
+ public static String createNewName() {
+ return "_" + (varCont++);
+ }
public Object clone() {
if (hasValue()) {
Modified: trunk/src/jason/asSyntax/VarTerm.java
===================================================================
--- trunk/src/jason/asSyntax/VarTerm.java 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/src/jason/asSyntax/VarTerm.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -53,6 +53,8 @@
private Term value = null;
+ private String unnamedId = null; // set when transformed in unnamed var
+
public VarTerm(String s) {
super(s);
if (s != null && Character.isLowerCase(s.charAt(0))) {
@@ -79,6 +81,7 @@
// do not call constructor with term parameter!
VarTerm t = new VarTerm(super.getFunctor());
t.setSrc(this);
+ t.unnamedId = this.unnamedId;
if (hasAnnot())
t.setAnnots((ListTerm) getAnnots().clone());
return t;
@@ -91,8 +94,21 @@
}
public boolean isUnnamedVar() {
- return false;
+ return unnamedId != null;
}
+
+ /** change the functor of the var to _ */
+ public void setUnnamed() {
+ unnamedId = UnnamedVar.createNewName();
+ }
+ public void setUnnamed(String id) {
+ unnamedId = id;
+ }
+
+ /** undo the setUnanamed() */
+ public void setNamed() {
+ unnamedId = null;
+ }
@Override
public boolean isGround() {
@@ -192,7 +208,10 @@
@Override
public String getFunctor() {
if (value == null) {
- return super.getFunctor();
+ if (unnamedId != null)
+ return unnamedId;
+ else
+ return super.getFunctor();
} else if (value.isStructure()) {
return ((Structure)getValue()).getFunctor();
} else {
Modified: trunk/src/jason/environment/Environment.java
===================================================================
--- trunk/src/jason/environment/Environment.java 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/src/jason/environment/Environment.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -324,6 +324,7 @@
* Execute an action on the environment. This method is probably overridden in the user environment class.
*/
public boolean executeAction(String agName, Structure act) {
+ logger.info("The action "+act+" done by "+agName+" is not implemented in the default environment.");
return true;
}
}
Modified: trunk/src/test/VarTermTest.java
===================================================================
--- trunk/src/test/VarTermTest.java 2008-06-14 20:29:35 UTC (rev 1341)
+++ trunk/src/test/VarTermTest.java 2008-06-24 13:15:06 UTC (rev 1342)
@@ -485,4 +485,14 @@
x.apply(u);
assertEquals(x.toString(), "10");
}
+
+ public void testTransformUnnamed() {
+ VarTerm x = new VarTerm("X");
+ assertFalse(x.isUnnamedVar());
+ x.setUnnamed();
+ assertTrue(x.isUnnamedVar());
+ assertFalse("X".equals(x.toString()));
+ x.setNamed();
+ assertTrue("X".equals(x.toString()));
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-06-14 20:29:40
|
Revision: 1341
http://jason.svn.sourceforge.net/jason/?rev=1341&view=rev
Author: jomifred
Date: 2008-06-14 13:29:35 -0700 (Sat, 14 Jun 2008)
Log Message:
-----------
update faq for new "style" of c-build.xml
Modified Paths:
--------------
trunk/doc/faq/faq.tex
trunk/examples/food-simulation/src/java/FoodEnvironment.java
trunk/release-notes.txt
Modified: trunk/doc/faq/faq.tex
===================================================================
--- trunk/doc/faq/faq.tex 2008-06-13 17:42:44 UTC (rev 1340)
+++ trunk/doc/faq/faq.tex 2008-06-14 20:29:35 UTC (rev 1341)
@@ -304,11 +304,26 @@
Several items can be added as strings separated by ";". This
approach is used in the examples/sniffer.
-\item If a more customised startup is required for your system, rename
- bin/build.xml to bin/c-build.xml and edit the c-build.xml script as
- you want. If a c-build.xml file exists, it is used instead of
- build.xml and no new script is created each time you execute the
- system.
+\item If a more customised startup is required for your system, create
+ a file named bin/c-build.xml with the template below:
+
+\begin{verbatim}
+<project name ="mybuild" basedir="..">
+ <import file="build.xml"/>
+
+ <target name="user-init">
+ <!-- add here all your custom initialisation -->
+ </target>
+
+ <target name="user-end">
+ <!-- add here all your custom termination -->
+ </target>
+
+ <!-- you can also "override" other tasks from build.xml -->
+</project>
+\end{verbatim}
+ If a c-build.xml file exists, it is used to run your application
+ instead of build.xml.
\end{enumerate}
\subsection{Which execution modes are available?}
Modified: trunk/examples/food-simulation/src/java/FoodEnvironment.java
===================================================================
--- trunk/examples/food-simulation/src/java/FoodEnvironment.java 2008-06-13 17:42:44 UTC (rev 1340)
+++ trunk/examples/food-simulation/src/java/FoodEnvironment.java 2008-06-14 20:29:35 UTC (rev 1341)
@@ -56,6 +56,8 @@
id2ag.put(lastUsedId, agName);
return lastUsedId;
}
+
+ // TODO: implement simultaneous attack
@Override
public boolean executeAction(String agName, Structure action) {
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-06-13 17:42:44 UTC (rev 1340)
+++ trunk/release-notes.txt 2008-06-14 20:29:35 UTC (rev 1341)
@@ -60,7 +60,7 @@
presented in http://jasss.soc.surrey.ac.uk/1/3/3.html
Bugs fixed:
-. BUF add annotation "source(percept)" in the perception deletion event
+. BUF doesn't add annotation "source(percept)" in the perception deletion event
. drop_desire does not remove desires in Circumstance.Event correctly
when annotations are used
. print works like println
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-06-13 17:42:52
|
Revision: 1340
http://jason.svn.sourceforge.net/jason/?rev=1340&view=rev
Author: tomklapiscak
Date: 2008-06-13 10:42:44 -0700 (Fri, 13 Jun 2008)
Log Message:
-----------
Contradiction rejection mechanism moved from bb.add to agent.brf
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgent.java
trunk/applications/jasdl-owlapi/src/jasdl/bb/JASDLBeliefBase.java
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgent.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgent.java 2008-06-12 02:15:26 UTC (rev 1339)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgent.java 2008-06-13 17:42:44 UTC (rev 1340)
@@ -128,8 +128,8 @@
@Override
public List<Literal>[] brf(Literal beliefToAdd, Literal beliefToDel, Intention i) throws RevisionFailedException {
- // if experimental feature is disabled or we are only removing (in which case brf need not be applied - OWL-DL is monotonic)
- if (!config.isBeliefRevisionEnabled() || beliefToDel != null) {
+ // if we are only removing brf need not be applied - OWL-DL is monotonic
+ if (beliefToDel != null) {
return super.brf(beliefToAdd, beliefToDel, i);
}
@@ -140,63 +140,72 @@
boolean prevAnnotationGathering = getConfig().isAnnotationGatheringEnabled();
boolean prevContraction = getConfig().isContractionEnabled();
getConfig().setAnnotationGatheringEnabled(false);
- getConfig().setContractionEnabled(false);
+ getConfig().setContractionEnabled(false);
- SELiteral sl;
- OWLAxiom l;
try {
- sl = getSELiteralFactory().construct(beliefToAdd);
- l = getSELiteralToAxiomConverter().create(sl);
List<Literal> addList = new Vector<Literal>();
List<Literal> delList = new Vector<Literal>();
+ SELiteral sl = getSELiteralFactory().construct(beliefToAdd);
+ OWLAxiom l = getSELiteralToAxiomConverter().create(sl);
+
// Add the belief
if (!getBB().add(beliefToAdd)) throw new RevisionFailedException("Addition of "+beliefToAdd+" failed");
addList.add(beliefToAdd);
- getJom().refreshReasoner();
- OWLDescription desc = new IndividualAxiomToDescriptionConverter(jom.getOntologyManager().getOWLDataFactory()).convert(l);
- while(!jom.areOntologiesConsistent()){
-
- getLogger().info("Attemping to accommodate "+beliefToAdd);
-
- BlackBoxExplanation bbgen = new BlackBoxExplanation(OWLManager.createOWLOntologyManager()); // need to use fresh ontology manager to avoid pollution from explanation process
- bbgen.setOntology(sl.getOntology());
- bbgen.setReasoner(jom.getReasoner());
- bbgen.setReasonerFactory(new JASDLReasonerFactory());
-
- Set<OWLAxiom> just = bbgen.getExplanation(desc);
-
- just.add(l); // SEMI-revision: can reject incoming belief
-
- TBoxAxiomKernelsetFilter filter = new TBoxAxiomKernelsetFilter();
- Set<OWLAxiom> filtered = filter.filterSingleKernel(just);
- JASDLIncisionFunction incisor = new JASDLIncisionFunction(this, sl);
- Set<OWLAxiom> incised = incisor.applyToOne(filtered);
-
- getLogger().info("Justification for "+sl+": "+just);
- getLogger().info("... Filtered: "+filtered);
- getLogger().info("... Incised: "+incised);
-
- if(incised.contains(l)){
- // roll back changes
- if (!getBB().remove(beliefToAdd)) throw new RevisionFailedException("Rollback of "+beliefToAdd+" addition failed");
- for(Literal del : delList){
- if (!getBB().add(del)) throw new RevisionFailedException("Rollback of "+del+" removal failed");
- }
+ if(config.isBeliefRevisionEnabled()){
+ //DL BASED SEMI-REVISION
+
+ OWLDescription desc = new IndividualAxiomToDescriptionConverter(jom.getOntologyManager().getOWLDataFactory()).convert(l);
+ while(!jom.areOntologiesConsistent()){
+
+ getLogger().info("Attemping to accommodate "+beliefToAdd);
+
+ BlackBoxExplanation bbgen = new BlackBoxExplanation(OWLManager.createOWLOntologyManager()); // need to use fresh ontology manager to avoid pollution from explanation process
+ bbgen.setOntology(sl.getOntology());
+ bbgen.setReasoner(jom.getReasoner());
+ bbgen.setReasonerFactory(new JASDLReasonerFactory());
+
+ Set<OWLAxiom> just = bbgen.getExplanation(desc);
+
+ just.add(l); // SEMI-revision: can reject incoming belief
+
+ TBoxAxiomKernelsetFilter filter = new TBoxAxiomKernelsetFilter();
+ Set<OWLAxiom> filtered = filter.filterSingleKernel(just);
+ JASDLIncisionFunction incisor = new JASDLIncisionFunction(this, sl);
+ Set<OWLAxiom> incised = incisor.applyToOne(filtered);
+
+ getLogger().fine("Justification for "+sl+": "+just);
+ getLogger().fine("... Filtered: "+filtered);
+ getLogger().fine("... Incised: "+incised);
+
+ if(incised.contains(l)){
+ // roll back changes
+ if (!getBB().remove(beliefToAdd)) throw new RevisionFailedException("Rollback of "+beliefToAdd+" addition failed");
+ for(Literal del : delList){
+ if (!getBB().add(del)) throw new RevisionFailedException("Rollback of "+del+" removal failed");
+ }
+ throw new RevisionFailedException("Rejected new belief "+l);
+ }else{
+ for(OWLAxiom del : incised){
+ SELiteral delsl = getAxiomToSELiteralConverter().convert((OWLIndividualAxiom)del);
+ getLogger().info("... removing "+delsl+" "+del);
+ if (!getBB().remove(delsl.getLiteral())) throw new RevisionFailedException("Removal of "+delsl+" failed");
+ delList.add(delsl.getLiteral());
+ }
+ }
+ }
+
+ }else{
+ // CONTRADICTION REJECTION
+ if (!getJom().areOntologiesConsistent()) {
+ getLogger().info("Contradiction rejection " + beliefToAdd);
+ if (!getBB().remove(beliefToAdd)) throw new RevisionFailedException("Rollback of "+beliefToAdd+" addition failed");
throw new RevisionFailedException("Rejected new belief "+l);
- }else{
- for(OWLAxiom del : incised){
- SELiteral delsl = getAxiomToSELiteralConverter().convert((OWLIndividualAxiom)del);
- getLogger().info("... removing "+delsl+" "+del);
- if (!getBB().remove(delsl.getLiteral())) throw new RevisionFailedException("Removal of "+delsl+" failed");
- delList.add(delsl.getLiteral());
- }
}
-
-
- }
+
+ }
return new List[]{addList,delList};
@@ -204,11 +213,11 @@
return super.brf(beliefToAdd, beliefToDel, i);
} catch (Exception e) {
throw new RevisionFailedException("", e);
- } finally{
- getLogger().info("Finally restoring contraction and annotation gathering status");
+ }finally{
+ getLogger().fine("Restoring contraction and annotation gathering status");
getConfig().setAnnotationGatheringEnabled(prevAnnotationGathering);
getConfig().setContractionEnabled(prevContraction);
- }
+ }
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/JASDLBeliefBase.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JASDLBeliefBase.java 2008-06-12 02:15:26 UTC (rev 1339)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JASDLBeliefBase.java 2008-06-13 17:42:44 UTC (rev 1340)
@@ -96,15 +96,17 @@
}
if (!containsAxiom || !containsAllAnnots) {
- if (!agent.getConfig().isBeliefRevisionEnabled()) { // if brf disabled, resort to legacy consistency maintenance mechanism
- if (!agent.getJom().areOntologiesConsistent()) {
- getLogger().info("legacy consistency assurance: rejected " + axiom);
- RemoveAxiom rem = new RemoveAxiom(ontology, axiom);
- agent.getOntologyManager().applyChange(rem);
- agent.getJom().refreshReasoner();
- return false;
- }
- }
+
+ // 13-06-2008: Moved to brf
+ // if (!agent.getConfig().isBeliefRevisionEnabled()) { // if brf disabled, resort to legacy consistency maintenance mechanism
+ // if (!agent.getJom().areOntologiesConsistent()) {
+ // getLogger().info("legacy consistency assurance: rejected " + axiom);
+ // RemoveAxiom rem = new RemoveAxiom(ontology, axiom);
+ // agent.getOntologyManager().applyChange(rem);
+ // agent.getJom().refreshReasoner();
+ // return false;
+ // }
+ // }
if (l.hasAnnot(TPercept)) {
percepts.add(l);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-06-12 02:15:34
|
Revision: 1339
http://jason.svn.sourceforge.net/jason/?rev=1339&view=rev
Author: tomklapiscak
Date: 2008-06-11 19:15:26 -0700 (Wed, 11 Jun 2008)
Log Message:
-----------
jasdl_tg_cause annotation deprecated in favour of jasdl.ia.get_tg_cause(Trigger, RetainAnnots) internal action.
Tidied up and improved efficiency of DL based semi-revision.
Most specific SE-Plan precedence implemented using JMCA option selection module rather than in plan library. This is configured for commerce case-study using JMCA OWL2MAS extensions.
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/examples/commerce/onts/commerce.owl
trunk/applications/jasdl-owlapi/examples/commerce/onts/society.owl
trunk/applications/jasdl-owlapi/examples/commerce/run.sh
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/pa.asl
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/shop.asl
trunk/applications/jasdl-owlapi/lib/bebops.jar
trunk/applications/jasdl-owlapi/onts/jasdl.owl
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/util/owlapi/IndividualAxiomToDescriptionConverter.java
Added Paths:
-----------
trunk/applications/jasdl-owlapi/src/jasdl/ia/get_tg_cause.java
trunk/applications/jasdl-owlapi/src/jasdl/jmca/
trunk/applications/jasdl-owlapi/src/jasdl/jmca/selection/
trunk/applications/jasdl-owlapi/src/jasdl/jmca/selection/MostSpecificOptionSelectionStrategy.java
Property Changed:
----------------
trunk/applications/jasdl-owlapi/examples/
trunk/applications/jasdl-owlapi/examples/commerce/src/asl/
Property changes on: trunk/applications/jasdl-owlapi/examples
___________________________________________________________________
Name: svn:ignore
- testing
brf_test
commerce (copy)
commerce (another copy)
ica
owls
+ testing
brf_test
commerce (copy)
commerce (another copy)
ica
owls
brf
Modified: trunk/applications/jasdl-owlapi/examples/commerce/onts/commerce.owl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/onts/commerce.owl 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/examples/commerce/onts/commerce.owl 2008-06-12 02:15:26 UTC (rev 1339)
@@ -3,9 +3,9 @@
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
- <!ENTITY owl11 "http://www.w3.org/2006/12/owl11#" >
+ <!ENTITY owl2 "http://www.w3.org/2006/12/owl2#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
- <!ENTITY owl11xml "http://www.w3.org/2006/12/owl11-xml#" >
+ <!ENTITY owl2xml "http://www.w3.org/2006/12/owl2-xml#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY commerce "http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#" >
@@ -14,10 +14,10 @@
<rdf:RDF xmlns="http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#"
xml:base="http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl"
+ xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#"
xmlns:commerce="http://www.dur.ac.uk/t.g.klapiscak/onts/commerce.owl#"
- xmlns:owl11="http://www.w3.org/2006/12/owl11#"
- xmlns:owl11xml="http://www.w3.org/2006/12/owl11-xml#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
+ xmlns:owl2="http://www.w3.org/2006/12/owl2#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#">
@@ -160,6 +160,9 @@
<owl:Class rdf:about="#Beef">
<rdfs:subClassOf rdf:resource="#MeatProduct"/>
+ <owl:disjointWith rdf:resource="#Chicken"/>
+ <owl:disjointWith rdf:resource="#Fish"/>
+ <owl:disjointWith rdf:resource="#Lamb"/>
</owl:Class>
@@ -177,6 +180,7 @@
<owl:Class rdf:about="#Butter">
<rdfs:subClassOf rdf:resource="#Dairy"/>
<owl:disjointWith rdf:resource="#Cream"/>
+ <owl:disjointWith rdf:resource="#Milk"/>
</owl:Class>
@@ -185,7 +189,6 @@
<owl:Class rdf:about="#Chicken">
<rdfs:subClassOf rdf:resource="#MeatProduct"/>
- <owl:disjointWith rdf:resource="#Beef"/>
<owl:disjointWith rdf:resource="#Fish"/>
<owl:disjointWith rdf:resource="#Lamb"/>
</owl:Class>
@@ -196,6 +199,7 @@
<owl:Class rdf:about="#Cream">
<rdfs:subClassOf rdf:resource="#Dairy"/>
+ <owl:disjointWith rdf:resource="#Milk"/>
</owl:Class>
@@ -212,7 +216,6 @@
<owl:Class rdf:about="#Fish">
<rdfs:subClassOf rdf:resource="#MeatProduct"/>
- <owl:disjointWith rdf:resource="#Beef"/>
<owl:disjointWith rdf:resource="#Lamb"/>
</owl:Class>
@@ -222,6 +225,7 @@
<owl:Class rdf:about="#GreenVegetable">
<rdfs:subClassOf rdf:resource="#Vegetable"/>
+ <owl:disjointWith rdf:resource="#RootVegetable"/>
</owl:Class>
@@ -238,7 +242,6 @@
<owl:Class rdf:about="#Lamb">
<rdfs:subClassOf rdf:resource="#MeatProduct"/>
- <owl:disjointWith rdf:resource="#Beef"/>
</owl:Class>
@@ -247,6 +250,7 @@
<owl:Class rdf:about="#MeatProduct">
<rdfs:subClassOf rdf:resource="#Grocery"/>
+ <owl:disjointWith rdf:resource="#Vegetable"/>
</owl:Class>
@@ -255,8 +259,6 @@
<owl:Class rdf:about="#Milk">
<rdfs:subClassOf rdf:resource="#Dairy"/>
- <owl:disjointWith rdf:resource="#Butter"/>
- <owl:disjointWith rdf:resource="#Cream"/>
</owl:Class>
@@ -291,7 +293,6 @@
<owl:Class rdf:about="#RootVegetable">
<rdfs:subClassOf rdf:resource="#Vegetable"/>
- <owl:disjointWith rdf:resource="#GreenVegetable"/>
</owl:Class>
@@ -300,7 +301,6 @@
<owl:Class rdf:about="#Vegetable">
<rdfs:subClassOf rdf:resource="#Grocery"/>
- <owl:disjointWith rdf:resource="#MeatProduct"/>
</owl:Class>
@@ -308,4 +308,23 @@
<!-- http://www.w3.org/2002/07/owl#Thing -->
<owl:Class rdf:about="&owl;Thing"/>
+
+
+
+ <!--
+ ///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // General axioms
+ //
+ ///////////////////////////////////////////////////////////////////////////////////////
+ -->
+
+ <rdf:Description>
+ <rdf:type rdf:resource="&owl2;AllDisjointClasses"/>
+ <owl2:members rdf:parseType="Collection">
+ <rdf:Description rdf:about="#Order"/>
+ <rdf:Description rdf:about="#Product"/>
+ <rdf:Description rdf:about="#Purchase"/>
+ </owl2:members>
+ </rdf:Description>
</rdf:RDF>
Modified: trunk/applications/jasdl-owlapi/examples/commerce/onts/society.owl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/onts/society.owl 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/examples/commerce/onts/society.owl 2008-06-12 02:15:26 UTC (rev 1339)
@@ -9,6 +9,7 @@
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY mas "http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#" >
+ <!ENTITY jmca "http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#" >
<!ENTITY jasdl "http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jasdl.owl#" >
<!ENTITY society "http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/society.owl#" >
]>
@@ -19,6 +20,7 @@
xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#"
xmlns:mas="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#"
xmlns:jasdl="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jasdl.owl#"
+ xmlns:jmca="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:society="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/society.owl#"
xmlns:owl2="http://www.w3.org/2006/12/owl2#"
@@ -60,6 +62,18 @@
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#hasSelectionStrategyClass -->
+
+ <owl:ObjectProperty rdf:about="&jmca;hasSelectionStrategyClass"/>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#hasSelectionStrategyClassEntry -->
+
+ <owl:ObjectProperty rdf:about="&jmca;hasSelectionStrategyClassEntry"/>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#environment -->
<owl:ObjectProperty rdf:about="&mas;environment"/>
@@ -158,6 +172,12 @@
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#hasPosition -->
+
+ <owl:DatatypeProperty rdf:about="&jmca;hasPosition"/>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#agentModelDataProperty -->
<owl:DatatypeProperty rdf:about="&mas;agentModelDataProperty"/>
@@ -225,6 +245,12 @@
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#SelectionStrategyClassEntry -->
+
+ <owl:Class rdf:about="&jmca;SelectionStrategyClassEntry"/>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#Agent -->
<owl:Class rdf:about="&mas;Agent"/>
@@ -362,6 +388,12 @@
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jasdl.owl#MostSpecificOptionSelectionStrategyClass -->
+
+ <rdf:Description rdf:about="&jasdl;MostSpecificOptionSelectionStrategyClass"/>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#Centralised -->
<rdf:Description rdf:about="&mas;Centralised"/>
@@ -377,6 +409,15 @@
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/society.owl#MostSpecificOptionSelectionStrategyClassEntry -->
+
+ <jmca:SelectionStrategyClassEntry rdf:about="#MostSpecificOptionSelectionStrategyClassEntry">
+ <jmca:hasPosition rdf:datatype="&xsd;integer">1</jmca:hasPosition>
+ <jmca:hasSelectionStrategyClass rdf:resource="&jasdl;MostSpecificOptionSelectionStrategyClass"/>
+ </jmca:SelectionStrategyClassEntry>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/society.owl#a_butchers -->
<Butchers rdf:about="#a_butchers">
@@ -387,6 +428,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<employs rdf:resource="#delivery_van_2"/>
<jasdl:hasOntology rdf:resource="#society"/>
@@ -404,6 +446,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<employs rdf:resource="#delivery_van_3"/>
<jasdl:hasOntology rdf:resource="#society"/>
@@ -421,6 +464,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<employs rdf:resource="#delivery_van_1"/>
<employs rdf:resource="#delivery_van_4"/>
@@ -439,6 +483,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<employs rdf:resource="#cazs_pa"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<jasdl:hasOntology rdf:resource="#society"/>
@@ -454,6 +499,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<jasdl:hasOntology rdf:resource="#society"/>
</PA>
@@ -481,6 +527,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<jasdl:hasOntology rdf:resource="#society"/>
</DeliveryVan>
@@ -498,6 +545,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<jasdl:hasOntology rdf:resource="#society"/>
</DeliveryVan>
@@ -515,6 +563,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<jasdl:hasOntology rdf:resource="#society"/>
</DeliveryVan>
@@ -532,6 +581,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<jasdl:hasOntology rdf:resource="#society"/>
</DeliveryVan>
@@ -548,6 +598,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<employs rdf:resource="#jims_pa"/>
<jasdl:hasOntology rdf:resource="#society"/>
@@ -563,6 +614,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<jasdl:hasOntology rdf:resource="#society"/>
</PA>
@@ -624,6 +676,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<jasdl:hasOntology rdf:resource="#society"/>
<employs rdf:resource="#toms_pa"/>
@@ -639,6 +692,7 @@
<mas:hasAgentArchClass rdf:resource="&jasdl;JASDLAgArch"/>
<mas:hasAgentClass rdf:resource="&jasdl;JASDLAgent"/>
<mas:hasBeliefBaseClass rdf:resource="&jasdl;JASDLBeliefBase"/>
+ <jmca:hasSelectionStrategyClassEntry rdf:resource="#MostSpecificOptionSelectionStrategyClassEntry"/>
<jasdl:hasOntology rdf:resource="#commerce"/>
<jasdl:hasOntology rdf:resource="#society"/>
</PA>
Modified: trunk/applications/jasdl-owlapi/examples/commerce/run.sh
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/run.sh 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/examples/commerce/run.sh 2008-06-12 02:15:26 UTC (rev 1339)
@@ -5,7 +5,7 @@
exit 0
fi
-export CLASSPATH=$CLASSPATH:$PWD/../../lib/jasdl.jar
+export CLASSPATH=$CLASSPATH:$PWD/../../lib/jasdl.jar:$PWD/../../../jmca/lib/jmca.jar
bash $OWL2MAS_HOME/owl2mas.sh . soc ./onts/society.owl false $1
Property changes on: trunk/applications/jasdl-owlapi/examples/commerce/src/asl
___________________________________________________________________
Name: svn:ignore
- sho222p.asl
+ sho222p.asl
dalt08examples.asl
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/common/commerce.asl 2008-06-12 02:15:26 UTC (rev 1339)
@@ -46,7 +46,7 @@
purchase(ID)[o(c)]
<-
-hasProductDescription(ID, _)[o(c), source(_)];
- -includedIn(ID, _)[o(c), source(_)];
+ .abolish(includedIn(ID, _)[o(c), source(_)]);
-hasQuantity(ID, _)[o(c), source(_)];
-purchase(ID)[o(c), source(_)];
-hasShop(ID, _)[o(c), source(_)].
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/pa.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/pa.asl 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/pa.asl 2008-06-12 02:15:26 UTC (rev 1339)
@@ -51,8 +51,8 @@
// Ask for all brands that match these criteria
.send(Shop, askOne,
- productInStock(Brand)[o(self), id(ID), stockist(Stockist), jasdl_tg_cause(_)],
- productInStock(Brand)[o(self), id(ID), stockist(Stockist), jasdl_tg_cause(_)]);
+ productInStock(Brand)[o(self), id(ID), stockist(Stockist)],
+ productInStock(Brand)[o(self), id(ID), stockist(Stockist)]);
// ask for the customer's approval
!!approve(ID, Brand, ProductDescription, Shop, Qty, Order, Stockist).
Modified: trunk/applications/jasdl-owlapi/examples/commerce/src/asl/shop.asl
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/src/asl/shop.asl 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/examples/commerce/src/asl/shop.asl 2008-06-12 02:15:26 UTC (rev 1339)
@@ -59,7 +59,7 @@
* of whom it should submit the delivery request to.
*/
@found_product_for_PA
-+?product(Brand)[o(c), id(ID), stockist(Me), jasdl_tg_cause(OriginalQuery)] :
++?product(Brand)[o(c), id(ID), stockist(Me)] : jasdl.ia.get_tg_cause(OriginalQuery, false) &
OriginalQuery // the agent has found a suitable product within its belief base
<-
.print("Recieved request and is able to service it");
@@ -69,13 +69,13 @@
/** TODO: Match other, more specific, types of product and opportunistically present special offers to the PA
* i.e. "buy two get one free on all types of milk" using a plan such as:
*
- * +?milk(Brand)[o(c), id(ID), stockist(Me), jasdl_tg_cause(OriginalQuery)] :
+ * +?milk(Brand)[o(c), id(ID), stockist(Me)] : jasdl.ia.get_tg_cause(OriginalQuery, false) &
* OriginalQuery
* <-
* ...
*/
-+?milk(Brand)[o(c), id(ID), stockist(Me), jasdl_tg_cause(OriginalQuery)] :
++?milk(Brand)[o(c), id(ID), stockist(Me)] : jasdl.ia.get_tg_cause(OriginalQuery, false) &
OriginalQuery // the agent has found a suitable product within its belief base
<-
.print("Recieved request and is able to service it");
@@ -88,7 +88,7 @@
* since their are both more specific than owl:thing (which is the most general concept) - additionally, plan ordering
* is irrelevant here since JASDL automatically assigns precence according to concept specificity for trigger generalisation
*/
-+?thing(Brand)[o(owl), id(ID), stockist(_), jasdl_tg_cause(OriginalQuery)] :
++?thing(Brand)[o(owl), id(ID), stockist(_)] : jasdl.ia.get_tg_cause(OriginalQuery, false) &
not OriginalQuery // the agent has not found a suitable product within its belief base
<-
!reset(ID);
@@ -98,7 +98,7 @@
/**
* Requested a type of product that this agent cannot supply, try asking any other shop.
*/
-+?product(Brand)[o(c), id(ID), stockist(Stockist), jasdl_tg_cause(OriginalQuery)] :
++?product(Brand)[o(c), id(ID), stockist(Stockist)] : jasdl.ia.get_tg_cause(OriginalQuery, false) & .print(OriginalQuery) &
not OriginalQuery & // the agent has not found a suitable product within its belief base
possibleStockist(ID, "s:shop", Try)
<-
@@ -109,7 +109,7 @@
/**
* Requested a type of vegetable product that this agent cannot supply, try asking a greengrocer or a supermarket.
*/
-+?vegetable(Brand)[o(c), id(ID), stockist(Stockist), jasdl_tg_cause(OriginalQuery)] :
++?vegetable(Brand)[o(c), id(ID), stockist(Stockist)] : jasdl.ia.get_tg_cause(OriginalQuery, false) &
not OriginalQuery & // the agent has not found a suitable product within its belief base
possibleStockist(ID, "s:greenGrocers or s:supermarket", Try)
<-
@@ -120,7 +120,7 @@
/**
* Requested a type of meat product that this agent cannot supply, try asking a butchers.
*/
-+?meatProduct(Brand)[o(c), id(ID), stockist(Stockist), jasdl_tg_cause(OriginalQuery)] :
++?meatProduct(Brand)[o(c), id(ID), stockist(Stockist)] : jasdl.ia.get_tg_cause(OriginalQuery, false) &
not OriginalQuery & // the agent has not found a suitable product within its belief base
possibleStockist(ID, "s:butchers", Try)
<-
@@ -137,9 +137,8 @@
.print("Trying ", PossibleStockist);
.add_annot(Query, id(ID), Q1);
.add_annot(Q1, stockist(Stockist), Q2);
- .add_annot(Q2, jasdl_tg_cause(_), Q3);
- .send(PossibleStockist, askOne, Q3, Q3);
- jasdl.ia.get_individual(Q3, Answer).
+ .send(PossibleStockist, askOne, Q2, Q2);
+ jasdl.ia.get_individual(Q2, Answer).
/**
Modified: trunk/applications/jasdl-owlapi/lib/bebops.jar
===================================================================
(Binary files differ)
Modified: trunk/applications/jasdl-owlapi/onts/jasdl.owl
===================================================================
--- trunk/applications/jasdl-owlapi/onts/jasdl.owl 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/onts/jasdl.owl 2008-06-12 02:15:26 UTC (rev 1339)
@@ -9,6 +9,7 @@
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY mas "http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#" >
+ <!ENTITY jmca "http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#" >
<!ENTITY jasdl "http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jasdl.owl#" >
]>
@@ -18,12 +19,14 @@
xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#"
xmlns:mas="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#"
xmlns:jasdl="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jasdl.owl#"
+ xmlns:jmca="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:owl2="http://www.w3.org/2006/12/owl2#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#">
<owl:Ontology rdf:about="">
+ <owl:imports rdf:resource="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl"/>
<owl:imports rdf:resource="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl"/>
</owl:Ontology>
@@ -126,6 +129,12 @@
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#hasAspect -->
+
+ <owl:ObjectProperty rdf:about="&jmca;hasAspect"/>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#userAgentObjectProperty -->
<owl:ObjectProperty rdf:about="&mas;userAgentObjectProperty"/>
@@ -290,6 +299,12 @@
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#SelectionStrategyClass -->
+
+ <owl:Class rdf:about="&jmca;SelectionStrategyClass"/>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#Agent -->
<owl:Class rdf:about="&mas;Agent"/>
@@ -388,10 +403,26 @@
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jasdl.owl#MostSpecificOptionSelectionStrategyClass -->
+
+ <jmca:SelectionStrategyClass rdf:about="#MostSpecificOptionSelectionStrategyClass">
+ <mas:hasClassName rdf:datatype="&xsd;string"
+ >jasdl.jmca.selection.MostSpecificOptionSelectionStrategy</mas:hasClassName>
+ <jmca:hasAspect rdf:resource="&jmca;Option"/>
+ </jmca:SelectionStrategyClass>
+
+
+
<!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jasdl.owl#pellet -->
<ReasonerClass rdf:about="#pellet">
<mas:hasClassName
>org.mindswap.pellet.owlapi.Reasoner</mas:hasClassName>
</ReasonerClass>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#Option -->
+
+ <rdf:Description rdf:about="&jmca;Option"/>
</rdf:RDF>
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgent.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgent.java 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSemantics/JASDLAgent.java 2008-06-12 02:15:26 UTC (rev 1339)
@@ -25,7 +25,6 @@
import jasdl.asSyntax.SEPlan;
import jasdl.bb.JASDLBeliefBase;
import jasdl.bb.bebops.JASDLIncisionFunction;
-import jasdl.bb.bebops.JASDLKernelsetFilter;
import jasdl.bb.bebops.JASDLReasonerFactory;
import jasdl.bridge.JASDLOntologyManager;
import jasdl.bridge.factory.AxiomToSELiteralConverter;
@@ -38,37 +37,34 @@
import jasdl.bridge.seliteral.SELiteral;
import jasdl.util.exception.JASDLException;
import jasdl.util.exception.JASDLNotEnrichedException;
+import jasdl.util.owlapi.IndividualAxiomToDescriptionConverter;
import jason.JasonException;
import jason.RevisionFailedException;
import jason.architecture.AgArch;
import jason.asSemantics.Intention;
import jason.asSemantics.TransitionSystem;
-import jason.asSemantics.Unifier;
import jason.asSyntax.Literal;
import jason.bb.BeliefBase;
import jason.runtime.Settings;
-import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import jmca.asSemantics.JmcaAgent;
-import org.mindswap.pellet.owlapi.Reasoner;
+import org.semanticweb.owl.apibinding.OWLManager;
import org.semanticweb.owl.inference.OWLReasoner;
-import org.semanticweb.owl.model.AddAxiom;
import org.semanticweb.owl.model.OWLAxiom;
import org.semanticweb.owl.model.OWLDataFactory;
import org.semanticweb.owl.model.OWLDescription;
-import org.semanticweb.owl.model.OWLOntology;
+import org.semanticweb.owl.model.OWLIndividualAxiom;
import org.semanticweb.owl.model.OWLOntologyManager;
import org.semanticweb.owl.model.RemoveAxiom;
-import bebops.semirevision.BeliefBaseSemiRevisor;
-import bebops.util.exception.BebopsRevisionFailedException;
+import bebops.common.TBoxAxiomKernelsetFilter;
-import com.clarkparsia.explanation.SatisfiabilityConverter;
+import com.clarkparsia.explanation.BlackBoxExplanation;
/**
* JASDL's extension to JMCA agent (and hence the default Jason agent).
@@ -122,155 +118,102 @@
getLogger().finest(se.getTrigger().toString());
}
- //getTS().getC().addEventListener(new JASDLCircumstanceListener(this));
return ts;
}
+
-
-
-
@Override
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 (!config.isBeliefRevisionEnabled()) { // if experimental feature is disabled
+
+ // if experimental feature is disabled or we are only removing (in which case brf need not be applied - OWL-DL is monotonic)
+ if (!config.isBeliefRevisionEnabled() || beliefToDel != null) {
return super.brf(beliefToAdd, beliefToDel, i);
- }
-
- List<Literal> addList = new Vector<Literal>();
- List<Literal> removeList = new Vector<Literal>();
-
- // NO LONGER APPLICABLE: For efficiency reasons: no need to check beliefs to be contracted if established by BB revisor (since they are implicitly grounded)
-
- // just accept beliefToDel. Assumption: Deletions never lead to inconsistencies?!
- if (beliefToDel != null) {
- getLogger().finest("Revise: -" + beliefToDel);
- removeList.add(beliefToDel);
- } else if (beliefToAdd != null) {
- if (config.isBeliefRevisionEnabled()) {
- try {
- getLogger().fine("Revise: +" + beliefToAdd);
- SELiteral sl = getSELiteralFactory().construct(beliefToAdd);
- if (JASDLParams.USE_BEBOPS_BELIEF_REVISION) {
- applyBebopsBeliefRevision(sl);
- } else {
- applyPelletOnlyBeliefRevision(sl);
- }
- // *** this point is only reached if the addition is accepted ***
- addList.add(beliefToAdd);
- } catch (BebopsRevisionFailedException e) {
- throw new RevisionFailedException("", e);
- } catch (RevisionFailedException e) {
- getLogger().info("brf: rejected " + beliefToAdd);
- throw e; // propagate upwards
- } catch (JASDLNotEnrichedException e) {
- addList.add(beliefToAdd);// can't perform DL-based belief revision on SN-Literals
- } catch (Exception e) {
- throw new RuntimeException("Error encountered during belief revision ", e);
- }
-
- } else {
- addList.add(beliefToAdd); //brf disabled, just accept belief (legacy consistency assurance will be applied later)
- }
- } else {
- throw new RuntimeException("Unexpected behaviour, both beliefToAdd and beliefToDel are non-null...?");
- }
- List<Literal>[] toReturn = null;
-
- for (Literal removed : removeList) {
- // we need to ground unground removals
- Unifier u = null;
+ }
+
+
+ if(beliefToAdd != null){
+
+ // temporarily disable contraction and annotation gathering
+ boolean prevAnnotationGathering = getConfig().isAnnotationGatheringEnabled();
+ boolean prevContraction = getConfig().isContractionEnabled();
+ getConfig().setAnnotationGatheringEnabled(false);
+ getConfig().setContractionEnabled(false);
+
+ SELiteral sl;
+ OWLAxiom l;
try {
- u = i.peek().getUnif(); // get from current intention
- } catch (Exception e) {
- u = new Unifier();
- }
- if (believes(removed, u)) {
- removed.apply(u);
- 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);
- }
- }
- }
-
- // 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;
- }
-
- private void applyPelletOnlyBeliefRevision(SELiteral sl) throws Exception {
- OWLAxiom axiomToAdd = getSELiteralToAxiomConverter().create(sl);
- Reasoner pellet = (org.mindswap.pellet.owlapi.Reasoner) getReasoner();
- getOntologyManager().applyChange(new AddAxiom(sl.getOntology(), axiomToAdd));
- getJom().refreshReasoner();
-
- while (!pellet.isConsistent()) {
- getJom().refreshReasoner();
- SatisfiabilityConverter con = new SatisfiabilityConverter(getOWLDataFactory());
- OWLDescription desc = con.convert(axiomToAdd);
- pellet.getKB().setDoExplanation(true);
- pellet.isSatisfiable(desc);
- Set<OWLAxiom> explanation = pellet.getExplanation();
-
- explanation = new JASDLKernelsetFilter().filterSingleKernel(explanation);
- getLogger().fine("Incremental explanation: " + explanation);
-
- explanation = new JASDLIncisionFunction(this, sl).applyToOne(explanation);
- getLogger().fine("Remove: " + explanation);
-
- if (explanation.equals(Collections.singleton(axiomToAdd))) {
- // Axiom has been rejected,
- getOntologyManager().applyChange(new RemoveAxiom(sl.getOntology(), axiomToAdd));
+ sl = getSELiteralFactory().construct(beliefToAdd);
+ l = getSELiteralToAxiomConverter().create(sl);
+
+ List<Literal> addList = new Vector<Literal>();
+ List<Literal> delList = new Vector<Literal>();
+
+ // Add the belief
+ if (!getBB().add(beliefToAdd)) throw new RevisionFailedException("Addition of "+beliefToAdd+" failed");
+ addList.add(beliefToAdd);
getJom().refreshReasoner();
- throw new RevisionFailedException("" + sl);
- } else {
- for (OWLAxiom revision : explanation) {
- for (OWLOntology ontology : getOntologyManager().getOntologies()) { // across all known ontologies
- getOntologyManager().applyChange(new RemoveAxiom(ontology, revision));
+
+ OWLDescription desc = new IndividualAxiomToDescriptionConverter(jom.getOntologyManager().getOWLDataFactory()).convert(l);
+ while(!jom.areOntologiesConsistent()){
+
+ getLogger().info("Attemping to accommodate "+beliefToAdd);
+
+ BlackBoxExplanation bbgen = new BlackBoxExplanation(OWLManager.createOWLOntologyManager()); // need to use fresh ontology manager to avoid pollution from explanation process
+ bbgen.setOntology(sl.getOntology());
+ bbgen.setReasoner(jom.getReasoner());
+ bbgen.setReasonerFactory(new JASDLReasonerFactory());
+
+ Set<OWLAxiom> just = bbgen.getExplanation(desc);
+
+ just.add(l); // SEMI-revision: can reject incoming belief
+
+ TBoxAxiomKernelsetFilter filter = new TBoxAxiomKernelsetFilter();
+ Set<OWLAxiom> filtered = filter.filterSingleKernel(just);
+ JASDLIncisionFunction incisor = new JASDLIncisionFunction(this, sl);
+ Set<OWLAxiom> incised = incisor.applyToOne(filtered);
+
+ getLogger().info("Justification for "+sl+": "+just);
+ getLogger().info("... Filtered: "+filtered);
+ getLogger().info("... Incised: "+incised);
+
+ if(incised.contains(l)){
+ // roll back changes
+ if (!getBB().remove(beliefToAdd)) throw new RevisionFailedException("Rollback of "+beliefToAdd+" addition failed");
+ for(Literal del : delList){
+ if (!getBB().add(del)) throw new RevisionFailedException("Rollback of "+del+" removal failed");
+ }
+ throw new RevisionFailedException("Rejected new belief "+l);
+ }else{
+ for(OWLAxiom del : incised){
+ SELiteral delsl = getAxiomToSELiteralConverter().convert((OWLIndividualAxiom)del);
+ getLogger().info("... removing "+delsl+" "+del);
+ if (!getBB().remove(delsl.getLiteral())) throw new RevisionFailedException("Removal of "+delsl+" failed");
+ delList.add(delsl.getLiteral());
+ }
}
- }
- getJom().refreshReasoner();
+
+
+ }
+
+ return new List[]{addList,delList};
+
+ } catch (JASDLNotEnrichedException e){
+ return super.brf(beliefToAdd, beliefToDel, i);
+ } catch (Exception e) {
+ throw new RevisionFailedException("", e);
+ } finally{
+ getLogger().info("Finally restoring contraction and annotation gathering status");
+ getConfig().setAnnotationGatheringEnabled(prevAnnotationGathering);
+ getConfig().setContractionEnabled(prevContraction);
}
- }
- /** Will only be reached if addition has been accepted */
- // remove the axiom added only for the purpose of explanation generation
- getOntologyManager().applyChange(new RemoveAxiom(sl.getOntology(), axiomToAdd));
- getJom().refreshReasoner();
- }
+
- private void applyBebopsBeliefRevision(SELiteral sl) throws Exception {
- OWLAxiom axiomToAdd = getSELiteralToAxiomConverter().create(sl);
- BeliefBaseSemiRevisor bbrev = new BeliefBaseSemiRevisor(getOntologyManager(), new JASDLReasonerFactory(), getLogger());
- Set<OWLAxiom> revisions = bbrev.revise(axiomToAdd, new JASDLKernelsetFilter(), new JASDLIncisionFunction(this, sl));
- // *** this point is only reached if the addition is accepted ***
- for (OWLAxiom revision : revisions) {
- for (OWLOntology ontology : getOntologyManager().getOntologies()) { // across all known ontologies
- getOntologyManager().applyChange(new RemoveAxiom(ontology, revision));
- }
}
- getJom().refreshReasoner();
+
+ throw new RuntimeException("Unexpected behaviour, both beliefToAdd and beliefToDel are non-null.");
}
@@ -340,4 +283,59 @@
return config;
}
-}
\ No newline at end of file
+}
+/**
+private void applyPelletOnlyBeliefRevision(SELiteral sl) throws Exception {
+ OWLAxiom axiomToAdd = getSELiteralToAxiomConverter().create(sl);
+ Reasoner pellet = (org.mindswap.pellet.owlapi.Reasoner) getReasoner();
+ getOntologyManager().applyChange(new AddAxiom(sl.getOntology(), axiomToAdd));
+ getJom().refreshReasoner();
+
+ while (!pellet.isConsistent()) {
+ getJom().refreshReasoner();
+ SatisfiabilityConverter con = new SatisfiabilityConverter(getOWLDataFactory());
+ OWLDescription desc = con.convert(axiomToAdd);
+ pellet.getKB().setDoExplanation(true);
+ pellet.isSatisfiable(desc);
+ Set<OWLAxiom> explanation = pellet.getExplanation();
+
+ explanation = new JASDLKernelsetFilter().filterSingleKernel(explanation);
+ getLogger().fine("Incremental explanation: " + explanation);
+
+ explanation = new JASDLIncisionFunction(this, sl).applyToOne(explanation);
+ getLogger().fine("Remove: " + explanation);
+
+ if (explanation.equals(Collections.singleton(axiomToAdd))) {
+ // Axiom has been rejected,
+ getOntologyManager().applyChange(new RemoveAxiom(sl.getOntology(), axiomToAdd));
+ getJom().refreshReasoner();
+ throw new RevisionFailedException("" + sl);
+ } else {
+ for (OWLAxiom revision : explanation) {
+ for (OWLOntology ontology : getOntologyManager().getOntologies()) { // across all known ontologies
+ getOntologyManager().applyChange(new RemoveAxiom(ontology, revision));
+ }
+ }
+ getJom().refreshReasoner();
+ }
+ }
+ // Will only be reached if addition has been accepted
+ // remove the axiom added only for the purpose of explanation generation
+ getOntologyManager().applyChange(new RemoveAxiom(sl.getOntology(), axiomToAdd));
+ getJom().refreshReasoner();
+}
+
+private void applyBebopsBeliefRevision(SELiteral sl) throws Exception {
+ OWLAxiom axiomToAdd = getSELiteralToAxiomConverter().create(sl);
+ BeliefBaseSemiRevisor bbrev = new BeliefBaseSemiRevisor(getOntologyManager(), new JASDLReasonerFactory(), getLogger());
+ Set<OWLAxiom> revisions = bbrev.revise(axiomToAdd, new JASDLKernelsetFilter(), new JASDLIncisionFunction(this, sl));
+ // *** this point is only reached if the addition is accepted ***
+ for (OWLAxiom revision : revisions) {
+ for (OWLOntology ontology : getOntologyManager().getOntologies()) { // across all known ontologies
+ getOntologyManager().applyChange(new RemoveAxiom(ontology, revision));
+ //TODO: Use Jason's standard mechanisms, avoid contraction though!
+ }
+ }
+ getJom().refreshReasoner();
+}
+**/
\ No newline at end of file
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JASDLPlanLibrary.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JASDLPlanLibrary.java 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/JASDLPlanLibrary.java 2008-06-12 02:15:26 UTC (rev 1339)
@@ -67,11 +67,14 @@
if (containsSELiteral(p.getTrigger().getLiteral())) {
SEPlan sePlan = new SEPlan(agent, p);
+ /*
try {
insertSEPlan(sePlan);
} catch (OWLException e) {
throw new JasonException("Error placing SE-Plan "+p, e);
}
+ */
+ sePlans.add(sePlan);
super.add(sePlan);
} else {
@@ -115,7 +118,7 @@
if(candidate instanceof SEPlan){
candidate = (SEPlan)candidate.clone();
SEPlan seCandidate = (SEPlan)candidate;
- if(seCandidate.isRelevant(te) != null){
+ if(seCandidate.isRelevant(te) != null){
candidates.add(candidate);
}
}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/src/jasdl/asSyntax/SEPlan.java 2008-06-12 02:15:26 UTC (rev 1339)
@@ -25,6 +25,7 @@
import jason.asSemantics.Unifier;
import jason.asSyntax.Literal;
import jason.asSyntax.Plan;
+import jason.asSyntax.PlanBody;
import jason.asSyntax.Structure;
import jason.asSyntax.Trigger;
@@ -53,10 +54,8 @@
Unifier un = super.isRelevant(te);
if(un == null){
try {
- if(JASDLCommon.isMoreSpecific(te.getLiteral(), this.getTrigger().getLiteral(), agent.getJom())){
+ if(JASDLCommon.isMoreSpecific(te.getLiteral(), this.getTrigger().getLiteral(), agent.getJom())){
-
-
Literal trigger = te.getLiteral();
Literal oldLiteral = getTrigger().getLiteral();
@@ -77,22 +76,10 @@
newLiteral.delAnnot(oldO);
newLiteral.addAnnot(triggerO);
- getTrigger().setLiteral(newLiteral);
+ getTrigger().setLiteral(newLiteral);
+ un = new Unifier();
- Literal jasdl_tg_cause_annot = (Literal)trigger.getAnnots("jasdl_tg_cause").get(0);
- Literal jasdl_tg_cause = (Literal)te.getLiteral().clone();
-
- // musn't retain annots, except "o"
- jasdl_tg_cause.clearAnnots();
- jasdl_tg_cause.addAnnot(triggerO);
-
- // mutate the term
- jasdl_tg_cause_annot.setTerm(0, jasdl_tg_cause);
-
-
- un = new Unifier();
-
if(un.unifiesNoUndo(getTrigger(), te)){
return un;
}else{
Modified: trunk/applications/jasdl-owlapi/src/jasdl/bb/JASDLBeliefBase.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/bb/JASDLBeliefBase.java 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/src/jasdl/bb/JASDLBeliefBase.java 2008-06-12 02:15:26 UTC (rev 1339)
@@ -29,6 +29,7 @@
import jasdl.util.exception.JASDLNotEnrichedException;
import jason.asSemantics.Agent;
import jason.asSemantics.Unifier;
+import jason.asSyntax.Atom;
import jason.asSyntax.Literal;
import jason.asSyntax.Term;
import jason.bb.BeliefBase;
@@ -70,6 +71,7 @@
@Override
public boolean add(Literal l) {
getLogger().fine("Adding " + l);
+
try {
SELiteral sl = agent.getSELiteralFactory().construct(l);
Added: trunk/applications/jasdl-owlapi/src/jasdl/ia/get_tg_cause.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/ia/get_tg_cause.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/ia/get_tg_cause.java 2008-06-12 02:15:26 UTC (rev 1339)
@@ -0,0 +1,78 @@
+/*
+ * 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.JASDLParams;
+import jason.asSemantics.DefaultInternalAction;
+import jason.asSemantics.IntendedMeans;
+import jason.asSemantics.TransitionSystem;
+import jason.asSemantics.Unifier;
+import jason.asSyntax.Atom;
+import jason.asSyntax.Literal;
+import jason.asSyntax.Structure;
+import jason.asSyntax.Term;
+import jason.asSyntax.Trigger;
+
+import java.util.logging.Logger;
+
+/**
+ * @author Tom Klapiscak
+ *
+ * Note: Retrieving from context and retrieving from plan body MAY result in different annotations on cause
+ *
+ */
+public class get_tg_cause extends DefaultInternalAction {
+
+ private Logger logger = Logger.getLogger("jasdl." + get_tg_cause.class.getName());
+
+ @Override
+ public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
+ try {
+
+ Trigger te;
+ try{
+ IntendedMeans cause = ts.getC().getSelectedIntention().getIMs().peek();
+ te = cause.getPlan().getTrigger(); // Test within plan body, use intended means
+ }catch(NullPointerException noIM){
+ te = ts.getC().getSelectedEvent().getTrigger(); // Test within context, no intended means, use event instead
+ }
+ if(!te.getLiteral().hasSource()){
+ te.getLiteral().addSource(new Atom("self"));
+ }
+ Literal l = (Literal)te.getLiteral().clone();
+
+ // do not retain annotations (except ontology annotation)
+ if(args[1].equals(Literal.LFalse)){
+ for(Term annot : l.getAnnots()){
+ if(!((annot instanceof Structure) && ((Structure)annot).getFunctor().equals(JASDLParams.ONTOLOGY_ANNOTATION_FUNCTOR))){
+ l.delAnnot(annot);
+ }
+ }
+ }
+
+ return un.unifies(args[0], l);
+ } catch (Exception e) {
+ logger.warning("Error in internal action 'jasdl.ia.set_contraction_enabled'! Reason:");
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+}
\ No newline at end of file
Added: trunk/applications/jasdl-owlapi/src/jasdl/jmca/selection/MostSpecificOptionSelectionStrategy.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/jmca/selection/MostSpecificOptionSelectionStrategy.java (rev 0)
+++ trunk/applications/jasdl-owlapi/src/jasdl/jmca/selection/MostSpecificOptionSelectionStrategy.java 2008-06-12 02:15:26 UTC (rev 1339)
@@ -0,0 +1,54 @@
+package jasdl.jmca.selection;
+
+import jasdl.asSemantics.JASDLAgent;
+import jasdl.util.JASDLCommon;
+import jason.asSemantics.Agent;
+import jason.asSemantics.Option;
+
+import java.util.List;
+import java.util.Vector;
+
+import jmca.selection.SelectionStrategy;
+import jmca.util.JmcaException;
+
+public class MostSpecificOptionSelectionStrategy extends SelectionStrategy<Option> {
+
+ private JASDLAgent jasdlMaster;
+
+ public MostSpecificOptionSelectionStrategy(Agent master) {
+ super(master);
+ if(!(master instanceof JASDLAgent)){
+ throw new RuntimeException("Most Specific Option Selection Strategy may only be used in conjunction with a JASDL agent");
+ }
+ this.jasdlMaster = (JASDLAgent)master;
+ }
+
+ /**
+ * Selects the most specific option from the intersection chosen by the selection chain up till now.
+ */
+ @Override
+ public List<Option> select(List<Option> all, List<Option> intersection) throws JmcaException {
+
+ Option mostSpecific = null;
+ for(Option choice : intersection){
+ if(mostSpecific == null){
+ mostSpecific = choice;
+ }else{
+ try {
+ if(JASDLCommon.isMoreSpecific(
+ choice.getPlan().getTrigger().getLiteral(),
+ mostSpecific.getPlan().getTrigger().getLiteral(),
+ jasdlMaster.getJom())) mostSpecific = choice;
+ } catch (Exception e) {
+ throw new JmcaException("Most specific option selection failed", e);
+ }
+ }
+ }
+ List<Option> chosen = new Vector<Option>();
+ if(mostSpecific != null){
+ chosen.add(mostSpecific);
+ }
+ return chosen;
+ }
+
+}
Modified: trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/IndividualAxiomToDescriptionConverter.java
===================================================================
--- trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/IndividualAxiomToDescriptionConverter.java 2008-06-12 02:04:57 UTC (rev 1338)
+++ trunk/applications/jasdl-owlapi/src/jasdl/util/owlapi/IndividualAxiomToDescriptionConverter.java 2008-06-12 02:15:26 UTC (rev 1339)
@@ -75,7 +75,6 @@
* @author Tom Klapiscak
*
*/
-@Deprecated
public class IndividualAxiomToDescriptionConverter implements OWLAxiomVisitor {
private OWLDataFactory factory;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-06-12 02:05:16
|
Revision: 1338
http://jason.svn.sourceforge.net/jason/?rev=1338&view=rev
Author: tomklapiscak
Date: 2008-06-11 19:04:57 -0700 (Wed, 11 Jun 2008)
Log Message:
-----------
Added OWL2MAS configuration ontology extension for JMCA applications.
Selection strategies now passed choices made by previous strategy in composition chain - allows for more cooperative strategies (such as JASDL's new option selection strategy that selects the option with the most specific plan from those chosen by the previous strategy).
Modified Paths:
--------------
trunk/applications/jmca/applications/alpha/src/alpha/selection/AlphaOptionSelectionStrategy.java
trunk/applications/jmca/applications/elbpp/src/elbpp/selection/ElbppOptionSelectionStrategy.java
trunk/applications/jmca/src/jmca/asSemantics/JmcaAgent.java
trunk/applications/jmca/src/jmca/mediation/OverrulingIntersection.java
trunk/applications/jmca/src/jmca/selection/SelectionStrategy.java
trunk/applications/jmca/src/jmca/util/JmcaException.java
Added Paths:
-----------
trunk/applications/jmca/lib/aterm-java-1.6.jar
trunk/applications/jmca/lib/commons-logging-1.1.jar
trunk/applications/jmca/lib/owlapi-bin.jar
trunk/applications/jmca/lib/pellet.jar
trunk/applications/jmca/lib/relaxngDatatype.jar
trunk/applications/jmca/lib/xsdlib.jar
trunk/applications/jmca/onts/
trunk/applications/jmca/onts/jmca.owl
trunk/applications/jmca/src/jmca/owl2mas/
trunk/applications/jmca/src/jmca/owl2mas/handler/
trunk/applications/jmca/src/jmca/owl2mas/handler/SelectionStrategyClassEntryHandler.java
trunk/applications/jmca/src/jmca/util/JMCAParams.java
Modified: trunk/applications/jmca/applications/alpha/src/alpha/selection/AlphaOptionSelectionStrategy.java
===================================================================
--- trunk/applications/jmca/applications/alpha/src/alpha/selection/AlphaOptionSelectionStrategy.java 2008-06-11 21:27:35 UTC (rev 1337)
+++ trunk/applications/jmca/applications/alpha/src/alpha/selection/AlphaOptionSelectionStrategy.java 2008-06-12 02:04:57 UTC (rev 1338)
@@ -47,7 +47,7 @@
super(master);
}
- public List<Option> select(List<Option> options){
+ public List<Option> select(List<Option> options, List<Option> intersection){
Comparator<Option> comp = new Comparator<Option>(){
public int compare(Option a, Option b) {
String af = a.getPlan().getLabel().getFunctor();
Modified: trunk/applications/jmca/applications/elbpp/src/elbpp/selection/ElbppOptionSelectionStrategy.java
===================================================================
--- trunk/applications/jmca/applications/elbpp/src/elbpp/selection/ElbppOptionSelectionStrategy.java 2008-06-11 21:27:35 UTC (rev 1337)
+++ trunk/applications/jmca/applications/elbpp/src/elbpp/selection/ElbppOptionSelectionStrategy.java 2008-06-12 02:04:57 UTC (rev 1338)
@@ -50,7 +50,7 @@
}
- public List<Option> select(List<Option> options){
+ public List<Option> select(List<Option> options, List<Option> intersection){
List<Option> chosen = new Vector<Option>();
// get highest priority in list:
Added: trunk/applications/jmca/lib/aterm-java-1.6.jar
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jmca/lib/aterm-java-1.6.jar
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jmca/lib/commons-logging-1.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jmca/lib/commons-logging-1.1.jar
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jmca/lib/owlapi-bin.jar
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jmca/lib/owlapi-bin.jar
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jmca/lib/pellet.jar
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jmca/lib/pellet.jar
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jmca/lib/relaxngDatatype.jar
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jmca/lib/relaxngDatatype.jar
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jmca/lib/xsdlib.jar
===================================================================
(Binary files differ)
Property changes on: trunk/applications/jmca/lib/xsdlib.jar
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ application/octet-stream
Added: trunk/applications/jmca/onts/jmca.owl
===================================================================
--- trunk/applications/jmca/onts/jmca.owl (rev 0)
+++ trunk/applications/jmca/onts/jmca.owl 2008-06-12 02:04:57 UTC (rev 1338)
@@ -0,0 +1,199 @@
+<?xml version="1.0"?>
+
+
+<!DOCTYPE rdf:RDF [
+ <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
+ <!ENTITY owl2 "http://www.w3.org/2006/12/owl2#" >
+ <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
+ <!ENTITY owl2xml "http://www.w3.org/2006/12/owl2-xml#" >
+ <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
+ <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
+ <!ENTITY mas "http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#" >
+ <!ENTITY jmca "http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#" >
+]>
+
+
+<rdf:RDF xmlns="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#"
+ xml:base="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl"
+ xmlns:owl2xml="http://www.w3.org/2006/12/owl2-xml#"
+ xmlns:mas="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#"
+ xmlns:jmca="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
+ xmlns:owl2="http://www.w3.org/2006/12/owl2#"
+ xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:owl="http://www.w3.org/2002/07/owl#">
+ <owl:Ontology rdf:about="">
+ <owl:imports rdf:resource="http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl"/>
+ </owl:Ontology>
+
+
+
+ <!--
+ ///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Annotation properties
+ //
+ ///////////////////////////////////////////////////////////////////////////////////////
+ -->
+
+ <owl:AnnotationProperty rdf:about="&mas;PropertyHandler"/>
+
+
+
+ <!--
+ ///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Object Properties
+ //
+ ///////////////////////////////////////////////////////////////////////////////////////
+ -->
+
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#hasAspect -->
+
+ <owl:ObjectProperty rdf:about="#hasAspect">
+ <rdf:type rdf:resource="&owl;FunctionalProperty"/>
+ <rdfs:range rdf:resource="#Aspect"/>
+ <rdfs:domain rdf:resource="#SelectionStrategyClass"/>
+ </owl:ObjectProperty>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#hasSelectionStrategyClass -->
+
+ <owl:ObjectProperty rdf:about="#hasSelectionStrategyClass">
+ <rdfs:range rdf:resource="#SelectionStrategyClass"/>
+ <rdfs:domain rdf:resource="#SelectionStrategyClassEntry"/>
+ </owl:ObjectProperty>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#hasSelectionStrategyClassEntry -->
+
+ <owl:ObjectProperty rdf:about="#hasSelectionStrategyClassEntry">
+ <mas:PropertyHandler
+ >jmca.owl2mas.handler.SelectionStrategyClassEntryHandler</mas:PropertyHandler>
+ <rdfs:range rdf:resource="#SelectionStrategyClassEntry"/>
+ <rdfs:subPropertyOf rdf:resource="&mas;userAgentObjectProperty"/>
+ </owl:ObjectProperty>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/mas.owl#userAgentObjectProperty -->
+
+ <owl:ObjectProperty rdf:about="&mas;userAgentObjectProperty"/>
+
+
+
+ <!--
+ ///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Data properties
+ //
+ ///////////////////////////////////////////////////////////////////////////////////////
+ -->
+
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#hasPosition -->
+
+ <owl:DatatypeProperty rdf:about="#hasPosition">
+ <rdf:type rdf:resource="&owl;FunctionalProperty"/>
+ <rdfs:domain rdf:resource="#SelectionStrategyClassEntry"/>
+ <rdfs:range rdf:resource="&xsd;integer"/>
+ </owl:DatatypeProperty>
+
+
+
+ <!--
+ ///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Classes
+ //
+ ///////////////////////////////////////////////////////////////////////////////////////
+ -->
+
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#Aspect -->
+
+ <owl:Class rdf:about="#Aspect">
+ <rdfs:subClassOf rdf:resource="#JMCAParameter"/>
+ </owl:Class>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#JMCAParameter -->
+
+ <owl:Class rdf:about="#JMCAParameter">
+ <rdfs:subClassOf rdf:resource="&owl;Thing"/>
+ </owl:Class>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#SelectionStrategyClass -->
+
+ <owl:Class rdf:about="#SelectionStrategyClass">
+ <rdfs:subClassOf rdf:resource="#JMCAParameter"/>
+ </owl:Class>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#SelectionStrategyClassEntry -->
+
+ <owl:Class rdf:about="#SelectionStrategyClassEntry">
+ <rdfs:subClassOf rdf:resource="#JMCAParameter"/>
+ </owl:Class>
+
+
+
+ <!-- http://www.w3.org/2002/07/owl#Thing -->
+
+ <owl:Class rdf:about="&owl;Thing"/>
+
+
+
+ <!--
+ ///////////////////////////////////////////////////////////////////////////////////////
+ //
+ // Individuals
+ //
+ ///////////////////////////////////////////////////////////////////////////////////////
+ -->
+
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#ActionExec -->
+
+ <Aspect rdf:about="#ActionExec"/>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#Event -->
+
+ <Aspect rdf:about="#Event"/>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#Intention -->
+
+ <Aspect rdf:about="#Intention"/>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#Message -->
+
+ <Aspect rdf:about="#Message"/>
+
+
+
+ <!-- http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#Option -->
+
+ <Aspect rdf:about="#Option"/>
+</rdf:RDF>
Modified: trunk/applications/jmca/src/jmca/asSemantics/JmcaAgent.java
===================================================================
--- trunk/applications/jmca/src/jmca/asSemantics/JmcaAgent.java 2008-06-11 21:27:35 UTC (rev 1337)
+++ trunk/applications/jmca/src/jmca/asSemantics/JmcaAgent.java 2008-06-12 02:04:57 UTC (rev 1338)
@@ -34,7 +34,6 @@
import jason.runtime.Settings;
import java.lang.reflect.Constructor;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
@@ -44,6 +43,7 @@
import jmca.mediation.MediationStrategy;
import jmca.selection.SelectionStrategy;
import jmca.util.Common;
+import jmca.util.JMCAParams;
import jmca.util.JmcaException;
@@ -83,15 +83,9 @@
*/
private HashMap<Class, MediationStrategy> aspectMediationStrategyMap;
- /**
- * A static list of aspect types (classes) this Jmca supports (current Option, Message, Intention, Event, ActionExec)
- */
- private static Vector<Class> aspects = new Vector<Class>();
- static{
- aspects.addAll(Arrays.asList(new Class[] {Option.class, Message.class, Intention.class, Event.class, ActionExec.class}));
- }
+
/**
* Instantiates selection and mediation strategies for this JmcaAgent, then calls Jason's default initAg method
*/
@@ -99,7 +93,7 @@
public TransitionSystem initAg(AgArch arch, BeliefBase bb, java.lang.String asSrc, Settings stts) throws JasonException{
aspectSelectionStrategyMap = new HashMap<Class, List<SelectionStrategy>>();
aspectMediationStrategyMap = new HashMap<Class, MediationStrategy>();
- for(Class aspect : aspects){
+ for(Class aspect : JMCAParams.aspects){
aspectSelectionStrategyMap.put(aspect, getSelectionStrategyClasses(this, arch, bb, asSrc, stts, aspect));
aspectMediationStrategyMap.put(aspect, getMediationStrategyClass(stts, aspect));
}
@@ -167,7 +161,8 @@
try{
asList = strategy.apply(modules, asList);
}catch(JmcaException e){
- getLogger().severe("Error in jmca "+getUCN(aspect)+" selection. Reason: "+e);
+ getLogger().severe("Error in jmca "+getUCN(aspect)+" selection. Reason: ");
+ e.printStackTrace();
return null;
}
if(asList.isEmpty()){
Modified: trunk/applications/jmca/src/jmca/mediation/OverrulingIntersection.java
===================================================================
--- trunk/applications/jmca/src/jmca/mediation/OverrulingIntersection.java 2008-06-11 21:27:35 UTC (rev 1337)
+++ trunk/applications/jmca/src/jmca/mediation/OverrulingIntersection.java 2008-06-12 02:04:57 UTC (rev 1338)
@@ -47,7 +47,7 @@
List<T> intersection = new Vector<T>();
intersection.addAll(elements);
for(SelectionStrategy selectionStrategy : selectionStrategies){
- List<T> chosen = selectionStrategy.select(elements);
+ List<T> chosen = selectionStrategy.select(elements, intersection);
intersection.retainAll(chosen);
if(intersection.isEmpty()){ // no agreement, override earlier selections
intersection = chosen;
Added: trunk/applications/jmca/src/jmca/owl2mas/handler/SelectionStrategyClassEntryHandler.java
===================================================================
--- trunk/applications/jmca/src/jmca/owl2mas/handler/SelectionStrategyClassEntryHandler.java (rev 0)
+++ trunk/applications/jmca/src/jmca/owl2mas/handler/SelectionStrategyClassEntryHandler.java 2008-06-12 02:04:57 UTC (rev 1338)
@@ -0,0 +1,108 @@
+package jmca.owl2mas.handler;
+
+import java.net.URI;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import jmca.util.JMCAParams;
+
+import org.semanticweb.owl.model.OWLIndividual;
+
+import owl2mas.OWL2MASLoader;
+import owl2mas.exception.OWL2MASInvalidMASOntologyException;
+import owl2mas.handler.ObjectPropertyHandler;
+
+
+public class SelectionStrategyClassEntryHandler implements ObjectPropertyHandler{
+
+ class ClassEntry implements Comparable{
+ public String className;
+ public Integer position;
+
+
+ public ClassEntry(String className, Integer position) {
+ super();
+ this.className = className;
+ this.position = position;
+ }
+
+
+ public int compareTo(Object o) {
+ if(o instanceof ClassEntry){
+ ClassEntry c = (ClassEntry)o;
+ return position.compareTo(c.position);
+ }else{
+ throw new RuntimeException("Attempting to compare a class entry to something that is not a class entry");
+ }
+ }
+
+
+ }
+
+ public void handle(OWLIndividual agent, Set<OWLIndividual> values, OWL2MASLoader loader, HashMap<String, String> optionMap) throws OWL2MASInvalidMASOntologyException {
+ Set<OWLIndividual> classEntries = loader.getPellet().getRelatedIndividuals(
+ agent,
+ loader.getFactory().getOWLObjectProperty(URI.create(JMCAParams.JMCA_OWL_NS + "hasSelectionStrategyClassEntry")));
+
+ System.out.println("Class entries for "+agent+": "+classEntries);
+
+ HashMap<Class, Vector<ClassEntry>> aspectLists = new HashMap<Class, Vector<ClassEntry>>();
+ for(Class aspect : JMCAParams.aspects){
+ aspectLists.put(aspect, new Vector<ClassEntry>());
+ }
+
+ System.out.println("Aspects: "+aspectLists);
+
+
+ for(OWLIndividual classEntry : classEntries){
+ OWLIndividual cls = loader.getPellet().getRelatedIndividual(
+ classEntry,
+ loader.getFactory().getOWLObjectProperty(URI.create(JMCAParams.JMCA_OWL_NS+"hasSelectionStrategyClass")));
+
+ System.out.println("Class: "+cls);
+
+ String className = loader.getPellet().getRelatedValue(
+ cls,
+ loader.getFactory().getOWLDataProperty(URI.create(loader.getMAS_NS() + "hasClassName"))).getLiteral();
+
+ int position = Integer.parseInt(loader.getPellet().getRelatedValue(
+ classEntry,
+ loader.getFactory().getOWLDataProperty(URI.create(JMCAParams.JMCA_OWL_NS+"hasPosition"))).getLiteral());
+
+
+ String aspectName = loader.getPellet().getRelatedIndividual(
+ cls,
+ loader.getFactory().getOWLObjectProperty(URI.create(JMCAParams.JMCA_OWL_NS+"hasAspect"))).getURI().getFragment();
+
+ Class aspect;
+ try {
+ aspect = Class.forName("jason.asSemantics."+aspectName);
+ } catch (ClassNotFoundException e) {
+ throw new OWL2MASInvalidMASOntologyException("Unknown aspect class ", e);
+ }
+ aspectLists.get(aspect).add(new ClassEntry(className, position));
+
+ }
+
+
+ for(Map.Entry<Class, Vector<ClassEntry>> entry : aspectLists.entrySet()){
+ String paramName = "jmca_"+entry.getKey().getSimpleName()+"_selection_strategies";
+ String paramValue = "";
+
+ Collections.sort(entry.getValue());
+
+ for(ClassEntry value : entry.getValue()){
+ paramValue += value.className+",";
+ }
+ if(paramValue.length() >0 ){
+ paramValue = paramValue.substring(0, paramValue.length()-1);
+ optionMap.put(paramName, "\""+paramValue+"\"");
+ }
+
+
+ }
+ }
+}
Modified: trunk/applications/jmca/src/jmca/selection/SelectionStrategy.java
===================================================================
--- trunk/applications/jmca/src/jmca/selection/SelectionStrategy.java 2008-06-11 21:27:35 UTC (rev 1337)
+++ trunk/applications/jmca/src/jmca/selection/SelectionStrategy.java 2008-06-12 02:04:57 UTC (rev 1338)
@@ -47,7 +47,7 @@
* @return a set of acceptable aspects
* @throws JmcaException
*/
- public abstract List<T> select(List<T> from) throws JmcaException;
+ public abstract List<T> select(List<T> from, List<T>intersection) throws JmcaException;
public String toString(){
return master.toString();
Added: trunk/applications/jmca/src/jmca/util/JMCAParams.java
===================================================================
--- trunk/applications/jmca/src/jmca/util/JMCAParams.java (rev 0)
+++ trunk/applications/jmca/src/jmca/util/JMCAParams.java 2008-06-12 02:04:57 UTC (rev 1338)
@@ -0,0 +1,23 @@
+package jmca.util;
+
+import jason.asSemantics.ActionExec;
+import jason.asSemantics.Event;
+import jason.asSemantics.Intention;
+import jason.asSemantics.Message;
+import jason.asSemantics.Option;
+
+import java.util.Arrays;
+import java.util.Vector;
+
+public class JMCAParams {
+
+ /**
+ * A static list of aspect types (classes) this Jmca supports (current Option, Message, Intention, Event, ActionExec)
+ */
+ public static Vector<Class> aspects = new Vector<Class>();
+ static{
+ aspects.addAll(Arrays.asList(new Class[] {Option.class, Message.class, Intention.class, Event.class, ActionExec.class}));
+ }
+
+ public static String JMCA_OWL_NS = "http://www.dur.ac.uk/t.g.klapiscak/onts/owl2mas/jmca.owl#";
+}
Modified: trunk/applications/jmca/src/jmca/util/JmcaException.java
===================================================================
--- trunk/applications/jmca/src/jmca/util/JmcaException.java 2008-06-11 21:27:35 UTC (rev 1337)
+++ trunk/applications/jmca/src/jmca/util/JmcaException.java 2008-06-12 02:04:57 UTC (rev 1338)
@@ -22,7 +22,12 @@
import jason.JasonException;
-public class JmcaException extends JasonException {
+public class JmcaException extends JasonException {
+
+ public JmcaException(String msg, Exception cause) {
+ super(msg, cause);
+ }
+
public JmcaException(String message){
super(message);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jom...@us...> - 2008-06-11 21:27:40
|
Revision: 1337
http://jason.svn.sourceforge.net/jason/?rev=1337&view=rev
Author: jomifred
Date: 2008-06-11 14:27:35 -0700 (Wed, 11 Jun 2008)
Log Message:
-----------
improve comments in the food-simulation example
Modified Paths:
--------------
trunk/examples/food-simulation/FoodSimulation.mas2j
trunk/examples/food-simulation/src/asl/blind.asl
trunk/examples/food-simulation/src/asl/normative.asl
trunk/examples/food-simulation/src/asl/reputation.asl
trunk/examples/food-simulation/src/asl/strategic.asl
trunk/release-notes.txt
Modified: trunk/examples/food-simulation/FoodSimulation.mas2j
===================================================================
--- trunk/examples/food-simulation/FoodSimulation.mas2j 2008-06-09 22:54:15 UTC (rev 1336)
+++ trunk/examples/food-simulation/FoodSimulation.mas2j 2008-06-11 21:27:35 UTC (rev 1337)
@@ -1,13 +1,15 @@
/*
Jason Project
- -- create on December 20, 2007
-
-- Food Simulation --
based on the description available at
http://jasss.soc.surrey.ac.uk/1/3/3.html
-
+
+ used in the chapter about Jason in the book
+ "Agents, Simulation and Applications" by
+ Adelinde M. Uhrmacher and Danny Weyns
+
*/
/*
@@ -63,4 +65,4 @@
reputation [verbose=0] #25;
aslSourcePath: "src/asl";
-}
\ No newline at end of file
+}
Modified: trunk/examples/food-simulation/src/asl/blind.asl
===================================================================
--- trunk/examples/food-simulation/src/asl/blind.asl 2008-06-09 22:54:15 UTC (rev 1336)
+++ trunk/examples/food-simulation/src/asl/blind.asl 2008-06-11 21:27:35 UTC (rev 1337)
@@ -1,14 +1,16 @@
-// rule 1: food in my position
+/* -- blind agent -- */
+
+// rule 1: If there is food in my cell, eat.
+step(_) : food(X,Y,my_pos,_) <- eat.
-// rule 2: food I see
+// rule 2: If I see food in a free cell, move to there
+step(_) : food(X,Y,see,_) & not agent(_,X,Y,_,_) <- move(X,Y).
-// rule 3: food I see
+// rule 3: If I see food in an occupied cell, attack the agent at that cell
+step(_) : food(X,Y,see,_) & agent(_,X,Y,_,eating) <- attack(X,Y).
-// rule 4: food I smell
+// rule 4: If I smell food, move to there
+step(_) : food(X,Y,smell,_) <- move(X,Y).
-// rule 5
+// rule 5: Otherwise, do a random movement
+step(_) <- random_move.
Modified: trunk/examples/food-simulation/src/asl/normative.asl
===================================================================
--- trunk/examples/food-simulation/src/asl/normative.asl 2008-06-09 22:54:15 UTC (rev 1336)
+++ trunk/examples/food-simulation/src/asl/normative.asl 2008-06-11 21:27:35 UTC (rev 1337)
@@ -1,16 +1,24 @@
+/* -- normative agent -- */
-// food in my position
+// Rule-n1: only eat food that is free or allocated to me
+step(_) : food(X,Y,my_pos,A) & (pos(A,_,_) | A == -1) <- eat.
-// food I see
+// Rule-n2: if I see food allocated to me, move to there
+step(_) : food(X,Y,see,Me) & pos(Me,_,_) & not agent(_,X,Y,_,_) <- move(X,Y).
+
+// Rule-n3: if I see unallocated food, move to there
+step(_) : food(X,Y,see,-1) & not agent(_,X,Y,_,_) <- move(X,Y).
+
+// Rule-n4: if I see another agent eating food owned by others, attack it
+step(_) : food(X,Y,see,OAg) & agent(AgId,X,Y,_,eating) &
AgId \== OAg & OAg \== -1
<- attack(X,Y).
-// food I smell
+// Rule-n5: if I smell my food, move to there
+step(_) : food(X,Y,smell,Me) & pos(Me,_,_) <- move(X,Y).
+
+// Rule-n6: if I smell unallocated food, move to there
+step(_) : food(X,Y,smell,-1) <- move(X,Y).
+// Rule-n7: otherwise, move randomly
+step(_) <- random_move.
Modified: trunk/examples/food-simulation/src/asl/reputation.asl
===================================================================
--- trunk/examples/food-simulation/src/asl/reputation.asl 2008-06-09 22:54:15 UTC (rev 1336)
+++ trunk/examples/food-simulation/src/asl/reputation.asl 2008-06-11 21:27:35 UTC (rev 1337)
@@ -1,20 +1,28 @@
+/* -- reputation agent -- */
-// food in my position
+// Rule-r1: eat food that is either allocate to me, free, or belongs to a cheater
+step(_) : food(_,_,my_pos,A) & (pos(A,_,_) | A == -1 | cheater(A)) <- eat.
-// food I see
+// Rule-r2: if I see food allocated to me, move to there
+step(_) : food(X,Y,see,Me) & pos(Me,_,_) & not agent(_,X,Y,_,_) <- move(X,Y).
+
+// Rule-r3: if I see unallocated food, move to there
+step(_) : food(X,Y,see,-1) & not agent(_,X,Y,_,_) <- move(X,Y).
+
+// Rule-r4: attack cheaters that are weaker than me
+step(_) : food(X,Y,see,_) & agent(AgId,X,Y,S,eating) &
cheater(AgId) &
strength(MS) & MS > S
<- attack(X,Y).
-// food I smell
+// Rule-r5: if I smell my food, move to there
+step(_) : food(X,Y,smell,Me) & pos(Me,_,_) <- move(X,Y).
+
+// Rule-r6: if I smell unallocated food, move to there
+step(_) : food(X,Y,smell,-1) <- move(X,Y).
+// Rule-r7: otherwise, move randomly
+step(_) <- random_move.
Modified: trunk/examples/food-simulation/src/asl/strategic.asl
===================================================================
--- trunk/examples/food-simulation/src/asl/strategic.asl 2008-06-09 22:54:15 UTC (rev 1336)
+++ trunk/examples/food-simulation/src/asl/strategic.asl 2008-06-11 21:27:35 UTC (rev 1337)
@@ -1,3 +1,4 @@
+/* -- strategic agent -- */
// food in my position
+step(_) : food(X,Y,my_pos,_) <- eat.
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2008-06-09 22:54:15 UTC (rev 1336)
+++ trunk/release-notes.txt 2008-06-11 21:27:35 UTC (rev 1337)
@@ -62,7 +62,8 @@
Bugs fixed:
. BUF add annotation "source(percept)" in the perception deletion event
. drop_desire does not remove desires in Circumstance.Event correctly
- when annotations are used.
+ when annotations are used
+. print works like println
-------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tom...@us...> - 2008-06-09 22:54:15
|
Revision: 1336
http://jason.svn.sourceforge.net/jason/?rev=1336&view=rev
Author: tomklapiscak
Date: 2008-06-09 15:54:15 -0700 (Mon, 09 Jun 2008)
Log Message:
-----------
Re-added Bebops library
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-06-09 20:59:11
|
Revision: 1335
http://jason.svn.sourceforge.net/jason/?rev=1335&view=rev
Author: tomklapiscak
Date: 2008-06-09 13:59:02 -0700 (Mon, 09 Jun 2008)
Log Message:
-----------
Removed generated files
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/lib/bebops.jar
Deleted: 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-06-09 20:58:46
|
Revision: 1334
http://jason.svn.sourceforge.net/jason/?rev=1334&view=rev
Author: tomklapiscak
Date: 2008-06-09 13:58:44 -0700 (Mon, 09 Jun 2008)
Log Message:
-----------
Removed generated files
Removed Paths:
-------------
trunk/applications/owl2mas/lib/owl2mas.jar
Deleted: trunk/applications/owl2mas/lib/owl2mas.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-06-09 20:58:01
|
Revision: 1333
http://jason.svn.sourceforge.net/jason/?rev=1333&view=rev
Author: tomklapiscak
Date: 2008-06-09 13:58:00 -0700 (Mon, 09 Jun 2008)
Log Message:
-----------
Removed generated files
Modified Paths:
--------------
trunk/applications/jasdl-owlapi/lib/bebops.jar
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/lib/owl2mas.jar
Modified: trunk/applications/jasdl-owlapi/lib/bebops.jar
===================================================================
(Binary files differ)
Deleted: trunk/applications/jasdl-owlapi/lib/owl2mas.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-06-09 20:56:07
|
Revision: 1332
http://jason.svn.sourceforge.net/jason/?rev=1332&view=rev
Author: tomklapiscak
Date: 2008-06-09 13:55:59 -0700 (Mon, 09 Jun 2008)
Log Message:
-----------
Removed generated files
Removed Paths:
-------------
trunk/applications/jasdl-owlapi/examples/commerce/MAS.mas2j
trunk/applications/jasdl-owlapi/examples/commerce/bin/build.xml
Deleted: trunk/applications/jasdl-owlapi/examples/commerce/MAS.mas2j
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/MAS.mas2j 2008-06-09 20:39:41 UTC (rev 1331)
+++ trunk/applications/jasdl-owlapi/examples/commerce/MAS.mas2j 2008-06-09 20:55:59 UTC (rev 1332)
@@ -1,29 +0,0 @@
-/*
- Jason Project
-
- -- created on June 09, 2008
-*/
-
-MAS soc {
- infrastructure: Centralised
-
- environment: commerce.env.CommerceEnvironment
-
- agents:
- delivery_van_1 delivery_van.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- caz customer.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- a_butchers shop.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- a_greengrocers shop.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- jims_pa pa.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- tom customer.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- delivery_van_2 delivery_van.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- delivery_van_3 delivery_van.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- delivery_van_4 delivery_van.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- toms_pa pa.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- a_supermarket shop.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- cazs_pa pa.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
- jim customer.asl [jasdl_ontologies="c,s", jasdl_s_uri="/onts/society.owl", jasdl_c_uri="/onts/commerce.owl", jasdl_useContraction="true"] agentArchClass jasdl.architecture.JASDLAgArch agentClass jasdl.asSemantics.JASDLAgent beliefBaseClass jasdl.bb.JASDLBeliefBase;
-
- classpath: "../../lib/**/*.jar";
- aslSourcePath: "src/asl";
-}
\ No newline at end of file
Deleted: trunk/applications/jasdl-owlapi/examples/commerce/bin/build.xml
===================================================================
--- trunk/applications/jasdl-owlapi/examples/commerce/bin/build.xml 2008-06-09 20:39:41 UTC (rev 1331)
+++ trunk/applications/jasdl-owlapi/examples/commerce/bin/build.xml 2008-06-09 20:55:59 UTC (rev 1332)
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-
-<!--
-
- This file was generated by Jason 1.1.2
- http://jason.sf.net
-
- June 09, 2008 - 22:03:32
--->
-
-<project name ="soc"
- basedir=".."
- default="run">
-
- <property name="mas2j.project.file" value="MAS.mas2j"/>
- <property name="debug" value=""/> <!-- use "-debug" to run in debug mode -->
- <property name="build.dir" value="${basedir}/bin/classes" />
-
- <property name="jasonJar" value="/Users/jomi/Jason/Jason-svn/lib/jason.jar"/>
-
- <path id="project.classpath">
- <pathelement location="${basedir}"/>
- <pathelement location="${build.dir}"/>
- <pathelement location="${jasonJar}"/>
- <fileset dir="../../lib" > <include name="**/*.jar" /> </fileset>
-
- </path>
-
- <!-- tasks the user can override in his/her c-build.xml script -->
- <target name="user-init">
- </target>
- <target name="user-end">
- </target>
-
- <target name="init">
- <mkdir dir="${build.dir}" />
- <antcall target="user-init" />
- </target>
-
- <target name="compile" depends="init">
- <condition property="srcdir" value="${basedir}/src/java" else="${basedir}" >
- <available file="${basedir}/src/java" />
- </condition>
- <javac srcdir="${srcdir}" destdir="${build.dir}" debug="true" optimize="true" >
- <classpath refid="project.classpath"/>
- </javac>
- </target>
-
- <target name="jar" depends="compile">
- <delete file="${ant.project.name}.jar" />
- <copy file="${jasonJar}" tofile="${ant.project.name}.jar" />
- <copy file="${mas2j.project.file}" tofile="default.mas2j" />
- <jar update="yes" jarfile="${ant.project.name}.jar" >
- <fileset dir="${basedir}">
- <include name="**/*.asl" />
- <include name="**/*.mas2j" />
- </fileset>
- <fileset dir="${build.dir}">
- <include name="**/*.class" />
- </fileset>
- </jar>
- <delete file="default.mas2j" />
- </target>
-
-
- <target name="jnlp" depends="jar" >
- <mkdir dir="${basedir}/${ant.project.name}-jws"/>
- <java classname="jason.infra.centralised.CreateJNLP"
- failonerror="true" fork="yes" dir="${basedir}/${ant.project.name}-jws" >
- <classpath refid="project.classpath"/>
- <arg line="${ant.project.name} ${mas2j.project.file}"/>
- </java>
- <copy todir="${basedir}/${ant.project.name}-jws" failonerror="no">
- <fileset dir="${basedir}/lib" includes="**/*.jar" />
- <fileset dir="${basedir}" includes="${ant.project.name}.jar" />
- <fileset dir="/Users/jomi/Jason/Jason-svn/src/images" includes="Jason-GMoreau-Icon.jpg" />
- </copy>
- <signjar jar="${basedir}/${ant.project.name}-jws/${ant.project.name}.jar" alias="jason"
- storepass="rbjhja" keypass="rbjhja" keystore="/Users/jomi/Jason/Jason-svn/src/jasonKeystore" />
- <echo message="**" />
- <echo message="** Java Web Start application created in directory ${ant.project.name}-jws" />
- <echo message="** Update the codebase (in the second line of the .jnlp file)" />
- <echo message="** with the URL where you will upload the application." />
- <echo message="**" />
- </target>
-
-
- <target name="run" depends="compile" >
- <echo message="Running project ${ant.project.name}" />
- <java classname="jason.infra.centralised.RunCentralisedMAS"
- failonerror="true" fork="yes" dir="${basedir}" >
- <classpath refid="project.classpath"/>
- <arg line="${mas2j.project.file} ${debug} "/>
- <jvmarg line="-Xmx750M"/>
- </java>
- <antcall target="user-end" />
- </target>
-
- <target name="clean" >
- <delete failonerror="no" includeEmptyDirs="true" verbose="true">
- <fileset dir="${basedir}" includes="**/*.class"/>
- </delete>
- </target>
-
-
-
-</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|