From: <jom...@us...> - 2011-04-12 18:47:20
|
Revision: 1640 http://jason.svn.sourceforge.net/jason/?rev=1640&view=rev Author: jomifred Date: 2011-04-12 18:47:14 +0000 (Tue, 12 Apr 2011) Log Message: ----------- fix bug related to include+functions reported by Francisco Grimaldo Modified Paths: -------------- trunk/src/jason/asSemantics/Agent.java Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2011-04-01 22:54:30 UTC (rev 1639) +++ trunk/src/jason/asSemantics/Agent.java 2011-04-12 18:47:14 UTC (rev 1640) @@ -154,6 +154,7 @@ addInitialBelsInBB(); addInitialGoalsFromProjectInBB(); addInitialGoalsInTS(); + fixAgInIAandFunctions(this); // used to fix agent reference in functions used inside includes } // kqml Plans at the end of the ag PS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2011-04-13 20:01:10
|
Revision: 1642 http://jason.svn.sourceforge.net/jason/?rev=1642&view=rev Author: jomifred Date: 2011-04-13 20:01:04 +0000 (Wed, 13 Apr 2011) Log Message: ----------- improve clone method in Agent class as suggested by Marcos C?\195?\180rtes Modified Paths: -------------- trunk/src/jason/asSemantics/Agent.java Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2011-04-13 19:52:04 UTC (rev 1641) +++ trunk/src/jason/asSemantics/Agent.java 2011-04-13 20:01:04 UTC (rev 1642) @@ -209,7 +209,16 @@ * A new TS is created (based on the cloned circumstance). */ public Agent clone(AgArch arch) { - Agent a = new Agent(); + Agent a = null; + try { + a = this.getClass().newInstance(); + } catch (InstantiationException e1) { + logger.severe(" cannot create derived class" +e1); + return null; + } catch (IllegalAccessException e2) { + logger.severe(" cannot create derived class" +e2); + return null; + } a.setLogger(arch); if (this.getTS().getSettings().verbose() >= 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2011-06-23 12:17:15
|
Revision: 1650 http://jason.svn.sourceforge.net/jason/?rev=1650&view=rev Author: jomifred Date: 2011-06-23 12:17:09 +0000 (Thu, 23 Jun 2011) Log Message: ----------- call initAg in clone() Modified Paths: -------------- trunk/src/jason/asSemantics/Agent.java Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2011-06-10 11:48:27 UTC (rev 1649) +++ trunk/src/jason/asSemantics/Agent.java 2011-06-23 12:17:09 UTC (rev 1650) @@ -233,10 +233,11 @@ } a.aslSource = this.aslSource; a.internalActions = new HashMap<String, InternalAction>(); - a.initDefaultFunctions(); a.setTS(new TransitionSystem(a, this.getTS().getC().clone(), this.getTS().getSettings(), arch)); if (a.getPL().hasMetaEventPlans()) a.getTS().addGoalListener(new GoalListenerForMetaEvents(a.getTS())); + + a.initAg(); //for initDefaultFunctions() and for overridden/custom agent return a; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-04-25 21:04:51
|
Revision: 1775 http://sourceforge.net/p/jason/svn/1775 Author: jomifred Date: 2014-04-25 21:04:48 +0000 (Fri, 25 Apr 2014) Log Message: ----------- fix initial bels from project (add source and allows atoms) Modified Paths: -------------- trunk/src/jason/asSemantics/Agent.java Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2014-04-23 13:24:33 UTC (rev 1774) +++ trunk/src/jason/asSemantics/Agent.java 2014-04-25 21:04:48 UTC (rev 1775) @@ -504,7 +504,10 @@ if (sBels != null) { try { for (Term t: ASSyntax.parseList("["+sBels+"]")) { - getBB().add((Literal)t); + Literal b = ((Literal)t).forceFullLiteralImpl(); + if (!b.hasSource()) + b.addAnnot(BeliefBase.TSelf); + getBB().add(b); } } catch (Exception e) { logger.log(Level.WARNING, "Initial beliefs from project '["+sBels+"]' is not a list of literals."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2015-12-11 11:01:10
|
Revision: 1866 http://sourceforge.net/p/jason/svn/1866 Author: jomifred Date: 2015-12-11 11:01:07 +0000 (Fri, 11 Dec 2015) Log Message: ----------- new buf Modified Paths: -------------- trunk/src/jason/asSemantics/Agent.java Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2015-12-09 14:20:46 UTC (rev 1865) +++ trunk/src/jason/asSemantics/Agent.java 2015-12-11 11:01:07 UTC (rev 1866) @@ -45,6 +45,7 @@ import jason.asSyntax.parser.as2j; import jason.bb.BeliefBase; import jason.bb.DefaultBeliefBase; +import jason.bb.StructureWrapperForLiteral; import jason.functions.Count; import jason.functions.RuleToFunction; import jason.jeditplugin.Config; @@ -64,10 +65,12 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Queue; +import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.logging.Level; @@ -714,6 +717,7 @@ * @return the number of changes (add + dels) */ public int buf(List<Literal> percepts) { + // complexity 3n if (percepts == null) { return 0; } @@ -723,11 +727,33 @@ int dels = 0; //long startTime = qProfiling == null ? 0 : System.nanoTime(); + // to copy percepts allows the use of contains below + Set<StructureWrapperForLiteral> perW = new HashSet<StructureWrapperForLiteral>(); + Iterator<Literal> iper = percepts.iterator(); + while (iper.hasNext()) + perW.add(new StructureWrapperForLiteral(iper.next())); + + // deleting percepts in the BB that is not perceived anymore Iterator<Literal> perceptsInBB = getBB().getPercepts(); while (perceptsInBB.hasNext()) { Literal l = perceptsInBB.next(); - + if (! perW.remove(new StructureWrapperForLiteral(l))) { // l is not perceived anymore + dels++; + perceptsInBB.remove(); // remove l as perception from BB + + // new version (it is sure that l is in BB, only clone l when the event is relevant) + Trigger te = new Trigger(TEOperator.del, TEType.belief, l); + if (ts.getC().hasListener() || pl.hasCandidatePlan(te)) { + l = ASSyntax.createLiteral(l.getFunctor(), l.getTermsArray()); + l.addAnnot(BeliefBase.TPercept); + te.setLiteral(l); + ts.getC().addEvent(new Event(te, Intention.EmptyInt)); + } + } + } + /* + ////// previous version, without perW hashset // could not use percepts.contains(l), since equalsAsTerm must be // used (to ignore annotations) boolean wasPerceived = false; @@ -759,7 +785,7 @@ te.setLiteral(l); ts.getC().addEvent(new Event(te, Intention.EmptyInt)); } - + */ /* // old version // can not delete l, but l[source(percept)] @@ -770,22 +796,19 @@ ts.updateEvents(new Event(new Trigger(TEOperator.del, TEType.belief, l), Intention.EmptyInt)); } */ - } - } + //} + //} - // BUF only adds a belief when appropriate - // checking all percepts for new beliefs - for (Literal lp : percepts) { + for (StructureWrapperForLiteral lw: perW) { try { - lp = lp.copy().forceFullLiteralImpl(); + Literal lp = lw.getLiteral().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)); + ts.updateEvents(new Event(new Trigger(TEOperator.add, TEType.belief, lp), Intention.EmptyInt)); } } catch (Exception e) { - logger.log(Level.SEVERE, "Error adding percetion " + lp, e); + logger.log(Level.SEVERE, "Error adding percetion " + lw.getLiteral(), e); } } @@ -796,6 +819,61 @@ return adds + dels; } + public int bufAlternative(List<Literal> percepts) { + // complexity 4n + + if (percepts == null) { + return 0; + } + + // stat + int adds = 0; + int dels = 0; + + //Set<Literal> pinBB = ((DefaultBeliefBase)getBB()).getPerceptsSet(); + Set<StructureWrapperForLiteral> pinBBW = new HashSet<StructureWrapperForLiteral>(); + Iterator<Literal> ibb = getBB().getPercepts(); + while (ibb.hasNext()) + pinBBW.add(new StructureWrapperForLiteral( ibb.next())); + + Iterator<Literal> ip = percepts.iterator(); + while (ip.hasNext()) { + Literal t = ip.next(); + StructureWrapperForLiteral lrt = new StructureWrapperForLiteral(t); + if ( pinBBW.remove(lrt) ) { + // since this percept in in BB, do not need to be added neither removed + ip.remove(); + } + } + + // percepts that are not in BB + for (Literal lp : percepts) { + try { + lp = lp.copy().forceFullLiteralImpl(); + lp.addAnnot(BeliefBase.TPercept); + if (getBB().add(lp)) { + adds++; + ts.updateEvents(new Event(new Trigger(TEOperator.add, TEType.belief, lp), Intention.EmptyInt)); + } + } catch (Exception e) { + logger.log(Level.SEVERE, "Error adding percetion " + lp, e); + } + } + + // remove what was not perceived + for (StructureWrapperForLiteral lw: pinBBW) { + Literal l = lw.getLiteral(); + l = ASSyntax.createLiteral(l.getFunctor(), l.getTermsArray()); + l.addAnnot(BeliefBase.TPercept); + if (bb.remove(l)) { + dels++; + ts.updateEvents(new Event(new Trigger(TEOperator.del, TEType.belief, l), Intention.EmptyInt)); + } + } + return adds + dels; + } + + /* public QueryCacheSimple getQueryCache() { return qCache; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |