|
From: <jom...@us...> - 2010-08-10 13:48:51
|
Revision: 1606
http://jason.svn.sourceforge.net/jason/?rev=1606&view=rev
Author: jomifred
Date: 2010-08-10 13:48:45 +0000 (Tue, 10 Aug 2010)
Log Message:
-----------
improve atomic status computation for intentions
Modified Paths:
--------------
trunk/src/jason/asSemantics/Intention.java
trunk/src/test/TSTest.java
Modified: trunk/src/jason/asSemantics/Intention.java
===================================================================
--- trunk/src/jason/asSemantics/Intention.java 2010-08-03 20:12:59 UTC (rev 1605)
+++ trunk/src/jason/asSemantics/Intention.java 2010-08-10 13:48:45 UTC (rev 1606)
@@ -52,12 +52,12 @@
private static int idCount = 0;
private int id;
- private boolean isAtomic = false;
+ private int atomicCount = 0; // how many atomic intended means there are in the intention
private boolean isSuspended = false;
private Stack<IntendedMeans> intendedMeans = new Stack<IntendedMeans>();
- // static private Logger logger = Logger.getLogger(Intention.class.getName());
+ //static private Logger logger = Logger.getLogger(Intention.class.getName());
public Intention() {
id = ++idCount;
@@ -69,9 +69,8 @@
public void push(IntendedMeans im) {
intendedMeans.push(im);
- if (im.isAtomic()) {
- isAtomic = true;
- }
+ if (im.isAtomic())
+ atomicCount++;
}
public IntendedMeans peek() {
@@ -85,16 +84,27 @@
public IntendedMeans pop() {
IntendedMeans top = intendedMeans.pop();
- isAtomic = false;
- for (IntendedMeans im : intendedMeans) {
- if (im.isAtomic()) {
- isAtomic = true;
- break;
- }
+ if (isAtomic() && top.isAtomic()) {
+ atomicCount--;
+ /* for (IntendedMeans im : intendedMeans) {
+ if (im.isAtomic()) {
+ isAtomic = true;
+ break;
+ }
+ }*/
}
return top;
}
+ public boolean isAtomic() {
+ return atomicCount > 0;
+ }
+
+ public void setAtomic(int a) { // used for test
+ atomicCount = a;
+ }
+
+
public ListIterator<IntendedMeans> iterator() {
return intendedMeans.listIterator(intendedMeans.size());
}
@@ -107,14 +117,6 @@
return intendedMeans.size();
}
- public boolean isAtomic() {
- return isAtomic;
- }
-
- public void setAtomic(boolean b) {
- isAtomic = b;
- }
-
public void setSuspended(boolean b) {
isSuspended = b;
}
@@ -161,8 +163,10 @@
/** implements atomic intentions > not atomic intentions */
public int compareTo(Intention o) {
- if (o.isAtomic && !this.isAtomic) return 1;
- if (this.isAtomic && !o.isAtomic) return -1;
+ //if (o.isAtomic() && !this.isAtomic()) return 1;
+ //if (this.isAtomic() && !o.isAtomic()) return -1;
+ if (o.atomicCount > this.atomicCount) return 1;
+ if (this.atomicCount > o.atomicCount) return -1;
return 0;
}
@@ -180,7 +184,7 @@
public Intention clone() {
Intention i = new Intention();
i.id = id;
- i.isAtomic = isAtomic;
+ i.atomicCount = atomicCount;
i.intendedMeans = new Stack<IntendedMeans>();
for (IntendedMeans im: intendedMeans) {
i.intendedMeans.add((IntendedMeans)im.clone());
Modified: trunk/src/test/TSTest.java
===================================================================
--- trunk/src/test/TSTest.java 2010-08-03 20:12:59 UTC (rev 1605)
+++ trunk/src/test/TSTest.java 2010-08-10 13:48:45 UTC (rev 1606)
@@ -83,7 +83,7 @@
Intention i2 = new Intention();
Intention i3 = new Intention();
- i3.setAtomic(true);
+ i3.setAtomic(1);
assertTrue(i3.isAtomic());
Intention i4 = new Intention();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|