|
From: <jom...@us...> - 2015-12-24 09:26:33
|
Revision: 1868
http://sourceforge.net/p/jason/svn/1868
Author: jomifred
Date: 2015-12-24 09:26:31 +0000 (Thu, 24 Dec 2015)
Log Message:
-----------
fix: wait with formula parameter does not wait if the ag already believes in the formula
Modified Paths:
--------------
trunk/applications/as-unit-test/src/jason/tests/BugIfGoalReturn.java
trunk/build.xml
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSyntax/UnnamedVar.java
trunk/src/jason/stdlib/wait.java
Modified: trunk/applications/as-unit-test/src/jason/tests/BugIfGoalReturn.java
===================================================================
--- trunk/applications/as-unit-test/src/jason/tests/BugIfGoalReturn.java 2015-12-11 13:05:52 UTC (rev 1867)
+++ trunk/applications/as-unit-test/src/jason/tests/BugIfGoalReturn.java 2015-12-24 09:26:31 UTC (rev 1868)
@@ -48,6 +48,7 @@
);
}
+ @SuppressWarnings("deprecation")
@Test(timeout=2000)
public void testRule() {
ag.addGoal("start");
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2015-12-11 13:05:52 UTC (rev 1867)
+++ trunk/build.xml 2015-12-24 09:26:31 UTC (rev 1868)
@@ -12,8 +12,8 @@
<property name="build.dir" value="${basedir}/bin/classes" />
<property name="dist.properties" value="${basedir}/bin/dist.properties" />
- <property name="version" value="1" />
- <property name="release" value="2.beta" />
+ <property name="version" value="2" />
+ <property name="release" value="0.beta" />
<property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" />
<property name="distFile" value="${env.HOME}/Jason-${version}.${release}" />
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2015-12-11 13:05:52 UTC (rev 1867)
+++ trunk/src/jason/asSemantics/Agent.java 2015-12-24 09:26:31 UTC (rev 1868)
@@ -717,7 +717,21 @@
* @return the number of changes (add + dels)
*/
public int buf(List<Literal> percepts) {
+
+ /*
// complexity 3n
+
+ HashSet percepts = clone from the list of current environment percepts // 1n
+
+ for b in BBPercept (the set of perceptions already in BB) // 1n
+ if b not in percepts // constant time test
+ remove b in BBPercept // constant time
+ remove b in percept
+
+ for p still in percepts // 1n
+ add p in BBPercepts
+ */
+
if (percepts == null) {
return 0;
}
@@ -752,7 +766,8 @@
}
}
}
- /*
+
+ /*
////// previous version, without perW hashset
// could not use percepts.contains(l), since equalsAsTerm must be
// used (to ignore annotations)
@@ -787,7 +802,7 @@
}
*/
/*
- // old version
+ // even older version
// can not delete l, but l[source(percept)]
l = (Literal)l.clone();
l.clearAnnots();
@@ -819,61 +834,7 @@
return adds + dels;
}
- public int bufAlternative(List<Literal> percepts) {
- // complexity 4n
-
- if (percepts == null) {
- return 0;
- }
-
- // stat
- int adds = 0;
- int dels = 0;
- //Set<Literal> pinBB = ((DefaultBeliefBase)getBB()).getPerceptsSet();
- Set<StructureWrapperForLiteral> pinBBW = new HashSet<StructureWrapperForLiteral>();
- Iterator<Literal> ibb = getBB().getPercepts();
- while (ibb.hasNext())
- pinBBW.add(new StructureWrapperForLiteral( ibb.next()));
-
- Iterator<Literal> ip = percepts.iterator();
- while (ip.hasNext()) {
- Literal t = ip.next();
- StructureWrapperForLiteral lrt = new StructureWrapperForLiteral(t);
- if ( pinBBW.remove(lrt) ) {
- // since this percept in in BB, do not need to be added neither removed
- ip.remove();
- }
- }
-
- // percepts that are not in BB
- for (Literal lp : percepts) {
- try {
- lp = lp.copy().forceFullLiteralImpl();
- lp.addAnnot(BeliefBase.TPercept);
- if (getBB().add(lp)) {
- adds++;
- ts.updateEvents(new Event(new Trigger(TEOperator.add, TEType.belief, lp), Intention.EmptyInt));
- }
- } catch (Exception e) {
- logger.log(Level.SEVERE, "Error adding percetion " + lp, e);
- }
- }
-
- // remove what was not perceived
- for (StructureWrapperForLiteral lw: pinBBW) {
- Literal l = lw.getLiteral();
- l = ASSyntax.createLiteral(l.getFunctor(), l.getTermsArray());
- l.addAnnot(BeliefBase.TPercept);
- if (bb.remove(l)) {
- dels++;
- ts.updateEvents(new Event(new Trigger(TEOperator.del, TEType.belief, l), Intention.EmptyInt));
- }
- }
- return adds + dels;
- }
-
-
/*
public QueryCacheSimple getQueryCache() {
return qCache;
Modified: trunk/src/jason/asSyntax/UnnamedVar.java
===================================================================
--- trunk/src/jason/asSyntax/UnnamedVar.java 2015-12-11 13:05:52 UTC (rev 1867)
+++ trunk/src/jason/asSyntax/UnnamedVar.java 2015-12-24 09:26:31 UTC (rev 1868)
@@ -78,12 +78,7 @@
}
public Term clone() {
- UnnamedVar newv = new UnnamedVar(getNS(), getFunctor());
- newv.myId = this.myId;
- newv.hashCodeCache = this.hashCodeCache;
- if (hasAnnot())
- newv.addAnnots(this.getAnnots().cloneLT());
- return newv;
+ return cloneNS(getNS());
}
@Override
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2015-12-11 13:05:52 UTC (rev 1867)
+++ trunk/src/jason/stdlib/wait.java 2015-12-24 09:26:31 UTC (rev 1868)
@@ -113,6 +113,8 @@
te = Trigger.tryToGetTrigger(args[0]); // wait for event
if (te == null && args[0] instanceof LogicalFormula) { // wait for an expression to become true
f = (LogicalFormula)args[0];
+ if (ts.getAg().believes(f, un))
+ return true;
}
if (args.length >= 2)
timeout = (long) ((NumberTerm) args[1]).solve();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|