|
From: <jom...@us...> - 2015-03-31 17:28:09
|
Revision: 1827
http://sourceforge.net/p/jason/svn/1827
Author: jomifred
Date: 2015-03-31 17:28:01 +0000 (Tue, 31 Mar 2015)
Log Message:
-----------
concurrent BB
Modified Paths:
--------------
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/InternalActionLiteral.java
trunk/src/jason/bb/DefaultBeliefBase.java
trunk/src/jason/jeditplugin/Config.java
trunk/src/jason/stdlib/abolish.java
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2015-03-31 12:44:42 UTC (rev 1826)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2015-03-31 17:28:01 UTC (rev 1827)
@@ -859,8 +859,9 @@
private Literal prepareBodyForEvent(Literal body, Unifier u, IntendedMeans imRenamedVars) {
body = (Literal)body.capply(u);
Unifier renamedVars = new Unifier();
- //System.out.println("antes "+body+" "+u+" ");
+ //getLogger().info("antes "+body+" "+u+" ");
body.makeVarsAnnon(renamedVars); // free variables in an event cannot conflict with those in the plan
+ //getLogger().info("depois "+body+" "+renamedVars);
if (imRenamedVars != null) {
imRenamedVars.renamedVars = renamedVars;
@@ -870,8 +871,8 @@
Map<VarTerm, Term> adds = null;
for (VarTerm v: renamedVars) {
Term t = u.function.get(v);
- if (t != null) {
- //System.out.println("adding "+t+"="+renamedVars.function.get(v));
+ if (t != null && t.isVar()) {
+ getLogger().info("adding "+t+"="+v+"="+renamedVars.function.get(v)+" u="+u);
if (adds == null)
adds = new HashMap<VarTerm, Term>();
try {
Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java
===================================================================
--- trunk/src/jason/asSyntax/InternalActionLiteral.java 2015-03-31 12:44:42 UTC (rev 1826)
+++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2015-03-31 17:28:01 UTC (rev 1827)
@@ -134,7 +134,8 @@
}*/
}
} catch (ConcurrentModificationException e) {
- System.out.println("*-*-* .count concurrent exception - try later");
+ System.out.println("*-*-* "+getFunctor()+" concurrent exception - try later");
+ e.printStackTrace();
// try again later
try { Thread.sleep(200); } catch (InterruptedException e1) { }
return logicalConsequence(ag, un);
Modified: trunk/src/jason/bb/DefaultBeliefBase.java
===================================================================
--- trunk/src/jason/bb/DefaultBeliefBase.java 2015-03-31 12:44:42 UTC (rev 1826)
+++ trunk/src/jason/bb/DefaultBeliefBase.java 2015-03-31 17:28:01 UTC (rev 1827)
@@ -29,15 +29,13 @@
import jason.asSyntax.PredicateIndicator;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
+import java.util.Deque;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.LinkedBlockingDeque;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -55,7 +53,7 @@
* belsMap is a table where the key is the bel.getFunctorArity and the value
* is a list of literals with the same functorArity.
*/
- private Map<PredicateIndicator, BelEntry> belsMap = new ConcurrentHashMap<PredicateIndicator, BelEntry>();
+ private Map<PredicateIndicator, BelEntry> belsMap = new ConcurrentHashMap<PredicateIndicator, BelEntry>(50, (float)0.75, 3);
private int size = 0;
@@ -259,7 +257,8 @@
public Iterator<Literal> getCandidateBeliefs(PredicateIndicator pi) {
BelEntry entry = belsMap.get(pi);
if (entry != null)
- return Collections.unmodifiableList(entry.list).iterator();
+ //return Collections.unmodifiableList(entry.list).iterator();
+ return entry.list.iterator();
else
return null;
}
@@ -271,7 +270,8 @@
} else {
BelEntry entry = belsMap.get(l.getPredicateIndicator());
if (entry != null)
- return Collections.unmodifiableList(entry.list).iterator();
+ //return Collections.unmodifiableList(entry.list).iterator();
+ return entry.list.iterator();
else
return null;
}
@@ -314,15 +314,15 @@
/** each predicate indicator has one BelEntry assigned to it */
final class BelEntry {
- final private List<Literal> list = new LinkedList<Literal>(); // maintains the order of the beliefs
- final private Map<LiteralWrapper,Literal> map = new HashMap<LiteralWrapper,Literal>(); // to find content faster
+ final private Deque<Literal> list = new LinkedBlockingDeque<Literal>(); // maintains the order of the beliefs
+ final private Map<LiteralWrapper,Literal> map = new ConcurrentHashMap<LiteralWrapper,Literal>(30,(float)0.75,3); // to find content faster
public void add(Literal l, boolean addInEnd) {
map.put(new LiteralWrapper(l), l);
if (addInEnd) {
- list.add(l);
+ list.addLast(l);
} else {
- list.add(0,l);
+ list.addFirst(l);
}
}
Modified: trunk/src/jason/jeditplugin/Config.java
===================================================================
--- trunk/src/jason/jeditplugin/Config.java 2015-03-31 12:44:42 UTC (rev 1826)
+++ trunk/src/jason/jeditplugin/Config.java 2015-03-31 17:28:01 UTC (rev 1827)
@@ -330,6 +330,10 @@
if (getProperty(NB_TH_SCH) == null) {
put(NB_TH_SCH, "2");
}
+
+ if (getProperty(SHORT_UNNAMED_VARS) == null) {
+ put(SHORT_UNNAMED_VARS,"true");
+ }
// Default infrastructures
put("infrastructure.Centralised", CentralisedFactory.class.getName());
Modified: trunk/src/jason/stdlib/abolish.java
===================================================================
--- trunk/src/jason/stdlib/abolish.java 2015-03-31 12:44:42 UTC (rev 1826)
+++ trunk/src/jason/stdlib/abolish.java 2015-03-31 17:28:01 UTC (rev 1827)
@@ -34,19 +34,22 @@
<p>Internal action: <b><code>.abolish</code></b>.
<p>Description: removes all beliefs that match the argument. As for the
- "-" operator, an event will be generated for each deletion.
+ "-" operator, an event will be generated for each deletion.
+ Different from the "-" operator, which consider "self" as the default source, .abolish will ignore the source if not informed.
<p>Parameters:<ul>
<li>+ pattern (literal or variable): the "pattern" for what should be removed.<br/>
</ul>
<p>Examples:<ul>
- <li> <code>.abolish(b(_))</code>: remove all <code>b/1</code> beliefs, regardless of the argument value.</li>
+ <li> <code>.abolish(b(_))</code>: remove all <code>b/1</code> beliefs, regardless of the argument value and the source of the belief.</li>
<li> <code>.abolish(c(_,t))</code>: remove all <code>c/2</code> beliefs where the second argument is <code>2</code>.</li>
<li> <code>.abolish(c(_,_)[source(ag1)])</code>: remove all <code>c/2</code> beliefs that have <code>ag1</code> as source.</li>
<li> <code>.abolish(_[source(ag1)])</code>: remove any beliefs that have <code>ag1</code> as source.</li>
</ul>
+ @see jason.stdlib.asserta
+
*/
public class abolish extends DefaultInternalAction {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|