From: <jom...@us...> - 2016-04-09 21:04:38
|
Revision: 1892 http://sourceforge.net/p/jason/svn/1892 Author: jomifred Date: 2016-04-09 21:04:35 +0000 (Sat, 09 Apr 2016) Log Message: ----------- use java 1.7 Modified Paths: -------------- trunk/build.xml trunk/release-notes.txt trunk/src/jason/bb/BeliefBase.java trunk/src/jason/bb/ChainBBAdapter.java trunk/src/jason/bb/DefaultBeliefBase.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2016-04-09 12:22:00 UTC (rev 1891) +++ trunk/build.xml 2016-04-09 21:04:35 UTC (rev 1892) @@ -137,7 +137,9 @@ <target name="compile" depends="init,parsers"> - <javac srcdir="src" destdir="${build.dir}" debug="true" deprecation="true" optimize="true" nowarn="true" source="1.6" target="1.6" includeantruntime="false"> + <javac srcdir="src" destdir="${build.dir}" + debug="true" deprecation="true" optimize="true" nowarn="true" + source="1.7" target="1.7" includeantruntime="false"> <classpath refid="project.classpath" /> </javac> </target> Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2016-04-09 12:22:00 UTC (rev 1891) +++ trunk/release-notes.txt 2016-04-09 21:04:35 UTC (rev 1892) @@ -1,10 +1,15 @@ --------------------------- -version 1.4.3 +version 2.0.0 revision xxxx on SVN --------------------------- New features: + +- modules and namespaces, see doc/modules.pdf + +- concurrent plans and advanced concurrent agent architectures, see doc/concurrency.pdf + - the operator "+" works with plans and rules enclosed by { and }. For instance: ... + { p :- q & r }; @@ -15,6 +20,7 @@ with the plans that implement the KQML semantics) and kqmlReceivedFunctor (the functor used to produce new message events). +- improved BUF function with linear time (previous BUF was exponential) New internal actions: - .asserta: inserts a belief (or rule) in the begin of the belief base (can be used in prolog like rules) @@ -23,6 +29,10 @@ - .lower_case and upper_case for strings - .include: to load an asl source code at run time +Changes in the API: +- AgArch act method has just one parameter +- Java 8 is used + New Tutorial on BDI (see doc/index.html) --------------------------- Modified: trunk/src/jason/bb/BeliefBase.java =================================================================== --- trunk/src/jason/bb/BeliefBase.java 2016-04-09 12:22:00 UTC (rev 1891) +++ trunk/src/jason/bb/BeliefBase.java 2016-04-09 21:04:35 UTC (rev 1892) @@ -42,7 +42,7 @@ * Common interface for all kinds of Jason Belief bases, even those * customised by the user. */ -public interface BeliefBase extends Iterable<Literal>, Cloneable { +public abstract class BeliefBase implements Iterable<Literal>, Cloneable { public static final Term ASelf = new Atom("self"); public static final Term APercept = new Atom("percept"); @@ -60,39 +60,36 @@ * <code>agent BeliefBaseClass(1,bla);</code><br> * the init args will be ["1", "bla"]. */ - public void init(Agent ag, String[] args); + public void init(Agent ag, String[] args) {} - public Set<Atom> getNameSpaces(); - /** Called just before the end of MAS execution */ - public void stop(); + public void stop() {} /** removes all beliefs from BB */ - public void clear(); - + public void clear() {} + + public Set<Atom> getNameSpaces() { return null; } + /** Adds a belief in the end of the BB, returns true if succeed. * The annots of l may be changed to reflect what was changed in the BB, * for example, if l is p[a,b] in a BB with p[a], l will be changed to * p[b] to produce the event +p[b], since only the annotation b is changed * in the BB. */ - public boolean add(Literal l); + public boolean add(Literal l) { return false; } /** Adds a belief in the BB at <i>index</i> position, returns true if succeed */ - public boolean add(int index, Literal l); + public boolean add(int index, Literal l) { return false; } /** Returns an iterator for all beliefs. */ - public Iterator<Literal> iterator(); + public abstract Iterator<Literal> iterator(); - /** @deprecated use iterator() instead of getAll */ - public Iterator<Literal> getAll(); - /** * Returns an iterator for all literals in the default namespace of the BB that match the functor/arity * of the parameter.<br> */ - public Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi); - public default Iterator<Literal> getCandidateBeliefs(Atom namespace, PredicateIndicator pi) { return null; } + public Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi) { return getCandidateBeliefs(Literal.DefaultNS, pi); } + public Iterator<Literal> getCandidateBeliefs(Atom namespace, PredicateIndicator pi) { return null; } /** * Returns an iterator for all literals relevant for l's predicate @@ -106,41 +103,38 @@ * {{a(10),a(20)}. The <code>getCandidateBeliefs(a(X), {X -> 5})</code> * should also return {{a(10),a(20)}.<br> */ - public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u); + public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u) { return null; } - /** @deprecated use getCandidateBeliefs(l,null) instead */ - public Iterator<Literal> getRelevant(Literal l); - /** * Returns the literal l as it is in BB, this method does not * consider annotations in the search. <br> Example, if * BB={a(10)[a,b]}, <code>contains(a(10)[d])</code> returns * a(10)[a,b]. */ - public Literal contains(Literal l); + public Literal contains(Literal l) { return null; } /** Returns the number of beliefs in BB */ - public int size(); + public int size() { return 0; } /** Returns all beliefs that have "percept" as source */ - public Iterator<Literal> getPercepts(); + public Iterator<Literal> getPercepts() { return null; } /** Removes a literal from BB, returns true if succeed */ - public boolean remove(Literal l); + public boolean remove(Literal l) { return false; } /** Removes all believes with some functor/arity in the default namespace */ - public boolean abolish(PredicateIndicator pi); - public default boolean abolish(Atom namespace, PredicateIndicator pi) { return false; } + public boolean abolish(PredicateIndicator pi) { return abolish(Literal.DefaultNS, pi); } + public boolean abolish(Atom namespace, PredicateIndicator pi) { return false; } /** Gets the BB as XML */ - public Element getAsDOM(Document document); + public Element getAsDOM(Document document) { return null; } - public BeliefBase clone(); + public abstract BeliefBase clone(); Object lock = new Object(); /** Gets a lock for the BB */ - public default Object getLock() { + public Object getLock() { return lock; } } Modified: trunk/src/jason/bb/ChainBBAdapter.java =================================================================== --- trunk/src/jason/bb/ChainBBAdapter.java 2016-04-09 12:22:00 UTC (rev 1891) +++ trunk/src/jason/bb/ChainBBAdapter.java 2016-04-09 21:04:35 UTC (rev 1892) @@ -1,19 +1,17 @@ package jason.bb; +import java.util.Iterator; +import java.util.Set; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + import jason.asSemantics.Agent; import jason.asSemantics.Unifier; import jason.asSyntax.Atom; import jason.asSyntax.Literal; import jason.asSyntax.PredicateIndicator; -import jason.bb.BeliefBase; -import jason.bb.DefaultBeliefBase; -import java.util.Iterator; -import java.util.Set; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - /** This class is to be extended by customised belief bases that may be @@ -53,8 +51,7 @@ @author Jomi */ -@SuppressWarnings("deprecation") -public abstract class ChainBBAdapter implements BeliefBase { +public abstract class ChainBBAdapter extends BeliefBase { protected BeliefBase nextBB = null; // the next BB in the chain @@ -84,13 +81,16 @@ // Methods of BB interface + @Override public void init(Agent ag, String[] args) { nextBB.init(ag, args); } + @Override public void stop() { nextBB.stop(); } + @Override public void clear() { nextBB.clear(); } @@ -100,54 +100,57 @@ return nextBB.getNameSpaces(); } + @Override public boolean add(Literal l) { return nextBB.add(l); } + @Override public boolean add(int index, Literal l) { return nextBB.add(index, l); } + @Override public Literal contains(Literal l) { return nextBB.contains(l); } - public Iterator<Literal> getAll() { - return nextBB.getAll(); - } - + @Override public Iterator<Literal> iterator() { return nextBB.iterator(); } + @Override public Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi) { return nextBB.getCandidateBeliefs(pi); } + @Override public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u) { return nextBB.getCandidateBeliefs(l, u); } + @Override public Iterator<Literal> getPercepts() { return nextBB.getPercepts(); } - public Iterator<Literal> getRelevant(Literal l) { - return nextBB.getRelevant(l); - } - + @Override public boolean abolish(PredicateIndicator pi) { return nextBB.abolish(pi); } + @Override public boolean remove(Literal l) { return nextBB.remove(l); } + @Override public int size() { return nextBB.size(); } + @Override public Element getAsDOM(Document document) { return nextBB.getAsDOM(document); } Modified: trunk/src/jason/bb/DefaultBeliefBase.java =================================================================== --- trunk/src/jason/bb/DefaultBeliefBase.java 2016-04-09 12:22:00 UTC (rev 1891) +++ trunk/src/jason/bb/DefaultBeliefBase.java 2016-04-09 21:04:35 UTC (rev 1892) @@ -45,7 +45,7 @@ /** * Default implementation of Jason BB. */ -public class DefaultBeliefBase implements BeliefBase { +public class DefaultBeliefBase extends BeliefBase { private static Logger logger = Logger.getLogger(DefaultBeliefBase.class.getSimpleName()); @@ -66,23 +66,24 @@ nameSpaces.put(Literal.DefaultNS, belsMapDefaultNS); } + @Override public void init(Agent ag, String[] args) { if (ag != null) { logger = Logger.getLogger(ag.getTS().getUserAgArch().getAgName() + "-"+DefaultBeliefBase.class.getSimpleName()); } } + @Override public Set<Atom> getNameSpaces() { return nameSpaces.keySet(); } - public void stop() { - } - + @Override public int size() { return size; } + @Override public void clear() { size = 0; percepts.clear(); @@ -91,6 +92,7 @@ nameSpaces.put(Literal.DefaultNS, belsMapDefaultNS); } + @Override public Iterator<Literal> getPercepts() { final Iterator<Literal> i = percepts.iterator(); return new Iterator<Literal>() { @@ -123,10 +125,12 @@ return percepts; } + @Override public boolean add(Literal l) { return add(l, false); } + @Override public boolean add(int index, Literal l) { return add(l, index != 0); } @@ -183,6 +187,7 @@ return entry; } + @Override public boolean remove(Literal l) { Literal bl = contains(l); if (bl != null) { @@ -214,6 +219,7 @@ } } + @Override public Iterator<Literal> iterator() { final Iterator<Map<PredicateIndicator, BelEntry>> ins = nameSpaces.values().iterator(); return new Iterator<Literal>() { @@ -256,15 +262,8 @@ } }; } - - /** @deprecated use iterator() instead of getAll */ - public Iterator<Literal> getAll() { - return iterator(); - } - public boolean abolish(PredicateIndicator pi) { - return abolish(Literal.DefaultNS, pi); - } + @Override public boolean abolish(Atom namespace, PredicateIndicator pi) { BelEntry entry = nameSpaces.get(namespace).remove(pi); if (entry != null) { @@ -284,6 +283,7 @@ //return belsMap.remove(pi) != null; } + @Override public Literal contains(Literal l) { Map<PredicateIndicator, BelEntry> belsMap = l.getNS() == Literal.DefaultNS ? belsMapDefaultNS : nameSpaces.get(l.getNS()); if (belsMap == null) @@ -297,9 +297,7 @@ } } - public Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi) { - return getCandidateBeliefs(Literal.DefaultNS, pi); - } + @Override public Iterator<Literal> getCandidateBeliefs(Atom namespace, PredicateIndicator pi) { BelEntry entry = nameSpaces.get(namespace).get(pi); if (entry != null) @@ -308,6 +306,7 @@ return null; } + @Override public Iterator<Literal> getCandidateBeliefs(Literal l, Unifier u) { if (l.isVar()) { // all bels are relevant @@ -334,16 +333,12 @@ } } } - - /** @deprecated use getCandidateBeliefs(l,null) instead */ - public Iterator<Literal> getRelevant(Literal l) { - return getCandidateBeliefs(l, null); - } public String toString() { return nameSpaces.toString(); } + @Override public BeliefBase clone() { DefaultBeliefBase bb = new DefaultBeliefBase(); for (Literal b: this) { @@ -352,6 +347,7 @@ return bb; } + @Override public Element getAsDOM(Document document) { int tries = 0; Element ebels = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |