From: <jom...@us...> - 2015-12-09 14:20:48
|
Revision: 1865 http://sourceforge.net/p/jason/svn/1865 Author: jomifred Date: 2015-12-09 14:20:46 +0000 (Wed, 09 Dec 2015) Log Message: ----------- comment profiling code Modified Paths: -------------- trunk/src/jason/architecture/AgArch.java trunk/src/jason/asSemantics/Agent.java trunk/src/jason/asSyntax/Atom.java trunk/src/jason/asSyntax/Literal.java trunk/src/test/BeliefBaseTest.java Modified: trunk/src/jason/architecture/AgArch.java =================================================================== --- trunk/src/jason/architecture/AgArch.java 2015-12-08 20:19:43 UTC (rev 1864) +++ trunk/src/jason/architecture/AgArch.java 2015-12-09 14:20:46 UTC (rev 1865) @@ -29,7 +29,6 @@ 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; @@ -149,9 +148,9 @@ * when a new reasoning cycle is starting */ public void reasoningCycleStarting() { - QueryProfiling q = getTS().getAg().getQueryProfiling(); - if (q != null) - q.setNbReasoningCycles(getCycleNumber()); + //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 2015-12-08 20:19:43 UTC (rev 1864) +++ trunk/src/jason/asSemantics/Agent.java 2015-12-09 14:20:46 UTC (rev 1865) @@ -49,7 +49,6 @@ import jason.functions.RuleToFunction; import jason.jeditplugin.Config; import jason.mas2j.ClassParameters; -import jason.profiling.QueryProfiling; import jason.runtime.Settings; import java.io.File; @@ -106,8 +105,8 @@ private static ScheduledExecutorService scheduler = null; //private QueryCache qCache = null; - private QueryCacheSimple qCache = null; - private QueryProfiling qProfiling = null; + //private QueryCacheSimple qCache = null; + //private QueryProfiling qProfiling = null; protected Logger logger = Logger.getLogger(Agent.class.getName()); @@ -162,8 +161,8 @@ 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); + //if (ts.getSettings().hasQueryProfiling()) qProfiling = new QueryProfiling(this); + //if (ts.getSettings().hasQueryCache()) qCache = new QueryCacheSimple(this, qProfiling); if (! "false".equals(Config.get().getProperty(Config.START_WEB_MI))) MindInspectorWeb.get().registerAg(this); } @@ -273,8 +272,8 @@ public void stopAg() { bb.stop(); - if (qProfiling != null) - qProfiling.show(); + //if (qProfiling != null) + // qProfiling.show(); //if (scheduler != null) // scheduler.shutdownNow(); @@ -722,7 +721,7 @@ // stat int adds = 0; int dels = 0; - long startTime = qProfiling == null ? 0 : System.nanoTime(); + //long startTime = qProfiling == null ? 0 : System.nanoTime(); // deleting percepts in the BB that is not perceived anymore Iterator<Literal> perceptsInBB = getBB().getPercepts(); @@ -790,19 +789,21 @@ } } - if (qCache != null) - qCache.reset(); - if (qProfiling != null) - qProfiling.newUpdateCycle(getTS().getUserAgArch().getCycleNumber(), adds+dels, System.nanoTime()-startTime); + //if (qCache != null) + // qCache.reset(); + //if (qProfiling != null) + // qProfiling.newUpdateCycle(getTS().getUserAgArch().getCycleNumber(), adds+dels, System.nanoTime()-startTime); return adds + dels; } + /* public QueryCacheSimple getQueryCache() { return qCache; } public QueryProfiling getQueryProfiling() { return qProfiling; } + */ /** * Returns true if BB contains the literal <i>bel</i> (using unification to test). Modified: trunk/src/jason/asSyntax/Atom.java =================================================================== --- trunk/src/jason/asSyntax/Atom.java 2015-12-08 20:19:43 UTC (rev 1864) +++ trunk/src/jason/asSyntax/Atom.java 2015-12-09 14:20:46 UTC (rev 1865) @@ -63,10 +63,7 @@ public Atom(Atom namespace, Literal l) { this.functor = l.getFunctor(); - if (namespace.functor.equals("default")) // in case namespace is an ordinary Atom with functor "default", we need to replace by the Default NS - this.ns = DefaultNS; // TODO: not necessary, the parsers takes care of it - else - this.ns = namespace; + this.ns = namespace; predicateIndicatorCache = l.predicateIndicatorCache; hashCodeCache = l.hashCodeCache; srcInfo = l.srcInfo; Modified: trunk/src/jason/asSyntax/Literal.java =================================================================== --- trunk/src/jason/asSyntax/Literal.java 2015-12-08 20:19:43 UTC (rev 1864) +++ trunk/src/jason/asSyntax/Literal.java 2015-12-09 14:20:46 UTC (rev 1865) @@ -26,10 +26,8 @@ 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; @@ -269,6 +267,7 @@ * Returns an iterator for all unifiers that are logCons. */ public Iterator<Unifier> logicalConsequence(final Agent ag, final Unifier un) { + /* final QueryProfiling qProfiling; final QueryCacheSimple qCache; final long startTime; @@ -286,7 +285,8 @@ qProfiling = null; startTime = 0; } - + */ + final Iterator<Literal> il = ag.getBB().getCandidateBeliefs(this, un); if (il == null) // no relevant bels return LogExpr.EMPTY_UNIF_LIST.iterator(); @@ -304,23 +304,22 @@ 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; + //Literal kForChache = null; + //Iterator<Unifier> cacheIt = null; + //List<Unifier> cacheResults = null; public boolean hasNext() { if (needsUpdate) get(); + /* 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; } @@ -338,6 +337,7 @@ if (arch != null && !arch.isRunning()) return; // try cache iterator + /* if (cacheIt != null) { while (cacheIt.hasNext()) { Literal ltmp = (Literal)Literal.this.capply( cacheIt.next() ); @@ -352,6 +352,7 @@ cacheIt = null; return; // do not try others after cache } + */ // try annots iterator @@ -381,15 +382,8 @@ 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); + //if (cacheResults != null) + // cacheResults.add(unC); return; } } @@ -412,21 +406,9 @@ } // 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)Literal.this.capply(un); - //System.out.println("try "+kForChache); cacheIt = qCache.getCache(kForChache); if (cacheIt != null) { //System.out.println("use cache for "+kForChache); @@ -437,6 +419,7 @@ //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 Modified: trunk/src/test/BeliefBaseTest.java =================================================================== --- trunk/src/test/BeliefBaseTest.java 2015-12-08 20:19:43 UTC (rev 1864) +++ trunk/src/test/BeliefBaseTest.java 2015-12-09 14:20:46 UTC (rev 1865) @@ -684,7 +684,7 @@ } assertEquals(s1,s2); - ag.getQueryCache().reset(); + //ag.getQueryCache().reset(); q = ASSyntax.parseLiteral("p(x,B)"); s1 = ""; @@ -695,16 +695,10 @@ assertEquals(s1,s2); // must have cache for the following - assertNotNull(ag.getQueryCache().getCache(ASSyntax.parseLiteral("p(x,B)"))); - /*assertNotNull(ag.getQueryCache().getCache(ASSyntax.parseLiteral("p(x,II)"))); - assertNotNull(ag.getQueryCache().getCache(ASSyntax.parseLiteral("p(x,10)"))); - - // must NOT have cache for the following - assertNull(ag.getQueryCache().getCache(ASSyntax.parseLiteral("p(UU,II)"))); - */ + //assertNotNull(ag.getQueryCache().getCache(ASSyntax.parseLiteral("p(x,B)"))); // test partial results - ag.getQueryCache().reset(); + //ag.getQueryCache().reset(); q = ASSyntax.parseLiteral("p(A,B)"); i = q.logicalConsequence(ag, new Unifier()); @@ -722,7 +716,7 @@ assertEquals("p(x,10)p(w,10)p(k,10)",s1); // test order - ag.getQueryCache().reset(); + //ag.getQueryCache().reset(); q = ASSyntax.parseLiteral("p(x,10)"); i = q.logicalConsequence(ag, new Unifier()); while (i.hasNext()) { @@ -781,6 +775,7 @@ } assertEquals(s1,s2); //System.out.println(ag.getQueryCache()); + /* ag.getQueryProfiling().newUpdateCycle(1,0,0); i = q.logicalConsequence(ag, new Unifier()); @@ -791,6 +786,7 @@ ag.getQueryProfiling().newUpdateCycle(2,0,0); assertTrue(1.0 <= ag.getQueryProfiling().getP()); ag.getQueryProfiling().show(); + */ } public void testGen() throws ParseException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |