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...> - 2012-12-07 10:51:18
|
Revision: 1715 http://jason.svn.sourceforge.net/jason/?rev=1715&view=rev Author: jomifred Date: 2012-12-07 10:51:06 +0000 (Fri, 07 Dec 2012) Log Message: ----------- add missing classes (related to chache query) Modified Paths: -------------- trunk/src/jason/asSemantics/QueryCacheAdv.java trunk/src/jason/asSemantics/QueryCacheSimple.java trunk/src/jason/asSyntax/InternalActionLiteral.java Added Paths: ----------- trunk/src/jason/asSemantics/QueryCacheKey.java Modified: trunk/src/jason/asSemantics/QueryCacheAdv.java =================================================================== --- trunk/src/jason/asSemantics/QueryCacheAdv.java 2012-10-17 20:21:33 UTC (rev 1714) +++ trunk/src/jason/asSemantics/QueryCacheAdv.java 2012-12-07 10:51:06 UTC (rev 1715) @@ -19,7 +19,7 @@ private Agent ag; private Map<PredicateIndicator, List<Pair<Literal,List<Unifier>>>> cache = null; private Map<PredicateIndicator, List<Pair<Literal,List<Unifier>>>> tmp = null; - private Set<CacheKey> noCache = null; + private Set<QueryCacheKey> noCache = null; private QueryProfiling prof; @@ -31,7 +31,7 @@ logger = Logger.getLogger(QueryCacheAdv.class.getName()+"-"+ag.getTS().getUserAgArch().getAgName()); cache = new HashMap<PredicateIndicator, List<Pair<Literal,List<Unifier>>>>(); tmp = new HashMap<PredicateIndicator, List<Pair<Literal,List<Unifier>>>>(); - noCache = new HashSet<CacheKey>(); + noCache = new HashSet<QueryCacheKey>(); } public void reset() { @@ -58,7 +58,7 @@ } List<Pair<Literal,List<Unifier>>> optsTmp = tmp.get(f.getPredicateIndicator()); - if (optsTmp != null && !noCache.contains(new CacheKey(f))) { + if (optsTmp != null && !noCache.contains(new QueryCacheKey(f))) { for (Pair<Literal,List<Unifier>> ic: optsTmp) { // for each possible entry in the cache //System.out.println(" try opt tmp "+ic+" "+new Unifier().unifies(f, ic.getFirst()) + " "+f.subsumes(ic.getFirst())); if (new Unifier().unifies(f, ic.getFirst()) && ic.getFirst().subsumes(f)) { @@ -69,7 +69,7 @@ final List<Unifier> listTmp = ic.getSecond(); final int listSize = listTmp.size(); - noCache.add(new CacheKey(lTmp)); + noCache.add(new QueryCacheKey(lTmp)); // use already obtained solutions return new Pair<Literal,Iterator<Unifier>>(lTmp,new Iterator<Unifier>() { @@ -118,7 +118,7 @@ } public void addAnswer(Literal f, Unifier a) { - if (noCache.contains(new CacheKey(f))) + if (noCache.contains(new QueryCacheKey(f))) return; List<Unifier> ans = null; Added: trunk/src/jason/asSemantics/QueryCacheKey.java =================================================================== --- trunk/src/jason/asSemantics/QueryCacheKey.java (rev 0) +++ trunk/src/jason/asSemantics/QueryCacheKey.java 2012-12-07 10:51:06 UTC (rev 1715) @@ -0,0 +1,61 @@ +package jason.asSemantics; + +import jason.asSyntax.Literal; + +public class QueryCacheKey { + final Literal l; + //final Unifier u; + + public QueryCacheKey(Literal o1) { + this.l = o1; + //this.u = o2; + } + + @Override + public int hashCode() { + return l.getPredicateIndicator().hashCode(); + } + + public Literal getLiteral() { + return l; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) return false; + if (obj == this) return true; + if (obj instanceof QueryCacheKey) { + if (obj.hashCode() != this.hashCode()) return false; + QueryCacheKey o = (QueryCacheKey)obj; + //System.out.println("* try cache "+o.l+" for "+this.l + " :: "+o.l.compareTo(this.l)); + return new Unifier().unifies(this.l, o.l) && o.l.subsumes(this.l); // the compare is here to avoid using p(10,Y) as cache for p(X,Y). + /* + if (!o.l.getPredicateIndicator().equals(this.l.getPredicateIndicator())) return false; // compares functor & arity + + // compare only terms ignoring unbound vars + for (int i=0; i<l.getArity(); i++) { + Term t1 = l.getTerm(i); + Term t2 = o.l.getTerm(i); + + if (t2.isVar()) { + if (o.u == null) { + continue; + } + t2 = o.u.get((VarTerm)t2); + if (t2 == null) + continue; // do not compare + } + if (!t1.equals(t2)) // TODO: it is not equals here, should be unification! + return false; + } + return true; + */ + } + return false; + } + + @Override + public String toString() { + return "<"+l+">"; + } +} Modified: trunk/src/jason/asSemantics/QueryCacheSimple.java =================================================================== --- trunk/src/jason/asSemantics/QueryCacheSimple.java 2012-10-17 20:21:33 UTC (rev 1714) +++ trunk/src/jason/asSemantics/QueryCacheSimple.java 2012-12-07 10:51:06 UTC (rev 1715) @@ -11,33 +11,12 @@ public class QueryCacheSimple { - //private Agent ag; private QueryProfiling prof; private Map<Literal, List<Unifier>> cache = null; - - /* - private int nbUpdateCycles = 0; - private int nbUpdates = 0; - private int nbReasoningCycles = 0; - private int uses = 0; - private int nbQueries = 0; - private int nbUniqueQueries = 0; - private int nbQueriesNoCache = 0; - private long timeForQueries = 0; - private long timeForUpdates = 0; - - private float p = 0; - private Set<String> uniqueQueries = new HashSet<String>(); - private Set<String> lastUniqueQueries = null; - - private static int nbAgs = -1; - */ - protected Logger logger = null; public QueryCacheSimple(Agent ag, QueryProfiling p) { - //this.ag = ag; this.prof = p; logger = Logger.getLogger(QueryCacheSimple.class.getName()+"-"+ag.getTS().getUserAgArch().getAgName()); cache = new HashMap<Literal,List<Unifier>>(); @@ -61,124 +40,4 @@ cache.put(f, r); } - /* - public void newReasoningCycle(int n) { - nbReasoningCycles = n; - } - - public void newUpdateCycle(int n, int u, long time) { - nbUpdateCycles++; // = n; - nbUpdates += u; - - timeForUpdates += time; - - //System.out.println("counting "+uniqueQueries+" cache="+cache); - - int uqSize = uniqueQueries.size(); - //System.out.println(lastUniqueQueries+" intersect "+uniqueQueries); - if (lastUniqueQueries != null) { - if (uqSize != 0) { - lastUniqueQueries.retainAll(uniqueQueries); - p += (float)lastUniqueQueries.size()/uqSize; - //System.out.println("******* "+lastUniqueQueries.size()+"/"+uqSize+"="+(float)lastUniqueQueries.size()/uqSize+ " : "+p); - //if (lastUniqueQueries.size() > uqSize) { - // System.out.println(" ***** "+lastUniqueQueries+" intersect "+uniqueQueries); - //} - } - } - nbUniqueQueries += uqSize; - - lastUniqueQueries = uniqueQueries; - cache.clear(); - uniqueQueries = new HashSet<String>(); - - if (nbAgs < 0) - try { - nbAgs = ag.getTS().getUserAgArch().getRuntimeServices().getAgentsQty(); - } catch (Exception e) { - logger.fine("Error getting number of agents: "+e); - } - } -*/ - - /* - public static int nbStops = 0; - public static float nT = 0; - public static float pT = 0; - public static float uT = 0; - public static float cqryT = 0; - public static float cupdT = 0; - //private static int nbCyclesT = 0; - private static float usesT = 0; - private static float nbQueriesT = 0; - private static float nbUniqueQueriesT = 0; - private static int nbAgsT = 0; - private static int nbupdateCyclesT = 0; - - public int getNbUses() { - return uses; - } - - public float getP() { - return p; - } - - public void newQueryStared(Literal l) { - uniqueQueries.add(l.toString()); - nbQueries++; - } - - public void addQueryTime(long ns) { - nbQueriesNoCache++; - timeForQueries += ns; - } - - public void stop() { - float N = (float)nbQueries/nbUpdateCycles; - float K = (float)nbUniqueQueries/nbUpdateCycles; - float n = N/K; - float u = (float)nbUpdates/nbUpdateCycles; - float cqry = (float)timeForQueries/nbQueriesNoCache; - float cupd = (float)timeForUpdates/nbUpdateCycles; - - p = p / nbUpdateCycles; - - if (K>0) { - nbAgsT++; - nbQueriesT += N; - nbUniqueQueriesT += K; - nT += n; - pT += p; - uT += u; - cqryT += cqry; - cupdT += cupd; - usesT += ((float)uses/nbUpdateCycles); - nbupdateCyclesT += nbUpdateCycles; - } - - logger.info("Number of update cycles : "+nbUpdateCycles); - logger.info("Number of reasoning cycles : "+nbReasoningCycles); - logger.info("Queries by cycle (N) : "+ N); - logger.info("Number of unique queries by cycle (K) : "+ K); - logger.info("N/K (n) : "+ n); - logger.info("% queries from last cycle (p) : "+ p); - logger.info("Query cost (Cqry) : "+ cqry+ " ns"); - logger.info("Number of updates by cycle (U) : "+ u); - logger.info("Update cost (Cupd) : "+ cupd+ " ns"); - logger.info("Query cache reused by cycle : "+ (float)uses/nbUpdateCycles); - - nbStops++; - if (nbStops == nbAgs) { - logger.info("* Number of reasoning cycles : "+ nbupdateCyclesT/nbAgsT); - logger.info("* Queries by cycle (N) : "+ nbQueriesT/nbAgsT); - logger.info("* Number of unique queries by cycle (K) : "+ nbUniqueQueriesT/nbAgsT); - logger.info("* N/K (n) : "+ nT/nbAgsT); - logger.info("* % queries from last cycle (p) : "+ pT/nbAgsT); - logger.info("* Query cost (Cqry) : "+ (cqry/nbAgsT)+ " ns"); - logger.info("* Number of updates by cycle (U) : "+ uT/nbAgsT); - logger.info("* Update cost (Cupd) : "+ (cupdT/nbAgsT)+ " ns"); - logger.info("* Query cache reused by cycle : "+ usesT/nbAgsT); - } - - } */ } Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java =================================================================== --- trunk/src/jason/asSyntax/InternalActionLiteral.java 2012-10-17 20:21:33 UTC (rev 1714) +++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2012-12-07 10:51:06 UTC (rev 1715) @@ -24,7 +24,7 @@ package jason.asSyntax; import jason.asSemantics.Agent; -import jason.asSemantics.CacheKey; +import jason.asSemantics.QueryCacheKey; import jason.asSemantics.InternalAction; import jason.asSemantics.QueryCacheAdv; import jason.asSemantics.Unifier; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-10-17 20:21:42
|
Revision: 1714 http://jason.svn.sourceforge.net/jason/?rev=1714&view=rev Author: jomifred Date: 2012-10-17 20:21:33 +0000 (Wed, 17 Oct 2012) Log Message: ----------- initial implementation of query cache for jason Modified Paths: -------------- trunk/applications/as-unit-test/src/example/TestExampleEnvironment.java trunk/build.xml trunk/demos/idle/idle.mas2j trunk/demos/idle/idleag.asl trunk/examples/blocks-world/BlocksEnv/BlocksWorld.java trunk/examples/blocks-world/BlocksEnv/WorldModel.java trunk/release-notes.txt trunk/src/jason/architecture/AgArch.java trunk/src/jason/asSemantics/Agent.java trunk/src/jason/asSemantics/Unifier.java trunk/src/jason/asSyntax/DefaultTerm.java trunk/src/jason/asSyntax/InternalActionLiteral.java trunk/src/jason/asSyntax/Literal.java trunk/src/jason/asSyntax/LiteralImpl.java trunk/src/jason/asSyntax/LogExpr.java trunk/src/jason/asSyntax/Structure.java trunk/src/jason/asSyntax/Term.java trunk/src/jason/asSyntax/VarTerm.java trunk/src/jason/functions/Length.java trunk/src/jason/runtime/Settings.java trunk/src/test/BeliefBaseTest.java trunk/src/test/TermTest.java Added Paths: ----------- trunk/src/jason/asSemantics/QueryCacheAdv.java trunk/src/jason/asSemantics/QueryCacheSimple.java trunk/src/jason/profiling/ trunk/src/jason/profiling/QueryProfiling.java trunk/src/jason/util/Pair.java Modified: trunk/applications/as-unit-test/src/example/TestExampleEnvironment.java =================================================================== --- trunk/applications/as-unit-test/src/example/TestExampleEnvironment.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/applications/as-unit-test/src/example/TestExampleEnvironment.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -43,6 +43,6 @@ @Test(timeout=3000) public void testAction() { ag.addGoal("start"); // add a new goal for the agent - ag.assertAct("a1", 10); // the agent have to perform 'a1' in 10 reasoning cycles + ag.assertAct("a1", 20); // the agent have to perform 'a1' in 10 reasoning cycles } } Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/build.xml 2012-10-17 20:21:33 UTC (rev 1714) @@ -12,7 +12,7 @@ <property name="dist.properties" value="${basedir}/bin/dist.properties" /> <property name="version" value="1" /> - <property name="release" value="3.8" /> + <property name="release" value="3.9-alpha" /> <property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" /> <property name="distFile" value="${env.HOME}/Jason-${version}.${release}" /> Modified: trunk/demos/idle/idle.mas2j =================================================================== --- trunk/demos/idle/idle.mas2j 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/demos/idle/idle.mas2j 2012-10-17 20:21:33 UTC (rev 1714) @@ -1,6 +1,6 @@ MAS idle_demo { - agents: - idleag [verbose=0]; - sender; -} \ No newline at end of file + agents: + idleag [verbose=0]; + sender; +} Modified: trunk/demos/idle/idleag.asl =================================================================== --- trunk/demos/idle/idleag.asl 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/demos/idle/idleag.asl 2012-10-17 20:21:33 UTC (rev 1714) @@ -3,7 +3,7 @@ +hi(X)[source(A)] <- .println; .println("hi ",A," ",X); .println. -+!jag_sleeping <- .println("i am going to sleep"). ++!jag_sleeping <- .println("i am going to have a pleasant idleness"). +!jag_awaking <- .println("i am back"). //^!jag_sleeping[state(S)] <- .print("sleep goal state is ",S). Modified: trunk/examples/blocks-world/BlocksEnv/BlocksWorld.java =================================================================== --- trunk/examples/blocks-world/BlocksEnv/BlocksWorld.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/examples/blocks-world/BlocksEnv/BlocksWorld.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -71,7 +71,7 @@ switch (w) { case 1: model = WorldModel.world1(); break; case 2: model = WorldModel.world2(); break; - case 3: model = WorldModel.world2(); break; + case 3: model = WorldModel.world3(); break; default: logger.info("Invalid index!"); return; Modified: trunk/examples/blocks-world/BlocksEnv/WorldModel.java =================================================================== --- trunk/examples/blocks-world/BlocksEnv/WorldModel.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/examples/blocks-world/BlocksEnv/WorldModel.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -2,6 +2,7 @@ import jason.environment.grid.GridWorldModel; +import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Stack; @@ -89,7 +90,8 @@ stackList.remove(aS); } modelToGrid(); - view.update(); + if (view != null) + view.update(); return true; } @@ -103,6 +105,7 @@ model.names = new String[GWidth][GHeight]; Stack<String> s1 = new Stack<String>(); + s1.addAll(Arrays.asList(new String[] {"table", "c", "b", "a"})); s1.push("table"); s1.push("c"); s1.push("b"); s1.push("a"); model.stackList.add(s1); Stack<String> s2 = new Stack<String>(); @@ -133,6 +136,15 @@ return model; } + static WorldModel world4() throws Exception { + GWidth =50; + GHeight=10; + WorldModel model = WorldModel.create(GWidth, GHeight, 0); + model.names = new String[GWidth][GHeight]; + model.modelToGrid(); + return model; + } + void modelToGrid() { for (int i=0; i<GWidth; i++) { for (int j=0; j<GHeight-1; j++) { Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/release-notes.txt 2012-10-17 20:21:33 UTC (rev 1714) @@ -18,9 +18,13 @@ starts an idle period, rather than being generated again at every reasoning cycle as with +!idle in previous releases. +- new agent options: + [qcache=cycle]: it enables cache for queries on the same cycle, this could + improve the agent performance in some applications. + [qprofiling=yes]: it generates some statistical data related to queries and is used + to measure the performance of the qcache option - --------------------------- version 1.3.8 Modified: trunk/src/jason/architecture/AgArch.java =================================================================== --- trunk/src/jason/architecture/AgArch.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/architecture/AgArch.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -29,6 +29,7 @@ import jason.asSyntax.Literal; import jason.infra.centralised.CentralisedAgArch; import jason.mas2j.ClassParameters; +import jason.profiling.QueryProfiling; import jason.runtime.RuntimeServicesInfraTier; import jason.runtime.Settings; @@ -146,6 +147,9 @@ * when a new reasoning cycle is starting */ public void reasoningCycleStarting() { + QueryProfiling q = getTS().getAg().getQueryProfiling(); + if (q != null) + q.setNbReasoningCycles(getCycleNumber()); if (successor != null) successor.reasoningCycleStarting(); } Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/asSemantics/Agent.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -47,6 +47,7 @@ import jason.functions.Count; import jason.functions.RuleToFunction; import jason.mas2j.ClassParameters; +import jason.profiling.QueryProfiling; import jason.runtime.Settings; import java.io.File; @@ -101,6 +102,9 @@ private ScheduledExecutorService scheduler = null; + //private QueryCache qCache = null; + private QueryCacheSimple qCache = null; + private QueryProfiling qProfiling = null; protected Logger logger = Logger.getLogger(Agent.class.getName()); @@ -147,6 +151,10 @@ initDefaultFunctions(); if (ts == null) ts = new TransitionSystem(this, null, null, new AgArch()); + + //if (ts.getSettings().hasQueryCache()) qCache = new QueryCache(this); + if (ts.getSettings().hasQueryProfiling()) qProfiling = new QueryProfiling(this); + if (ts.getSettings().hasQueryCache()) qCache = new QueryCacheSimple(this, qProfiling); } @@ -233,7 +241,9 @@ public void stopAg() { bb.stop(); - + if (qProfiling != null) + qProfiling.show(); + if (scheduler != null) scheduler.shutdownNow(); } @@ -644,12 +654,10 @@ return; } - /*long startTime; - if (logger.isLoggable(Level.FINE)) { - startTime = System.nanoTime(); - } else { - startTime = 0; - }*/ + // stat + int adds = 0; + int dels = 0; + long startTime = System.nanoTime(); // deleting percepts in the BB that is not perceived anymore Iterator<Literal> perceptsInBB = getBB().getPercepts(); @@ -675,6 +683,7 @@ } } if (!wasPerceived) { + dels++; // new version (it is sure that l is in BB, only clone l when the event is relevant) perceptsInBB.remove(); // remove l as perception from BB @@ -707,6 +716,7 @@ lp = lp.copy().forceFullLiteralImpl(); lp.addAnnot(BeliefBase.TPercept); if (getBB().add(lp)) { + adds++; Trigger te = new Trigger(TEOperator.add, TEType.belief, lp); ts.updateEvents(new Event(te, Intention.EmptyInt)); } @@ -715,10 +725,19 @@ } } - //if (logger.isLoggable(Level.FINE)) - // logger.fine("Finished BUF for "+percepts+" in "+(System.nanoTime()-startTime)+" nanoseconds"); + if (qCache != null) + qCache.reset(); + if (qProfiling != null) + qProfiling.newUpdateCycle(getTS().getUserAgArch().getCycleNumber(), adds+dels, System.nanoTime()-startTime); } + public QueryCacheSimple getQueryCache() { + return qCache; + } + public QueryProfiling getQueryProfiling() { + return qProfiling; + } + /** * Returns true if BB contains the literal <i>bel</i> (using unification to test). * The unifier <i>un</i> is updated by the method. @@ -808,7 +827,6 @@ result[1] = Collections.singletonList(beliefToDel); } } - } } catch (Exception e) { logger.log(Level.WARNING, "Error at BRF.",e); Added: trunk/src/jason/asSemantics/QueryCacheAdv.java =================================================================== --- trunk/src/jason/asSemantics/QueryCacheAdv.java (rev 0) +++ trunk/src/jason/asSemantics/QueryCacheAdv.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -0,0 +1,243 @@ +package jason.asSemantics; + +import jason.asSyntax.Literal; +import jason.asSyntax.PredicateIndicator; +import jason.profiling.QueryProfiling; +import jason.util.Pair; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.logging.Logger; + +public class QueryCacheAdv { + + private Agent ag; + private Map<PredicateIndicator, List<Pair<Literal,List<Unifier>>>> cache = null; + private Map<PredicateIndicator, List<Pair<Literal,List<Unifier>>>> tmp = null; + private Set<CacheKey> noCache = null; + + private QueryProfiling prof; + + protected Logger logger = null; + + public QueryCacheAdv(Agent ag, QueryProfiling p) { + this.ag = ag; + this.prof = p; + logger = Logger.getLogger(QueryCacheAdv.class.getName()+"-"+ag.getTS().getUserAgArch().getAgName()); + cache = new HashMap<PredicateIndicator, List<Pair<Literal,List<Unifier>>>>(); + tmp = new HashMap<PredicateIndicator, List<Pair<Literal,List<Unifier>>>>(); + noCache = new HashSet<CacheKey>(); + } + + public void reset() { + cache.clear(); + tmp.clear(); + noCache.clear(); + } + + public Pair<Literal,Iterator<Unifier>> getCache(final Literal f) { + List<Pair<Literal,List<Unifier>>> opts = cache.get(f.getPredicateIndicator()); + if (opts != null) { + //System.out.println("options for "+f+" are "+opts); + // TODO: sort the opts lists as more specific are tried first + for (Pair<Literal,List<Unifier>> ic: opts) { // for each possible entry in the cache + //System.out.println(" try opt "+ic+" "+new Unifier().unifies(f, ic.getFirst()) + " "+f.isMoreGeneral(ic.getFirst())); + if (new Unifier().unifies(f, ic.getFirst()) && ic.getFirst().subsumes(f)) { + if (prof != null) + prof.incHits(); + //System.out.println("reuse "+opts+" for "+f); + return new Pair<Literal,Iterator<Unifier>>(ic.getFirst(),ic.getSecond().iterator()); + + } + } + } + + List<Pair<Literal,List<Unifier>>> optsTmp = tmp.get(f.getPredicateIndicator()); + if (optsTmp != null && !noCache.contains(new CacheKey(f))) { + for (Pair<Literal,List<Unifier>> ic: optsTmp) { // for each possible entry in the cache + //System.out.println(" try opt tmp "+ic+" "+new Unifier().unifies(f, ic.getFirst()) + " "+f.subsumes(ic.getFirst())); + if (new Unifier().unifies(f, ic.getFirst()) && ic.getFirst().subsumes(f)) { + //System.out.println(" potential use for "+f+" with "+ic); + if (prof != null) + prof.incHits(); + final Literal lTmp = ic.getFirst(); + final List<Unifier> listTmp = ic.getSecond(); + final int listSize = listTmp.size(); + + noCache.add(new CacheKey(lTmp)); + + // use already obtained solutions + return new Pair<Literal,Iterator<Unifier>>(lTmp,new Iterator<Unifier>() { + Iterator<Unifier> i = null; + int iTmp = 0; + boolean fromTmp = true; + + public boolean hasNext() { + boolean hn = iTmp < listSize; + if (hn) { + return true; + } else if (fromTmp) { + fromTmp = false; + //System.out.println("now on from logCons for "+f+" using "+ct.getFirst()); + // stop using tmp and use logCons + i = lTmp.logicalConsequence(ag, new Unifier()); + // skip the elements in tmp cache + for (int c=0; c<listSize; c++) + i.next(); + } + hn = i != null && i.hasNext(); // use new iterator to compute hasNext + if (!hn) { + queryFinished(lTmp); + //noCache.remove(new CacheKey(lTmp)); + } + return hn; + } + public Unifier next() { + if (fromTmp) { + //System.out.println(" from tmp "+listTmp.get(iTmp)+" cache="+fromTmp); + return listTmp.get(iTmp++); + } else { + Unifier a = i.next(); + //System.out.println(" from tmp "+a+" cache="+fromTmp); + listTmp.add(a); + return a; + } + } + public void remove() { } + }); + + } + } + } + return null; + } + + public void addAnswer(Literal f, Unifier a) { + if (noCache.contains(new CacheKey(f))) + return; + + List<Unifier> ans = null; + List<Pair<Literal,List<Unifier>>> opts = tmp.get(f.getPredicateIndicator()); + if (opts == null) { + opts = new ArrayList<Pair<Literal,List<Unifier>>>(); + tmp.put(f.getPredicateIndicator(), opts); + } else { + for (Pair<Literal,List<Unifier>> ic: opts) { // for each possible entry in the cache + if (f.equals(ic.getFirst())) { + ans = ic.getSecond(); + break; + } + } + } + if (ans == null) { + ans = new ArrayList<Unifier>(); + opts.add(new Pair<Literal, List<Unifier>>(f,ans)); + } + //System.out.println(" add "+a+" for "+f); + ans.add(a); + } + + + public void queryFinished(Literal f) { + List<Pair<Literal,List<Unifier>>> opts = tmp.get(f.getPredicateIndicator()); + if (opts != null) { + Iterator<Pair<Literal,List<Unifier>>> i = opts.iterator(); + while (i.hasNext()) { + Pair<Literal,List<Unifier>> ic = i.next(); + if (f.equals(ic.getFirst())) { + i.remove(); + + List<Pair<Literal,List<Unifier>>> optsCache = cache.get(f.getPredicateIndicator()); + if (optsCache == null) { + optsCache = new ArrayList<Pair<Literal,List<Unifier>>>(); + cache.put(f.getPredicateIndicator(), optsCache); + } + optsCache.add(ic); + //System.out.println("finished "+f+" with "+ic); + return; + } + } + } + } + + @Override + public String toString() { + StringBuilder out = new StringBuilder(); + out.append("In cache:\n"); + for (List<Pair<Literal,List<Unifier>>> q: cache.values()) { + for (Pair<Literal,List<Unifier>> ic: q) { + out.append(" "+ic.getFirst()+": "+ic.getSecond()+"\n"); + } + } + out.append("In cache (but not finished):\n"); + for (List<Pair<Literal,List<Unifier>>> q: tmp.values()) { + for (Pair<Literal,List<Unifier>> ic: q) { + out.append(" "+ic.getFirst()+": "+ic.getSecond()+"\n"); + } + } + return out.toString(); + } + /* + public Iterator<Unifier> queryFilter(final CacheKey f, final Iterator<Unifier> iun) { + // store results in the cache + return new Iterator<Unifier>() { + public boolean hasNext() { + if (iun.hasNext()) + return true; + else { + //ag.getLogger().info("finished query "+f); + queryFinished(f); + return false; + } + } + public Unifier next() { + Unifier n = iun.next(); + addAnswer(f, n); + return n; + } + public void remove() { } + }; + } + */ + //private static Unifier emptyUnif = new Unifier(); + /*public CacheKey prepareForCache(Literal l, Unifier u) { + nbQueries++; + */ + /*Map<VarTerm, Integer> all = new HashMap<VarTerm, Integer>(); + l.countVars(all); + Unifier newu = new Unifier(); + for (VarTerm v: u) { + if (!v.isUnnamedVar() && all.containsKey(v)) { + Term vl = u.get(v); + if (vl != null) + newu.bind(v, u.get(v)); + } + } + //System.out.println(l+"="+u+" .... "+newu); + return new Pair<LogicalFormula,Unifier>(l,newu); + */ + /*l = l.copy(); + l.apply(u); + */ + // TODO: use special compare, unvalued vars are equals. + //return new Pair<LogicalFormula,Unifier>(new LiteralEqualWrapper(l),emptyUnif); + /* return new CacheKey(l,u); + }*/ + /* + public Pair prepareForCache(LogExpr l, Unifier u) { + LogExpr nl = (LogExpr)l.clone(); + try { + nl.apply(u); + //ag.getLogger().info(l+" *** prep = "+nl); + return nl; + } catch (Exception e) { + return null; + } + }*/ + +} Added: trunk/src/jason/asSemantics/QueryCacheSimple.java =================================================================== --- trunk/src/jason/asSemantics/QueryCacheSimple.java (rev 0) +++ trunk/src/jason/asSemantics/QueryCacheSimple.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -0,0 +1,184 @@ +package jason.asSemantics; + +import jason.asSyntax.Literal; +import jason.profiling.QueryProfiling; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +public class QueryCacheSimple { + + //private Agent ag; + private QueryProfiling prof; + + private Map<Literal, List<Unifier>> cache = null; + + /* + private int nbUpdateCycles = 0; + private int nbUpdates = 0; + private int nbReasoningCycles = 0; + private int uses = 0; + private int nbQueries = 0; + private int nbUniqueQueries = 0; + private int nbQueriesNoCache = 0; + private long timeForQueries = 0; + private long timeForUpdates = 0; + + private float p = 0; + private Set<String> uniqueQueries = new HashSet<String>(); + private Set<String> lastUniqueQueries = null; + + private static int nbAgs = -1; + */ + + protected Logger logger = null; + + public QueryCacheSimple(Agent ag, QueryProfiling p) { + //this.ag = ag; + this.prof = p; + logger = Logger.getLogger(QueryCacheSimple.class.getName()+"-"+ag.getTS().getUserAgArch().getAgName()); + cache = new HashMap<Literal,List<Unifier>>(); + } + + public void reset() { + cache.clear(); + } + + public Iterator<Unifier> getCache(final Literal f) { + List<Unifier> l = cache.get(f); + if (l == null) + return null; + if (prof != null) + prof.incHits(); + return l.iterator(); + } + + public void queryFinished(Literal f, List<Unifier> r) { + //System.out.println("finished "+f+" with "+r); + cache.put(f, r); + } + + /* + public void newReasoningCycle(int n) { + nbReasoningCycles = n; + } + + public void newUpdateCycle(int n, int u, long time) { + nbUpdateCycles++; // = n; + nbUpdates += u; + + timeForUpdates += time; + + //System.out.println("counting "+uniqueQueries+" cache="+cache); + + int uqSize = uniqueQueries.size(); + //System.out.println(lastUniqueQueries+" intersect "+uniqueQueries); + if (lastUniqueQueries != null) { + if (uqSize != 0) { + lastUniqueQueries.retainAll(uniqueQueries); + p += (float)lastUniqueQueries.size()/uqSize; + //System.out.println("******* "+lastUniqueQueries.size()+"/"+uqSize+"="+(float)lastUniqueQueries.size()/uqSize+ " : "+p); + //if (lastUniqueQueries.size() > uqSize) { + // System.out.println(" ***** "+lastUniqueQueries+" intersect "+uniqueQueries); + //} + } + } + nbUniqueQueries += uqSize; + + lastUniqueQueries = uniqueQueries; + cache.clear(); + uniqueQueries = new HashSet<String>(); + + if (nbAgs < 0) + try { + nbAgs = ag.getTS().getUserAgArch().getRuntimeServices().getAgentsQty(); + } catch (Exception e) { + logger.fine("Error getting number of agents: "+e); + } + } +*/ + + /* + public static int nbStops = 0; + public static float nT = 0; + public static float pT = 0; + public static float uT = 0; + public static float cqryT = 0; + public static float cupdT = 0; + //private static int nbCyclesT = 0; + private static float usesT = 0; + private static float nbQueriesT = 0; + private static float nbUniqueQueriesT = 0; + private static int nbAgsT = 0; + private static int nbupdateCyclesT = 0; + + public int getNbUses() { + return uses; + } + + public float getP() { + return p; + } + + public void newQueryStared(Literal l) { + uniqueQueries.add(l.toString()); + nbQueries++; + } + + public void addQueryTime(long ns) { + nbQueriesNoCache++; + timeForQueries += ns; + } + + public void stop() { + float N = (float)nbQueries/nbUpdateCycles; + float K = (float)nbUniqueQueries/nbUpdateCycles; + float n = N/K; + float u = (float)nbUpdates/nbUpdateCycles; + float cqry = (float)timeForQueries/nbQueriesNoCache; + float cupd = (float)timeForUpdates/nbUpdateCycles; + + p = p / nbUpdateCycles; + + if (K>0) { + nbAgsT++; + nbQueriesT += N; + nbUniqueQueriesT += K; + nT += n; + pT += p; + uT += u; + cqryT += cqry; + cupdT += cupd; + usesT += ((float)uses/nbUpdateCycles); + nbupdateCyclesT += nbUpdateCycles; + } + + logger.info("Number of update cycles : "+nbUpdateCycles); + logger.info("Number of reasoning cycles : "+nbReasoningCycles); + logger.info("Queries by cycle (N) : "+ N); + logger.info("Number of unique queries by cycle (K) : "+ K); + logger.info("N/K (n) : "+ n); + logger.info("% queries from last cycle (p) : "+ p); + logger.info("Query cost (Cqry) : "+ cqry+ " ns"); + logger.info("Number of updates by cycle (U) : "+ u); + logger.info("Update cost (Cupd) : "+ cupd+ " ns"); + logger.info("Query cache reused by cycle : "+ (float)uses/nbUpdateCycles); + + nbStops++; + if (nbStops == nbAgs) { + logger.info("* Number of reasoning cycles : "+ nbupdateCyclesT/nbAgsT); + logger.info("* Queries by cycle (N) : "+ nbQueriesT/nbAgsT); + logger.info("* Number of unique queries by cycle (K) : "+ nbUniqueQueriesT/nbAgsT); + logger.info("* N/K (n) : "+ nT/nbAgsT); + logger.info("* % queries from last cycle (p) : "+ pT/nbAgsT); + logger.info("* Query cost (Cqry) : "+ (cqry/nbAgsT)+ " ns"); + logger.info("* Number of updates by cycle (U) : "+ uT/nbAgsT); + logger.info("* Update cost (Cupd) : "+ (cupdT/nbAgsT)+ " ns"); + logger.info("* Query cache reused by cycle : "+ usesT/nbAgsT); + } + + } */ +} Modified: trunk/src/jason/asSemantics/Unifier.java =================================================================== --- trunk/src/jason/asSemantics/Unifier.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/asSemantics/Unifier.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -37,13 +37,14 @@ import jason.asSyntax.VarTerm; import java.util.HashMap; +import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; import org.w3c.dom.Document; import org.w3c.dom.Element; -public class Unifier implements Cloneable { +public class Unifier implements Cloneable, Iterable<VarTerm> { private static Logger logger = Logger.getLogger(Unifier.class.getName()); @@ -75,6 +76,9 @@ return function.remove(v); } + public Iterator<VarTerm> iterator() { + return function.keySet().iterator(); + } /** * gets the value for a Var, if it is unified with another var, gets this * other's value @@ -366,6 +370,15 @@ } } + @Override + public int hashCode() { + int s = 0; + for (VarTerm v: function.keySet()) { + s += v.hashCode(); + } + return s * 31; + } + public boolean equals(Object o) { if (o == null) return false; if (o == this) return true; Modified: trunk/src/jason/asSyntax/DefaultTerm.java =================================================================== --- trunk/src/jason/asSyntax/DefaultTerm.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/asSyntax/DefaultTerm.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -103,6 +103,14 @@ return this.toString().compareTo(t.toString()); } + public boolean subsumes(Term l) { + if (l.isVar()) + return false; + else + return true; + } + + public boolean apply(Unifier u) { return false; } Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java =================================================================== --- trunk/src/jason/asSyntax/InternalActionLiteral.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -24,7 +24,9 @@ package jason.asSyntax; import jason.asSemantics.Agent; +import jason.asSemantics.CacheKey; import jason.asSemantics.InternalAction; +import jason.asSemantics.QueryCacheAdv; import jason.asSemantics.Unifier; import java.util.ConcurrentModificationException; @@ -42,7 +44,7 @@ @navassoc - ia - InternalAction */ -public class InternalActionLiteral extends Structure { +public class InternalActionLiteral extends Structure implements LogicalFormula { private static final long serialVersionUID = 1L; private static Logger logger = Logger.getLogger(InternalActionLiteral.class.getName()); @@ -80,13 +82,41 @@ public Iterator<Unifier> logicalConsequence(Agent ag, Unifier un) { if (ag == null || ag.getTS().getUserAgArch().isRunning()) { try { + /*final QueryCache qCache; + final CacheKey kForChache; + if (ag != null) { + qCache = ag.getQueryCache(); + if (qCache != null) { + kForChache = qCache.prepareForCache(this, un); + Iterator<Unifier> ic = qCache.getCache(kForChache); + if (ic != null) { + //ag.getLogger().info("from cache internal action "+this); + return ic; + } + } else { + kForChache = null; + } + } else { + qCache = null; + kForChache = null; + }*/ + InternalAction ia = getIA(ag); // calls IA's execute method Object oresult = ia.execute(ag.getTS(), un, ia.prepareArguments(this, un)); if (oresult instanceof Boolean && (Boolean)oresult) { + /*if (kForChache != null) { + qCache.addAnswer(kForChache, un); + qCache.queryFinished(kForChache); + }*/ return LogExpr.createUnifIterator(un); } else if (oresult instanceof Iterator) { - return ((Iterator<Unifier>)oresult); + //if (kForChache == null) { + return ((Iterator<Unifier>)oresult); + /*} else { + // add a wrapper to collect results into the cache + return qCache.queryFilter(kForChache, (Iterator<Unifier>)oresult); + }*/ } } catch (ConcurrentModificationException e) { System.out.println("*-*-* .count concurrent exception - try later"); Modified: trunk/src/jason/asSyntax/Literal.java =================================================================== --- trunk/src/jason/asSyntax/Literal.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/asSyntax/Literal.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -26,8 +26,10 @@ import jason.JasonException; import jason.architecture.AgArch; import jason.asSemantics.Agent; +import jason.asSemantics.QueryCacheSimple; import jason.asSemantics.Unifier; import jason.asSyntax.parser.as2j; +import jason.profiling.QueryProfiling; import java.io.StringReader; import java.util.ArrayList; @@ -191,6 +193,7 @@ public boolean equalsAsStructure(Object p) { return false; } + /* Not implemented methods */ // structure @@ -247,7 +250,6 @@ /** changes the negation of the literal and return this */ public Literal setNegated(boolean b) { logger.log(Level.SEVERE, "setNegated is not implemented in the class "+this.getClass().getSimpleName(), new Exception()); return null; } - /** * logicalConsequence checks whether one particular predicate * is a logical consequence of the belief base. @@ -255,13 +257,23 @@ * Returns an iterator for all unifiers that are logCons. */ public Iterator<Unifier> logicalConsequence(final Agent ag, final Unifier un) { - /*final long startTime; - if (logger.isLoggable(Level.FINE)) { - logger.fine("Starting logicalConsequence for "+this+" unifier= "+un); - startTime = System.nanoTime(); + final QueryProfiling qProfiling; + final QueryCacheSimple qCache; + final long startTime; + if (ag != null) { + qCache = ag.getQueryCache(); + qProfiling = ag.getQueryProfiling(); + if (qProfiling != null) { + qProfiling.queryStared(this); + startTime = System.nanoTime(); + } else { + startTime = 0; + } } else { - startTime = 0; - }*/ + qCache = null; + qProfiling = null; + startTime = 0; + } final Iterator<Literal> il = ag.getBB().getCandidateBeliefs(this, un); if (il == null) // no relevant bels @@ -280,23 +292,32 @@ Iterator<List<Term>> annotsOptions = null; Literal belInBB = null; + Literal kForChache = null; + Iterator<Unifier> cacheIt = null; + //Literal cacheLit = null; + //Unifier cacheUn = null; + List<Unifier> cacheResults = null; + public boolean hasNext() { if (needsUpdate) get(); - //if (logger.isLoggable(Level.FINE)) - // logger.fine("hasNext logicalConsequence for "+Literal.this+" answer is "+(current != null)+" in "+(System.nanoTime()-startTime)+" ns"); + + if (current == null) { // end of query + if (qCache != null && cacheResults != null) + qCache.queryFinished(kForChache, cacheResults); + if (qProfiling != null) + qProfiling.queryFinished(Literal.this, System.nanoTime() - startTime); + } + return current != null; } public Unifier next() { if (needsUpdate) get(); - Unifier a = current; if (current != null) needsUpdate = true; - //if (logger.isLoggable(Level.FINE)) - // logger.fine("next logicalConsequence for "+Literal.this+" answer is "+a+" in "+(System.nanoTime()-startTime)+" ns"); - return a; + return current; } private void get() { @@ -304,33 +325,66 @@ current = null; if (arch != null && !arch.isRunning()) return; + // try cache iterator + if (cacheIt != null) { + while (cacheIt.hasNext()) { + Literal ltmp = Literal.this.copy(); + ltmp.apply( cacheIt.next() ); + Unifier u = un.clone(); + //System.out.println(" try "+ltmp); + if (u.unifiesNoUndo(Literal.this, ltmp)) { + //System.out.println(" - ans from cache "+Literal.this+": "+u); + current = u; + return; + } + } + cacheIt = null; + return; // do not try others after cache + } + + // try annots iterator - while (annotsOptions != null && annotsOptions.hasNext()) { - Literal belToTry = belInBB.copy().setAnnots(null).addAnnots( annotsOptions.next() ); - - Unifier u = un.clone(); - if (u.unifiesNoUndo(Literal.this, belToTry)) { - current = u; - return; - } + if (annotsOptions != null) { + while (annotsOptions.hasNext()) { + Literal belToTry = belInBB.copy().setAnnots(null).addAnnots( annotsOptions.next() ); + + Unifier u = un.clone(); + if (u.unifiesNoUndo(Literal.this, belToTry)) { + current = u; + return; + } + } + annotsOptions = null; } // try rule iterator - while (ruleIt != null && ruleIt.hasNext()) { - // unifies the rule head with the result of rule evaluation - Unifier ruleUn = ruleIt.next(); // evaluation result - Literal rhead = rule.headClone(); - rhead.apply(ruleUn); - useDerefVars(rhead, ruleUn); // replace vars by the bottom in the var clusters (e.g. X=_2; Y=_2, a(X,Y) ===> A(_2,_2)) - rhead.makeVarsAnnon(); // to remove vars in head with original names - - Unifier unC = un.clone(); - if (unC.unifiesNoUndo(Literal.this, rhead)) { - current = unC; - return; + if (ruleIt != null) { + while (ruleIt.hasNext()) { + // unifies the rule head with the result of rule evaluation + Unifier ruleUn = ruleIt.next(); // evaluation result + Literal rhead = rule.headClone(); + rhead.apply(ruleUn); + useDerefVars(rhead, ruleUn); // replace vars by the bottom in the var clusters (e.g. X=_2; Y=_2, a(X,Y) ===> A(_2,_2)) + rhead.makeVarsAnnon(); // to remove vars in head with original names + + Unifier unC = un.clone(); + if (unC.unifiesNoUndo(Literal.this, rhead)) { + current = unC; + /*if (kForChache != null) { + Unifier uforC = new Unifier(); + if (uforC.unifiesNoUndo(kForChache, rhead)) + qCache.addAnswer(kForChache, uforC); + cacheResults.add(uforC); + }*/ + //System.out.println(" sol:"+unC+ " "+cacheResults); + if (cacheResults != null) + cacheResults.add(unC); + return; + } } + ruleIt = null; } - + // try literal iterator while (il.hasNext()) { belInBB = il.next(); // b is the relevant entry in BB @@ -346,6 +400,35 @@ cloneAnnon.apply(un); cloneAnnon.makeVarsAnnon(); } + + // try cache + if (ag != null && qCache != null) { + /*if (ag != null && qCache != null && kForChache == null) { // try cache only for the first rule (do not use cache for itself) + kForChache = cloneAnnon; + Pair<Literal,Iterator<Unifier>> pair = qCache.getCache(kForChache); + if (pair != null) { + cacheIt = pair.getSecond(); + cacheLit = pair.getFirst(); + //cacheUn = new Unifier(); + //cacheUn.unifies(cacheLit, Literal.this); + //System.out.println("use un "+cacheUn+"/"+cacheLit+" for "+kForChache); + get(); + return; + }*/ + kForChache = Literal.this.copy(); + kForChache.apply(un); + //System.out.println("try "+kForChache); + cacheIt = qCache.getCache(kForChache); + if (cacheIt != null) { + //System.out.println("use cache for "+kForChache); + get(); + if (current != null) // if it get a value + return; + } + //System.out.println("start collecting "+kForChache); + cacheResults = new ArrayList<Unifier>(); + } + Unifier ruleUn = new Unifier(); if (ruleUn.unifiesNoUndo(cloneAnnon, rule)) { // the rule head unifies with the literal ruleIt = rule.getBody().logicalConsequence(ag,ruleUn); @@ -364,7 +447,7 @@ return; } } - } else { + } else { // it is an ordinary query on a belief Unifier u = un.clone(); if (u.unifiesNoUndo(Literal.this, belInBB)) { current = u; Modified: trunk/src/jason/asSyntax/LiteralImpl.java =================================================================== --- trunk/src/jason/asSyntax/LiteralImpl.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/asSyntax/LiteralImpl.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -30,7 +30,7 @@ /** * A Literal extends a Pred with strong negation (~). */ -public class LiteralImpl extends Pred implements LogicalFormula { +public class LiteralImpl extends Pred { private static final long serialVersionUID = 1L; //private static Logger logger = Logger.getLogger(LiteralImpl.class.getName()); Modified: trunk/src/jason/asSyntax/LogExpr.java =================================================================== --- trunk/src/jason/asSyntax/LogExpr.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/asSyntax/LogExpr.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -24,6 +24,8 @@ package jason.asSyntax; import jason.asSemantics.Agent; +import jason.asSemantics.CacheKey; +import jason.asSemantics.QueryCacheAdv; import jason.asSemantics.Unifier; import jason.asSyntax.parser.as2j; @@ -82,6 +84,26 @@ public Iterator<Unifier> logicalConsequence(final Agent ag, final Unifier un) { try { + /*final QueryCache qCache; + final CacheKey kForChache; + if (ag != null && (op == LogicalOp.and || op == LogicalOp.or)) { + qCache = null; //ag.getQueryCache(); + if (qCache != null) { + kForChache = qCache.prepareForCache(this, un); + Iterator<Unifier> ic = qCache.getCache(kForChache); + if (ic != null) { + //ag.getLogger().info("from cache expression!"+this); + return ic; + } + } else { + kForChache = null; + } + } else { + qCache = null; + kForChache = null; + } + */ + switch (op) { case not: @@ -100,15 +122,19 @@ public boolean hasNext() { if (needsUpdate) get(); + //if (kForChache != null && current == null) + // qCache.queryFinished(kForChache); return current != null; } public Unifier next() { if (needsUpdate) get(); - Unifier a = current; + //Unifier a = current; if (current != null) needsUpdate = true; - return a; + //if (kForChache != null) + // qCache.addAnswer(kForChache, current); + return current; } private void get() { needsUpdate = false; @@ -131,15 +157,19 @@ public boolean hasNext() { if (needsUpdate) get(); + //if (kForChache != null && current == null) + // qCache.queryFinished(kForChache); return current != null; } public Unifier next() { if (needsUpdate) get(); - Unifier a = current; + //Unifier a = current; if (current != null) needsUpdate = true; - return a; + //if (kForChache != null) + // qCache.addAnswer(kForChache, current); + return current; } private void get() { needsUpdate = false; Modified: trunk/src/jason/asSyntax/Structure.java =================================================================== --- trunk/src/jason/asSyntax/Structure.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/asSyntax/Structure.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -153,6 +153,25 @@ } @Override + public boolean subsumes(Term t) { + if (t.isStructure()) { + Structure tAsStruct = (Structure)t; + + final int ma = getArity(); + final int oa = tAsStruct.getArity(); + for (int i=0; i<ma && i<oa; i++) { + //System.out.println(getTerm(i)+" comp "+tAsStruct.getTerm(i)+"="+getTerm(i).isMoreGeneral(tAsStruct.getTerm(i))); + if (! getTerm(i).subsumes(tAsStruct.getTerm(i))) + return false; + } + return true; + } else { + return super.subsumes(t); + } + } + + + @Override public boolean apply(Unifier u) { boolean r = false; // do not use iterator! (see ListTermImpl class) Modified: trunk/src/jason/asSyntax/Term.java =================================================================== --- trunk/src/jason/asSyntax/Term.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/asSyntax/Term.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -38,6 +38,8 @@ public boolean equals(Object o); + public boolean subsumes(Term l); + /** replaces variables by their values in the unifier, returns true if some variable was applied */ public boolean apply(Unifier u); Modified: trunk/src/jason/asSyntax/VarTerm.java =================================================================== --- trunk/src/jason/asSyntax/VarTerm.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/asSyntax/VarTerm.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -217,6 +217,14 @@ else return 1; } + + @Override + public boolean subsumes(Term t) { + if (value != null) + return value.subsumes(t); + else + return true; + } // ---------- // Term methods overridden Modified: trunk/src/jason/functions/Length.java =================================================================== --- trunk/src/jason/functions/Length.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/functions/Length.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -41,8 +41,10 @@ return a == 1; } + /* @Override public boolean allowUngroundTerms() { return true; } + */ } Added: trunk/src/jason/profiling/QueryProfiling.java =================================================================== --- trunk/src/jason/profiling/QueryProfiling.java (rev 0) +++ trunk/src/jason/profiling/QueryProfiling.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -0,0 +1,154 @@ +package jason.profiling; + +import jason.asSemantics.Agent; +import jason.asSyntax.Literal; + +import java.util.HashSet; +import java.util.Set; +import java.util.logging.Logger; + +public class QueryProfiling { + + private int nbUpdateCycles = 0; + private int nbUpdates = 0; + private int nbReasoningCycles = 0; + private int nbCacheHits = 0; + private int nbQueries = 0; + private int nbUniqueQueries = 0; + private long timeForQueries = 0; + private long timeForUpdates = 0; + + private float p = 0; // probability of same queries on the next cycle (see ProMAS paper) + + private static int nbAgs = -1; + + protected Logger logger = null; + + private Set<String> uniqueQueries = new HashSet<String>(); + private Set<String> lastUniqueQueries = null; + + private Agent ag; + + public QueryProfiling(Agent ag) { + this.ag = ag; + logger = Logger.getLogger(QueryProfiling.class.getName()+"-"+ag.getTS().getUserAgArch().getAgName()); + } + + public void incHits() { + nbCacheHits++; + } + + public void queryStared(Literal l) { + uniqueQueries.add(l.toString()); + nbQueries++; + } + + public void queryFinished(Literal l, long time) { + timeForQueries += time; + } + + public void setNbReasoningCycles(int n) { + nbReasoningCycles = n; + } + + public void newUpdateCycle(int n, int u, long time) { + nbUpdateCycles++; + nbUpdates += u; + + timeForUpdates += time; + + int uqSize = uniqueQueries.size(); + //System.out.println(lastUniqueQueries+" intersect "+uniqueQueries); + if (lastUniqueQueries != null) { + if (uqSize != 0) { + lastUniqueQueries.retainAll(uniqueQueries); + p += (float)lastUniqueQueries.size()/uqSize; + //System.out.println("******* "+lastUniqueQueries.size()+"/"+uqSize+"="+(float)lastUniqueQueries.size()/uqSize+ " : "+p); + //if (lastUniqueQueries.size() > uqSize) { + // System.out.println(" ***** "+lastUniqueQueries+" intersect "+uniqueQueries); + //} + } + } + nbUniqueQueries += uqSize; + + lastUniqueQueries = uniqueQueries; + uniqueQueries = new HashSet<String>(); + + if (nbAgs < 0) + try { + nbAgs = ag.getTS().getUserAgArch().getRuntimeServices().getAgentsQty(); + } catch (Exception e) { + logger.fine("Error getting number of agents: "+e); + } + } + + public static int nbStops = 0; + public static float nT = 0; + public static float pT = 0; + public static float uT = 0; + public static float cqryT = 0; + public static float cupdT = 0; + //private static int nbCyclesT = 0; + private static float usesT = 0; + private static float nbQueriesT = 0; + private static float nbUniqueQueriesT = 0; + private static int nbAgsT = 0; + private static int nbupdateCyclesT = 0; + + public int getNbUses() { + return nbCacheHits; + } + + public float getP() { + return p; + } + + public void show() { + float N = (float)nbQueries/nbUpdateCycles; + float K = (float)nbUniqueQueries/nbUpdateCycles; + float n = N/K; + float u = (float)nbUpdates/nbUpdateCycles; + float cqry = (float)timeForQueries/nbQueries; + float cupd = (float)timeForUpdates/nbUpdateCycles; + + p = p / nbUpdateCycles; + + if (K>0) { + nbAgsT++; + nbQueriesT += N; + nbUniqueQueriesT += K; + nT += n; + pT += p; + uT += u; + cqryT += cqry; + cupdT += cupd; + usesT += ((float)nbCacheHits/nbUpdateCycles); + nbupdateCyclesT += nbUpdateCycles; + } + + logger.info("Number of update cycles : "+nbUpdateCycles); + logger.info("Number of reasoning cycles : "+nbReasoningCycles); + logger.info("Queries by cycle (N) : "+ N); + logger.info("Number of unique queries by cycle (K) : "+ K); + logger.info("N/K (n) : "+ n); + logger.info("% queries from last cycle (p) : "+ p); + logger.info("Query cost (Cqry) : "+ cqry+ " ns"); + logger.info("Number of updates by cycle (U) : "+ u); + logger.info("Update cost (Cupd) : "+ cupd+ " ns"); + logger.info("Query cache reused by cycle (hits) : "+ (float)nbCacheHits/nbUpdateCycles); + + nbStops++; + if (nbStops == nbAgs) { + logger.info("* Number of reasoning cycles : "+ nbupdateCyclesT/nbAgsT); + logger.info("* Queries by cycle (N) : "+ nbQueriesT/nbAgsT); + logger.info("* Number of unique queries by cycle (K) : "+ nbUniqueQueriesT/nbAgsT); + logger.info("* N/K (n) : "+ nT/nbAgsT); + logger.info("* % queries from last cycle (p) : "+ pT/nbAgsT); + logger.info("* Query cost (Cqry) : "+ (cqry/nbAgsT)+ " ns"); + logger.info("* Number of updates by cycle (U) : "+ uT/nbAgsT); + logger.info("* Update cost (Cupd) : "+ (cupdT/nbAgsT)+ " ns"); + logger.info("* Query cache reused by cycle (hits) : "+ usesT/nbAgsT); + } + + } +} Modified: trunk/src/jason/runtime/Settings.java =================================================================== --- trunk/src/jason/runtime/Settings.java 2012-10-17 17:00:48 UTC (rev 1713) +++ trunk/src/jason/runtime/Settings.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -45,11 +45,13 @@ private static Logger logger = Logger.getLogger(Settings.class.getName()); - private byte events = ODiscard; - private boolean intBels = OSameFocus; - private int nrcbp = ODefaultNRC; - private int verbose = ODefaultVerbose; - private boolean sync = ODefaultSync; + private byte events = ODiscard; + private boolean intBels = OSameFocus; + private int nrcbp = ODefaultNRC; + private int verbose = ODefaultVerbose; + private boolean sync = ODefaultSync; + private boolean qCache = false; // whether to use query cache + private boolean qProfiling = false; // whether has query profiling private Map<String,Object> userParameters = new HashMap<String,Object>(); @@ -105,12 +107,11 @@ setVerbose(verbose); } else if (key.equals("synchronised")) { - String sSync = (String)options.get("synchronised"); - if (sSync.equals("true")) { - setSync(true); - } else { - setSync(false); - } + setSync("true".equals((String)options.get("synchronised"))); + } else if (key.equals("qcache")) { + setQueryCache( "cycle".equals((String)options.get("qcache")) ); + } else if (key.equals("qprofiling")) { + setQueryProfiling( "yes".equals((String)options.get("qprofiling")) ); } else { //userParameters.put(key, options.get(key)); } @@ -199,6 +200,20 @@ sync = pSync; } + public boolean hasQueryCache() { + return qCache; + } + public void setQueryCache(boolean b) { + qCache = b; + } + + public boolean hasQueryProfiling() { + return qProfiling; + } + public void setQueryProfiling(boolean b) { + qProfiling = b; + } + public Map<String,Object> getUserParameters() { return userParameters; } Added: trunk/src/jason/util/Pair.java =================================================================== --- trunk/src/jason/util/Pair.java (rev 0) +++ trunk/src/jason/util/Pair.java 2012-10-17 20:21:33 UTC (rev 1714) @@ -0,0 +1,55 @@ +package jason.util; + + +public class Pair<T1,T2> implements Comparable<Pair<T1,T2>> { + + final T1 o1; + final T2 o2; + int hc; + + public Pair(T1 o1, T2 o2) { + this.o1 = o1; + this.o2 = o2; + hc = (o1.hashCode() + o2.hashCode()) * 31; + } + + public T1 getFirst() { + return o1; + } + + public T2 getSecond() { + return o2; + } + + @Override + public int hashCode() { + return hc; + } + + @SuppressWarnings("rawtypes") + @Override + public boolean equals(Object obj) { + if (obj == null) return false; + if (obj == this) return true; + if (obj instanceof Pair) { + Pair o = (Pair)obj; + return o.o1.equals(this.o1) && o.o2.equals(this.o2); + } + return false; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + p... [truncated message content] |
From: <jom...@us...> - 2012-10-17 17:00:57
|
Revision: 1713 http://jason.svn.sourceforge.net/jason/?rev=1713&view=rev Author: jomifred Date: 2012-10-17 17:00:48 +0000 (Wed, 17 Oct 2012) Log Message: ----------- fix bug reported by Nikolay Ryabykh related to failure handling Modified Paths: -------------- trunk/src/jason/asSemantics/TransitionSystem.java Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2012-09-21 23:38:55 UTC (rev 1712) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2012-10-17 17:00:48 UTC (rev 1713) @@ -850,12 +850,14 @@ // should became // +!s: !z im = i.peek(); - if (im.isFinished() || !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral) || im.getCurrentStep().getBodyTerm() instanceof VarTerm) { + if (im.isFinished() + || !(im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral) && im.getCurrentStep().getBodyType() == BodyType.achieve) + || im.getCurrentStep().getBodyTerm() instanceof VarTerm) { im = i.pop(); // +!c above } while (!i.isFinished() && //i.size() > 0 && - !im.unif.unifies(im.getTrigger().getLiteral(), topLiteral) && - !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral)) { + !(im.unif.unifies(im.getTrigger().getLiteral(), topLiteral) && im.getTrigger().isAchvGoal()) && + !(im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral) && im.getCurrentStep().getBodyType() == BodyType.achieve)) { im = i.pop(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <xsp...@us...> - 2012-09-21 23:39:01
|
Revision: 1712 http://jason.svn.sourceforge.net/jason/?rev=1712&view=rev Author: xsplyter Date: 2012-09-21 23:38:55 +0000 (Fri, 21 Sep 2012) Log Message: ----------- Changed version due new compilation with Java 1.6 instead of 1.7 Modified Paths: -------------- trunk/applications/jason-eclipse-plugin2/jasonide/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml trunk/applications/jason-eclipse-plugin2/jasonide_site/artifacts.jar trunk/applications/jason-eclipse-plugin2/jasonide_site/content.jar trunk/applications/jason-eclipse-plugin2/jasonide_site/logs.zip trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml Modified: trunk/applications/jason-eclipse-plugin2/jasonide/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide/META-INF/MANIFEST.MF 2012-09-17 20:06:15 UTC (rev 1711) +++ trunk/applications/jason-eclipse-plugin2/jasonide/META-INF/MANIFEST.MF 2012-09-21 23:38:55 UTC (rev 1712) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Jasonide Bundle-SymbolicName: jasonide;singleton:=true -Bundle-Version: 1.0.7 +Bundle-Version: 1.0.8 Bundle-Activator: jasonide.Activator Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF 2012-09-17 20:06:15 UTC (rev 1711) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF 2012-09-21 23:38:55 UTC (rev 1712) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: jasonide.xtext.asl Bundle-Vendor: Jason team -Bundle-Version: 1.0.7 +Bundle-Version: 1.0.8 Bundle-SymbolicName: jasonide.xtext.asl; singleton:=true Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.xtext;bundle-version="2.0.0";visibility:=reexport, Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/META-INF/MANIFEST.MF 2012-09-17 20:06:15 UTC (rev 1711) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/META-INF/MANIFEST.MF 2012-09-21 23:38:55 UTC (rev 1712) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: jasonide.xtext.asl.ui Bundle-Vendor: Jason team -Bundle-Version: 1.0.7 +Bundle-Version: 1.0.8 Bundle-SymbolicName: jasonide.xtext.asl.ui; singleton:=true Bundle-ActivationPolicy: lazy Require-Bundle: jasonide.xtext.asl;visibility:=reexport, Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF 2012-09-17 20:06:15 UTC (rev 1711) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF 2012-09-21 23:38:55 UTC (rev 1712) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: jasonide.xtext.mas2j Bundle-Vendor: Jason team -Bundle-Version: 1.0.7 +Bundle-Version: 1.0.8 Bundle-SymbolicName: jasonide.xtext.mas2j; singleton:=true Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.xtext;bundle-version="2.0.0";visibility:=reexport, Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/META-INF/MANIFEST.MF 2012-09-17 20:06:15 UTC (rev 1711) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/META-INF/MANIFEST.MF 2012-09-21 23:38:55 UTC (rev 1712) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: jasonide.xtext.mas2j.ui Bundle-Vendor: Jason team -Bundle-Version: 1.0.7 +Bundle-Version: 1.0.8 Bundle-SymbolicName: jasonide.xtext.mas2j.ui; singleton:=true Bundle-ActivationPolicy: lazy Require-Bundle: jasonide.xtext.mas2j;visibility:=reexport, Modified: trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml 2012-09-17 20:06:15 UTC (rev 1711) +++ trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml 2012-09-21 23:38:55 UTC (rev 1712) @@ -2,7 +2,7 @@ <feature id="jasonide_feature" label="Jasonide_feature" - version="1.0.7.qualifier"> + version="1.0.8.qualifier"> <description url="http://jason.sf.net"> Jason is an interpreter for an extended version of AgentSpeak Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/artifacts.jar =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/content.jar =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/logs.zip =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml 2012-09-17 20:06:15 UTC (rev 1711) +++ trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml 2012-09-21 23:38:55 UTC (rev 1712) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <site> - <feature url="features/jasonide_feature_1.0.7.201207142008.jar" id="jasonide_feature" version="1.0.7.201207142008"> + <feature url="features/jasonide_feature_1.0.8.201209212003.jar" id="jasonide_feature" version="1.0.8.201209212003"> <category name="jasonide"/> </feature> <category-def name="jasonide" label="jasonide"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-09-17 20:06:21
|
Revision: 1711 http://jason.svn.sourceforge.net/jason/?rev=1711&view=rev Author: jomifred Date: 2012-09-17 20:06:15 +0000 (Mon, 17 Sep 2012) Log Message: ----------- improve .delete to accept a term as the second argument Modified Paths: -------------- trunk/src/jason/stdlib/delete.java Modified: trunk/src/jason/stdlib/delete.java =================================================================== --- trunk/src/jason/stdlib/delete.java 2012-08-25 11:35:01 UTC (rev 1710) +++ trunk/src/jason/stdlib/delete.java 2012-09-17 20:06:15 UTC (rev 1711) @@ -95,7 +95,11 @@ if (args[0].isString() && args[1].isString()) { return un.unifies(args[2], deleteFromString((StringTerm)args[0],(StringTerm)args[1])); } + if (args[0].isString()) { // consider arg[1] as string + return un.unifies(args[2], deleteFromString((StringTerm)args[0], new StringTermImpl(args[1].toString()))); + } + // first element as term if (args[1].isList()) { return un.unifies(args[2], deleteFromList(args[0],(ListTerm)args[1], un.clone())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-08-25 11:35:07
|
Revision: 1710 http://jason.svn.sourceforge.net/jason/?rev=1710&view=rev Author: jomifred Date: 2012-08-25 11:35:01 +0000 (Sat, 25 Aug 2012) Log Message: ----------- add a new feature on Jason to generate +!jag_sleeping and +!jag_awaking events +!idle is deprecated see release notes for more details. Modified Paths: -------------- trunk/release-notes.txt trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/asSyntax/PlanLibrary.java Added Paths: ----------- trunk/demos/idle/ trunk/demos/idle/idle.mas2j trunk/demos/idle/idleag.asl trunk/demos/idle/sender.asl Added: trunk/demos/idle/idle.mas2j =================================================================== --- trunk/demos/idle/idle.mas2j (rev 0) +++ trunk/demos/idle/idle.mas2j 2012-08-25 11:35:01 UTC (rev 1710) @@ -0,0 +1,6 @@ +MAS idle_demo { + + agents: + idleag [verbose=0]; + sender; +} \ No newline at end of file Added: trunk/demos/idle/idleag.asl =================================================================== --- trunk/demos/idle/idleag.asl (rev 0) +++ trunk/demos/idle/idleag.asl 2012-08-25 11:35:01 UTC (rev 1710) @@ -0,0 +1,10 @@ + +/* Plans */ + ++hi(X)[source(A)] <- .println; .println("hi ",A," ",X); .println. + ++!jag_sleeping <- .println("i am going to sleep"). ++!jag_awaking <- .println("i am back"). + +//^!jag_sleeping[state(S)] <- .print("sleep goal state is ",S). + Added: trunk/demos/idle/sender.asl =================================================================== --- trunk/demos/idle/sender.asl (rev 0) +++ trunk/demos/idle/sender.asl 2012-08-25 11:35:01 UTC (rev 1710) @@ -0,0 +1,11 @@ +// Agent sender in project ttt + +/* Initial beliefs and rules */ + +/* Initial goals */ + +!start(0). + +/* Plans */ + ++!start(X) <- .wait(1500); .send(idleag,tell,hi(X)); !!start(X+1). Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2012-08-10 20:29:31 UTC (rev 1709) +++ trunk/release-notes.txt 2012-08-25 11:35:01 UTC (rev 1710) @@ -1,4 +1,27 @@ --------------------------- +version 1.3.9 + +revision XXX on SVN +--------------------------- + +New features +- new special achievement goal events + +!jag_sleeping + +!jag_awaking + that are created when the agent is going to sleep (is becoming idle) and + becoming busy after sleeping, respectively. + + see demos/idle for an example of how to use this feature. + + **NB: The +!idle event is deprecated, you must use +!jag_sleeping instead! + Note however that the +!jag_sleeping event is only generated when the agent + starts an idle period, rather than being generated again at every reasoning + cycle as with +!idle in previous releases. + + + + +--------------------------- version 1.3.8 revision 1709 on SVN Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2012-08-10 20:29:31 UTC (rev 1709) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2012-08-25 11:35:01 UTC (rev 1710) @@ -74,8 +74,10 @@ private Circumstance C = null; private Settings setts = null; private State step = State.StartRC; // first step of the SOS - private int nrcslbr = Settings.ODefaultNRC; // number of reasoning cycles since last belief revision + private int nrcslbr = Settings.ODefaultNRC; // number of reasoning cycles since last belief revision + private boolean sleepingEvt = false; + private List<GoalListener> goalListeners = null; // both configuration and configuration' point to this @@ -1122,6 +1124,8 @@ /**********************************************************************/ //Circumstance pc1, pc2, pc3, pc4; + + public boolean reasoningCycle() { if (logger.isLoggable(Level.FINE)) logger.fine("Start new reasoning cycle"); getUserAgArch().reasoningCycleStarting(); @@ -1171,13 +1175,33 @@ nrcslbr++; // counting number of cycles since last belief revision if (canSleep()) { - if (ag.pl.getIdlePlans() != null) { - logger.fine("generating idle event"); - C.addExternalEv(PlanLibrary.TE_IDLE); + if (!sleepingEvt) { + sleepingEvt = true; + if (ag.pl.getCandidatePlans(PlanLibrary.TE_JAG_SLEEPING) != null) + C.addExternalEv(PlanLibrary.TE_JAG_SLEEPING); } else { getUserAgArch().sleep(); return false; } + } else if (sleepingEvt) { // code to turn idleEvt false again + if (C.hasMsg()) { // the agent has messages + sleepingEvt = false; + } else if (C.hasEvent()) { + // check if there is an event in C.E not produced by idle intention + for (Event e: C.getEvents()) { + Intention i = e.getIntention(); + if ( !e.getTrigger().equals(PlanLibrary.TE_JAG_SLEEPING) + || + (i != null && i.hasTrigger(PlanLibrary.TE_JAG_SLEEPING, new Unifier())) + ) { + sleepingEvt = false; + break; + } + } + } + if (!sleepingEvt && ag.pl.getCandidatePlans(PlanLibrary.TE_JAG_AWAKING) != null) { + C.addExternalEv(PlanLibrary.TE_JAG_AWAKING); + } } step = State.StartRC; Modified: trunk/src/jason/asSyntax/PlanLibrary.java =================================================================== --- trunk/src/jason/asSyntax/PlanLibrary.java 2012-08-10 20:29:31 UTC (rev 1709) +++ trunk/src/jason/asSyntax/PlanLibrary.java 2012-08-25 11:35:01 UTC (rev 1710) @@ -353,12 +353,9 @@ return l; // if no rel plan, have to return null instead of empty list } - public static final Trigger TE_IDLE = new Trigger(TEOperator.add, TEType.achieve, new Atom("idle")); + public static final Trigger TE_JAG_SLEEPING = new Trigger(TEOperator.add, TEType.achieve, new Atom("jag_sleeping")); + public static final Trigger TE_JAG_AWAKING = new Trigger(TEOperator.add, TEType.achieve, new Atom("jag_awaking")); - public List<Plan> getIdlePlans() { - return relPlans.get(TE_IDLE.getPredicateIndicator()); - } - public PlanLibrary clone() { PlanLibrary pl = new PlanLibrary(); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-08-10 20:29:37
|
Revision: 1709 http://jason.svn.sourceforge.net/jason/?rev=1709&view=rev Author: jomifred Date: 2012-08-10 20:29:31 +0000 (Fri, 10 Aug 2012) Log Message: ----------- final changes for release 1.3.8 Modified Paths: -------------- trunk/build.xml trunk/examples/auction/auctioneer.asl trunk/examples/game-of-life/bin/c-build.xml trunk/release-notes.txt Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2012-08-06 21:55:11 UTC (rev 1708) +++ trunk/build.xml 2012-08-10 20:29:31 UTC (rev 1709) @@ -12,7 +12,7 @@ <property name="dist.properties" value="${basedir}/bin/dist.properties" /> <property name="version" value="1" /> - <property name="release" value="3.8beta" /> + <property name="release" value="3.8" /> <property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" /> <property name="distFile" value="${env.HOME}/Jason-${version}.${release}" /> @@ -372,7 +372,7 @@ <target name="cleanExamples"> <delete failonerror="no" includeEmptyDirs="true" verbose="true"> - <fileset dir="${basedir}/examples" includes="**/bin/**" /> + <fileset dir="${basedir}/examples" includes="**/bin/**" excludes="**/game-of-life/bin/c-build.xml"/> <fileset dir="${basedir}/demos" includes="**/bin/**" /> <fileset dir="${basedir}/examples" includes="**/work" /> Modified: trunk/examples/auction/auctioneer.asl =================================================================== --- trunk/examples/auction/auctioneer.asl 2012-08-06 21:55:11 UTC (rev 1708) +++ trunk/examples/auction/auctioneer.asl 2012-08-10 20:29:31 UTC (rev 1709) @@ -1,34 +1,16 @@ -// this agent starts the auction and identify the winner +// this agent manages the auction and identify the winner -/* beliefs and rules */ ++!start_auction(N) // this goal is created by the GUI of the agent + <- .broadcast(tell, auction(N)). -all_bids_received(N) :- .count(place_bid(N,_),3). -/* plans */ - -+!start_auction(N) : true // this goal is created by the GUI of the agent - <- -+auction(N); - -+winner(N, noone, 0); - .broadcast(tell, auction(N)). - -// receive bid and check for new winner @pb1[atomic] -+place_bid(N,V)[source(S)] - : auction(N) & winner(N,CurWin,CurVl) & V > CurVl - <- -winner(N,CurWin,CurVl); - +winner(N,S,V); .print("New winner is ",S, " with value ",V); - !check_end(N). - -@pb2[atomic] -+place_bid(N,_) : true - <- !check_end(N). - -+!check_end(N) - : all_bids_received(N) & - winner(N,W,Vl) - <- .print("Winner is ",W," with ", Vl); ++place_bid(N,_) // receives bids and checks for new winner + : .findall(b(V,A),place_bid(N,V)[source(A)],L) & + .length(L,3) // all 3 expected bids was received + <- .max(L,b(V,W)); + .print("Winner is ",W," with ", V); show_winner(N,W); // show it in the GUI .broadcast(tell, winner(W)); .abolish(place_bid(N,_)). -+!check_end(_). Modified: trunk/examples/game-of-life/bin/c-build.xml =================================================================== --- trunk/examples/game-of-life/bin/c-build.xml 2012-08-06 21:55:11 UTC (rev 1708) +++ trunk/examples/game-of-life/bin/c-build.xml 2012-08-10 20:29:31 UTC (rev 1709) @@ -16,9 +16,9 @@ default="run"> <import file="build.xml"/> - - - + + + <target name="run" depends="compile" > <echo message="Running project ${ant.project.name}" /> <java classname="jason.infra.centralised.RunCentralisedMAS" Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2012-08-06 21:55:11 UTC (rev 1708) +++ trunk/release-notes.txt 2012-08-10 20:29:31 UTC (rev 1709) @@ -1,7 +1,7 @@ --------------------------- version 1.3.8 -revision XXX on SVN +revision 1709 on SVN --------------------------- New features This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-08-06 21:55:17
|
Revision: 1708 http://jason.svn.sourceforge.net/jason/?rev=1708&view=rev Author: jomifred Date: 2012-08-06 21:55:11 +0000 (Mon, 06 Aug 2012) Log Message: ----------- update release notes Modified Paths: -------------- trunk/release-notes.txt trunk/src/jason/infra/centralised/CentralisedAgArch.java Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2012-08-06 11:13:20 UTC (rev 1707) +++ trunk/release-notes.txt 2012-08-06 21:55:11 UTC (rev 1708) @@ -10,11 +10,13 @@ whether an agent accepts to be killed by another. (implemented only in Centralised infrastructure) - performance improvement for pool of threads +- some kqmlPlans (tell/achieve) are bypassed if not + customized by the user and not running in debug mode + to improve performance - Bugs fixed -- unique id of Intention wan't thread safe -- indexedBB doesn't work on pool of threads +- unique id of Intention wasn't thread safe +- indexedBB didn't work on pool of threads --------------------------- version 1.3.7 Modified: trunk/src/jason/infra/centralised/CentralisedAgArch.java =================================================================== --- trunk/src/jason/infra/centralised/CentralisedAgArch.java 2012-08-06 11:13:20 UTC (rev 1707) +++ trunk/src/jason/infra/centralised/CentralisedAgArch.java 2012-08-06 21:55:11 UTC (rev 1708) @@ -206,7 +206,7 @@ } } } - logger.info("I finished!"); + logger.fine("I finished!"); } private Object sleepSync = new Object(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-08-06 11:13:26
|
Revision: 1707 http://jason.svn.sourceforge.net/jason/?rev=1707&view=rev Author: jomifred Date: 2012-08-06 11:13:20 +0000 (Mon, 06 Aug 2012) Log Message: ----------- small improvement on method removeAtomicEvent in C Modified Paths: -------------- trunk/release-notes.txt trunk/src/jason/asSemantics/Circumstance.java trunk/src/jason/asSemantics/Event.java Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2012-08-04 14:11:09 UTC (rev 1706) +++ trunk/release-notes.txt 2012-08-06 11:13:20 UTC (rev 1707) @@ -9,7 +9,13 @@ - new method in Agent class (killAcc) to customise whether an agent accepts to be killed by another. (implemented only in Centralised infrastructure) +- performance improvement for pool of threads + +Bugs fixed +- unique id of Intention wan't thread safe +- indexedBB doesn't work on pool of threads + --------------------------- version 1.3.7 Modified: trunk/src/jason/asSemantics/Circumstance.java =================================================================== --- trunk/src/jason/asSemantics/Circumstance.java 2012-08-04 14:11:09 UTC (rev 1706) +++ trunk/src/jason/asSemantics/Circumstance.java 2012-08-06 11:13:20 UTC (rev 1707) @@ -59,6 +59,7 @@ protected Intention SI; private Intention AI; // Atomic Intention private boolean atomicIntSuspended = false; // whether the current atomic intention is suspended in PA or PI + private boolean hasAtomicEvent = false; private Map<Integer, ActionExec> PA; // Pending actions, waiting action execution (key is the intention id) private List<ActionExec> FA; // Feedback actions, those that are already executed @@ -116,6 +117,9 @@ public void addEvent(Event ev) { E.add(ev); + if (ev.isAtomic()) + hasAtomicEvent = true; + // notify listeners if (listeners != null) for (CircumstanceListener el : listeners) @@ -143,7 +147,14 @@ } public boolean removeEvent(Event ev) { - return E.remove(ev); + if (E.remove(ev)) { + if (hasAtomicEvent && !ev.isAtomic()) { + hasAtomicEvent = false; + } + return true; + } else { + return false; + } } public void clearEvents() { @@ -154,6 +165,7 @@ el.intentionDropped(ev.getIntention()); E.clear(); + hasAtomicEvent = false; } public Queue<Event> getEvents() { @@ -166,10 +178,13 @@ /** remove and returns the event with atomic intention, null if none */ public Event removeAtomicEvent() { + if (!hasAtomicEvent) + return null; + Iterator<Event> i = E.iterator(); while (i.hasNext()) { Event e = i.next(); - if (e.getIntention() != null && e.getIntention().isAtomic()) { + if (e.isAtomic()) { i.remove(); return e; } @@ -536,6 +551,9 @@ /** clone E, I, MB, PA, PI, FA, and AI */ public Circumstance clone() { Circumstance c = new Circumstance(); + c.hasAtomicEvent = this.hasAtomicEvent; + c.atomicIntSuspended = this.atomicIntSuspended; + for (Event e: this.E) { c.E.add((Event)e.clone()); } Modified: trunk/src/jason/asSemantics/Event.java =================================================================== --- trunk/src/jason/asSemantics/Event.java 2012-08-04 14:11:09 UTC (rev 1706) +++ trunk/src/jason/asSemantics/Event.java 2012-08-06 11:13:20 UTC (rev 1707) @@ -64,7 +64,11 @@ public boolean isInternal() { return intention != Intention.EmptyInt; } + public boolean isAtomic() { + return intention != null && intention.isAtomic(); + } + @Override public boolean equals(Object o) { if (o == null) return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-08-04 14:11:15
|
Revision: 1706 http://jason.svn.sourceforge.net/jason/?rev=1706&view=rev Author: jomifred Date: 2012-08-04 14:11:09 +0000 (Sat, 04 Aug 2012) Log Message: ----------- define some fields as volatile Modified Paths: -------------- trunk/examples/gold-miners-II/arch/LocalMinerArch.java trunk/src/jason/control/ExecutionControl.java trunk/src/jason/infra/centralised/CentralisedAgArch.java trunk/src/jason/infra/centralised/RunCentralisedMAS.java Modified: trunk/examples/gold-miners-II/arch/LocalMinerArch.java =================================================================== --- trunk/examples/gold-miners-II/arch/LocalMinerArch.java 2012-08-03 20:19:58 UTC (rev 1705) +++ trunk/examples/gold-miners-II/arch/LocalMinerArch.java 2012-08-04 14:11:09 UTC (rev 1706) @@ -11,7 +11,7 @@ public class LocalMinerArch extends MinerArch { - /** this version of perceive is used in local simulator. it get + /** this version of perceive is used in local simulator. it gets the perception and updates the world model. only relevant percepts are leaved in the list of perception for the agent. */ Modified: trunk/src/jason/control/ExecutionControl.java =================================================================== --- trunk/src/jason/control/ExecutionControl.java 2012-08-03 20:19:58 UTC (rev 1705) +++ trunk/src/jason/control/ExecutionControl.java 2012-08-04 14:11:09 UTC (rev 1706) @@ -54,9 +54,9 @@ protected ExecutionControlInfraTier infraControl = null; private Set<String> finished = new HashSet<String>(); // the agents that have finished its reasoning cycle - private int cycleNumber = 0; - private boolean runningCycle = true; - private boolean isRunning = true; + private volatile int cycleNumber = 0; + private volatile boolean runningCycle = true; + private volatile boolean isRunning = true; private int nbAgs = -1; Modified: trunk/src/jason/infra/centralised/CentralisedAgArch.java =================================================================== --- trunk/src/jason/infra/centralised/CentralisedAgArch.java 2012-08-03 20:19:58 UTC (rev 1705) +++ trunk/src/jason/infra/centralised/CentralisedAgArch.java 2012-08-04 14:11:09 UTC (rev 1706) @@ -65,10 +65,10 @@ private CentralisedExecutionControl infraControl = null; private RunCentralisedMAS masRunner = RunCentralisedMAS.getRunner(); - private String agName = ""; - private boolean running = true; - private Queue<Message> mbox = new ConcurrentLinkedQueue<Message>(); - protected Logger logger = Logger.getLogger(CentralisedAgArch.class.getName()); + private String agName = ""; + private volatile boolean running = true; + private Queue<Message> mbox = new ConcurrentLinkedQueue<Message>(); + protected Logger logger = Logger.getLogger(CentralisedAgArch.class.getName()); private static List<MsgListener> msgListeners = null; public static void addMsgListener(MsgListener l) { @@ -305,8 +305,8 @@ return mbox.isEmpty() && isRunning(); } - private Object syncMonitor = new Object(); - private boolean inWaitSyncMonitor = false; + private Object syncMonitor = new Object(); + private volatile boolean inWaitSyncMonitor = false; /** * waits for a signal to continue the execution (used in synchronised Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2012-08-03 20:19:58 UTC (rev 1705) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2012-08-04 14:11:09 UTC (rev 1706) @@ -520,7 +520,7 @@ /** an agent architecture for the infra based on thread pool */ private final class CentralisedAgArchForPool extends CentralisedAgArch { - boolean runWakeAfterTS = false; + private volatile boolean runWakeAfterTS = false; @Override public void sleep() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-08-03 20:20:06
|
Revision: 1705 http://jason.svn.sourceforge.net/jason/?rev=1705&view=rev Author: jomifred Date: 2012-08-03 20:19:58 +0000 (Fri, 03 Aug 2012) Log Message: ----------- fix bug in Intention identification fix bug in pool of thread (Centralised infra) by pass kqmlPlans when not customised by the programmer Modified Paths: -------------- trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java trunk/applications/jasdl-owlapi/src/jasdl/ia/get_tg_cause.java trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java trunk/examples/airport/mds/MDSAgent.java trunk/src/asl/kqmlPlans.asl trunk/src/jason/asSemantics/ActionExec.java trunk/src/jason/asSemantics/Agent.java trunk/src/jason/asSemantics/Circumstance.java trunk/src/jason/asSemantics/ConcurrentInternalAction.java trunk/src/jason/asSemantics/IntendedMeans.java trunk/src/jason/asSemantics/Intention.java trunk/src/jason/asSemantics/Message.java trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/asSemantics/Unifier.java trunk/src/jason/asSyntax/ListTermImpl.java trunk/src/jason/asSyntax/PlanLibrary.java trunk/src/jason/control/ExecutionControlGUI.java trunk/src/jason/infra/centralised/CentralisedAgArch.java trunk/src/jason/infra/centralised/RunCentralisedMAS.java trunk/src/jason/stdlib/add_nested_source.java trunk/src/jason/stdlib/at.java trunk/src/jason/stdlib/desire.java trunk/src/jason/stdlib/puts.java trunk/src/jason/stdlib/succeed_goal.java trunk/src/test/ASParserTest.java trunk/src/test/StdLibTest.java trunk/src/xml/agInspection.xsl Modified: trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java =================================================================== --- trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/applications/as-unit-test/src/jason/asunit/TestAgent.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -4,7 +4,6 @@ import jason.JasonException; import jason.RevisionFailedException; import jason.asSemantics.Agent; -import jason.asSemantics.Circumstance; import jason.asSemantics.Event; import jason.asSemantics.Intention; import jason.asSemantics.TransitionSystem; @@ -17,7 +16,6 @@ import jason.asSyntax.parser.ParseException; import jason.bb.BeliefBase; import jason.infra.centralised.RunCentralisedMAS; -import jason.runtime.Settings; import java.io.StringReader; import java.util.logging.Level; @@ -41,7 +39,7 @@ arch = new TestArch(); else arch = new TestArch(agName); - new TransitionSystem(this, new Circumstance(), new Settings(), arch); + new TransitionSystem(this, null, null, arch); arch.insertAgArch(arch); initAg(); } catch (Exception e) { Modified: trunk/applications/jasdl-owlapi/src/jasdl/ia/get_tg_cause.java =================================================================== --- trunk/applications/jasdl-owlapi/src/jasdl/ia/get_tg_cause.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/applications/jasdl-owlapi/src/jasdl/ia/get_tg_cause.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -48,7 +48,7 @@ Trigger te; try{ - IntendedMeans cause = ts.getC().getSelectedIntention().getIMs().peek(); + IntendedMeans cause = ts.getC().getSelectedIntention().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 Modified: trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java =================================================================== --- trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -2,11 +2,9 @@ import jason.architecture.AgArch; import jason.asSemantics.ActionExec; import jason.asSemantics.Agent; -import jason.asSemantics.Circumstance; import jason.asSemantics.TransitionSystem; import jason.asSyntax.Literal; import jason.infra.centralised.RunCentralisedMAS; -import jason.runtime.Settings; import java.util.ArrayList; import java.util.List; @@ -33,7 +31,7 @@ // set up the Jason agent try { Agent ag = new Agent(); - new TransitionSystem(ag, new Circumstance(), new Settings(), this); + new TransitionSystem(ag, null, null, this); ag.initAg("demo.asl"); } catch (Exception e) { logger.log(Level.SEVERE, "Init error", e); Modified: trunk/examples/airport/mds/MDSAgent.java =================================================================== --- trunk/examples/airport/mds/MDSAgent.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/examples/airport/mds/MDSAgent.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -24,11 +24,8 @@ // sub-goal that generates other events (+!<sub-goal>), in this case // the +unattended_luggage event is in the bottom of the stack if (e.getIntention() != null) { - Iterator<IntendedMeans> j = e.getIntention().iterator(); - while (j.hasNext()) { - IntendedMeans im = j.next(); - Trigger it = (Trigger) im.getPlan().getTrigger(); - if (it.getLiteral().getFunctor().equals("unattended_luggage")) { + for (IntendedMeans im: e.getIntention()) { + if (im.getPlan().getTrigger().getLiteral().getFunctor().equals("unattended_luggage")) { i.remove(); return e; } Modified: trunk/src/asl/kqmlPlans.asl =================================================================== --- trunk/src/asl/kqmlPlans.asl 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/asl/kqmlPlans.asl 2012-08-03 20:19:58 UTC (rev 1705) @@ -14,9 +14,9 @@ +!kqml_received(Sender, tell, Content, _) : .literal(Content) & .ground(Content) & - not .list(Content) - <- .add_nested_source(Content, Sender, CA); - +CA. + not .list(Content) & + .add_nested_source(Content, Sender, CA) + <- +CA. @kqmlReceivedTellList +!kqml_received(Sender, tell, Content, _) : .list(Content) @@ -47,9 +47,8 @@ @kqmlReceivedAchieve +!kqml_received(Sender, achieve, Content, _) - : not .list(Content) - <- .add_nested_source(Content, Sender, CA); - !!CA. + : not .list(Content) & .add_nested_source(Content, Sender, CA) + <- !!CA. @kqmlReceivedAchieveList +!kqml_received(Sender, achieve, Content, _) : .list(Content) Modified: trunk/src/jason/asSemantics/ActionExec.java =================================================================== --- trunk/src/jason/asSemantics/ActionExec.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/asSemantics/ActionExec.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -36,8 +36,6 @@ public class ActionExec implements Serializable { - private static final long serialVersionUID = 1L; - private Literal action; private Intention intention; private boolean result; Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/asSemantics/Agent.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -119,7 +119,7 @@ try { Agent ag = (Agent) Class.forName(agClass).newInstance(); - new TransitionSystem(ag, new Circumstance(), stts, arch); + new TransitionSystem(ag, null, stts, arch); BeliefBase bb = (BeliefBase) Class.forName(bbPars.getClassName()).newInstance(); ag.setBB(bb); // the agent's BB have to be already set for the BB initialisation @@ -146,7 +146,7 @@ if (internalActions == null) internalActions = new HashMap<String, InternalAction>(); initDefaultFunctions(); - if (ts == null) ts = new TransitionSystem(this, new Circumstance(), new Settings(), new AgArch()); + if (ts == null) ts = new TransitionSystem(this, null, null, new AgArch()); } @@ -222,7 +222,7 @@ try { if (bb != null) setBB(bb); - new TransitionSystem(this, new Circumstance(), stts, arch); + new TransitionSystem(this, null, stts, arch); initAg(asSrc); return ts; } catch (Exception e) { @@ -890,7 +890,7 @@ static DocumentBuilder builder = null; - /** Gets the agent "mind" (Beliefs, plans and circumstance) as XML */ + /** Gets the agent "mind" (beliefs, plans, and circumstance) as XML */ public Document getAgState() { if (builder == null) { try { Modified: trunk/src/jason/asSemantics/Circumstance.java =================================================================== --- trunk/src/jason/asSemantics/Circumstance.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/asSemantics/Circumstance.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -27,6 +27,7 @@ import jason.asSyntax.Trigger; import jason.asSyntax.Trigger.TEOperator; import jason.asSyntax.Trigger.TEType; +import jason.infra.centralised.CentralisedAgArch; import java.io.Serializable; import java.util.AbstractList; @@ -47,10 +48,10 @@ private static final long serialVersionUID = 1L; - private Queue<Event> E; - private Queue<Intention> I; + private Queue<Event> E; + private Queue<Intention> I; protected ActionExec A; - private Queue<Message> MB; + private Queue<Message> MB; protected List<Option> RP; protected List<Option> AP; protected Event SE; @@ -67,11 +68,17 @@ private List<CircumstanceListener> listeners = new CopyOnWriteArrayList<CircumstanceListener>(); + private TransitionSystem ts = null; + public Circumstance() { create(); reset(); } - + + public void setTS(TransitionSystem ts) { + this.ts = ts; + } + /** creates new collections for E, I, MB, PA, PI, and FA */ public void create() { // use LinkedList since we use a lot of remove(0) in selectEvent @@ -558,21 +565,36 @@ public Element getAsDOM(Document document) { Element c = (Element) document.createElement("circumstance"); Element e; + boolean add; // MB + add = false; + Element ms = (Element) document.createElement("mailbox"); if (MB != null && hasMsg()) { - Element ms = (Element) document.createElement("mailbox"); for (Message m: MB) { + add = true; e = (Element) document.createElement("message"); e.appendChild(document.createTextNode(m.toString())); ms.appendChild(e); } + } + if (ts != null) { + try { + for (Message m: ((CentralisedAgArch)ts.getUserAgArch().getArchInfraTier()).getMBox()) { + add = true; + e = (Element) document.createElement("message"); + e.appendChild(document.createTextNode(m.toString() + " in arch inbox.")); + ms.appendChild(e); + } + + } catch (Exception ex) { } + } + if (add) c.appendChild(ms); - } // events Element events = (Element) document.createElement("events"); - boolean add = false; + add = false; if (E != null && !E.isEmpty()) { for (Event evt: E) { add = true; @@ -644,13 +666,13 @@ Element ints = (Element) document.createElement("intentions"); Element selIntEle = null; Intention ci = getSelectedIntention(); - if (ci != null && !ci.isFinished()) { + if (ci != null) { selIntEle = ci.getAsDOM(document); selIntEle.setAttribute("selected", "true"); ints.appendChild(selIntEle); } for (Intention in : getIntentions()) { - if (getSelectedIntention() != in && !in.isFinished()) { + if (getSelectedIntention() != in) { ints.appendChild(in.getAsDOM(document)); } } Modified: trunk/src/jason/asSemantics/ConcurrentInternalAction.java =================================================================== --- trunk/src/jason/asSemantics/ConcurrentInternalAction.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/asSemantics/ConcurrentInternalAction.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -6,6 +6,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; /** @@ -54,7 +55,7 @@ */ public abstract class ConcurrentInternalAction implements InternalAction { - private static int actcount = 0; + private static AtomicInteger actcount = new AtomicInteger(0); public boolean canBeUsedInContext() { return false; @@ -86,7 +87,7 @@ * @return the final key used to store the intention in PI, this key is used the resume the intention */ public String suspendInt(final TransitionSystem ts, String basekey, int timeout) { - final String key = basekey + "/" + (actcount++); + final String key = basekey + "/" + (actcount.incrementAndGet()); final Circumstance C = ts.getC(); Intention i = C.getSelectedIntention(); i.setSuspended(true); Modified: trunk/src/jason/asSemantics/IntendedMeans.java =================================================================== --- trunk/src/jason/asSemantics/IntendedMeans.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/asSemantics/IntendedMeans.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -118,8 +118,10 @@ public Object clone() { IntendedMeans c = new IntendedMeans(); c.unif = this.unif.clone(); - c.planBody = this.planBody.clonePB(); + if (this.planBody != null) + c.planBody = this.planBody.clonePB(); c.trigger = this.trigger.clone(); + c.plan = this.plan; return c; } Modified: trunk/src/jason/asSemantics/Intention.java =================================================================== --- trunk/src/jason/asSemantics/Intention.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/asSemantics/Intention.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -31,8 +31,10 @@ import jason.asSyntax.Trigger; import java.io.Serializable; -import java.util.ListIterator; -import java.util.Stack; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.Iterator; +import java.util.concurrent.atomic.AtomicInteger; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -45,22 +47,24 @@ * * @author Jomi & Rafael */ -public class Intention implements Serializable, Comparable<Intention> { +public class Intention implements Serializable, Comparable<Intention>, Iterable<IntendedMeans> { private static final long serialVersionUID = 1L; public static final Intention EmptyInt = null; - private static int idCount = 0; + private static AtomicInteger idCount = new AtomicInteger(0); private int id; 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>(); - + private Deque<IntendedMeans> intendedMeans = new ArrayDeque<IntendedMeans>(); + + //private Trigger initialTrigger = null; // just for adicional information/debug (not really necessary) + //static private Logger logger = Logger.getLogger(Intention.class.getName()); public Intention() { - id = ++idCount; + id = idCount.incrementAndGet(); } public int getId() { @@ -71,16 +75,14 @@ intendedMeans.push(im); if (im.isAtomic()) atomicCount++; + //if (initialTrigger == null) + // initialTrigger = im.getTrigger(); } - + public IntendedMeans peek() { return intendedMeans.peek(); } - public IntendedMeans get(int index) { - return intendedMeans.get(index); - } - public IntendedMeans pop() { IntendedMeans top = intendedMeans.pop(); @@ -100,13 +102,13 @@ return atomicCount > 0; } - public void setAtomic(int a) { // used for test + public void setAtomic(int a) { // used for testing atomicCount = a; } - public ListIterator<IntendedMeans> iterator() { - return intendedMeans.listIterator(intendedMeans.size()); + public Iterator<IntendedMeans> iterator() { + return intendedMeans.iterator(); } public boolean isFinished() { @@ -125,10 +127,6 @@ return isSuspended; } - public Stack<IntendedMeans> getIMs() { - return intendedMeans; - } - /** returns the IntendedMeans with TE = g, returns null if there isn't one */ public IntendedMeans getIM(Trigger g, Unifier u) { for (IntendedMeans im : intendedMeans) @@ -163,8 +161,6 @@ /** 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.atomicCount > this.atomicCount) return 1; if (this.atomicCount > o.atomicCount) return -1; return 0; @@ -185,7 +181,7 @@ Intention i = new Intention(); i.id = id; i.atomicCount = atomicCount; - i.intendedMeans = new Stack<IntendedMeans>(); + i.intendedMeans = new ArrayDeque<IntendedMeans>(); for (IntendedMeans im: intendedMeans) { i.intendedMeans.add((IntendedMeans)im.clone()); } @@ -193,11 +189,11 @@ } public String toString() { - StringBuilder s = new StringBuilder(); - ListIterator<IntendedMeans> i = intendedMeans.listIterator(intendedMeans.size()); - while (i.hasPrevious()) { - s.append(" " + i.previous() + "\n"); - } + StringBuilder s = new StringBuilder("intention "+id+": "); + for (IntendedMeans im: intendedMeans) + s.append(" " + im + "\n"); + if (isFinished()) + s.append("<finished intention>"); return s.toString(); } @@ -205,10 +201,8 @@ Structure intention = new Structure("intention"); intention.addTerm(new NumberTermImpl(getId())); ListTerm lt = new ListTermImpl(); - ListIterator<IntendedMeans> i = intendedMeans.listIterator(intendedMeans.size()); - while (i.hasPrevious()) { - lt.add(i.previous().getAsTerm()); - } + for (IntendedMeans im: intendedMeans) + lt.add(im.getAsTerm()); intention.addTerm(lt); return intention; } @@ -217,10 +211,12 @@ public Element getAsDOM(Document document) { Element eint = (Element) document.createElement("intention"); eint.setAttribute("id", id + ""); - for (int i = intendedMeans.size() - 1; i >= 0; i--) { - IntendedMeans im = (IntendedMeans) intendedMeans.get(i); + for (IntendedMeans im: intendedMeans) eint.appendChild(im.getAsDOM(document)); - } + //if (intendedMeans.isEmpty()) + // eint.appendChild( initialTrigger.getAsDOM(document)); + eint.setAttribute("finished", ""+isFinished()); + return eint; } Modified: trunk/src/jason/asSemantics/Message.java =================================================================== --- trunk/src/jason/asSemantics/Message.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/asSemantics/Message.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -28,6 +28,7 @@ import jason.asSyntax.parser.ParseException; import java.io.Serializable; +import java.util.concurrent.atomic.AtomicInteger; public class Message implements Serializable { @@ -39,18 +40,20 @@ private String msgId = null; private String inReplyTo = null; - private static int idCount = 1; + private static AtomicInteger idCount = new AtomicInteger(0); public final static String[] knownPerformatives = {"tell","untell","achieve","unachieve","askOne","askAll","tellHow", "untellHow","askHow"}; public final static String msgIdPrefix = "mid"; public final static String msgIdSyncAskPrefix = "samid"; + public final static String kqmlReceivedFunctor = "kqml_received"; + public Message() { } public Message(String ilf, String s, String r, Object c) { - this(ilf, s, r, c, msgIdPrefix+(idCount++)); + this(ilf, s, r, c, msgIdPrefix+(idCount.incrementAndGet())); } public Message(String ilf, String s, String r, Object c, String id) { @@ -71,7 +74,7 @@ } public void setSyncAskMsgId() { - msgId = msgIdSyncAskPrefix+(idCount++); + msgId = msgIdSyncAskPrefix+(idCount.incrementAndGet()); } public String getIlForce() { Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -38,25 +38,25 @@ import jason.asSyntax.NumberTermImpl; import jason.asSyntax.Plan; import jason.asSyntax.PlanBody; +import jason.asSyntax.PlanBody.BodyType; import jason.asSyntax.PlanLibrary; import jason.asSyntax.StringTermImpl; import jason.asSyntax.Structure; import jason.asSyntax.Term; import jason.asSyntax.Trigger; -import jason.asSyntax.VarTerm; -import jason.asSyntax.PlanBody.BodyType; import jason.asSyntax.Trigger.TEOperator; import jason.asSyntax.Trigger.TEType; +import jason.asSyntax.VarTerm; import jason.asSyntax.parser.ParseException; import jason.bb.BeliefBase; import jason.runtime.Settings; +import jason.stdlib.add_nested_source; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; -import java.util.ListIterator; import java.util.Map; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; @@ -87,16 +87,18 @@ public TransitionSystem(Agent a, Circumstance c, Settings s, AgArch ar) { ag = a; - C = c; agArch = ar; - + if (s == null) setts = new Settings(); else setts = s; - if (C == null) + if (c == null) C = new Circumstance(); + else + C = c; + C.setTS(this); // we need to initialise this "aliases" conf = confP = this; @@ -145,19 +147,19 @@ CircumstanceListener cl = new CircumstanceListener() { public void intentionDropped(Intention i) { - for (IntendedMeans im: i.getIMs()) + for (IntendedMeans im: i) //.getIMs()) if (im.getTrigger().isAddition() && im.getTrigger().isGoal()) gl.goalFinished(im.getTrigger()); } public void intentionSuspended(Intention i, String reason) { - for (IntendedMeans im: i.getIMs()) + for (IntendedMeans im: i) //.getIMs()) if (im.getTrigger().isAddition() && im.getTrigger().isGoal()) gl.goalSuspended(im.getTrigger(), reason); } public void intentionResumed(Intention i) { - for (IntendedMeans im: i.getIMs()) + for (IntendedMeans im: i) //.getIMs()) if (im.getTrigger().isAddition() && im.getTrigger().isGoal()) gl.goalResumed(im.getTrigger()); } @@ -296,16 +298,28 @@ String sender = m.getSender(); if (sender.equals(getUserAgArch().getAgName())) sender = "self"; - if (m.getIlForce().equals("achieve") && content.isLiteral()) { - updateEvents(new Event(new Trigger(TEOperator.add, TEType.achieve, (Literal)content), Intention.EmptyInt)); - } else { - Literal received = new LiteralImpl("kqml_received").addTerms( - new Atom(sender), - new Atom(m.getIlForce()), - content, - new Atom(m.getMsgId())); - - updateEvents(new Event(new Trigger(TEOperator.add, TEType.achieve, received), Intention.EmptyInt)); + + boolean added = false; + if (!setts.isSync() && !ag.getPL().hasUserKqmlReceivedPlans() && content.isLiteral() && !content.isList()) { // optimisation to jump kqmlPlans + if (m.getIlForce().equals("achieve") ) { + content = add_nested_source.addAnnotToList(content, new Atom(sender)); + updateEvents(new Event(new Trigger(TEOperator.add, TEType.achieve, (Literal)content), Intention.EmptyInt)); + added = true; + } else if (m.getIlForce().equals("tell") ) { + content = add_nested_source.addAnnotToList(content, new Atom(sender)); + getAg().addBel((Literal)content); + added = true; + } + } + + if (!added) { + Literal received = new LiteralImpl(Message.kqmlReceivedFunctor).addTerms( + new Atom(sender), + new Atom(m.getIlForce()), + content, + new Atom(m.getMsgId())); + + updateEvents(new Event(new Trigger(TEOperator.add, TEType.achieve, received), Intention.EmptyInt)); } } else { logger.fine("Ignoring message "+m+" because it is received after the timeout."); @@ -495,7 +509,7 @@ if (hasGoalListener()) for (GoalListener gl: getGoalListeners()) - for (IntendedMeans im: confP.C.SI.getIMs()) + for (IntendedMeans im: confP.C.SI) //.getIMs()) gl.goalResumed(im.getTrigger()); } else { String reason = a.getFailureMsg(); @@ -664,14 +678,14 @@ // Rule Achieve case achieve: body = prepareBodyForEvent(body, u); - Event evt = conf.C.addAchvGoal(body, conf.C.SI); + conf.C.addAchvGoal(body, conf.C.SI); confP.step = State.StartRC; break; // Rule Achieve as a New Focus (the !! operator) case achieveNF: body = prepareBodyForEvent(body, u); - evt = conf.C.addAchvGoal(body, Intention.EmptyInt); + conf.C.addAchvGoal(body, Intention.EmptyInt); updateIntention(); break; @@ -687,7 +701,7 @@ body = prepareBodyForEvent(body, u); if (body.isLiteral()) { // in case body is a var with content that is not a literal (note the VarTerm pass in the instanceof Literal) Trigger te = new Trigger(TEOperator.add, TEType.test, body); - evt = new Event(te, conf.C.SI); + Event evt = new Event(te, conf.C.SI); if (ag.getPL().hasCandidatePlan(te)) { if (logger.isLoggable(Level.FINE)) logger.fine("Test Goal '" + h + "' failed as simple query. Generating internal event for it: "+te); conf.C.addEvent(evt); @@ -823,7 +837,7 @@ } // if has finished a failure handling IM ... - if (im.getTrigger().isGoal() && !im.getTrigger().isAddition() && i.size() > 0) { + if (im.getTrigger().isGoal() && !im.getTrigger().isAddition() && !i.isFinished()) {//i.size() > 0) { // needs to get rid of the IM until a goal that // has failure handling. E.g, // -!b @@ -837,7 +851,7 @@ if (im.isFinished() || !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral) || im.getCurrentStep().getBodyTerm() instanceof VarTerm) { im = i.pop(); // +!c above } - while (i.size() > 0 && + while (!i.isFinished() && //i.size() > 0 && !im.unif.unifies(im.getTrigger().getLiteral(), topLiteral) && !im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral)) { im = i.pop(); @@ -938,8 +952,7 @@ /** remove the top action and requeue the current intention */ private void updateIntention() { if (!conf.C.SI.isFinished()) { - IntendedMeans im = conf.C.SI.peek(); - im.removeCurrentStep(); + conf.C.SI.peek().removeCurrentStep(); confP.C.addIntention(conf.C.SI); } else { logger.fine("trying to update a finished intention!"); @@ -979,7 +992,7 @@ else if (setts.requeue()) { // get the external event (or the one that started // the whole focus of attention) and requeue it - im = i.get(0); + im = i.peek(); //get(0); confP.C.addExternalEv(im.getTrigger()); } else { logger.warning("Could not finish intention: " + i + "\tTrigger: " + failEvent.getTrigger()); @@ -1029,12 +1042,12 @@ public Event findEventForFailure(Intention i, Trigger tevent) { Trigger failTrigger = new Trigger(TEOperator.del, tevent.getType(), tevent.getLiteral()); if (i != Intention.EmptyInt) { - ListIterator<IntendedMeans> ii = i.iterator(); - while (!getAg().getPL().hasCandidatePlan(failTrigger) && ii.hasPrevious()) { + Iterator<IntendedMeans> ii = i.iterator(); + while (!getAg().getPL().hasCandidatePlan(failTrigger) && ii.hasNext()) { // TODO: pop IM until +!g or *!g (this TODO is valid only if meta events are pushed on top of the intention) // If *!g is found first, no failure event // - while popping, if some meta event (* > !) is in the stack, stop and simple pop instead of producing an failure event - IntendedMeans im = ii.previous(); + IntendedMeans im = ii.next(); tevent = im.getTrigger(); failTrigger = new Trigger(TEOperator.del, tevent.getType(), tevent.getLiteral()); } @@ -1107,10 +1120,39 @@ /* plus the other parts of the agent architecture besides */ /* the actual transition system of the AS interpreter */ /**********************************************************************/ + //Circumstance pc1, pc2, pc3, pc4; + public boolean reasoningCycle() { if (logger.isLoggable(Level.FINE)) logger.fine("Start new reasoning cycle"); getUserAgArch().reasoningCycleStarting(); + /* used to find bugs (ignore) + int is = C.getIntentions().size(); + int es = C.getEvents().size(); + if (is+es != 4) { + logger.info("1****"+is+" "+es); + logger.info(C.toString()); + try { + logger.info("======"+applyClrInt(C.SI)); + logger.info("======"+C.SI.isFinished()); + logger.info("======"+C.SI.getB()); + //logger.info(""+getAg().getPL()); + } catch (JasonException e) { + e.printStackTrace(); + } + logger.info("old 1"+pc1.toString()); + logger.info("old 2"+pc2.toString()); + logger.info("old 3"+pc3.toString()); + logger.info("old 4"+pc4.toString()); + System.exit(0); + return false; + } + + pc4 = pc3; + pc3 = pc2; + pc2 = pc1; + pc1 = C.clone();*/ + try { C.reset(); Modified: trunk/src/jason/asSemantics/Unifier.java =================================================================== --- trunk/src/jason/asSemantics/Unifier.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/asSemantics/Unifier.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -103,7 +103,7 @@ u.unifier( a(X,10), a(1,1) ); does not change u, i.e., u = {} */ - @SuppressWarnings("unchecked") + @SuppressWarnings({ "rawtypes", "unchecked" }) public boolean unifies(Term t1, Term t2) { HashMap cfunction = (HashMap)function.clone(); if (unifiesNoUndo(t1,t2)) { @@ -353,7 +353,7 @@ } } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public Unifier clone() { try { Unifier newUn = new Unifier(); Modified: trunk/src/jason/asSyntax/ListTermImpl.java =================================================================== --- trunk/src/jason/asSyntax/ListTermImpl.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/asSyntax/ListTermImpl.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -609,7 +609,7 @@ return getLast().append(o) != null; } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public boolean addAll(Collection c) { if (c == null) return false; ListTerm lt = this; // where to add @@ -620,7 +620,7 @@ return true; } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public boolean addAll(int index, Collection c) { Iterator<Term> i = c.iterator(); int p = index; @@ -644,7 +644,7 @@ return false; } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public boolean containsAll(Collection c) { boolean r = true; Iterator<Term> i = c.iterator(); @@ -762,7 +762,7 @@ return false; } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "rawtypes" }) public boolean removeAll(Collection c) { boolean r = true; Iterator i = c.iterator(); @@ -772,7 +772,7 @@ return r; } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "rawtypes" }) public boolean retainAll(Collection c) { boolean r = true; Iterator i = iterator(); Modified: trunk/src/jason/asSyntax/PlanLibrary.java =================================================================== --- trunk/src/jason/asSyntax/PlanLibrary.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/asSyntax/PlanLibrary.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -26,6 +26,7 @@ import jason.JasonException; +import jason.asSemantics.Message; import jason.asSyntax.Trigger.TEOperator; import jason.asSyntax.Trigger.TEType; import jason.asSyntax.parser.ParseException; @@ -36,6 +37,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -62,8 +64,10 @@ private boolean hasMetaEventPlans = false; - private static int lastPlanLabel = 0; + private static AtomicInteger lastPlanLabel = new AtomicInteger(0); + private boolean hasUserKqmlReceived = false; + //private Logger logger = Logger.getLogger(PlanLibrary.class.getName()); /** @@ -168,6 +172,12 @@ // add self source if (!p.getLabel().hasSource()) p.getLabel().addAnnot(BeliefBase.TSelf); + + if (p.getTrigger().getLiteral().getFunctor().equals(Message.kqmlReceivedFunctor)) { + if (! (p.getSrcInfo() != null && "kqmlPlans.asl".equals(p.getSrcInfo().getSrcFile()))) { + hasUserKqmlReceived = true; + } + } p.setAsPlanTerm(false); // it is not a term anymore @@ -226,12 +236,16 @@ public boolean hasMetaEventPlans() { return hasMetaEventPlans; } + + public boolean hasUserKqmlReceivedPlans() { + return hasUserKqmlReceived; + } /** add a label to the plan */ private Pred getUniqueLabel() { String l; do { - l = "l__" + (lastPlanLabel++); + l = "l__" + (lastPlanLabel.incrementAndGet()); } while (planLabels.keySet().contains(l)); return new Pred(l); } Modified: trunk/src/jason/control/ExecutionControlGUI.java =================================================================== --- trunk/src/jason/control/ExecutionControlGUI.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/control/ExecutionControlGUI.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -178,6 +178,21 @@ showAgState(); } }); + + /* + JButton jBtRefresh = new JButton("Show extra info"); + jBtRefresh.setEnabled(true); + jBtRefresh.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + agsHistory.clear(); + showAgState(); + System.out.println("***"+RunCentralisedMAS.getRunner().sleepingAgs); + for (CentralisedAgArch ar: RunCentralisedMAS.getRunner().sleepingAgs) { + System.out.println(ar+":"+ar.canSleep()); + } + } + });*/ + jTA = new JTextPane(); jTA.setEditable(false); @@ -251,6 +266,7 @@ pButtons.add(jCbWho); pButtons.add(new JLabel(" view as:")); pButtons.add(jCbViewAs); + //pButtons.add(jBtRefresh); JSplitPane splitPaneHor = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPaneHor.setTopComponent(spList); Modified: trunk/src/jason/infra/centralised/CentralisedAgArch.java =================================================================== --- trunk/src/jason/infra/centralised/CentralisedAgArch.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/infra/centralised/CentralisedAgArch.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -38,6 +38,7 @@ import jason.runtime.Settings; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; @@ -64,9 +65,6 @@ private CentralisedExecutionControl infraControl = null; private RunCentralisedMAS masRunner = RunCentralisedMAS.getRunner(); - /** The user implementation of the architecture */ - //protected AgArch userAgArch; - private String agName = ""; private boolean running = true; private Queue<Message> mbox = new ConcurrentLinkedQueue<Message>(); @@ -285,6 +283,10 @@ im = mbox.poll(); } } + + public Collection<Message> getMBox() { + return mbox; + } /** called by the TS to ask the execution of an action in the environment */ public void act(ActionExec action, List<ActionExec> feedback) { Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -475,12 +475,10 @@ } // create the pool - // executor = Executors.newCachedThreadPool(); executor = Executors.newFixedThreadPool(poolSize); // initially, add all agents in the tasks for (CentralisedAgArch ag : ags.values()) { - //myAgTasks.offer(ag); executor.execute(ag); } @@ -500,10 +498,29 @@ } } }.start();*/ + + /* + new Thread("wakeup") { + public void run() { + while (runner != null) { + try { + sleep(1000); + for (CentralisedAgArch ar: sleepingAgs) { + if (!ar.getTS().canSleep()) + ar.wake(); + } + } catch (Exception e) { + System.out.println("**"); + } + } + } + }.start();*/ } /** an agent architecture for the infra based on thread pool */ private final class CentralisedAgArchForPool extends CentralisedAgArch { + + boolean runWakeAfterTS = false; @Override public void sleep() { @@ -513,21 +530,33 @@ } @Override - public void wake() { + public void wake() { if (sleepingAgs.remove(this)) { /*try { ThreadPoolExecutor tp = (ThreadPoolExecutor)executor; if (tp.getQueue().contains(this)) { System.out.println("ops... ading ag that is already in the pool "+this); } - } catch (Exception e) { }*/ + } catch (Exception e) { }*/ executor.execute(this); + } else { + runWakeAfterTS = true; } } + /*@Override + public void receiveMsg(final Message m) { + executor.execute(new Runnable() { + public void run() { + CentralisedAgArchForPool.super.receiveMsg(m); + } + }); + }*/ + @Override public void run() { if (isRunning()) { + runWakeAfterTS = false; if (getTS().reasoningCycle()) { // the agent run a cycle (did not enter in sleep) /*try { ThreadPoolExecutor tp = (ThreadPoolExecutor)executor; @@ -536,6 +565,8 @@ } } catch (Exception e) { }*/ executor.execute(this); + } else if (runWakeAfterTS) { + wake(); } } } Modified: trunk/src/jason/stdlib/add_nested_source.java =================================================================== --- trunk/src/jason/stdlib/add_nested_source.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/stdlib/add_nested_source.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -85,15 +85,15 @@ @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { checkArguments(args); - Term result = addAnnotToList(un, args[0], args[1].clone()); + Term result = addAnnotToList(args[0], args[1]); return un.unifies(result,args[2]); } - public Term addAnnotToList(Unifier unif, Term l, Term source) { + public static Term addAnnotToList(Term l, Term source) { if (l.isList()) { ListTerm result = new ListTermImpl(); for (Term lTerm: (ListTerm)l) { - Term t = addAnnotToList( unif, lTerm, source); + Term t = addAnnotToList( lTerm, source); if (t != null) { result.add(t); } Modified: trunk/src/jason/stdlib/at.java =================================================================== --- trunk/src/jason/stdlib/at.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/stdlib/at.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -37,6 +37,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; /** <p>Internal action: <b><code>.at</code></b>. @@ -128,7 +129,7 @@ return true; } - private static int idCount = 0; + private static AtomicInteger idCount = new AtomicInteger(0); private Map<Integer,CheckDeadline> ats = new ConcurrentHashMap<Integer,CheckDeadline>(); public void cancelAts() { @@ -143,8 +144,7 @@ private boolean cancelled = false; public CheckDeadline(Trigger te, TransitionSystem ts) { - idCount++; - this.id = idCount; + this.id = idCount.incrementAndGet(); this.event = new Event(te, Intention.EmptyInt); this.ts = ts; ats.put(id, this); Modified: trunk/src/jason/stdlib/desire.java =================================================================== --- trunk/src/jason/stdlib/desire.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/stdlib/desire.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -141,7 +141,7 @@ if (C.getSelectedEvent() != null) { Trigger t = C.getSelectedEvent().getTrigger(); Intention i = C.getSelectedEvent().getIntention(); - if (i != Intention.EmptyInt && i.size() > 0) { + if (i != Intention.EmptyInt && !i.isFinished()) { //i.size() > 0) { t = t.clone(); t.apply(i.peek().getUnif()); } @@ -161,7 +161,7 @@ Event ei = evtIterator.next(); Trigger t = ei.getTrigger(); Intention i = ei.getIntention(); - if (i != Intention.EmptyInt && i.size() > 0) { + if (i != Intention.EmptyInt && !i.isFinished()) { //i.size() > 0) { t = t.clone(); t.apply(i.peek().getUnif()); } Modified: trunk/src/jason/stdlib/puts.java =================================================================== --- trunk/src/jason/stdlib/puts.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/stdlib/puts.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -63,9 +63,6 @@ public class puts extends DefaultInternalAction { - /** - * - */ private static final long serialVersionUID = 1L; private static InternalAction singleton = null; Modified: trunk/src/jason/stdlib/succeed_goal.java =================================================================== --- trunk/src/jason/stdlib/succeed_goal.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/jason/stdlib/succeed_goal.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -120,7 +120,7 @@ } else { // test in the event Trigger t = e.getTrigger(); - if (i != Intention.EmptyInt && i.size() > 0) { + if (i != Intention.EmptyInt && !i.isFinished()) { //i.size() > 0) { t = t.clone(); t.apply(i.peek().getUnif()); } @@ -146,7 +146,7 @@ } else { // test in the event Trigger t = e.getTrigger(); - if (i != Intention.EmptyInt && i.size() > 0) { + if (i != Intention.EmptyInt && !i.isFinished()) { //i.size() > 0) { t = t.clone(); t.apply(i.peek().getUnif()); } Modified: trunk/src/test/ASParserTest.java =================================================================== --- trunk/src/test/ASParserTest.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/test/ASParserTest.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -46,7 +46,8 @@ assertTrue(ag.parseAS(new File("src/asl/kqmlPlans.asl"))); assertTrue(ag.parseAS(new File("examples/auction/ag1.asl"))); - Plan p = ag.getPL().get("l__0"); + Plan p = ag.getPL().get("l__1"); + assertNotNull(p); assertEquals(p.getBody().getPlanSize(), 1); assertEquals(((PlanBody)p.getBody()).getBodyType(), PlanBody.BodyType.internalAction); assertTrue(ag.parseAS(new File("examples/auction/ag2.asl"))); Modified: trunk/src/test/StdLibTest.java =================================================================== --- trunk/src/test/StdLibTest.java 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/test/StdLibTest.java 2012-08-03 20:19:58 UTC (rev 1705) @@ -2,7 +2,6 @@ import jason.RevisionFailedException; import jason.asSemantics.Agent; -import jason.asSemantics.Circumstance; import jason.asSemantics.IntendedMeans; import jason.asSemantics.Intention; import jason.asSemantics.Option; @@ -229,7 +228,7 @@ } } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public void testSubString() throws Exception { StringTerm s1 = new StringTermImpl("a"); StringTerm s2 = new StringTermImpl("bbacca"); @@ -263,11 +262,10 @@ } public void testDropGoal2() throws Exception { - Circumstance c = new Circumstance(); Agent ag = new Agent(); ag.initAg(); - c.addIntention(intention1); - TransitionSystem ts = new TransitionSystem(ag, c, null, null); + TransitionSystem ts = new TransitionSystem(ag, null, null, null); + ts.getC().addIntention(intention1); assertFalse(ts.hasGoalListener()); new succeed_goal().drop(ts, Literal.parseLiteral("g2"), new Unifier()); assertEquals(intention1.size(), 1); @@ -277,12 +275,12 @@ } public void testDropGoal3() throws Exception { - Circumstance c = new Circumstance(); - c.addIntention(intention1); - TransitionSystem ts = new TransitionSystem(ag, c, null, null); + //Circumstance c = new Circumstance(); + TransitionSystem ts = new TransitionSystem(ag, null, null, null); + ts.getC().addIntention(intention1); new fail_goal().drop(ts, Literal.parseLiteral("g2"), new Unifier()); assertEquals(intention1.size(),2); - assertEquals(c.getEvents().size(),1); + assertEquals(ts.getC().getEvents().size(),1); } @SuppressWarnings("unchecked") @@ -571,7 +569,7 @@ assertEquals("\"bc\"",u.get("X").toString()); } - @SuppressWarnings("unchecked") + @SuppressWarnings({ "rawtypes" }) private int iteratorSize(Iterator i) { int c = 0; while (i.hasNext()) { Modified: trunk/src/xml/agInspection.xsl =================================================================== --- trunk/src/xml/agInspection.xsl 2012-07-31 19:07:11 UTC (rev 1704) +++ trunk/src/xml/agInspection.xsl 2012-08-03 20:19:58 UTC (rev 1705) @@ -265,6 +265,9 @@ <td valign="top"> <table cellspacing="0" cellpadding="2"> <xsl:apply-templates /> + <xsl:if test="@finished = 'true'"> + <b> (finished)</b> + </xsl:if> </table> <hr/> </td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-07-31 19:07:18
|
Revision: 1704 http://jason.svn.sourceforge.net/jason/?rev=1704&view=rev Author: jomifred Date: 2012-07-31 19:07:11 +0000 (Tue, 31 Jul 2012) Log Message: ----------- refactor some methods in Circumstance Modified Paths: -------------- trunk/src/jason/asSemantics/Circumstance.java trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/control/ExecutionControlGUI.java trunk/src/jason/infra/centralised/CentralisedAgArch.java trunk/src/jason/infra/centralised/RunCentralisedMAS.java Modified: trunk/src/jason/asSemantics/Circumstance.java =================================================================== --- trunk/src/jason/asSemantics/Circumstance.java 2012-07-15 03:02:41 UTC (rev 1703) +++ trunk/src/jason/asSemantics/Circumstance.java 2012-07-31 19:07:11 UTC (rev 1704) @@ -33,7 +33,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Queue; @@ -51,7 +50,7 @@ private Queue<Event> E; private Queue<Intention> I; protected ActionExec A; - protected Queue<Message> MB; + private Queue<Message> MB; protected List<Option> RP; protected List<Option> AP; protected Event SE; @@ -78,7 +77,7 @@ // use LinkedList since we use a lot of remove(0) in selectEvent E = new ConcurrentLinkedQueue<Event>(); I = new ConcurrentLinkedQueue<Intention>(); - MB = new LinkedList<Message>(); + MB = new ConcurrentLinkedQueue<Message>(); PA = new ConcurrentHashMap<Integer, ActionExec>(); PI = new ConcurrentHashMap<String, Intention>(); PE = new ConcurrentHashMap<String, Event>(); @@ -201,6 +200,14 @@ public Queue<Message> getMailBox() { return MB; } + + public void addMsg(Message m) { + MB.offer(m); + } + + public boolean hasMsg() { + return !MB.isEmpty(); + } /** Intentions */ @@ -553,9 +560,9 @@ Element e; // MB - if (getMailBox() != null && !getMailBox().isEmpty()) { + if (MB != null && hasMsg()) { Element ms = (Element) document.createElement("mailbox"); - for (Message m: getMailBox()) { + for (Message m: MB) { e = (Element) document.createElement("message"); e.appendChild(document.createTextNode(m.toString())); ms.appendChild(e); Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2012-07-15 03:02:41 UTC (rev 1703) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2012-07-31 19:07:11 UTC (rev 1704) @@ -219,8 +219,8 @@ private void applyProcMsg() throws JasonException { confP.step = State.SelEv; - if (!conf.C.MB.isEmpty()) { - Message m = conf.ag.selectMessage(conf.C.MB); + if (conf.C.hasMsg()) { + Message m = conf.ag.selectMessage(conf.C.getMailBox()); if (m == null) return; // get the content, it can be any term (literal, list, number, ...; see ask) @@ -296,6 +296,9 @@ String sender = m.getSender(); if (sender.equals(getUserAgArch().getAgName())) sender = "self"; + if (m.getIlForce().equals("achieve") && content.isLiteral()) { + updateEvents(new Event(new Trigger(TEOperator.add, TEType.achieve, (Literal)content), Intention.EmptyInt)); + } else { Literal received = new LiteralImpl("kqml_received").addTerms( new Atom(sender), new Atom(m.getIlForce()), @@ -303,6 +306,7 @@ new Atom(m.getMsgId())); updateEvents(new Event(new Trigger(TEOperator.add, TEType.achieve, received), Intention.EmptyInt)); + } } else { logger.fine("Ignoring message "+m+" because it is received after the timeout."); } @@ -1080,10 +1084,10 @@ } public boolean canSleep() { - return (C.isAtomicIntentionSuspended() && conf.C.MB.isEmpty()) + return (C.isAtomicIntentionSuspended() && !conf.C.hasMsg()) || (!conf.C.hasEvent() && !conf.C.hasIntention() && !conf.C.hasFeedbackAction() && - conf.C.MB.isEmpty() && + !conf.C.hasMsg() && //taskForBeginOfCycle.isEmpty() && getUserAgArch().canSleep()); } Modified: trunk/src/jason/control/ExecutionControlGUI.java =================================================================== --- trunk/src/jason/control/ExecutionControlGUI.java 2012-07-15 03:02:41 UTC (rev 1703) +++ trunk/src/jason/control/ExecutionControlGUI.java 2012-07-31 19:07:11 UTC (rev 1704) @@ -42,6 +42,8 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.Map; +import java.util.Set; +import java.util.TreeSet; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.logging.Level; @@ -291,7 +293,8 @@ void setListOfAgsFromInfra() { try { - for (String ag: getExecutionControlInfraTier().getRuntimeServices().getAgentsNames()) { + Set<String> ags = new TreeSet<String>(getExecutionControlInfraTier().getRuntimeServices().getAgentsNames()); + for (String ag: ags) { //getExecutionControlInfraTier().getRuntimeServices().getAgentsNames()) { listModel.addElement(ag); } } catch (Exception e) { Modified: trunk/src/jason/infra/centralised/CentralisedAgArch.java =================================================================== --- trunk/src/jason/infra/centralised/CentralisedAgArch.java 2012-07-15 03:02:41 UTC (rev 1703) +++ trunk/src/jason/infra/centralised/CentralisedAgArch.java 2012-07-31 19:07:11 UTC (rev 1704) @@ -29,6 +29,7 @@ import jason.architecture.MindInspectorAgArch; import jason.asSemantics.ActionExec; import jason.asSemantics.Agent; +import jason.asSemantics.Circumstance; import jason.asSemantics.Message; import jason.asSemantics.TransitionSystem; import jason.asSyntax.Literal; @@ -245,7 +246,7 @@ if (m.getSender() == null) m.setSender(getAgName()); CentralisedAgArch rec = masRunner.getAg(m.getReceiver()); - + if (rec == null) { if (isRunning()) throw new ReceiverNotFoundException("Receiver '" + m.getReceiver() + "' does not exists! Could not send " + m); @@ -276,11 +277,12 @@ // Default procedure for checking messages, move message from local mbox to C.mbox public void checkMail() { - Queue<Message> tsmb = getTS().getC().getMailBox(); - while (!mbox.isEmpty()) { - Message im = mbox.poll(); - tsmb.offer(im); + Circumstance C = getTS().getC(); + Message im = mbox.poll(); + while (im != null) { + C.addMsg(im); if (logger.isLoggable(Level.FINE)) logger.fine("received message: " + im); + im = mbox.poll(); } } Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2012-07-15 03:02:41 UTC (rev 1703) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2012-07-31 19:07:11 UTC (rev 1704) @@ -526,7 +526,6 @@ } @Override - //synchronized public void run() { if (isRunning()) { if (getTS().reasoningCycle()) { // the agent run a cycle (did not enter in sleep) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <xsp...@us...> - 2012-07-15 03:02:48
|
Revision: 1703 http://jason.svn.sourceforge.net/jason/?rev=1703&view=rev Author: xsplyter Date: 2012-07-15 03:02:41 +0000 (Sun, 15 Jul 2012) Log Message: ----------- added the dependence org.eclipse.xtext.logging updated the plugin.xml with the content of plugin.xml_gen removed the dependence org.eclipse.xtend2 and org.eclipse.xtext.xtend2 Modified Paths: -------------- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/plugin.xml trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml_gen trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/plugin.xml trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml_gen trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml trunk/applications/jason-eclipse-plugin2/jasonide_site/artifacts.jar trunk/applications/jason-eclipse-plugin2/jasonide_site/content.jar trunk/applications/jason-eclipse-plugin2/jasonide_site/logs.zip trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF 2012-07-14 17:12:03 UTC (rev 1702) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF 2012-07-15 03:02:41 UTC (rev 1703) @@ -17,11 +17,9 @@ org.eclipse.emf.common, org.antlr.runtime, org.eclipse.xtext.common.types -Import-Package: org.apache.log4j, - org.apache.commons.logging, - org.eclipse.xtext.xbase.lib, - org.eclipse.xtext.xtend2.lib, - org.eclipse.xtend2.lib +Import-Package: org.apache.commons.logging, + org.apache.log4j, + org.eclipse.xtext.xbase.lib Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: jasonide.xtext.asl, jasonide.xtext.asl.services, Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/plugin.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/plugin.xml 2012-07-14 17:12:03 UTC (rev 1702) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/plugin.xml 2012-07-15 03:02:41 UTC (rev 1703) @@ -11,10 +11,4 @@ </extension> - - <requires> - <import plugin="org.eclipse.xtext"/> - </requires> - - </plugin> Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml 2012-07-14 17:12:03 UTC (rev 1702) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml 2012-07-15 03:02:41 UTC (rev 1703) @@ -72,6 +72,19 @@ </page> </extension> <extension + point="org.eclipse.ui.propertyPages"> + <page + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage" + id="jasonide.xtext.asl.Asl" + name="Asl"> + <keywordReference id="jasonide.xtext.asl.ui.keyword_Asl"/> + <enabledWhen> + <adapt type="org.eclipse.core.resources.IProject"/> + </enabledWhen> + <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/> + </page> + </extension> + <extension point="org.eclipse.ui.keywords"> <keyword id="jasonide.xtext.asl.ui.keyword_Asl" @@ -139,6 +152,28 @@ </extension> + <!-- marker definitions for jasonide.xtext.asl.Asl --> + <extension + id="asl.check.fast" + name="Asl Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.fast"/> + <persistent value="true"/> + </extension> + <extension + id="asl.check.normal" + name="Asl Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.normal"/> + <persistent value="true"/> + </extension> + <extension + id="asl.check.expensive" + name="Asl Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.expensive"/> + <persistent value="true"/> + </extension> <extension point="org.eclipse.xtext.builder.participant"> @@ -146,6 +181,30 @@ class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant"> </participant> </extension> + <extension + point="org.eclipse.ui.preferencePages"> + <page + category="jasonide.xtext.asl.Asl" + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage" + id="jasonide.xtext.asl.Asl.compiler.preferencePage" + name="Compiler"> + <keywordReference id="jasonide.xtext.asl.ui.keyword_Asl"/> + </page> + </extension> + <extension + point="org.eclipse.ui.propertyPages"> + <page + category="jasonide.xtext.asl.Asl" + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage" + id="jasonide.xtext.asl.Asl.compiler.propertyPage" + name="Compiler"> + <keywordReference id="jasonide.xtext.asl.ui.keyword_Asl"/> + <enabledWhen> + <adapt type="org.eclipse.core.resources.IProject"/> + </enabledWhen> + <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/> + </page> + </extension> <!-- Quick Outline --> <extension @@ -180,14 +239,34 @@ </command> </menuContribution> </extension> - <!-- quickfix marker resolution generator --> - <extension - point="org.eclipse.ui.ide.markerResolution"> - <markerResolutionGenerator - class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"> - </markerResolutionGenerator> - </extension> - + <!-- quickfix marker resolution generator for jasonide.xtext.asl.Asl --> + <extension + point="org.eclipse.ui.ide.markerResolution"> + <markerResolutionGenerator + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.asl.ui.asl.check.fast"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + <markerResolutionGenerator + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.asl.ui.asl.check.normal"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + <markerResolutionGenerator + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.asl.ui.asl.check.expensive"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + </extension> <!-- Rename Refactoring --> <extension point="org.eclipse.ui.handlers"> <handler @@ -213,6 +292,15 @@ </command> </menuContribution> </extension> + <extension point="org.eclipse.ui.preferencePages"> + <page + category="jasonide.xtext.asl.Asl" + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage" + id="jasonide.xtext.asl.Asl.refactoring" + name="Refactoring"> + <keywordReference id="jasonide.xtext.asl.ui.keyword_Asl"/> + </page> + </extension> <extension point="org.eclipse.compare.contentViewers"> <viewer id="jasonide.xtext.asl.Asl.compare.contentViewers" @@ -233,8 +321,4 @@ </provider> </extension> - <requires> - <import plugin="org.eclipse.xtext"/> - </requires> - </plugin> Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml_gen =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml_gen 2012-07-14 17:12:03 UTC (rev 1702) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml_gen 2012-07-15 03:02:41 UTC (rev 1703) @@ -151,6 +151,28 @@ </extension> + <!-- marker definitions for jasonide.xtext.asl.Asl --> + <extension + id="asl.check.fast" + name="Asl Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.fast"/> + <persistent value="true"/> + </extension> + <extension + id="asl.check.normal" + name="Asl Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.normal"/> + <persistent value="true"/> + </extension> + <extension + id="asl.check.expensive" + name="Asl Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.expensive"/> + <persistent value="true"/> + </extension> <extension point="org.eclipse.xtext.builder.participant"> @@ -216,13 +238,34 @@ </command> </menuContribution> </extension> - <!-- quickfix marker resolution generator --> - <extension - point="org.eclipse.ui.ide.markerResolution"> - <markerResolutionGenerator - class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"> - </markerResolutionGenerator> - </extension> + <!-- quickfix marker resolution generator for jasonide.xtext.asl.Asl --> + <extension + point="org.eclipse.ui.ide.markerResolution"> + <markerResolutionGenerator + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.asl.ui.asl.check.fast"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + <markerResolutionGenerator + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.asl.ui.asl.check.normal"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + <markerResolutionGenerator + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.asl.ui.asl.check.expensive"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + </extension> <!-- Rename Refactoring --> <extension point="org.eclipse.ui.handlers"> <handler Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF 2012-07-14 17:12:03 UTC (rev 1702) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF 2012-07-15 03:02:41 UTC (rev 1703) @@ -7,7 +7,7 @@ Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.xtext;bundle-version="2.0.0";visibility:=reexport, org.apache.log4j;bundle-version="1.2.15";visibility:=reexport, - org.apache.commons.logging;bundle-version="1.0.4";resolution:=optional;visibility:=reexport, + org.apache.commons.logging;bundle-version="1.0.4", org.eclipse.xtext.generator;resolution:=optional, org.eclipse.emf.codegen.ecore;resolution:=optional, org.eclipse.emf.mwe.utils;resolution:=optional, @@ -21,9 +21,7 @@ org.eclipse.core.runtime;bundle-version="3.7.0" Import-Package: org.apache.log4j, org.apache.commons.logging, - org.eclipse.xtext.xbase.lib, - org.eclipse.xtext.xtend2.lib, - org.eclipse.xtend2.lib + org.eclipse.xtext.xbase.lib Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: jasonide.xtext.mas2j, jasonide.xtext.mas2j.services, Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/plugin.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/plugin.xml 2012-07-14 17:12:03 UTC (rev 1702) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/plugin.xml 2012-07-15 03:02:41 UTC (rev 1703) @@ -11,10 +11,4 @@ </extension> - - <requires> - <import plugin="org.eclipse.xtext"/> - </requires> - - </plugin> Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml 2012-07-14 17:12:03 UTC (rev 1702) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml 2012-07-15 03:02:41 UTC (rev 1703) @@ -72,6 +72,19 @@ </page> </extension> <extension + point="org.eclipse.ui.propertyPages"> + <page + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage" + id="jasonide.xtext.mas2j.Mas2j" + name="Mas2j"> + <keywordReference id="jasonide.xtext.mas2j.ui.keyword_Mas2j"/> + <enabledWhen> + <adapt type="org.eclipse.core.resources.IProject"/> + </enabledWhen> + <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/> + </page> + </extension> + <extension point="org.eclipse.ui.keywords"> <keyword id="jasonide.xtext.mas2j.ui.keyword_Mas2j" @@ -139,6 +152,28 @@ </extension> + <!-- marker definitions for jasonide.xtext.mas2j.Mas2j --> + <extension + id="mas2j.check.fast" + name="Mas2j Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.fast"/> + <persistent value="true"/> + </extension> + <extension + id="mas2j.check.normal" + name="Mas2j Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.normal"/> + <persistent value="true"/> + </extension> + <extension + id="mas2j.check.expensive" + name="Mas2j Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.expensive"/> + <persistent value="true"/> + </extension> <extension point="org.eclipse.xtext.builder.participant"> @@ -146,6 +181,30 @@ class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant"> </participant> </extension> + <extension + point="org.eclipse.ui.preferencePages"> + <page + category="jasonide.xtext.mas2j.Mas2j" + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage" + id="jasonide.xtext.mas2j.Mas2j.compiler.preferencePage" + name="Compiler"> + <keywordReference id="jasonide.xtext.mas2j.ui.keyword_Mas2j"/> + </page> + </extension> + <extension + point="org.eclipse.ui.propertyPages"> + <page + category="jasonide.xtext.mas2j.Mas2j" + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage" + id="jasonide.xtext.mas2j.Mas2j.compiler.propertyPage" + name="Compiler"> + <keywordReference id="jasonide.xtext.mas2j.ui.keyword_Mas2j"/> + <enabledWhen> + <adapt type="org.eclipse.core.resources.IProject"/> + </enabledWhen> + <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/> + </page> + </extension> <!-- Quick Outline --> <extension @@ -180,14 +239,34 @@ </command> </menuContribution> </extension> - <!-- quickfix marker resolution generator --> - <extension - point="org.eclipse.ui.ide.markerResolution"> - <markerResolutionGenerator - class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"> - </markerResolutionGenerator> - </extension> - + <!-- quickfix marker resolution generator for jasonide.xtext.mas2j.Mas2j --> + <extension + point="org.eclipse.ui.ide.markerResolution"> + <markerResolutionGenerator + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.mas2j.ui.mas2j.check.fast"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + <markerResolutionGenerator + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.mas2j.ui.mas2j.check.normal"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + <markerResolutionGenerator + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.mas2j.ui.mas2j.check.expensive"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + </extension> <!-- Rename Refactoring --> <extension point="org.eclipse.ui.handlers"> <handler @@ -213,6 +292,15 @@ </command> </menuContribution> </extension> + <extension point="org.eclipse.ui.preferencePages"> + <page + category="jasonide.xtext.mas2j.Mas2j" + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage" + id="jasonide.xtext.mas2j.Mas2j.refactoring" + name="Refactoring"> + <keywordReference id="jasonide.xtext.mas2j.ui.keyword_Mas2j"/> + </page> + </extension> <extension point="org.eclipse.compare.contentViewers"> <viewer id="jasonide.xtext.mas2j.Mas2j.compare.contentViewers" @@ -233,8 +321,4 @@ </provider> </extension> - <requires> - <import plugin="org.eclipse.xtext"/> - </requires> - </plugin> Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml_gen =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml_gen 2012-07-14 17:12:03 UTC (rev 1702) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml_gen 2012-07-15 03:02:41 UTC (rev 1703) @@ -151,6 +151,28 @@ </extension> + <!-- marker definitions for jasonide.xtext.mas2j.Mas2j --> + <extension + id="mas2j.check.fast" + name="Mas2j Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.fast"/> + <persistent value="true"/> + </extension> + <extension + id="mas2j.check.normal" + name="Mas2j Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.normal"/> + <persistent value="true"/> + </extension> + <extension + id="mas2j.check.expensive" + name="Mas2j Problem" + point="org.eclipse.core.resources.markers"> + <super type="org.eclipse.xtext.ui.check.expensive"/> + <persistent value="true"/> + </extension> <extension point="org.eclipse.xtext.builder.participant"> @@ -216,13 +238,34 @@ </command> </menuContribution> </extension> - <!-- quickfix marker resolution generator --> - <extension - point="org.eclipse.ui.ide.markerResolution"> - <markerResolutionGenerator - class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"> - </markerResolutionGenerator> - </extension> + <!-- quickfix marker resolution generator for jasonide.xtext.mas2j.Mas2j --> + <extension + point="org.eclipse.ui.ide.markerResolution"> + <markerResolutionGenerator + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.mas2j.ui.mas2j.check.fast"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + <markerResolutionGenerator + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.mas2j.ui.mas2j.check.normal"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + <markerResolutionGenerator + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator" + markerType="jasonide.xtext.mas2j.ui.mas2j.check.expensive"> + <attribute + name="FIXABLE_KEY" + value="true"> + </attribute> + </markerResolutionGenerator> + </extension> <!-- Rename Refactoring --> <extension point="org.eclipse.ui.handlers"> <handler Modified: trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml 2012-07-14 17:12:03 UTC (rev 1702) +++ trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml 2012-07-15 03:02:41 UTC (rev 1703) @@ -48,7 +48,6 @@ <import plugin="org.eclipse.xtext.util"/> <import plugin="org.eclipse.xtext.common.types"/> <import plugin="org.eclipse.xtext.xbase.lib"/> - <import plugin="org.eclipse.xtext.xtend2.lib"/> <import plugin="org.eclipse.xtext.ui"/> <import plugin="org.eclipse.xtext.ui.shared"/> <import plugin="org.eclipse.xtext.builder"/> @@ -118,4 +117,12 @@ version="0.0.0" unpack="false"/> + <plugin + id="org.eclipse.xtext.logging" + download-size="0" + install-size="0" + version="0.0.0" + fragment="true" + unpack="false"/> + </feature> Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/artifacts.jar =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/content.jar =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/logs.zip =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml 2012-07-14 17:12:03 UTC (rev 1702) +++ trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml 2012-07-15 03:02:41 UTC (rev 1703) @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <site> - <feature url="features/jasonide_feature_1.0.7.201207141346.jar" id="jasonide_feature" version="1.0.7.201207141346"> + <feature url="features/jasonide_feature_1.0.7.201207142008.jar" id="jasonide_feature" version="1.0.7.201207142008"> <category name="jasonide"/> </feature> <category-def name="jasonide" label="jasonide"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <xsp...@us...> - 2012-07-14 17:12:09
|
Revision: 1702 http://jason.svn.sourceforge.net/jason/?rev=1702&view=rev Author: xsplyter Date: 2012-07-14 17:12:03 +0000 (Sat, 14 Jul 2012) Log Message: ----------- Released new version compatible with Xtext2.2.1 and eclipse Juno Modified Paths: -------------- trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml trunk/applications/jason-eclipse-plugin2/jasonide_site/artifacts.jar trunk/applications/jason-eclipse-plugin2/jasonide_site/content.jar trunk/applications/jason-eclipse-plugin2/jasonide_site/logs.zip trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml Modified: trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml 2012-07-13 21:26:01 UTC (rev 1701) +++ trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml 2012-07-14 17:12:03 UTC (rev 1702) @@ -4,22 +4,23 @@ label="Jasonide_feature" version="1.0.7.qualifier"> - <description url="http://www.example.com/description"> + <description url="http://jason.sf.net"> Jason is an interpreter for an extended version of AgentSpeak First release: December 2003. -Jason is distributed under LGPL (see file LICENSE in the Jason directory). - -For more information, please read doc/index.html in the Jason directory. - +Jason is distributed under LGPL (see file LICENSE in the Jason +directory). +For more information, please read doc/index.html in the Jason +directory. Thank you for your interest in Jason! </description> - <copyright url="http://www.example.com/copyright"> + <copyright> Copyright (C) 2003 Rafael H. Bordini, Jomi F. Hubner, et al. -Jason is distributed under LGPL. See file LGPL.txt in the Jason directory. +Jason is distributed under LGPL. See file LGPL.txt in the Jason +directory. </copyright> - <license url="http://www.example.com/license"> + <license url=""> Copyright (C) 2003 Rafael H. Bordini, Jomi F. Hubner, et al. Jason is distributed under LGPL. See file LGPL.txt in the Jason directory. Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/artifacts.jar =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/content.jar =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/logs.zip =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml 2012-07-13 21:26:01 UTC (rev 1701) +++ trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml 2012-07-14 17:12:03 UTC (rev 1702) @@ -1,4 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <site> - <feature url="features/jasonide_feature_1.0.7.201207091232.jar" id="jasonide_feature" version="1.0.7.201207091232"/> + <feature url="features/jasonide_feature_1.0.7.201207141346.jar" id="jasonide_feature" version="1.0.7.201207141346"> + <category name="jasonide"/> + </feature> + <category-def name="jasonide" label="jasonide"/> </site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-07-13 21:26:08
|
Revision: 1701 http://jason.svn.sourceforge.net/jason/?rev=1701&view=rev Author: jomifred Date: 2012-07-13 21:26:01 +0000 (Fri, 13 Jul 2012) Log Message: ----------- improve performance of centralised + pool of threads Modified Paths: -------------- trunk/examples/game-of-life/bin/c-build.xml trunk/src/jason/architecture/AgArch.java trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/environment/Environment.java trunk/src/jason/infra/centralised/RunCentralisedMAS.java Modified: trunk/examples/game-of-life/bin/c-build.xml =================================================================== --- trunk/examples/game-of-life/bin/c-build.xml 2012-07-12 15:01:11 UTC (rev 1700) +++ trunk/examples/game-of-life/bin/c-build.xml 2012-07-13 21:26:01 UTC (rev 1701) @@ -11,7 +11,7 @@ June 24, 2011 - 10:32:24 --> -<project name ="game_of_life" +<project name ="game_of_life-custom" basedir=".." default="run"> Modified: trunk/src/jason/architecture/AgArch.java =================================================================== --- trunk/src/jason/architecture/AgArch.java 2012-07-12 15:01:11 UTC (rev 1700) +++ trunk/src/jason/architecture/AgArch.java 2012-07-13 21:26:01 UTC (rev 1701) @@ -52,7 +52,7 @@ * * Users can customise the architecture by overriding some methods of this class. */ -public class AgArch implements AgArchInfraTier { +public class AgArch implements AgArchInfraTier, Comparable<AgArch> { private TransitionSystem ts = null; @@ -265,5 +265,26 @@ public int getCycleNumber() { return cycleNumber; } + + @Override + public String toString() { + return "arch-"+getAgName(); + } + @Override + public int hashCode() { + return getAgName().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) return false; + if (obj == this) return true; + if (obj instanceof AgArch) return this.getAgName().equals(((AgArch)obj).getAgName()); + return false; + } + + public int compareTo(AgArch o) { + return getAgName().compareTo(o.getAgName()); + } } Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2012-07-12 15:01:11 UTC (rev 1700) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2012-07-13 21:26:01 UTC (rev 1701) @@ -1103,7 +1103,7 @@ /* plus the other parts of the agent architecture besides */ /* the actual transition system of the AS interpreter */ /**********************************************************************/ - public void reasoningCycle() { + public boolean reasoningCycle() { if (logger.isLoggable(Level.FINE)) logger.fine("Start new reasoning cycle"); getUserAgArch().reasoningCycleStarting(); @@ -1130,13 +1130,13 @@ C.addExternalEv(PlanLibrary.TE_IDLE); } else { getUserAgArch().sleep(); - return; + return false; } } step = State.StartRC; do { - if (!getUserAgArch().isRunning()) return; + if (!getUserAgArch().isRunning()) return false; applySemanticRule(); } while (step != State.StartRC); @@ -1151,6 +1151,8 @@ logger.log(Level.SEVERE, "*** ERROR in the transition system. "+conf.C+"\nCreating a new C!", e); conf.C.create(); } + + return true; } // Auxiliary functions Modified: trunk/src/jason/environment/Environment.java =================================================================== --- trunk/src/jason/environment/Environment.java 2012-07-12 15:01:11 UTC (rev 1700) +++ trunk/src/jason/environment/Environment.java 2012-07-13 21:26:01 UTC (rev 1701) @@ -321,9 +321,9 @@ return c; } - @SuppressWarnings("unchecked") public boolean containsPercept(String agName, Literal per) { if (per != null && agName != null) { + @SuppressWarnings("rawtypes") List agl = (List)agPercepts.get(agName); if (agl != null) { return agl.contains(per); Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2012-07-12 15:01:11 UTC (rev 1700) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2012-07-13 21:26:01 UTC (rev 1701) @@ -46,12 +46,13 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.util.Collections; +import java.util.HashSet; import java.util.Map; -import java.util.concurrent.BlockingQueue; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; 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; @@ -438,7 +439,7 @@ } } - /** creates on thread per agent */ + /** creates one thread per agent */ private void createAgsThreads() { for (CentralisedAgArch ag : ags.values()) { ag.setControlInfraTier(control); @@ -450,98 +451,95 @@ } } - private BlockingQueue<Runnable> myAgTasks; - private BlockingQueue<Runnable> mySleepAgs; + private Set<CentralisedAgArch> sleepingAgs; + private ExecutorService executor; /** creates a pool of threads shared by all agents */ private void createThreadPool() { - myAgTasks = new LinkedBlockingQueue<Runnable>(); - mySleepAgs = new LinkedBlockingQueue<Runnable>(); - - // create a thread that - // 1. creates the pool - // 2. feeds the pool with agent reasoning cycles - new Thread("feed-pool") { - public void run() { - // initially, add all agents in the tasks - for (CentralisedAgArch ag : ags.values()) { - myAgTasks.offer(ag); - } - - // get the max number of threads in the pool - int maxthreads = 10; - try { - if (project.getInfrastructure().hasParameters()) { - maxthreads = Integer.parseInt(project.getInfrastructure().getParameter(1)); - logger.info("Creating a thread pool with "+maxthreads+" thread(s)."); - } - } catch (Exception e) { - logger.warning("Error getting the number of thread for the pool."); - } + sleepingAgs = Collections.synchronizedSet(new HashSet<CentralisedAgArch>()); - // define pool size - int poolSize = ags.size(); - if (poolSize > maxthreads) { - poolSize = maxthreads; - } - - // create the pool - ExecutorService executor = Executors.newFixedThreadPool(poolSize); - - // include tasks in the pool - while (runner != null) { - try { - executor.execute(myAgTasks.take()); - // note that the agent, when finished the cycle, - // add themselves in the myAgTasks queue - } catch (InterruptedException e) { } - } - executor.shutdownNow(); + int maxthreads = 10; + try { + if (project.getInfrastructure().hasParameters()) { + maxthreads = Integer.parseInt(project.getInfrastructure().getParameter(1)); + logger.info("Creating a thread pool with "+maxthreads+" thread(s)."); } - }.start(); + } catch (Exception e) { + logger.warning("Error getting the number of thread for the pool."); + } + + // define pool size + int poolSize = ags.size(); + if (poolSize > maxthreads) { + poolSize = maxthreads; + } - // create a thread that wakeup the sleeping agents - new Thread("wake-sleep-ag") { + // create the pool + // executor = Executors.newCachedThreadPool(); + executor = Executors.newFixedThreadPool(poolSize); + + // initially, add all agents in the tasks + for (CentralisedAgArch ag : ags.values()) { + //myAgTasks.offer(ag); + executor.execute(ag); + } + + /*new Thread("monitor") { public void run() { while (runner != null) { try { - Runnable ag = mySleepAgs.poll(); - while (ag != null) { - myAgTasks.offer(ag); - ag = mySleepAgs.poll(); - } - sleep(2000); + System.out.println("#ag:"+ags.size()); + System.out.println("#slepping ags:"+mySleepAgs.size()); + try { + ThreadPoolExecutor tp = (ThreadPoolExecutor)executor; + System.out.println("#queue:"+tp.getQueue().size()); + System.out.println("#active:"+tp.getActiveCount()); + } catch (Exception e) { } + sleep(3000); } catch (InterruptedException e) { } } } - }.start(); + }.start();*/ } /** an agent architecture for the infra based on thread pool */ private final class CentralisedAgArchForPool extends CentralisedAgArch { - boolean inSleep; @Override - public void sleep() { - mySleepAgs.offer(this); - inSleep = true; + public void sleep() { + //if (sleepingAgs.contains(this)) + // System.out.println("*** ops already slepping "+this); + sleepingAgs.add(this); } @Override public void wake() { - if (mySleepAgs.remove(this)) - myAgTasks.offer(this); + if (sleepingAgs.remove(this)) { + /*try { + ThreadPoolExecutor tp = (ThreadPoolExecutor)executor; + if (tp.getQueue().contains(this)) { + System.out.println("ops... ading ag that is already in the pool "+this); + } + } catch (Exception e) { }*/ + executor.execute(this); + } } @Override + //synchronized public void run() { if (isRunning()) { - inSleep = false; - getTS().reasoningCycle(); - if (!inSleep) - myAgTasks.offer(this); + if (getTS().reasoningCycle()) { // the agent run a cycle (did not enter in sleep) + /*try { + ThreadPoolExecutor tp = (ThreadPoolExecutor)executor; + if (tp.getQueue().contains(this)) { + System.out.println("*** ops... ading ag that is already in the pool "+this); + } + } catch (Exception e) { }*/ + executor.execute(this); + } } - } + } } protected void stopAgs() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-07-12 15:01:22
|
Revision: 1700 http://jason.svn.sourceforge.net/jason/?rev=1700&view=rev Author: jomifred Date: 2012-07-12 15:01:11 +0000 (Thu, 12 Jul 2012) Log Message: ----------- fix a bug related to .suspend several goals that have the same literal Modified Paths: -------------- trunk/src/jason/stdlib/resume.java trunk/src/jason/stdlib/suspend.java Modified: trunk/src/jason/stdlib/resume.java =================================================================== --- trunk/src/jason/stdlib/resume.java 2012-07-09 16:33:00 UTC (rev 1699) +++ trunk/src/jason/stdlib/resume.java 2012-07-12 15:01:11 UTC (rev 1700) @@ -42,11 +42,11 @@ <p>Internal action: <b><code>.resume(<i>G</i>)</code></b>. - <p>Description: resume goals <i>G</i> that was suspended by <code>.suspend</code>. + <p>Description: resume goals <i>G</i> that were suspended by <code>.suspend</code>. <p>Example:<ul> - <li> <code>.resume(go(1,3))</code>: resume the goal of go to location 1,3. + <li> <code>.resume(go(1,3))</code>: resume the goal of going to location 1,3. </ul> @@ -93,12 +93,14 @@ ik.remove(); // remove the IA .suspend in case of self-suspend - if (k.equals(suspend.SELF_SUSPENDED_INT)) + if (k.startsWith(suspend.SELF_SUSPENDED_INT)) i.peek().removeCurrentStep(); // add it back in I if not in PA if (! C.getPendingActions().containsKey(i.getId())) C.resumeIntention(i); + + //System.out.println("res "+g+" from I "+i.getId()); } } } @@ -113,8 +115,9 @@ if (un.unifies(g, e.getTrigger()) || (i != null && i.hasTrigger(g, un))) { ik.remove(); C.addEvent(e); - if (i != null) + if (i != null) i.setSuspended(false); + //System.out.println("res "+g+" from E "+e.getTrigger()); } } } Modified: trunk/src/jason/stdlib/suspend.java =================================================================== --- trunk/src/jason/stdlib/suspend.java 2012-07-09 16:33:00 UTC (rev 1699) +++ trunk/src/jason/stdlib/suspend.java 2012-07-12 15:01:11 UTC (rev 1700) @@ -72,7 +72,7 @@ boolean suspendIntention = false; public static final String SUSPENDED_INT = "suspended-"; - public static final String SELF_SUSPENDED_INT = SUSPENDED_INT+"self"; + public static final String SELF_SUSPENDED_INT = SUSPENDED_INT+"self-"; @Override public int getMinArgs() { return 0; } @Override public int getMaxArgs() { return 1; } @@ -103,8 +103,7 @@ // use the argument to select the intention to suspend. Trigger g = new Trigger(TEOperator.add, TEType.achieve, (Literal)args[0]); - String k = SUSPENDED_INT+g.getLiteral(); - + // ** Must test in PA/PI first since some actions (as .suspend) put intention in PI // suspending from Pending Actions @@ -112,7 +111,7 @@ Intention i = a.getIntention(); if (i.hasTrigger(g, un)) { i.setSuspended(true); - C.addPendingIntention(k, i); + C.addPendingIntention(SUSPENDED_INT+i.getId(), i); } } @@ -127,7 +126,8 @@ if (i.hasTrigger(g, un)) { i.setSuspended(true); C.removeIntention(i); - C.addPendingIntention(k, i); + C.addPendingIntention(SUSPENDED_INT+i.getId(), i); + //System.out.println("sus "+g+" from I "+i.getId()+" #"+C.getPendingIntentions().size()); } } @@ -136,19 +136,22 @@ if (i.hasTrigger(g, un)) { suspendIntention = true; i.setSuspended(true); - C.addPendingIntention(SELF_SUSPENDED_INT, i); + C.addPendingIntention(SELF_SUSPENDED_INT+i.getId(), i); } // suspending G in Events + int c = 0; for (Event e: C.getEvents()) { i = e.getIntention(); if (un.unifies(g, e.getTrigger()) || (i != null && i.hasTrigger(g, un))) { C.removeEvent(e); - C.addPendingEvent(k, e); + C.addPendingEvent(SUSPENDED_INT+e.getTrigger()+(c++), e); if (i != null) i.setSuspended(true); + //System.out.println("sus "+g+" from E "+e.getTrigger()); } + /* if ( i != null && (i.hasTrigger(g, un) || // the goal is in the i's stack of IM This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <xsp...@us...> - 2012-07-09 16:33:09
|
Revision: 1699 http://jason.svn.sourceforge.net/jason/?rev=1699&view=rev Author: xsplyter Date: 2012-07-09 16:33:00 +0000 (Mon, 09 Jul 2012) Log Message: ----------- Included option to debug a Jason Application in the same places than the option to run a Jason Application Added c4jason.jar when environment = cartago or infrastructure = jacamo Change the default output to "bin/classes" instead of "bin" Included option to create an "Asl File" when the asl file is not an agent Modified Paths: -------------- trunk/applications/jason-eclipse-plugin2/jasonide/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide/plugin.xml trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonApplication.java trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonFile.java trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonFileEditor.java trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/core/JasonPropertyTester.java trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/core/PluginTemplates.java trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/JasonPerspective.java trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/plugin.xml_gen trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml_gen trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/src/jasonide/xtext/asl/ui/AslHighlightingConfiguration.java trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/plugin.xml_gen trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/META-INF/MANIFEST.MF trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml_gen trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/src/jasonide/xtext/mas2j/ui/Mas2jHighlightingCalculator.java trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/src/jasonide/xtext/mas2j/ui/Mas2jHighlightingConfiguration.java trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml trunk/applications/jason-eclipse-plugin2/jasonide_site/artifacts.jar trunk/applications/jason-eclipse-plugin2/jasonide_site/content.jar trunk/applications/jason-eclipse-plugin2/jasonide_site/logs.zip trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml Added Paths: ----------- trunk/applications/jason-eclipse-plugin2/jasonide/icons/debug.gif trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/wizards/NewAslFileWizard.java trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/wizards/NewAslFileWizardPage.java Modified: trunk/applications/jason-eclipse-plugin2/jasonide/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide/META-INF/MANIFEST.MF 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide/META-INF/MANIFEST.MF 2012-07-09 16:33:00 UTC (rev 1699) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Jasonide Bundle-SymbolicName: jasonide;singleton:=true -Bundle-Version: 1.0.6 +Bundle-Version: 1.0.7 Bundle-Activator: jasonide.Activator Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, Added: trunk/applications/jason-eclipse-plugin2/jasonide/icons/debug.gif =================================================================== (Binary files differ) Property changes on: trunk/applications/jason-eclipse-plugin2/jasonide/icons/debug.gif ___________________________________________________________________ Added: svn:mime-type + image/gif Modified: trunk/applications/jason-eclipse-plugin2/jasonide/plugin.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide/plugin.xml 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide/plugin.xml 2012-07-09 16:33:00 UTC (rev 1699) @@ -53,6 +53,18 @@ Create a Jason Internal Action </description> </wizard> + <wizard + category="jasonide.newJasonCategory" + class="jasonide.ui.wizards.NewAslFileWizard" + hasPages="true" + icon="icons/new_agent.gif" + id="jasonide.newAslFileWizard" + name="Asl File" + project="false"> + <description> + Create a Jason Asl File + </description> + </wizard> </extension> @@ -244,6 +256,19 @@ </test> </adapt></enablement> </commonWizard> + <commonWizard + type="new" + wizardId="jasonide.newAslFileWizard"> + <enablement> + <adapt + type="org.eclipse.core.runtime.IAdaptable"> + <test + property="jasonide.checkFullPath" + value="src/asl"> + </test> + </adapt> + </enablement> + </commonWizard> </navigatorContent> <commonFilter activeByDefault="true" @@ -302,6 +327,21 @@ </builder> </extension> + <extension + point="org.eclipse.ui.popupMenus"> + <objectContribution + id="jasonDebug" + nameFilter="*.mas2j" + objectClass="org.eclipse.core.resources.IFile"> + <action + class="jasonide.commands.RunJasonFile" + definitionId="debug" + icon="icons/debug.gif" + id="jasonide.popup.actions.NewAction" + label="Debug Jason Application" + menubarPath="additions"/> + </objectContribution> + </extension> <extension point="org.eclipse.ui.popupMenus"> @@ -318,6 +358,21 @@ menubarPath="additions"/> </objectContribution> </extension> + + <extension point="org.eclipse.ui.popupMenus"> + <viewerContribution + id="jasonDebug" + targetID="jasonide.xtext.mas2j.Mas2j.EditorContext"> + <action + id="jasonide.popup.actions.NewAction" + label="Debug Jason Application" + icon="icons/debug.gif" + menubarPath="additions" + definitionId="debug" + class="jasonide.commands.RunJasonFileEditor"> + </action> + </viewerContribution> + </extension> <extension point="org.eclipse.ui.popupMenus"> <viewerContribution @@ -328,6 +383,7 @@ label="Run Jason Application" icon="icons/run.gif" menubarPath="additions" + definitionId="run" class="jasonide.commands.RunJasonFileEditor"> </action> </viewerContribution> @@ -354,17 +410,38 @@ </with> </visibleWhen> </command> + + <command + commandId="jasonide.debugJasonApplication" + icon="icons/debug.gif" + id="jasonide.toolbar.debugJasonApplication" + style="push"> + <visibleWhen + checkEnabled="false"> + <with + variable="activeWorkbenchWindow.activePerspective"> + <equals + value="jasonide.jasonPerspective"> + </equals> + </with> + </visibleWhen> + </command> </toolbar> </menuContribution> </extension> - <extension point="org.eclipse.ui.commands"> <command defaultHandler="jasonide.commands.RunJasonApplication" id="jasonide.runJasonApplication" name="Run Jason Application"> </command> + + <command + defaultHandler="jasonide.commands.RunJasonApplication" + id="jasonide.debugJasonApplication" + name="Debug Jason Application"> + </command> </extension> <extension point="org.eclipse.ui.perspectives"> Modified: trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonApplication.java =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonApplication.java 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonApplication.java 2012-07-09 16:33:00 UTC (rev 1699) @@ -14,6 +14,7 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; @@ -59,6 +60,8 @@ public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection(); + boolean debug = event.getCommand().getId().equals("jasonide.debugJasonApplication"); + if (selection instanceof ITreeSelection) { ITreeSelection ts = (ITreeSelection)selection; Object firstElement = ts.getFirstElement(); @@ -77,7 +80,7 @@ try { if (project != null && project.isNatureEnabled("jasonide.jasonNature")) { - run(project); + run(debug, project); return null; } } catch (CoreException e) { @@ -91,7 +94,7 @@ if (resource != null){ IProject project = resource.getProject(); - run(project); + run(debug, project); return null; } } @@ -99,7 +102,7 @@ return null; } - private void run(IProject project) { + private void run(boolean debug, IProject project) { if (!Utils.checkErrorsInProject(project, "run")){ return; } @@ -113,7 +116,7 @@ } // System.out.println("Running Jason application " + project.getName()); - runProject(false, project); + runProject(debug, project); } public void runProject(final boolean debug, final IProject projectEclipse) { Modified: trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonFile.java =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonFile.java 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonFile.java 2012-07-09 16:33:00 UTC (rev 1699) @@ -51,7 +51,8 @@ @Override public void run(IAction action) { - runProject(false); + boolean debug = action.getActionDefinitionId().equals("debug"); + runProject(debug); } private void runProject(final boolean debug) { Modified: trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonFileEditor.java =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonFileEditor.java 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/commands/RunJasonFileEditor.java 2012-07-09 16:33:00 UTC (rev 1699) @@ -51,7 +51,8 @@ @Override public void run(IAction action) { - runProject(false); + boolean debug = action.getActionDefinitionId().equals("debug"); + runProject(debug); } private void runProject(final boolean debug) { Modified: trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/core/JasonPropertyTester.java =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/core/JasonPropertyTester.java 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/core/JasonPropertyTester.java 2012-07-09 16:33:00 UTC (rev 1699) @@ -73,7 +73,7 @@ try { String sourceMainFile = Utils.loadFile(mainFile.getLocation().toString()); - if (sourceMainFile.indexOf("c4jason.CartagoEnvironment") > -1) { + if (sourceMainFile.indexOf("c4jason.CartagoEnvironment") > -1 || sourceMainFile.indexOf("JaCaMo") > -1) { return true; } Modified: trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/core/PluginTemplates.java =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/core/PluginTemplates.java 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/core/PluginTemplates.java 2012-07-09 16:33:00 UTC (rev 1699) @@ -15,8 +15,10 @@ public static String getProjectClasspathContents(String projectName, boolean cartagoEnvironment, String infrastructure) { String cartagoLib = ""; + String c4jasonLib = ""; if (cartagoEnvironment || infrastructure.equals("JaCaMo")) { cartagoLib = "\t<classpathentry kind=\"lib\" path=\""+ Config.get().getJasonHome() + "/lib/cartago.jar" +"\"/>\n"; + c4jasonLib = "\t<classpathentry kind=\"lib\" path=\""+ Config.get().getJasonHome() + "/lib/c4jason.jar" +"\"/>\n"; } String jadeLib = ""; @@ -44,10 +46,12 @@ "\t<classpathentry kind=\"src\" path=\"src/java\" />\n" + "\t<classpathentry kind=\"lib\" path=\""+ Config.get().getJasonJar() +"\"/>\n" + cartagoLib + + c4jasonLib + jadeLib + saciLib + moiseLib + jacamoLib + + "<classpathentry kind=\"output\" path=\"bin/classes\"/>" + "</classpath>\n"; } Modified: trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/JasonPerspective.java =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/JasonPerspective.java 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/JasonPerspective.java 2012-07-09 16:33:00 UTC (rev 1699) @@ -54,6 +54,7 @@ layout.addNewWizardShortcut("jasonide.newAgentWizard"); layout.addNewWizardShortcut("jasonide.newArtifactWizard"); layout.addNewWizardShortcut("jasonide.newInternalActionWizard"); + layout.addNewWizardShortcut("jasonide.newAslFileWizard"); layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewPackageCreationWizard"); layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewClassCreationWizard"); Added: trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/wizards/NewAslFileWizard.java =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/wizards/NewAslFileWizard.java (rev 0) +++ trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/wizards/NewAslFileWizard.java 2012-07-09 16:33:00 UTC (rev 1699) @@ -0,0 +1,75 @@ +package jasonide.ui.wizards; + + +import jasonide.core.PluginConstants; +import jasonide.core.PluginTemplates; +import jasonide.core.Utils; +import jasonide.ui.ErrorDialog; +import java.io.InputStream; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; + +public class NewAslFileWizard extends Wizard implements INewWizard { + private IWorkbench workbench; + private IStructuredSelection selection; + private NewAslFileWizardPage page; + + public NewAslFileWizard() { + super(); + setWindowTitle("New Asl File"); + } + + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.selection = selection; + this.workbench = workbench; + } + + public void addPages() { + page = new NewAslFileWizardPage(workbench, selection); + addPage(page); + } + + @Override + public boolean performFinish() { + IProject project = page.getSelectedProject(); + String fileExtension = page.getAgentFileExtension(); + String agentName; + + if (fileExtension.length() == 0){ + agentName = page.getAgentName() + "." + PluginConstants.AGENT_EXT; + } else { + agentName = page.getAgentName(); + } + String containerName = "/" + project.getName() + "/src/asl"; + IResource agentsFolder = project.findMember("src/asl"); + IContainer container = (IContainer)agentsFolder; + IFile file = container.getFile(new Path(agentName)); + + try { + InputStream stream = PluginTemplates.openContentStreamAgent(containerName, agentName); + + if (file.exists()) { + file.setContents(stream, true, true, null); + } else { + file.create(stream, true, null); + } + stream.close(); + } catch (Exception e) { + e.printStackTrace(); + ErrorDialog.open(e); + } + Utils.selectAndReveal(getShell(), (IResource)file); + Utils.openResource(getShell(), file); + + return true; + } +} Added: trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/wizards/NewAslFileWizardPage.java =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/wizards/NewAslFileWizardPage.java (rev 0) +++ trunk/applications/jason-eclipse-plugin2/jasonide/src/jasonide/ui/wizards/NewAslFileWizardPage.java 2012-07-09 16:33:00 UTC (rev 1699) @@ -0,0 +1,187 @@ +package jasonide.ui.wizards; + +import jasonide.core.PluginConstants; +import jasonide.core.Utils; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; +import org.eclipse.swt.widgets.Widget; +import org.eclipse.ui.IWorkbench; + +public class NewAslFileWizardPage extends JasonWizardPage implements Listener { + private Label agentNameLabel; + private Text agentNameText; + + private IStatus agentNameStatus, agentAlreadyExistsStatus; + + public NewAslFileWizardPage(IWorkbench workbench, IStructuredSelection selection) { + super("New Jason Agent", "This wizard creates a new Jason Agent", "Create agent in project:", workbench, selection); + agentNameStatus = new Status(IStatus.OK, "not_used", 0, "", null); + agentAlreadyExistsStatus = new Status(IStatus.OK, "not_used", 0, "", null); + } + + @Override + public void createControl(Composite parent) { + super.createControl(parent); + GridLayout layout = new GridLayout(); + int nCols = 2; + layout.numColumns = nCols; + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); + GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); + gridData.widthHint = 250; + + //Asl filename + agentNameLabel = new Label(composite, SWT.NONE); + agentNameLabel.setText("Asl filename:"); + + agentNameText = new Text(composite, SWT.BORDER | SWT.SINGLE); + agentNameText.setLayoutData(gridData); + agentNameText.addListener(SWT.Modify, this); + agentNameText.setFocus(); + } + + @Override + public void handleEvent(Event event) { + Widget source = event.widget; + + if (source == agentNameText){ + checkAgentName(); + checkAgentAlreadyExists(); + checkProjectsList(); + } else if (source == projectsList){ + checkProjectsList(); + } + showStatus(findMostSevere()); + setPageComplete(isPageComplete()); + getWizard().getContainer().updateButtons(); + } + + private IStatus findMostSevere() { + if (projectStatus.matches(IStatus.ERROR)){ + return projectStatus; + } + + if (agentNameStatus.matches(IStatus.ERROR)){ + return agentNameStatus; + } + + if (agentAlreadyExistsStatus.matches(IStatus.ERROR)){ + return agentAlreadyExistsStatus; + } + return new Status(IStatus.OK, "not_used", 0, "", null); + } + + private void checkAgentName() { + Status status = new Status(IStatus.OK, "not_used", 0, "", null); + String agentNameWithoutExtension = Utils.removeFileExtension(agentNameText.getText()); + String fileExtension = getAgentFileExtension(); + boolean error = false; + + if (agentNameWithoutExtension.length() == 0){ + error = true; + status = new Status(IStatus.ERROR, "not_used", 0, "Agent name can't be empty", null); + } else { + char cFirst = agentNameWithoutExtension.charAt(0); + + if (!Character.isLowerCase(cFirst)){ + error = true; + status = new Status(IStatus.ERROR, "not_used", 0, "Agent name must start with a lowercase letter", null); + } else { + for (int i = 1; i < agentNameWithoutExtension.length(); i++){ + char c = agentNameWithoutExtension.charAt(i); + + if (!error && !Character.isLetterOrDigit(c) && c != '_'){ + error = true; + status = new Status(IStatus.ERROR, "not_used", 0, "Agent name must contain only letters, digits or '_'", null); + } + } + } + } + + if (!error) { + if (!fileExtension.equals("") && !fileExtension.equals("." + PluginConstants.AGENT_EXT)){ + status = new Status(IStatus.ERROR, "not_used", 0, "Invalid file extension. Use '." + PluginConstants.AGENT_EXT + "', or just omit it", null); + } + } + agentNameStatus = status; + } + + private void checkAgentAlreadyExists() { + Status status = new Status(IStatus.OK, "not_used", 0, "", null); + IProject project = getSelectedProject(); + String fileExtension = getAgentFileExtension(); + + if (fileExtension.length() == 0){ + IResource resource = project.findMember("src/asl/" + agentNameText.getText() + "." + PluginConstants.AGENT_EXT); + + if (resource != null){ + status = new Status(IStatus.ERROR, "not_used", 0, + "Agent '" + agentNameText.getText() + "." + PluginConstants.AGENT_EXT + "' already exists", null); + } + } else { + IResource resource = project.findMember("src/asl/" + agentNameText.getText()); + + if (resource != null){ + status = new Status(IStatus.ERROR, "not_used", 0, "Agent '" + agentNameText.getText() + "' already exists", null); + } + } + agentAlreadyExistsStatus = status; + } + + public boolean isPageComplete(){ + if (getErrorMessage() != null){ + return false; + } + + if (agentNameText.getText().length() == 0 || projectsList.getSelectionCount() == 0){ + return false; + } else { + return true; + } + } + + private void showStatus(IStatus status){ + String message = status.getMessage(); + if (message.length() == 0) message= null; + switch (status.getSeverity()) { + case IStatus.OK: + setErrorMessage(null); + setMessage(message); + break; + case IStatus.WARNING: + setErrorMessage(null); + setMessage(message, WizardPage.WARNING); + break; + case IStatus.INFO: + setErrorMessage(null); + setMessage(message, WizardPage.INFORMATION); + break; + default: + setErrorMessage(message); + setMessage(null); + break; + } + } + + public String getAgentName(){ + return agentNameText.getText(); + } + + public String getAgentFileExtension() { + return Utils.getFileExtensionWithDot(agentNameText.getText()); + } +} Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/META-INF/MANIFEST.MF 2012-07-09 16:33:00 UTC (rev 1699) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: jasonide.xtext.asl Bundle-Vendor: Jason team -Bundle-Version: 1.0.6 +Bundle-Version: 1.0.7 Bundle-SymbolicName: jasonide.xtext.asl; singleton:=true Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.xtext;bundle-version="2.0.0";visibility:=reexport, @@ -20,7 +20,8 @@ Import-Package: org.apache.log4j, org.apache.commons.logging, org.eclipse.xtext.xbase.lib, - org.eclipse.xtext.xtend2.lib + org.eclipse.xtext.xtend2.lib, + org.eclipse.xtend2.lib Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: jasonide.xtext.asl, jasonide.xtext.asl.services, @@ -30,4 +31,7 @@ jasonide.xtext.asl.serializer, jasonide.xtext.asl.parser.antlr, jasonide.xtext.asl.parser.antlr.internal, - jasonide.xtext.asl.validation + jasonide.xtext.asl.validation, + jasonide.xtext.asl.scoping, + jasonide.xtext.asl.generator, + jasonide.xtext.asl.formatting Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/plugin.xml_gen =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/plugin.xml_gen 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl/plugin.xml_gen 2012-07-09 16:33:00 UTC (rev 1699) @@ -14,5 +14,4 @@ - </plugin> Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/META-INF/MANIFEST.MF 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/META-INF/MANIFEST.MF 2012-07-09 16:33:00 UTC (rev 1699) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: jasonide.xtext.asl.ui Bundle-Vendor: Jason team -Bundle-Version: 1.0.6 +Bundle-Version: 1.0.7 Bundle-SymbolicName: jasonide.xtext.asl.ui; singleton:=true Bundle-ActivationPolicy: lazy Require-Bundle: jasonide.xtext.asl;visibility:=reexport, @@ -20,5 +20,6 @@ org.apache.commons.logging Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: jasonide.xtext.asl.ui.contentassist.antlr, - jasonide.xtext.asl.ui.internal + jasonide.xtext.asl.ui.internal, + jasonide.xtext.asl.ui.contentassist Bundle-Activator: jasonide.xtext.asl.ui.internal.AslActivator Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml 2012-07-09 16:33:00 UTC (rev 1699) @@ -191,7 +191,7 @@ <!-- Rename Refactoring --> <extension point="org.eclipse.ui.handlers"> <handler - class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RenameElementHandler" + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.IRenameElementHandler" commandId="org.eclipse.xtext.ui.refactoring.RenameElement"> <activeWhen> <reference Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml_gen =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml_gen 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/plugin.xml_gen 2012-07-09 16:33:00 UTC (rev 1699) @@ -71,6 +71,19 @@ </page> </extension> <extension + point="org.eclipse.ui.propertyPages"> + <page + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage" + id="jasonide.xtext.asl.Asl" + name="Asl"> + <keywordReference id="jasonide.xtext.asl.ui.keyword_Asl"/> + <enabledWhen> + <adapt type="org.eclipse.core.resources.IProject"/> + </enabledWhen> + <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/> + </page> + </extension> + <extension point="org.eclipse.ui.keywords"> <keyword id="jasonide.xtext.asl.ui.keyword_Asl" @@ -145,6 +158,30 @@ class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant"> </participant> </extension> + <extension + point="org.eclipse.ui.preferencePages"> + <page + category="jasonide.xtext.asl.Asl" + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage" + id="jasonide.xtext.asl.Asl.compiler.preferencePage" + name="Compiler"> + <keywordReference id="jasonide.xtext.asl.ui.keyword_Asl"/> + </page> + </extension> + <extension + point="org.eclipse.ui.propertyPages"> + <page + category="jasonide.xtext.asl.Asl" + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage" + id="jasonide.xtext.asl.Asl.compiler.propertyPage" + name="Compiler"> + <keywordReference id="jasonide.xtext.asl.ui.keyword_Asl"/> + <enabledWhen> + <adapt type="org.eclipse.core.resources.IProject"/> + </enabledWhen> + <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/> + </page> + </extension> <!-- Quick Outline --> <extension @@ -186,11 +223,10 @@ class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"> </markerResolutionGenerator> </extension> - <!-- Rename Refactoring --> <extension point="org.eclipse.ui.handlers"> <handler - class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RenameElementHandler" + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.IRenameElementHandler" commandId="org.eclipse.xtext.ui.refactoring.RenameElement"> <activeWhen> <reference @@ -212,6 +248,15 @@ </command> </menuContribution> </extension> + <extension point="org.eclipse.ui.preferencePages"> + <page + category="jasonide.xtext.asl.Asl" + class="jasonide.xtext.asl.ui.AslExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage" + id="jasonide.xtext.asl.Asl.refactoring" + name="Refactoring"> + <keywordReference id="jasonide.xtext.asl.ui.keyword_Asl"/> + </page> + </extension> <extension point="org.eclipse.compare.contentViewers"> <viewer id="jasonide.xtext.asl.Asl.compare.contentViewers" Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/src/jasonide/xtext/asl/ui/AslHighlightingConfiguration.java =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/src/jasonide/xtext/asl/ui/AslHighlightingConfiguration.java 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.asl.ui/src/jasonide/xtext/asl/ui/AslHighlightingConfiguration.java 2012-07-09 16:33:00 UTC (rev 1699) @@ -111,7 +111,7 @@ public void addType( IHighlightingConfigurationAcceptor acceptor, String s, int r, int g, int b, int style) { TextStyle textStyle = new TextStyle(); - textStyle.setBackgroundColor(new RGB(255, 255, 255)); + //textStyle.setBackgroundColor(new RGB(255, 255, 255)); textStyle.setColor(new RGB(r, g, b)); textStyle.setStyle(style); acceptor.acceptDefaultHighlighting(s, s, textStyle); Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/META-INF/MANIFEST.MF 2012-07-09 16:33:00 UTC (rev 1699) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: jasonide.xtext.mas2j Bundle-Vendor: Jason team -Bundle-Version: 1.0.6 +Bundle-Version: 1.0.7 Bundle-SymbolicName: jasonide.xtext.mas2j; singleton:=true Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.xtext;bundle-version="2.0.0";visibility:=reexport, @@ -22,7 +22,8 @@ Import-Package: org.apache.log4j, org.apache.commons.logging, org.eclipse.xtext.xbase.lib, - org.eclipse.xtext.xtend2.lib + org.eclipse.xtext.xtend2.lib, + org.eclipse.xtend2.lib Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: jasonide.xtext.mas2j, jasonide.xtext.mas2j.services, @@ -32,4 +33,7 @@ jasonide.xtext.mas2j.serializer, jasonide.xtext.mas2j.parser.antlr, jasonide.xtext.mas2j.parser.antlr.internal, - jasonide.xtext.mas2j.validation + jasonide.xtext.mas2j.validation, + jasonide.xtext.mas2j.scoping, + jasonide.xtext.mas2j.generator, + jasonide.xtext.mas2j.formatting Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/plugin.xml_gen =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/plugin.xml_gen 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j/plugin.xml_gen 2012-07-09 16:33:00 UTC (rev 1699) @@ -14,5 +14,4 @@ - </plugin> Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/META-INF/MANIFEST.MF =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/META-INF/MANIFEST.MF 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/META-INF/MANIFEST.MF 2012-07-09 16:33:00 UTC (rev 1699) @@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: jasonide.xtext.mas2j.ui Bundle-Vendor: Jason team -Bundle-Version: 1.0.6 +Bundle-Version: 1.0.7 Bundle-SymbolicName: jasonide.xtext.mas2j.ui; singleton:=true Bundle-ActivationPolicy: lazy Require-Bundle: jasonide.xtext.mas2j;visibility:=reexport, @@ -20,5 +20,6 @@ org.apache.commons.logging Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: jasonide.xtext.mas2j.ui.contentassist.antlr, - jasonide.xtext.mas2j.ui.internal + jasonide.xtext.mas2j.ui.internal, + jasonide.xtext.mas2j.ui.contentassist Bundle-Activator: jasonide.xtext.mas2j.ui.internal.Mas2jActivator Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml 2012-07-09 16:33:00 UTC (rev 1699) @@ -191,7 +191,7 @@ <!-- Rename Refactoring --> <extension point="org.eclipse.ui.handlers"> <handler - class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RenameElementHandler" + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.IRenameElementHandler" commandId="org.eclipse.xtext.ui.refactoring.RenameElement"> <activeWhen> <reference Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml_gen =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml_gen 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/plugin.xml_gen 2012-07-09 16:33:00 UTC (rev 1699) @@ -71,6 +71,19 @@ </page> </extension> <extension + point="org.eclipse.ui.propertyPages"> + <page + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.editor.preferences.LanguageRootPreferencePage" + id="jasonide.xtext.mas2j.Mas2j" + name="Mas2j"> + <keywordReference id="jasonide.xtext.mas2j.ui.keyword_Mas2j"/> + <enabledWhen> + <adapt type="org.eclipse.core.resources.IProject"/> + </enabledWhen> + <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/> + </page> + </extension> + <extension point="org.eclipse.ui.keywords"> <keyword id="jasonide.xtext.mas2j.ui.keyword_Mas2j" @@ -145,6 +158,30 @@ class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.builder.IXtextBuilderParticipant"> </participant> </extension> + <extension + point="org.eclipse.ui.preferencePages"> + <page + category="jasonide.xtext.mas2j.Mas2j" + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage" + id="jasonide.xtext.mas2j.Mas2j.compiler.preferencePage" + name="Compiler"> + <keywordReference id="jasonide.xtext.mas2j.ui.keyword_Mas2j"/> + </page> + </extension> + <extension + point="org.eclipse.ui.propertyPages"> + <page + category="jasonide.xtext.mas2j.Mas2j" + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.builder.preferences.BuilderPreferencePage" + id="jasonide.xtext.mas2j.Mas2j.compiler.propertyPage" + name="Compiler"> + <keywordReference id="jasonide.xtext.mas2j.ui.keyword_Mas2j"/> + <enabledWhen> + <adapt type="org.eclipse.core.resources.IProject"/> + </enabledWhen> + <filter name="projectNature" value="org.eclipse.xtext.ui.shared.xtextNature"/> + </page> + </extension> <!-- Quick Outline --> <extension @@ -186,11 +223,10 @@ class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.editor.quickfix.MarkerResolutionGenerator"> </markerResolutionGenerator> </extension> - <!-- Rename Refactoring --> <extension point="org.eclipse.ui.handlers"> <handler - class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RenameElementHandler" + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.IRenameElementHandler" commandId="org.eclipse.xtext.ui.refactoring.RenameElement"> <activeWhen> <reference @@ -212,6 +248,15 @@ </command> </menuContribution> </extension> + <extension point="org.eclipse.ui.preferencePages"> + <page + category="jasonide.xtext.mas2j.Mas2j" + class="jasonide.xtext.mas2j.ui.Mas2jExecutableExtensionFactory:org.eclipse.xtext.ui.refactoring.ui.RefactoringPreferencePage" + id="jasonide.xtext.mas2j.Mas2j.refactoring" + name="Refactoring"> + <keywordReference id="jasonide.xtext.mas2j.ui.keyword_Mas2j"/> + </page> + </extension> <extension point="org.eclipse.compare.contentViewers"> <viewer id="jasonide.xtext.mas2j.Mas2j.compare.contentViewers" Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/src/jasonide/xtext/mas2j/ui/Mas2jHighlightingCalculator.java =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/src/jasonide/xtext/mas2j/ui/Mas2jHighlightingCalculator.java 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/src/jasonide/xtext/mas2j/ui/Mas2jHighlightingCalculator.java 2012-07-09 16:33:00 UTC (rev 1699) @@ -1,8 +1,6 @@ package jasonide.xtext.mas2j.ui; import jasonide.xtext.mas2j.mas2j.ClsDef; - - import org.eclipse.xtext.Keyword; import org.eclipse.xtext.RuleCall; import org.eclipse.xtext.impl.TerminalRuleImpl; Modified: trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/src/jasonide/xtext/mas2j/ui/Mas2jHighlightingConfiguration.java =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/src/jasonide/xtext/mas2j/ui/Mas2jHighlightingConfiguration.java 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide.xtext.mas2j.ui/src/jasonide/xtext/mas2j/ui/Mas2jHighlightingConfiguration.java 2012-07-09 16:33:00 UTC (rev 1699) @@ -80,7 +80,7 @@ public void addType( IHighlightingConfigurationAcceptor acceptor, String s, int r, int g, int b, int style) { TextStyle textStyle = new TextStyle(); - textStyle.setBackgroundColor(new RGB(255, 255, 255)); + //textStyle.setBackgroundColor(new RGB(255, 255, 255)); textStyle.setColor(new RGB(r, g, b)); textStyle.setStyle(style); acceptor.acceptDefaultHighlighting(s, s, textStyle); Modified: trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide_feature/feature.xml 2012-07-09 16:33:00 UTC (rev 1699) @@ -2,7 +2,7 @@ <feature id="jasonide_feature" label="Jasonide_feature" - version="1.0.6.qualifier"> + version="1.0.7.qualifier"> <description url="http://www.example.com/description"> Jason is an interpreter for an extended version of AgentSpeak Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/artifacts.jar =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/content.jar =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/logs.zip =================================================================== (Binary files differ) Modified: trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml =================================================================== --- trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml 2012-07-02 14:18:59 UTC (rev 1698) +++ trunk/applications/jason-eclipse-plugin2/jasonide_site/site.xml 2012-07-09 16:33:00 UTC (rev 1699) @@ -1,7 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> <site> - <feature url="features/jasonide_feature_1.0.6.201204171351.jar" id="jasonide_feature" version="1.0.6.201204171351"> - <category name="jasonide"/> - </feature> - <category-def name="jasonide" label="jasonide"/> + <feature url="features/jasonide_feature_1.0.7.201207091232.jar" id="jasonide_feature" version="1.0.7.201207091232"/> </site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-07-02 14:19:10
|
Revision: 1698 http://jason.svn.sourceforge.net/jason/?rev=1698&view=rev Author: jomifred Date: 2012-07-02 14:18:59 +0000 (Mon, 02 Jul 2012) Log Message: ----------- include clone() in IndexedBB Modified Paths: -------------- trunk/src/jason/architecture/AgArch.java trunk/src/jason/bb/ChainBB.java trunk/src/jason/bb/ChainBBAdapter.java trunk/src/jason/bb/IndexedBB.java Modified: trunk/src/jason/architecture/AgArch.java =================================================================== --- trunk/src/jason/architecture/AgArch.java 2012-06-15 17:47:19 UTC (rev 1697) +++ trunk/src/jason/architecture/AgArch.java 2012-07-02 14:18:59 UTC (rev 1698) @@ -50,7 +50,7 @@ * Each member of the chain is a subclass of AgArch. The last arch in the chain is the infrastructure tier (Centralised, JADE, Saci, ...). * The getUserAgArch method returns the first arch in the chain. * - * Users can customise the architecture by overriding some this class methods. + * Users can customise the architecture by overriding some methods of this class. */ public class AgArch implements AgArchInfraTier { @@ -250,7 +250,7 @@ return successor == null || successor.isRunning(); } - /** sets the number of the current cycle in the sync execution mode */ + /** sets the number of the current cycle */ public void setCycleNumber(int cycle) { cycleNumber = cycle; if (successor != null) @@ -261,7 +261,7 @@ setCycleNumber(cycleNumber+1); } - /** gets the current cycle number in case of running in sync execution mode */ + /** gets the current cycle number */ public int getCycleNumber() { return cycleNumber; } Modified: trunk/src/jason/bb/ChainBB.java =================================================================== --- trunk/src/jason/bb/ChainBB.java 2012-06-15 17:47:19 UTC (rev 1697) +++ trunk/src/jason/bb/ChainBB.java 2012-07-02 14:18:59 UTC (rev 1698) @@ -19,7 +19,7 @@ * * jason.bb.ChainBB( bb1, bb2, bb3, ... ) * - * where each BB is bbclass(bb paramters) + * where each BB is bbclass(bb parameters) * * e.g.: * <pre> @@ -76,7 +76,7 @@ } } - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") public List<Class> getChainClasses() { List<Class> r = new ArrayList<Class>(); ChainBBAdapter c = getNextAdapter(); Modified: trunk/src/jason/bb/ChainBBAdapter.java =================================================================== --- trunk/src/jason/bb/ChainBBAdapter.java 2012-06-15 17:47:19 UTC (rev 1697) +++ trunk/src/jason/bb/ChainBBAdapter.java 2012-07-02 14:18:59 UTC (rev 1698) @@ -52,7 +52,7 @@ */ @SuppressWarnings("deprecation") -public class ChainBBAdapter implements BeliefBase { +public abstract class ChainBBAdapter implements BeliefBase { protected BeliefBase nextBB = null; // the next BB in the chain Modified: trunk/src/jason/bb/IndexedBB.java =================================================================== --- trunk/src/jason/bb/IndexedBB.java 2012-06-15 17:47:19 UTC (rev 1697) +++ trunk/src/jason/bb/IndexedBB.java 2012-07-02 14:18:59 UTC (rev 1698) @@ -88,6 +88,13 @@ remove(linbb); } } - return nextBB.add(bel); + return super.add(bel); } + + @Override + public BeliefBase clone() { + IndexedBB nbb = new IndexedBB(nextBB.clone()); + nbb.indexedBels = new HashMap<String,Structure>(this.indexedBels); + return nbb; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-06-15 17:47:25
|
Revision: 1697 http://jason.svn.sourceforge.net/jason/?rev=1697&view=rev Author: jomifred Date: 2012-06-15 17:47:19 +0000 (Fri, 15 Jun 2012) Log Message: ----------- add killAcc method in agent class Modified Paths: -------------- trunk/release-notes.txt trunk/src/jason/asSemantics/Agent.java trunk/src/jason/infra/centralised/CentralisedRuntimeServices.java trunk/src/jason/infra/centralised/KillAgentGUI.java trunk/src/jason/infra/jade/JadeRuntimeServices.java trunk/src/jason/runtime/RuntimeServicesInfraTier.java trunk/src/jason/stdlib/kill_agent.java Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2012-06-12 11:44:22 UTC (rev 1696) +++ trunk/release-notes.txt 2012-06-15 17:47:19 UTC (rev 1697) @@ -1,4 +1,16 @@ --------------------------- +version 1.3.8 + +revision XXX on SVN +--------------------------- + +New features +- new internal action .empty to check lists +- new method in Agent class (killAcc) to customise + whether an agent accepts to be killed by another. + (implemented only in Centralised infrastructure) + +--------------------------- version 1.3.7 revision 1687 on SVN Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2012-06-12 11:44:22 UTC (rev 1696) +++ trunk/src/jason/asSemantics/Agent.java 2012-06-15 17:47:19 UTC (rev 1697) @@ -564,6 +564,13 @@ return true; } + /** Returns true if this agent accepts to be killed by another agent called <i>agName</i>. + * This method can be overridden to customize this option. */ + public boolean killAcc(String agName) { + //System.out.println("I am being killed by "+agName+", but that is ok..."); + return true; + } + public Event selectEvent(Queue<Event> events) { // make sure the selected Event is removed from 'events' queue return events.poll(); Modified: trunk/src/jason/infra/centralised/CentralisedRuntimeServices.java =================================================================== --- trunk/src/jason/infra/centralised/CentralisedRuntimeServices.java 2012-06-12 11:44:22 UTC (rev 1696) +++ trunk/src/jason/infra/centralised/CentralisedRuntimeServices.java 2012-06-15 17:47:19 UTC (rev 1697) @@ -84,15 +84,14 @@ return masRunner.getAgs().keySet().size(); } - public boolean killAgent(String agName) { + public boolean killAgent(String agName, String byAg) { logger.fine("Killing centralised agent " + agName); CentralisedAgArch ag = masRunner.getAg(agName); - if (ag != null) { + if (ag != null && ag.getTS().getAg().killAcc(byAg)) { ag.stopAg(); return true; - } else { - return false; } + return false; } public void stopMAS() throws Exception { Modified: trunk/src/jason/infra/centralised/KillAgentGUI.java =================================================================== --- trunk/src/jason/infra/centralised/KillAgentGUI.java 2012-06-12 11:44:22 UTC (rev 1696) +++ trunk/src/jason/infra/centralised/KillAgentGUI.java 2012-06-15 17:47:19 UTC (rev 1697) @@ -48,7 +48,7 @@ Object[] sls = lAgs.getSelectedValues(); for (int i = 0; i < sls.length; i++) { String agName = sls[i].toString(); - services.killAgent(agName); + services.killAgent(agName, "KillAgGUI"); } } }.start(); Modified: trunk/src/jason/infra/jade/JadeRuntimeServices.java =================================================================== --- trunk/src/jason/infra/jade/JadeRuntimeServices.java 2012-06-12 11:44:22 UTC (rev 1696) +++ trunk/src/jason/infra/jade/JadeRuntimeServices.java 2012-06-15 17:47:19 UTC (rev 1697) @@ -111,13 +111,14 @@ } } - public boolean killAgent(String agName) { + public boolean killAgent(String agName, String byAg) { try { AgentController ac = cc.getAgent(agName); if (ac == null) { logger.warning("Agent "+agName+" does not exist!"); } else { - ac.kill(); + // TODO: if (ag.getTS().getAg().canBeKilledBy(byAg)) + ac.kill(); return true; } } catch (Exception e) { Modified: trunk/src/jason/runtime/RuntimeServicesInfraTier.java =================================================================== --- trunk/src/jason/runtime/RuntimeServicesInfraTier.java 2012-06-12 11:44:22 UTC (rev 1696) +++ trunk/src/jason/runtime/RuntimeServicesInfraTier.java 2012-06-15 17:47:19 UTC (rev 1697) @@ -45,10 +45,11 @@ public AgArch clone(Agent source, List<String> archClasses, String agName) throws JasonException; /** - * Kills the agent named <i>agName</i>. The stopAg() method, in + * Kills the agent named <i>agName</i> as a requested by <i>byAg</i>. + * The stopAg() method, in * the agent architecture is called before the agent is removed. */ - public boolean killAgent(String agName); + public boolean killAgent(String agName, String byAg); /** Returns a set of all agents' name */ public Set<String> getAgentsNames(); Modified: trunk/src/jason/stdlib/kill_agent.java =================================================================== --- trunk/src/jason/stdlib/kill_agent.java 2012-06-12 11:44:22 UTC (rev 1696) +++ trunk/src/jason/stdlib/kill_agent.java 2012-06-15 17:47:19 UTC (rev 1697) @@ -70,6 +70,6 @@ name = ((StringTerm)args[0]).getString(); else name = args[0].toString(); - return ts.getUserAgArch().getRuntimeServices().killAgent(name); + return ts.getUserAgArch().getRuntimeServices().killAgent(name, ts.getUserAgArch().getAgName()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-06-12 11:44:32
|
Revision: 1696 http://jason.svn.sourceforge.net/jason/?rev=1696&view=rev Author: jomifred Date: 2012-06-12 11:44:22 +0000 (Tue, 12 Jun 2012) Log Message: ----------- add internal action .empty Modified Paths: -------------- trunk/lib/jacamo.jar trunk/lib/moise.jar trunk/src/jason/stdlib/package.html Added Paths: ----------- trunk/src/jason/stdlib/empty.java Modified: trunk/lib/jacamo.jar =================================================================== (Binary files differ) Modified: trunk/lib/moise.jar =================================================================== (Binary files differ) Added: trunk/src/jason/stdlib/empty.java =================================================================== --- trunk/src/jason/stdlib/empty.java (rev 0) +++ trunk/src/jason/stdlib/empty.java 2012-06-12 11:44:22 UTC (rev 1696) @@ -0,0 +1,76 @@ +//---------------------------------------------------------------------------- +// 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.inf.ufrgs.br/~bordini +// http://www.das.ufsc.br/~jomi +// +//---------------------------------------------------------------------------- + +package jason.stdlib; + +import jason.asSemantics.DefaultInternalAction; +import jason.asSemantics.InternalAction; +import jason.asSemantics.TransitionSystem; +import jason.asSemantics.Unifier; +import jason.asSyntax.ListTerm; +import jason.asSyntax.StringTerm; +import jason.asSyntax.Term; + +/** + + <p>Internal action: <b><code>.empty</code></b>. + + <p>Description: checks whether a list has at least one term. + + <p>Parameters:<ul> + <li>+ argument (string or list): the term whose length is to be determined.<br/> + </ul> + + <p>Examples:<ul> + <li> <code>.empty([])</code>: true. + <li> <code>.empty([a,b])</code>: false. + <li> <code>.empty("a")</code>: false. + </ul> + + */ +public class empty extends DefaultInternalAction { + + private static InternalAction singleton = null; + public static InternalAction create() { + if (singleton == null) + singleton = new empty(); + return singleton; + } + + @Override public int getMinArgs() { return 1; } + @Override public int getMaxArgs() { return 1; } + + @Override + public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { + checkArguments(args); + Term l1 = args[0]; + if (l1.isList()) { + ListTerm lt = (ListTerm) l1; + return lt.isEmpty(); + } else if (l1.isString()) { + StringTerm st = (StringTerm) l1; + return st.getString().isEmpty(); + } + return false; + } +} Modified: trunk/src/jason/stdlib/package.html =================================================================== --- trunk/src/jason/stdlib/package.html 2012-05-29 12:07:03 UTC (rev 1695) +++ trunk/src/jason/stdlib/package.html 2012-06-12 11:44:22 UTC (rev 1696) @@ -61,6 +61,7 @@ <ul> <li>{@link jason.stdlib.member member}: list members. </li> <li>{@link jason.stdlib.length length}: size of lists. </li> + <li>{@link jason.stdlib.empty empty}: check whether the list is empty. </li> <li>{@link jason.stdlib.concat concat}: concat lists. </li> <li>{@link jason.stdlib.delete delete}: delete members of a lists. </li> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-05-29 12:07:14
|
Revision: 1695 http://jason.svn.sourceforge.net/jason/?rev=1695&view=rev Author: jomifred Date: 2012-05-29 12:07:03 +0000 (Tue, 29 May 2012) Log Message: ----------- improve gold-miner-II a little Modified Paths: -------------- trunk/build.xml trunk/demos/cArtAgOandJasonEnv/cArtAgOandJasonEnv.mas2j trunk/demos/cArtAgOandJasonEnv/src/asl/sample_agent.asl trunk/demos/cArtAgOandJasonEnv/src/java/SomeArt.java trunk/examples/cleaning-robots/MarsEnv.java trunk/examples/gold-miners-II/arch/LocalWorldModel.java trunk/examples/gold-miners-II/arch/MinerArch.java trunk/examples/gold-miners-II/env/WorldModel.java trunk/examples/gold-miners-II/env/WorldView.java trunk/examples/gold-miners-II/miners.mas2j Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2012-05-29 11:51:08 UTC (rev 1694) +++ trunk/build.xml 2012-05-29 12:07:03 UTC (rev 1695) @@ -152,7 +152,7 @@ <attribute name="Main-Class" value="jason.util.ConfigGUI"/> </manifest> </jar> - <copy file="${jasonJar}" todir="applications/jason-eclipse-plugin/lib" /> + <!-- copy file="${jasonJar}" todir="applications/jason-eclipse-plugin/lib" /--> </target> <target name="signjar" depends="jar"> Modified: trunk/demos/cArtAgOandJasonEnv/cArtAgOandJasonEnv.mas2j =================================================================== --- trunk/demos/cArtAgOandJasonEnv/cArtAgOandJasonEnv.mas2j 2012-05-29 11:51:08 UTC (rev 1694) +++ trunk/demos/cArtAgOandJasonEnv/cArtAgOandJasonEnv.mas2j 2012-05-29 12:07:03 UTC (rev 1695) @@ -10,18 +10,18 @@ MAS cArtAgOandJasonEnv { - infrastructure: Centralised + infrastructure: Centralised - environment: MixedEnvironment // this class uses normal Jason environment and also CArtAgO environment + environment: MixedEnvironment // this class uses normal Jason environment and also CArtAgO environment - agents: - agent1 sample_agent - agentArchClass MixedAgentArch // architecture that deal with Jason vs CArtAgO environment - agentArchClass c4jason.CAgentArch; // usual architecture of CArtAgO + agents: + agent1 sample_agent + agentArchClass MixedAgentArch // architecture that deal with Jason vs CArtAgO environment + agentArchClass c4jason.CAgentArch; // usual architecture of CArtAgO classpath: "/Users/jomi/Jason/svn-jason/lib/cartago.jar"; "/Users/jomi/Jason/svn-jason/lib/c4jason.jar"; - aslSourcePath: - "src/asl"; + aslSourcePath: + "src/asl"; } Modified: trunk/demos/cArtAgOandJasonEnv/src/asl/sample_agent.asl =================================================================== --- trunk/demos/cArtAgOandJasonEnv/src/asl/sample_agent.asl 2012-05-29 11:51:08 UTC (rev 1694) +++ trunk/demos/cArtAgOandJasonEnv/src/asl/sample_agent.asl 2012-05-29 12:07:03 UTC (rev 1695) @@ -17,4 +17,4 @@ +count(X) <- .print("Count is ",X). - \ No newline at end of file + Modified: trunk/demos/cArtAgOandJasonEnv/src/java/SomeArt.java =================================================================== --- trunk/demos/cArtAgOandJasonEnv/src/java/SomeArt.java 2012-05-29 11:51:08 UTC (rev 1694) +++ trunk/demos/cArtAgOandJasonEnv/src/java/SomeArt.java 2012-05-29 12:07:03 UTC (rev 1695) @@ -3,15 +3,15 @@ import cartago.*; public class SomeArt extends Artifact { - void init(int initialValue) { - defineObsProperty("count", initialValue); - } - - @OPERATION - void inc() { - ObsProperty prop = getObsProperty("count"); - prop.updateValue(prop.intValue()+1); - signal("tick"); - } + void init(int initialValue) { + defineObsProperty("count", initialValue); + } + + @OPERATION + void inc() { + ObsProperty prop = getObsProperty("count"); + prop.updateValue(prop.intValue()+1); + signal("tick"); + } } Modified: trunk/examples/cleaning-robots/MarsEnv.java =================================================================== --- trunk/examples/cleaning-robots/MarsEnv.java 2012-05-29 11:51:08 UTC (rev 1694) +++ trunk/examples/cleaning-robots/MarsEnv.java 2012-05-29 12:07:03 UTC (rev 1695) @@ -63,6 +63,7 @@ try { Thread.sleep(200); } catch (Exception e) {} + informAgsEnvironmentChanged(); return true; } Modified: trunk/examples/gold-miners-II/arch/LocalWorldModel.java =================================================================== --- trunk/examples/gold-miners-II/arch/LocalWorldModel.java 2012-05-29 11:51:08 UTC (rev 1694) +++ trunk/examples/gold-miners-II/arch/LocalWorldModel.java 2012-05-29 12:07:03 UTC (rev 1695) @@ -25,10 +25,6 @@ return new LocalWorldModel(w,h,nbAg); } - public LocalWorldModel(int w, int h) { - this(w, h, 6); - } - public LocalWorldModel(int w, int h, int nbAg) { super(w, h, nbAg); Modified: trunk/examples/gold-miners-II/arch/MinerArch.java =================================================================== --- trunk/examples/gold-miners-II/arch/MinerArch.java 2012-05-29 11:51:08 UTC (rev 1694) +++ trunk/examples/gold-miners-II/arch/MinerArch.java 2012-05-29 12:07:03 UTC (rev 1695) @@ -30,6 +30,7 @@ boolean playing = false; int cycle = 0; + int teamSize = 6; WriteModelThread writeModelT = null; protected Logger logger = Logger.getLogger(MinerArch.class.getName()); @@ -42,6 +43,9 @@ writeModelT = new WriteModelThread(); writeModelT.start(); } + if (getTS().getSettings().getUserParameter("teamSize") != null) { + teamSize = Integer.parseInt(getTS().getSettings().getUserParameter("teamSize")); + } } @Override @@ -74,7 +78,7 @@ if (view != null) { view.dispose(); } - model = new LocalWorldModel(w, h); + model = new LocalWorldModel(w, h, teamSize); if (gui) { view = new WorldView("Mining (view of miner "+(getMyId()+1)+")",model); } Modified: trunk/examples/gold-miners-II/env/WorldModel.java =================================================================== --- trunk/examples/gold-miners-II/env/WorldModel.java 2012-05-29 11:51:08 UTC (rev 1694) +++ trunk/examples/gold-miners-II/env/WorldModel.java 2012-05-29 12:07:03 UTC (rev 1695) @@ -48,6 +48,8 @@ public WorldModel(int w, int h, int nbAg) { super(w, h, nbAg); + agsByTeam = nbAg/2; + goldsWithAg = new int[nbAg]; for (int i=0; i< goldsWithAg.length; i++) goldsWithAg[i] = 0; } Modified: trunk/examples/gold-miners-II/env/WorldView.java =================================================================== --- trunk/examples/gold-miners-II/env/WorldView.java 2012-05-29 11:51:08 UTC (rev 1694) +++ trunk/examples/gold-miners-II/env/WorldView.java 2012-05-29 12:07:03 UTC (rev 1695) @@ -212,7 +212,8 @@ @Override public void drawAgent(Graphics g, int x, int y, Color c, int id) { int golds = ((WorldModel)model).getGoldsWithAg(id); - if (id < 6) { + int nbAgByTeam = ((WorldModel)model).getAgsByTeam(); + if (id < nbAgByTeam) { // red team int gw = (WorldModel.AG_CAPACITY - golds) + 1; g.setColor(Color.red); @@ -228,7 +229,7 @@ g.fillOval(x * cellSizeW + gw, y * cellSizeH + gw, cellSizeW - gw*2, cellSizeH - gw*2); if (id >= 0) { g.setColor(Color.white); - drawString(g, x, y, defaultFont, String.valueOf(id-5)); + drawString(g, x, y, defaultFont, String.valueOf(id-(nbAgByTeam-1))); } } if (golds > 0) { Modified: trunk/examples/gold-miners-II/miners.mas2j =================================================================== --- trunk/examples/gold-miners-II/miners.mas2j 2012-05-29 11:51:08 UTC (rev 1694) +++ trunk/examples/gold-miners-II/miners.mas2j 2012-05-29 12:07:03 UTC (rev 1695) @@ -30,7 +30,7 @@ leader beliefBaseClass agent.DiscardBelsBB("my_status","picked","committed_to","cell"); - miner + miner //[teamSize=6] agentClass agent.SelectEvent beliefBaseClass agent.UniqueBelsBB("gsize(_,_,_)","depot(_,_,_)","steps(_,_)","committed_to(_,_,key)") agentArchClass arch.LocalMinerArch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-05-29 11:51:15
|
Revision: 1694 http://jason.svn.sourceforge.net/jason/?rev=1694&view=rev Author: jomifred Date: 2012-05-29 11:51:08 +0000 (Tue, 29 May 2012) Log Message: ----------- fix a bug related to atomic intentions with actions that fail and a contingency plan Modified Paths: -------------- trunk/src/jason/asSemantics/TransitionSystem.java Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2012-05-25 18:22:41 UTC (rev 1693) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2012-05-29 11:51:08 UTC (rev 1694) @@ -328,8 +328,7 @@ confP.step = State.ProcAct; // need to go to ProcAct to see if an atomic intention received a feedback action return; } - - + if (conf.C.hasEvent()) { // Rule for atomic, events from atomic intention has priority confP.C.SE = C.removeAtomicEvent(); @@ -408,6 +407,7 @@ private void applySelAppl() throws JasonException { // Rule SelAppl confP.C.SO = conf.ag.selectOption(confP.C.AP); + if (confP.C.SO != null) { confP.step = State.AddIM; if (logger.isLoggable(Level.FINE)) logger.fine("Selected option "+confP.C.SO+" for event "+confP.C.SE); @@ -499,9 +499,8 @@ ListTerm annots = JasonException.createBasicErrorAnnots("action_failed", reason); if (a.getFailureReason() != null) annots.append(a.getFailureReason()); - if (!generateGoalDeletion(conf.C.SI, annots)) { - C.removeAtomicIntention(); // if (potential) atomic intention is not removed, it will be selected in selInt and runs again - } + generateGoalDeletion(conf.C.SI, annots); + C.removeAtomicIntention(); // if (potential) atomic intention is not removed, it will be selected in selInt or selEv and runs again } } else { applyProcAct(); // get next action @@ -840,6 +839,7 @@ im = i.pop(); } } + if (!i.isFinished()) { im = i.peek(); // +!s or +?s if (!im.isFinished()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-05-25 18:22:48
|
Revision: 1693 http://jason.svn.sourceforge.net/jason/?rev=1693&view=rev Author: jomifred Date: 2012-05-25 18:22:41 +0000 (Fri, 25 May 2012) Log Message: ----------- add eclipse-plugin doc Modified Paths: -------------- trunk/doc/index.html Added Paths: ----------- trunk/doc/mini-tutorial/src/eclipse-plugin/ trunk/doc/mini-tutorial/src/eclipse-plugin/Makefile trunk/doc/mini-tutorial/src/eclipse-plugin/images/ trunk/doc/mini-tutorial/src/eclipse-plugin/images/image00.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image01.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image02.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image03.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image04.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image05.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image06.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image07.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image08.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image09.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image10.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image11.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image12.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image13.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image14.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image15.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image16.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image17.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image18.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image19.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image20.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image21.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image22.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image23.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image24.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image25.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image26.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image27.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image28.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image29.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image30.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image31.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image32.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image33.png trunk/doc/mini-tutorial/src/eclipse-plugin/images/image34.png trunk/doc/mini-tutorial/src/eclipse-plugin/index.html Modified: trunk/doc/index.html =================================================================== --- trunk/doc/index.html 2012-05-18 14:57:42 UTC (rev 1692) +++ trunk/doc/index.html 2012-05-25 18:22:41 UTC (rev 1693) @@ -37,10 +37,10 @@ <ul> <li><a href="http://sourceforge.net/news/?group_id=98417">News</a> <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/Documents.html">Publications</a> - <li><a href="http://jason.sourceforge.net/JasonWebSite/Related%20Projects.html">Related + <li><a href="http://jason.sourceforge.net/Jason/Examples/Examples.html">Examples</a> + <li><a href="http://jason.sourceforge.net/Jason/Demos.html">Demos</a> + <li><a href="http://jason.sourceforge.net/Jason/Documents.html">Publications</a> + <li><a href="http://jason.sourceforge.net/Jason/Projects.html">Related projects</a> </ul> </li> @@ -54,7 +54,7 @@ </li> <br/> -<li><a href="https://docs.google.com/document/pub?id=1URDYMtFP64rHnlb7GcnKyUGbaypNcZmteWupWD5p6sM">Eclipse plugin</a></li><br/> +<li><a href="http://jason.sourceforge.net/mini-tutorial/eclipse-plugin">Eclipse plugin</a></li><br/> </ul> Added: trunk/doc/mini-tutorial/src/eclipse-plugin/Makefile =================================================================== --- trunk/doc/mini-tutorial/src/eclipse-plugin/Makefile (rev 0) +++ trunk/doc/mini-tutorial/src/eclipse-plugin/Makefile 2012-05-25 18:22:41 UTC (rev 1693) @@ -0,0 +1,12 @@ +# +# by Jomi +# + +#TARGET = $(shell ls *.tex | cut -f 1 -d ".") + +#all: +# latex2html -dir ../../jason-jade -mkdir -split 0 -white -image_type=png -nonavigation -noinfo -address "" -math -style ../labs.css $(TARGET) + +publish: + scp index.html jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/mini-tutorial/eclipse-plugin + scp -r images jomifred,ja...@we...:/home/groups/j/ja/jason/htdocs/mini-tutorial/eclipse-plugin Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/Makefile ___________________________________________________________________ Added: svn:executable + * Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image00.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image00.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image01.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image01.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image02.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image02.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image03.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image03.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image04.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image04.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image05.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image05.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image06.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image06.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image07.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image07.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image08.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image08.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image09.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image09.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image10.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image10.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image11.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image11.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image12.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image12.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image13.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image13.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image14.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image14.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image15.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image15.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image16.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image16.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image17.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image17.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image18.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image18.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image19.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image19.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image20.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image20.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image21.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image21.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image22.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image22.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image23.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image23.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image24.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image24.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image25.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image25.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image26.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image26.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image27.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image27.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image28.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image28.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image29.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image29.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image30.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image30.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image31.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image31.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image32.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image32.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image33.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image33.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image34.png =================================================================== (Binary files differ) Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/images/image34.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/doc/mini-tutorial/src/eclipse-plugin/index.html =================================================================== --- trunk/doc/mini-tutorial/src/eclipse-plugin/index.html (rev 0) +++ trunk/doc/mini-tutorial/src/eclipse-plugin/index.html 2012-05-25 18:22:41 UTC (rev 1693) @@ -0,0 +1 @@ +<html><head><title>How to install Jason plug-in for Eclipse</title><style type="text/css">ol{margin:0;padding:0}.c14{max-width:481.9pt;background-color:#ffffff;padding:56.7pt 56.7pt 56.7pt 56.7pt}.c7{line-height:1.5;margin-left:36pt}.c4{color:inherit;text-decoration:inherit}.c3{color:#1155cc;text-decoration:underline}.c8{color:#434343;font-size:12pt}.c1{height:11pt}.c12{font-family:"Courier New"}.c2{font-size:9pt}.c9{font-size:18pt}.c16{text-indent:36pt}.c5{font-weight:bold}.c0{direction:ltr}.c11{line-height:1.5}.c13{text-align:center}.c6{font-style:italic}.c10{font-size:12pt}.c15{margin-left:36pt}.title{padding-top:24pt;line-height:1.15;text-align:left;color:#000000;font-size:36pt;font-family:"Arial";font-weight:bold;padding-bottom:6pt}.subtitle{padding-top:18pt;line-height:1.15;text-align:left;color:#666666;font-style:italic;font-size:24pt;font-family:"Georgia";padding-bottom:4pt}li{color:#000000;font-size:11pt;font-family:"Arial"}p{color:#000000;font-size:11pt;margin:0;font-family:"Arial"}h1{padding-top:24pt;line-height:1.15;text-align:left;color:#000000;font-size:18pt;font-family:"Arial";font-weight:bold;padding-bottom:6pt}h2{padding-top:18pt;line-height:1.15;text-align:left;color:#000000;font-size:14pt;font-family:"Arial";font-weight:bold;padding-bottom:4pt}h3{padding-top:14pt;line-height:1.15;text-align:left;color:#666666;font-size:12pt;font-family:"Arial";font-weight:bold;padding-bottom:4pt}h4{padding-top:12pt;line-height:1.15;text-align:left;color:#666666;font-style:italic;font-size:11pt;font-family:"Arial";padding-bottom:2pt}h5{padding-top:11pt;line-height:1.15;text-align:left;color:#666666;font-size:10pt;font-family:"Arial";font-weight:bold;padding-bottom:2pt}h6{padding-top:10pt;line-height:1.15;text-align:left;color:#666666;font-style:italic;font-size:10pt;font-family:"Arial";padding-bottom:2pt}</style></head><body class="c14"><p class="c0 c13"><span class="c5 c9">Jason Eclipse Plugin</span></p><p class="c0 c13"><span>Maicon Rafael Zatelli</span></p><p class="c0 c13"><span>March 2012</span></p><p class="c1 c0"><span></span></p><p class="c0 c11"><span class="c5 c10">Contents</span></p><p class="c7 c0"><span class="c3"><a class="c4" href="#id.iyxfqy5c7qw">Installation</a></span></p><p class="c7 c0"><span class="c3"><a class="c4" href="#id.4t02whnfi6ma">Agent creation</a></span></p><p class="c7 c0"><span class="c3"><a class="c4" href="#id.htqo9k1d6z0b">Internal Action</a></span></p><p class="c7 c0"><span class="c3"><a class="c4" href="#id.9gnqginnpxoh">Artifacts</a></span></p><p class="c7 c0"><span class="c3"><a class="c4" href="#id.1cnwcumx5214">Importing projects</a></span></p><p class="c7 c0"><span class="c3"><a class="c4" href="#id.r719jdb0te0z">Exporting projects</a></span></p><p class="c7 c0"><span class="c3"><a class="c4" href="#id.ref9105fu1bn">Update</a></span></p><p class="c0 c7"><span class="c3"><a class="c4" href="#id.qjaxx1qxte51">Uninstall</a></span></p><p class="c1 c0"><span></span></p><a href="#" name="id.iyxfqy5c7qw"></a><h2 class="c0"><a name="h.4v671hwozea9"></a><span>Installation</span></h2><p class="c0"><span>In order to install the </span><span class="c3"><a class="c4" href="http://jason.sf.net">Jason</a></span><span> plug-in for Eclipse you should follow the steps below and have</span></p><p class="c0"><span>Eclipse version 3.7.0 (Indigo) or greater.</span></p><h3 class="c0"><a name="h.d9pnyt92vabx"></a><span class="c5">Step 1</span></h3><p class="c0"><span>Download the latest version of Jason at the link: </span><span class="c3"><a class="c4" href="http://sourceforge.net/projects/jason/files/">http://sourceforge.net/projects/jason/files/</a></span></p><h3 class="c0"><a name="h.n53v9fjwen7m"></a><span class="c5">Step 2</span></h3><p class="c0"><span>After the download, unpack it in any directory of your machine.</span></p><h3 class="c0"><a name="h.6h65on91kgn4"></a><span>Step 3</span></h3><p class="c0"><span>If you had never run Jason on your computer, execute the file "lib/jason.jar" by double clicking over it. You also could execute this file by with the following command:</span></p><p class="c0 c16"><span class="c12">java -jar lib/jason.jar</span></p><p class="c1 c0"><span></span></p><p class="c0"><span>The following figure shows the window that you have to see after you run the file jason.jar. Make sure about the directories of the libs. We suggest you only change the "Java Home" directory. The others are automatically filled out, but feel free to change them if you want to.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="688" src="images/image14.png" width="533"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.z6cpq4rbh5c7"></a><span>Step 4</span></h3><p class="c0"><span>Finally you could install the Jason plugin for Eclipse opening the Eclipse platform and going to the option "Install New Software..." at the "Help" menu:</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="309" src="images/image04.png" width="660"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.lorw8bxj6sb3"></a><span>Step 5</span></h3><p class="c0"><span>So, the following window will appear.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="489" src="images/image02.png" width="620"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.ujyahnqjvlp4"></a><span>Step 6</span></h3><p class="c0"><span>Click over the "Add" button, and fill out the form as shown in the next figure. The parameters are</span></p><p class="c1 c0"><span></span></p><p class="c0 c15"><span>Name: jasonide</span></p><p class="c0 c15"><span>Location: </span><span class="c3"><a class="c4" href="http://jason.sourceforge.net/eclipseplugin/">http://jason.sourceforge.net/eclipseplugin/</a></span></p><p class="c1 c0"><span></span></p><p class="c0"><span>To finish, click on the "OK" button.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="490" src="images/image08.png" width="620"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.igab6z1ev6de"></a><span>Step 7</span></h3><p class="c0"><span>Tick the option "jasonide" and then press the "next" button. So, you have to wait a moment while Eclipse search the dependences.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="124" src="images/image05.png" width="620"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.h93rbmhtky4l"></a><span>Step 8</span></h3><p class="c0"><span>In the next windows just press the "next" button again.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="490" src="images/image31.png" width="620"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.tyvsm7gwg6g4"></a><span>Step 9</span></h3><p class="c0"><span>The last window that will be shown for you is about the license. Tick the option "I accept the terms of the license agreements" and then press the "finish" button. Then the installation is proceeded, it could take several minutes, so please wait.</span></p><h3 class="c0"><a name="h.rvschlpb0215"></a><span>Step 10</span></h3><p class="c0"><span>In the end of these process will be shown a window in order to complete the installation. Choose the option "Restart Now".</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="165" src="images/image28.png" width="614"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.h4xcfbvgje2e"></a><span>Step 11</span></h3><p class="c0"><span>Now you have all set. In order to test the installation of the plug-in, we suggest the creation of a simple hello world project. You could do it in the menu (File > New > Jason Project) or (File > New > Other > Jason > Jason Project).</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="485" src="images/image27.png" width="605"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.7zr5nncdpjx4"></a><span>Step 12</span></h3><p class="c0"><span>Fill out the field "Project name" and press the "Finish" button.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="485" src="images/image11.png" width="605"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.tjemg2unl7r5"></a><span>Step 13</span></h3><p class="c0"><span>If everything is fine, you will have your first project created!</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="430" src="images/image25.png" width="620"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.7ksa6d3oxxqg"></a><span>Step 14</span></h3><p class="c0"><span>Now you can run the application by pressing the Run button.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="431" src="images/image17.png" width="621"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.uxdemhnfahpy"></a><span>Step 15</span></h3><p class="c0"><span>The result will be a "hello world" message in your screen.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="429" src="images/image32.png" width="621"></p><p class="c1 c0"><span></span></p><p class="c1 c0"><span class="c2"></span></p><a href="#" name="id.4t02whnfi6ma"></a><h2 class="c0"><a name="h.ur2un1ko95et"></a><span>How to create an agent</span></h2><h3 class="c0"><a name="h.9z3z7vkt8h6a"></a><span>Step 1</span></h3><p class="c0"><span>Click on the source folder named "src/asl" using the right button and go to the option New > Agent.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="480" src="images/image06.png" width="644"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.g7qbm2962owb"></a><span>Step 2</span></h3><p class="c0"><span>Fill out the form. The only required field is the name of the agent. </span></p><p class="c0"><span>After it, press the "Finish" button.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="527" src="images/image03.png" width="525"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.kp59jeouq7gh"></a><span>Step 3</span></h3><p class="c0"><span>The agent will be created and will be automatically added in the mas2j file.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="371" src="images/image33.png" width="622"></p><p class="c1 c0"><span></span></p><p class="c0"><img height="301" src="images/image34.png" width="640"></p><p class="c1 c0"><span class="c2"></span></p><a href="#" name="id.htqo9k1d6z0b"></a><h2 class="c0"><a name="h.bh2mv7f6hnu"></a><span>How to create an internal action</span></h2><h3 class="c0"><a name="h.7t2kbehnw889"></a><span>Step 1</span></h3><p class="c0"><span>Click on the source folder named "src/java" using the right button and go to the option New > Internal Action.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="513" src="images/image23.png" width="638"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.synn97kb6dr8"></a><span>Step 2</span></h3><p class="c0"><span>Fill out the form. An internal action is a java class, so the only required field is the name of the class.</span></p><p class="c1 c0"><span></span></p><p class="c0"><span class="c6">Note: we suggest you to give a name using the first letter in lower case and also naming the package.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="575" src="images/image19.png" width="601"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.gfly7d4o3o4w"></a><span>Step 3</span></h3><p class="c0"><span>The internal action will be created.</span></p><p class="c0 c1"><span></span></p><p class="c0"><img height="355" src="images/image10.png" width="638"></p><p class="c1 c0"><span class="c2"></span></p><a href="#" name="id.9gnqginnpxoh"></a><h2 class="c0"><a name="h.bzhvsgx9bbxb"></a><span>How to create an Artifact</span></h2><p class="c1 c16 c0"><span></span></p><p class="c0"><span class="c6">Note: A CArtAgO artifact is only used if you are using the CArtAgO as an environment for your MAS.</span></p><h3 class="c0"><a name="h.b519j7kll1jl"></a><span>Step 1</span></h3><p class="c0"><span>Click on the source folder named "src/java" using the right button and go to the option New > CArtAgO Artifact.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="471" src="images/image30.png" width="639"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.1u005hnz5a92"></a><span>Step 2</span></h3><p class="c0"><span>Fill out the form. A CArtAgO artifact is a java class, so the only required field is the name of the class.</span></p><p class="c1 c0"><span></span></p><p class="c0"><span class="c6">Note: in contrast to an internal action, in this case you could use a name with a first letter in upper case, and also we suggest you to name the package.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="575" src="images/image16.png" width="601"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.shec06byowov"></a><span>Step 3</span></h3><p class="c0"><span>The CArtAgO artifact will be created.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="374" src="images/image12.png" width="640"></p><p class="c1 c0"><span></span></p><a href="#" name="id.1cnwcumx5214"></a><h2 class="c0"><a name="h.46mdrlpzxuwf"></a><span>How to import a Jason project</span></h2><h3 class="c0"><a name="h.5v162a2eli6p"></a><span>Step 1</span></h3><p class="c0"><span>Click on the "File" menu and go to the option "Import...".</span></p><p class="c1 c0"><span class="c2"></span></p><p class="c0"><img height="510" src="images/image22.png" width="424"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.hi2s8y82cvvo"></a><span>Step 2</span></h3><p class="c0"><span>Select the option Jason > Jason Project.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="550" src="images/image26.png" width="525"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.b08uh9nw9rmx"></a><span>Step 3</span></h3><p class="c0"><span>Click on the "Browse" button and choose the directory of the project, tick the project that you wish to import and finally press the "Finish" button.</span></p><p class="c1 c0"><span class="c2"></span></p><p class="c0"><img height="626" src="images/image29.png" width="525"></p><p class="c1 c0"><span class="c2"></span></p><a href="#" name="id.r719jdb0te0z"></a><h2 class="c0"><a name="h.r3brc4lk8kfd"></a><span>How to export a Jason project</span></h2><h3 class="c0"><a name="h.5u1rygo7nvhw"></a><span>Step 1</span></h3><p class="c0"><span>Click on the project using the right button and go to the option "Export...".</span></p><p class="c1 c0"><span class="c2"></span></p><p class="c0"><img height="405" src="images/image15.png" width="444"></p><p class="c1 c0"><span class="c2"></span></p><h3 class="c0"><a name="h.pr2n8580jhdz"></a><span>Step 2</span></h3><p class="c0"><span>Select the option Jason > Jason Project.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="550" src="images/image21.png" width="525"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.idxnln4n5ac6"></a><span>Step 3</span></h3><p class="c0"><span>Click on the "Browse" button and select the directory that you wish to export the project and press the "Finish" button.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="598" src="images/image01.png" width="613"></p><p class="c1 c0"><span class="c2"></span></p><a href="#" name="id.ref9105fu1bn"></a><h2 class="c0"><a name="h.rldi9hitjce9"></a><span>How to update the Jason plugin</span></h2><p class="c0"><span>You have two ways to update your Jason eclipse plugin.</span></p><h4 class="c0"><a name="h.rl89fr64a6s0"></a><span class="c8 c5">First way</span></h4><p class="c0"><span>Simply c</span><span>lick on the "Help" menu and go to the option "Check for Updates".</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="306" src="images/image09.png" width="637"></p><p class="c1 c0"><span></span></p><h4 class="c0"><a name="h.hfgu1y7zj8k5"></a><span class="c5 c8">Second way</span></h4><h3 class="c0"><a name="h.24twe8wyxb8h"></a><span>Step 1</span></h3><p class="c0"><span>Click on the "Help" menu and go to the option "About Eclipse SDK".</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="308" src="images/image13.png" width="641"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.yzl92833i4pk"></a><span>Step 2</span></h3><p class="c0"><span>Press the "Installation Details" button.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="346" src="images/image00.png" width="634"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.bz2ay9opvq0k"></a><span>Step 3</span></h3><p class="c0"><span>Select the "jasonide_feature" and click on the "Update..." button.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="586" src="images/image07.png" width="637"></p><p class="c1 c0"><span class="c2"></span></p><a href="#" name="id.qjaxx1qxte51"></a><h2 class="c0"><a name="h.udleuktdxd5j"></a><span>How to uninstall the Jason plugin</span></h2><h3 class="c0"><a name="h.55irfnu0vv5d"></a><span>Step 1</span></h3><p class="c0"><span>Click on the "Help" menu and go to the option "About Eclipse SDK".</span></p><p class="c1 c0"><span class="c2"></span></p><p class="c0"><img height="307" src="images/image13.png" width="639"></p><p class="c1 c0"><span class="c2"></span></p><h3 class="c0"><a name="h.ynl000ou3561"></a><span>Step 2</span></h3><p class="c0"><span>Press the "Installation Details" button.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="346" src="images/image00.png" width="634"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.7gapdcaaf0q3"></a><span>Step 3</span></h3><p class="c0"><span>Select the "jasonide_feature" and click on the "Uninstall..." button.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="588" src="images/image24.png" width="639"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.uhi2plbqefo0"></a><span>Step 4</span></h3><p class="c0"><span>Confirm the process of uninstallation pressing the "Finish" button.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="533" src="images/image18.png" width="613"></p><p class="c1 c0"><span></span></p><h3 class="c0"><a name="h.dnyhf1jt6ydp"></a><span>Step 5</span></h3><p class="c0"><span>In order to complete the uninstallation press the "Restart Now" button.</span></p><p class="c1 c0"><span></span></p><p class="c0"><img height="170" src="images/image20.png" width="619"></p><p class="c1 c0"><span class="c2"></span></p><p class="c1 c0"><span class="c2"></span></p><p class="c0"><span>Thanks for you interest on Jason. You will find more information at </span><span class="c3"><a class="c4" href="http://jason.sf.net">http://jason.sf.net</a></span><span>.</span></p><p class="c1 c0"><span class="c2"></span></p></body></html> \ No newline at end of file Property changes on: trunk/doc/mini-tutorial/src/eclipse-plugin/index.html ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-05-18 14:57:51
|
Revision: 1692 http://jason.svn.sourceforge.net/jason/?rev=1692&view=rev Author: jomifred Date: 2012-05-18 14:57:42 +0000 (Fri, 18 May 2012) Log Message: ----------- add demo that shows how to use cartago and native jason environments in the same application Modified Paths: -------------- trunk/build.xml trunk/lib/c4jason.jar trunk/lib/cartago.jar Added Paths: ----------- trunk/demos/cArtAgOandJasonEnv/ trunk/demos/cArtAgOandJasonEnv/cArtAgOandJasonEnv.mas2j trunk/demos/cArtAgOandJasonEnv/src/ trunk/demos/cArtAgOandJasonEnv/src/asl/ trunk/demos/cArtAgOandJasonEnv/src/asl/sample_agent.asl trunk/demos/cArtAgOandJasonEnv/src/java/ trunk/demos/cArtAgOandJasonEnv/src/java/MixedAgentArch.java trunk/demos/cArtAgOandJasonEnv/src/java/MixedEnvironment.java trunk/demos/cArtAgOandJasonEnv/src/java/SomeArt.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2012-05-16 11:46:23 UTC (rev 1691) +++ trunk/build.xml 2012-05-18 14:57:42 UTC (rev 1692) @@ -12,7 +12,7 @@ <property name="dist.properties" value="${basedir}/bin/dist.properties" /> <property name="version" value="1" /> - <property name="release" value="3.7" /> + <property name="release" value="3.8beta" /> <property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" /> <property name="distFile" value="${env.HOME}/Jason-${version}.${release}" /> Added: trunk/demos/cArtAgOandJasonEnv/cArtAgOandJasonEnv.mas2j =================================================================== --- trunk/demos/cArtAgOandJasonEnv/cArtAgOandJasonEnv.mas2j (rev 0) +++ trunk/demos/cArtAgOandJasonEnv/cArtAgOandJasonEnv.mas2j 2012-05-18 14:57:42 UTC (rev 1692) @@ -0,0 +1,27 @@ +/* + * This example shows how to develop an aplication that + * uses both + * - a usual Jason environment and + * - a CArtAgO environment + * + * see the code of MixedEnvironment and MixedAgentArch for details. + * + */ + +MAS cArtAgOandJasonEnv { + + infrastructure: Centralised + + environment: MixedEnvironment // this class uses normal Jason environment and also CArtAgO environment + + agents: + agent1 sample_agent + agentArchClass MixedAgentArch // architecture that deal with Jason vs CArtAgO environment + agentArchClass c4jason.CAgentArch; // usual architecture of CArtAgO + + classpath: "/Users/jomi/Jason/svn-jason/lib/cartago.jar"; + "/Users/jomi/Jason/svn-jason/lib/c4jason.jar"; + + aslSourcePath: + "src/asl"; +} Added: trunk/demos/cArtAgOandJasonEnv/src/asl/sample_agent.asl =================================================================== --- trunk/demos/cArtAgOandJasonEnv/src/asl/sample_agent.asl (rev 0) +++ trunk/demos/cArtAgOandJasonEnv/src/asl/sample_agent.asl 2012-05-18 14:57:42 UTC (rev 1692) @@ -0,0 +1,20 @@ +/* Initial goals */ + +!start. + +/* Plans */ + ++!start + <- makeArtifact("a0","SomeArt",[10],Id); + focus(Id); + .print("Artifact created."). + ++percept(X) // from Jason Environment + <- .print("I see ",X); + a2; // action on Jason environment + .wait(100); + inc. // action on CArtAgO environment + ++count(X) + <- .print("Count is ",X). + \ No newline at end of file Added: trunk/demos/cArtAgOandJasonEnv/src/java/MixedAgentArch.java =================================================================== --- trunk/demos/cArtAgOandJasonEnv/src/java/MixedAgentArch.java (rev 0) +++ trunk/demos/cArtAgOandJasonEnv/src/java/MixedAgentArch.java 2012-05-18 14:57:42 UTC (rev 1692) @@ -0,0 +1,36 @@ +import jason.architecture.AgArch; +import jason.asSemantics.ActionExec; +import jason.asSyntax.Literal; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class MixedAgentArch extends AgArch { + + Set<String> jasonEnvActions = new HashSet<String>(); + + @Override + public void init() throws Exception { + jasonEnvActions.add("a2"); + // add other actions here + + super.init(); + } + + @Override + public List<Literal> perceive() { + super.perceive(); // run cartago perceive + return getArchInfraTier().perceive(); // the perceive of centralised arch + } + + /** Send specific actions to Jason environment */ + @Override + public void act(ActionExec act, List<ActionExec> fb) { + if (jasonEnvActions.contains(act.getActionTerm().getFunctor())) { + getArchInfraTier().act(act, fb); // uses the centralised ag arch + } else { + super.act(act, fb); // uses cartago ag arch + } + } +} Added: trunk/demos/cArtAgOandJasonEnv/src/java/MixedEnvironment.java =================================================================== --- trunk/demos/cArtAgOandJasonEnv/src/java/MixedEnvironment.java (rev 0) +++ trunk/demos/cArtAgOandJasonEnv/src/java/MixedEnvironment.java 2012-05-18 14:57:42 UTC (rev 1692) @@ -0,0 +1,44 @@ +import jason.asSyntax.Literal; +import jason.asSyntax.Structure; +import jason.environment.Environment; + +import java.util.logging.Logger; + +import c4jason.CartagoEnvironment; + + +public class MixedEnvironment extends Environment { + + private Logger logger = Logger.getLogger("CartJasonEnv."+MixedEnvironment.class.getName()); + + private CartagoEnvironment cartagoEnv; + + /** Called before the MAS execution with the args informed in .mas2j */ + @Override + public void init(String[] args) { + super.init(args); + addPercept(Literal.parseLiteral("percept(demo)")); + startCartago(args); + } + + public void startCartago(String[] args) { + cartagoEnv = new CartagoEnvironment(); + cartagoEnv.init(args); + } + + @Override + public boolean executeAction(String agName, Structure action) { + logger.info("executing: "+action); + addPercept(Literal.parseLiteral("percept(a2done)")); + return true; + } + + /** Called before the end of MAS execution */ + @Override + public void stop() { + super.stop(); + if (cartagoEnv != null) + cartagoEnv.stop(); + } + +} Added: trunk/demos/cArtAgOandJasonEnv/src/java/SomeArt.java =================================================================== --- trunk/demos/cArtAgOandJasonEnv/src/java/SomeArt.java (rev 0) +++ trunk/demos/cArtAgOandJasonEnv/src/java/SomeArt.java 2012-05-18 14:57:42 UTC (rev 1692) @@ -0,0 +1,17 @@ +// CArtAgO artifact code for project cArtAgOandJasonEnv + +import cartago.*; + +public class SomeArt extends Artifact { + void init(int initialValue) { + defineObsProperty("count", initialValue); + } + + @OPERATION + void inc() { + ObsProperty prop = getObsProperty("count"); + prop.updateValue(prop.intValue()+1); + signal("tick"); + } +} + Modified: trunk/lib/c4jason.jar =================================================================== (Binary files differ) Modified: trunk/lib/cartago.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2012-05-16 11:46:34
|
Revision: 1691 http://jason.svn.sourceforge.net/jason/?rev=1691&view=rev Author: jomifred Date: 2012-05-16 11:46:23 +0000 (Wed, 16 May 2012) Log Message: ----------- fix bug in build-template, the task used to create an executable jar used a wrong manifest Modified Paths: -------------- trunk/build.xml trunk/examples/food-simulation/src/java/FoodEnvironment.java trunk/examples/food-simulation/src/java/FoodModel.java trunk/release-notes.txt trunk/src/jason/architecture/AgArch.java trunk/src/jason/environment/Environment.java trunk/src/templates/build-template.xml Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2012-05-10 16:20:39 UTC (rev 1690) +++ trunk/build.xml 2012-05-16 11:46:23 UTC (rev 1691) @@ -317,9 +317,9 @@ <echo message="Generating Jason ${version}.${release}" /> - <fixcrlf eol="crlf" includes="**/*.txt,**/*.bat,**/*.mas2j,**/*.asl" srcdir="${basedir}" /> + <fixcrlf eol="crlf" includes="**/*.txt,**/*.bat,**/*.mas2j,**/*.asl" excludes="applications/**" srcdir="${basedir}" /> - <fixcrlf tab="remove" tablength="4" javafiles="true" includes="**/*.java,**/*.xml,**/*.mas2j,**/*.asl" srcdir="${basedir}" /> + <fixcrlf tab="remove" tablength="4" javafiles="true" includes="**/*.java,**/*.xml,**/*.mas2j,**/*.asl" excludes="applications/**" srcdir="${basedir}" /> <delete failonerror="no" includeEmptyDirs="true"> <fileset dir="${distDir}" /> Modified: trunk/examples/food-simulation/src/java/FoodEnvironment.java =================================================================== --- trunk/examples/food-simulation/src/java/FoodEnvironment.java 2012-05-10 16:20:39 UTC (rev 1690) +++ trunk/examples/food-simulation/src/java/FoodEnvironment.java 2012-05-16 11:46:23 UTC (rev 1691) @@ -77,6 +77,8 @@ int x = (int)(((NumberTerm)(action.getTerm(0))).solve()); int y = (int)(((NumberTerm)(action.getTerm(1))).solve()); model.attack(agId, x, y); + //int o = model.getAgAtPos(x, y); + //System.out.println("Attac "+agName+"->" +o+id2ag.get(o)+ " "+isEating(id2ag.get(o))); } else if (actId.equals("random_move")) { model.randomMove(agId); } else { @@ -89,7 +91,7 @@ @Override protected int requiredStepsForAction(String agName, Structure action) { if (action.getFunctor().equals("eat")) { - return 3; // eat takes 2 steps + return 3; // eat takes 3 steps } return super.requiredStepsForAction(agName, action); } Modified: trunk/examples/food-simulation/src/java/FoodModel.java =================================================================== --- trunk/examples/food-simulation/src/java/FoodModel.java 2012-05-10 16:20:39 UTC (rev 1690) +++ trunk/examples/food-simulation/src/java/FoodModel.java 2012-05-16 11:46:23 UTC (rev 1691) @@ -84,6 +84,8 @@ private boolean eat(int ag, int x, int y) { if (hasObject(FOOD, x, y)) { + //if (ag != owner[x][y] && owner[x][y] != -1) + // System.out.println(ag+" eating "+x+","+y+" "+owner[x][y]); remove(FOOD, x, y); owner[x][y] = -1; strengths[ag] += FOOD_NUTRITIVE_VALUE; Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2012-05-10 16:20:39 UTC (rev 1690) +++ trunk/release-notes.txt 2012-05-16 11:46:23 UTC (rev 1691) @@ -1,7 +1,7 @@ --------------------------- version 1.3.7 -revision YYY on SVN +revision 1687 on SVN --------------------------- New features Modified: trunk/src/jason/architecture/AgArch.java =================================================================== --- trunk/src/jason/architecture/AgArch.java 2012-05-10 16:20:39 UTC (rev 1690) +++ trunk/src/jason/architecture/AgArch.java 2012-05-16 11:46:23 UTC (rev 1691) @@ -130,8 +130,8 @@ AgArch a = (AgArch) Class.forName(agArchClass).newInstance(); a.setTS(ts); // so a.init() can use TS a.initAg(null, null, null, null); // for compatibility reasons + insertAgArch(a); a.init(); - insertAgArch(a); } catch (Exception e) { System.out.println("Error creating custom agent aarchitecture."+e); e.printStackTrace(); Modified: trunk/src/jason/environment/Environment.java =================================================================== --- trunk/src/jason/environment/Environment.java 2012-05-10 16:20:39 UTC (rev 1690) +++ trunk/src/jason/environment/Environment.java 2012-05-16 11:46:23 UTC (rev 1691) @@ -270,7 +270,7 @@ } /** Adds a perception for a specific agent */ - public void addPercept(String agName, Literal per) { + public void addPercept(String agName, Literal... per) { if (per != null && agName != null) { List<Literal> agl = agPercepts.get(agName); if (agl == null) { @@ -279,7 +279,8 @@ } if (! agl.contains(per)) { uptodateAgs.remove(agName); - agl.add(per); + for (Literal p: per) + agl.add(p); } } } Modified: trunk/src/templates/build-template.xml =================================================================== --- trunk/src/templates/build-template.xml 2012-05-10 16:20:39 UTC (rev 1690) +++ trunk/src/templates/build-template.xml 2012-05-16 11:46:23 UTC (rev 1691) @@ -57,6 +57,9 @@ <fileset dir="${build.dir}"> <include name="**/*.class" /> </fileset> + <manifest> + <attribute name="Main-Class" value="jason.infra.centralised.RunCentralisedMAS"/> + </manifest> </jar> <delete file="default.mas2j" /> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |