|
From: <jom...@us...> - 2016-05-17 11:06:48
|
Revision: 1915
http://sourceforge.net/p/jason/svn/1915
Author: jomifred
Date: 2016-05-17 11:06:45 +0000 (Tue, 17 May 2016)
Log Message:
-----------
improve config
Modified Paths:
--------------
trunk/build.xml
trunk/release-notes.txt
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/infra/centralised/CentralisedAgArch.java
trunk/src/jason/infra/centralised/CentralisedAgArchAsynchronous.java
trunk/src/jason/infra/centralised/RunCentralisedMAS.java
trunk/src/jason/infra/components/ActComponent.java
trunk/src/jason/infra/components/AgentComponent.java
trunk/src/jason/infra/components/CircumstanceListenerComponents.java
trunk/src/jason/infra/components/DeliberateComponent.java
trunk/src/jason/infra/components/SenseComponent.java
trunk/src/jason/util/Config.java
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/build.xml 2016-05-17 11:06:45 UTC (rev 1915)
@@ -4,7 +4,7 @@
<property environment="env" />
- <property name="version" value="2" />
+ <property name="version" value="2" />
<property name="release" value="0.beta" />
<property name="jasonJar" value="${basedir}/lib/jason-${version}.${release}.jar" />
@@ -12,7 +12,7 @@
<property name="jasonSJar" value="${basedir}/lib/s-jason.jar" />
<property name="replJar" value="${basedir}/lib/jason-repl.jar" />
<property name="coreJar" value="${basedir}/lib/jason-core.jar" />
-
+
<property name="build.dir" value="${basedir}/bin/classes" />
<property name="dist.properties" value="${basedir}/bin/dist.properties" />
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/release-notes.txt 2016-05-17 11:06:45 UTC (rev 1915)
@@ -6,7 +6,7 @@
New features:
-- modules and namespaces, see doc/modules.pdf
+- modules and namespaces, see doc/modules-namespaces.pdf
- concurrent plans and advanced concurrent agent architectures, see doc/concurrency.pdf
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2016-05-17 11:06:45 UTC (rev 1915)
@@ -1388,7 +1388,7 @@
}
public boolean canSleepAct() {
- //&& !C.hasPendingAction()
+ //&& !C.hasPendingAction()
return !C.hasIntention() && !C.hasFeedbackAction() && C.getSelectedIntention() == null && getUserAgArch().canSleep();
}
Modified: trunk/src/jason/infra/centralised/CentralisedAgArch.java
===================================================================
--- trunk/src/jason/infra/centralised/CentralisedAgArch.java 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/src/jason/infra/centralised/CentralisedAgArch.java 2016-05-17 11:06:45 UTC (rev 1915)
@@ -200,7 +200,7 @@
//int sumDel = 0; int nbDel = 0;
protected void deliberate() {
- TransitionSystem ts = getTS();
+ TransitionSystem ts = getTS();
int i = 0;
while (running && i++ < cyclesDeliberate && !ts.canSleepDeliberate()) {
ts.deliberate();
@@ -211,8 +211,8 @@
//int sumAct = 0; int nbAct = 0;
protected void act() {
- TransitionSystem ts = getTS();
-
+ TransitionSystem ts = getTS();
+
int i = 0;
int ca = cyclesAct;
if (cyclesAct == 9999)
@@ -226,9 +226,9 @@
}
protected void reasoningCycle() {
- sense();
- deliberate();
- act();
+ sense();
+ deliberate();
+ act();
}
public void run() {
Modified: trunk/src/jason/infra/centralised/CentralisedAgArchAsynchronous.java
===================================================================
--- trunk/src/jason/infra/centralised/CentralisedAgArchAsynchronous.java 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/src/jason/infra/centralised/CentralisedAgArchAsynchronous.java 2016-05-17 11:06:45 UTC (rev 1915)
@@ -10,11 +10,11 @@
import jason.infra.components.SenseComponent;
public class CentralisedAgArchAsynchronous extends CentralisedAgArch implements Runnable {
- private SenseComponent senseComponent;
+ private SenseComponent senseComponent;
private DeliberateComponent deliberateComponent;
private ActComponent actComponent;
- private ExecutorService executorSense;
+ private ExecutorService executorSense;
private ExecutorService executorDeliberate;
private ExecutorService executorAct;
@@ -23,80 +23,80 @@
public Object objAct = new Object();
public CentralisedAgArchAsynchronous() {
- super();
-
- senseComponent = new SenseComponent(this);
- deliberateComponent = new DeliberateComponent(this);
- actComponent = new ActComponent(this);
+ super();
+
+ senseComponent = new SenseComponent(this);
+ deliberateComponent = new DeliberateComponent(this);
+ actComponent = new ActComponent(this);
}
- public void wakeUpSense() {
- senseComponent.wakeUp();
- }
+ public void wakeUpSense() {
+ senseComponent.wakeUp();
+ }
- public void wakeUpDeliberate() {
- deliberateComponent.wakeUp();
- }
-
- public void wakeUpAct() {
- actComponent.wakeUp();
- }
-
- public SenseComponent getSenseComponent() {
- return senseComponent;
- }
+ public void wakeUpDeliberate() {
+ deliberateComponent.wakeUp();
+ }
- public DeliberateComponent getDeliberateComponent() {
- return deliberateComponent;
- }
-
- public ActComponent getActComponent() {
- return actComponent;
- }
-
+ public void wakeUpAct() {
+ actComponent.wakeUp();
+ }
+
+ public SenseComponent getSenseComponent() {
+ return senseComponent;
+ }
+
+ public DeliberateComponent getDeliberateComponent() {
+ return deliberateComponent;
+ }
+
+ public ActComponent getActComponent() {
+ return actComponent;
+ }
+
public ExecutorService getExecutorSense() {
- return executorSense;
- }
+ return executorSense;
+ }
- public ExecutorService getExecutorDeliberate() {
- return executorDeliberate;
- }
+ public ExecutorService getExecutorDeliberate() {
+ return executorDeliberate;
+ }
- public ExecutorService getExecutorAct() {
- return executorAct;
- }
+ public ExecutorService getExecutorAct() {
+ return executorAct;
+ }
- public void setExecutorAct(ExecutorService executorAct) {
- this.executorAct = executorAct;
- }
+ public void setExecutorAct(ExecutorService executorAct) {
+ this.executorAct = executorAct;
+ }
- public void setExecutorSense(ExecutorService executorSense) {
- this.executorSense = executorSense;
- }
+ public void setExecutorSense(ExecutorService executorSense) {
+ this.executorSense = executorSense;
+ }
- public void setExecutorDeliberate(ExecutorService executorDeliberate) {
- this.executorDeliberate = executorDeliberate;
- }
+ public void setExecutorDeliberate(ExecutorService executorDeliberate) {
+ this.executorDeliberate = executorDeliberate;
+ }
- public void setSenseComponent(SenseComponent senseComponent) {
- this.senseComponent = senseComponent;
- }
-
- public void addListenerToC(CircumstanceListener listener) {
- getTS().getC().addEventListener(listener);
- }
-
- public void receiveMsg(Message m) {
- synchronized (objSense) {
- super.receiveMsg(m);
- }
+ public void setSenseComponent(SenseComponent senseComponent) {
+ this.senseComponent = senseComponent;
}
+ public void addListenerToC(CircumstanceListener listener) {
+ getTS().getC().addEventListener(listener);
+ }
+
+ public void receiveMsg(Message m) {
+ synchronized (objSense) {
+ super.receiveMsg(m);
+ }
+ }
+
/** called the the environment when the action was executed */
public void actionExecuted(ActionExec action) {
- synchronized (objAct) {
- super.actionExecuted(action);
- }
+ synchronized (objAct) {
+ super.actionExecuted(action);
+ }
}
}
Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java
===================================================================
--- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2016-05-17 11:06:45 UTC (rev 1915)
@@ -433,20 +433,20 @@
public void createAgs() throws JasonException {
-
- RConf generalConf;
- if (project.getInfrastructure().hasParameter("pool")) {
- generalConf = RConf.POOL_SYNCH;
- } else if (project.getInfrastructure().hasParameter("synch_scheduled")) {
- generalConf = RConf.POOL_SYNCH_SCHEDULED;
- } else if (project.getInfrastructure().hasParameter("asynch")) {
- generalConf = RConf.ASYNCH;
- } else if (project.getInfrastructure().hasParameter("asynch_shared")) {
- generalConf = RConf.ASYNCH_SHARED_POOLS;
- } else {
- generalConf = RConf.TRHEADED;
- }
-
+
+ RConf generalConf;
+ if (project.getInfrastructure().hasParameter("pool")) {
+ generalConf = RConf.POOL_SYNCH;
+ } else if (project.getInfrastructure().hasParameter("synch_scheduled")) {
+ generalConf = RConf.POOL_SYNCH_SCHEDULED;
+ } else if (project.getInfrastructure().hasParameter("asynch")) {
+ generalConf = RConf.ASYNCH;
+ } else if (project.getInfrastructure().hasParameter("asynch_shared")) {
+ generalConf = RConf.ASYNCH_SHARED_POOLS;
+ } else {
+ generalConf = RConf.TRHEADED;
+ }
+
//boolean isPool = project.getInfrastructure().hasParameter("pool") || project.getInfrastructure().hasParameter("synch_scheduled");
//boolean isAsynch = project.getInfrastructure().hasParameter("asynch") || project.getInfrastructure().hasParameter("asynch_shared");
if (generalConf != RConf.TRHEADED) logger.info("Creating agents....");
@@ -480,38 +480,38 @@
RConf agentConf;
if (ap.getOption("rc") != null) {
- if (ap.getOption("rc").equals("pool")) {
- agentConf = RConf.POOL_SYNCH;
- } else if (ap.getOption("rc").equals("synch_scheduled")) {
- agentConf = RConf.POOL_SYNCH_SCHEDULED;
- } else if (ap.getOption("rc").equals("asynch")) {
- agentConf = RConf.ASYNCH;
- } else if (ap.getOption("rc").equals("asynch_shared")) {
- agentConf = RConf.ASYNCH_SHARED_POOLS;
- } else {
- agentConf = RConf.TRHEADED;
- }
+ if (ap.getOption("rc").equals("pool")) {
+ agentConf = RConf.POOL_SYNCH;
+ } else if (ap.getOption("rc").equals("synch_scheduled")) {
+ agentConf = RConf.POOL_SYNCH_SCHEDULED;
+ } else if (ap.getOption("rc").equals("asynch")) {
+ agentConf = RConf.ASYNCH;
+ } else if (ap.getOption("rc").equals("asynch_shared")) {
+ agentConf = RConf.ASYNCH_SHARED_POOLS;
+ } else {
+ agentConf = RConf.TRHEADED;
+ }
} else {
- agentConf = generalConf;
+ agentConf = generalConf;
}
//Get the number of reasoning cycles or number of cycles for each stage
int cycles = 0;
- int cyclesSense = 0;
- int cyclesDeliberate = 0;
- int cyclesAct = 0;
-
+ int cyclesSense = 0;
+ int cyclesDeliberate = 0;
+ int cyclesAct = 0;
+
if (ap.getOption("cycles") != null) {
- cycles = Integer.valueOf(ap.getOption("cycles"));
+ cycles = Integer.valueOf(ap.getOption("cycles"));
}
if (ap.getOption("cycles_sense") != null) {
- cyclesSense = Integer.valueOf(ap.getOption("cycles_sense"));
+ cyclesSense = Integer.valueOf(ap.getOption("cycles_sense"));
}
if (ap.getOption("cycles_deliberate") != null) {
- cyclesDeliberate = Integer.valueOf(ap.getOption("cycles_deliberate"));
+ cyclesDeliberate = Integer.valueOf(ap.getOption("cycles_deliberate"));
}
if (ap.getOption("cycles_act") != null) {
- cyclesAct = Integer.valueOf(ap.getOption("cycles_act"));
+ cyclesAct = Integer.valueOf(ap.getOption("cycles_act"));
}
//Create agents according to the specific architecture
@@ -520,44 +520,44 @@
} else if (agentConf == RConf.POOL_SYNCH_SCHEDULED) {
agArch = new CentralisedAgArchSynchronousScheduled();
if (cycles != 0) {
- if (cyclesSense == 0) {
- cyclesSense = cycles;
- }
- if (cyclesDeliberate == 0) {
- cyclesDeliberate = cycles;
- }
- if (cyclesAct == 0) {
- cyclesAct = cycles;
- }
- cycles = 1;
+ if (cyclesSense == 0) {
+ cyclesSense = cycles;
+ }
+ if (cyclesDeliberate == 0) {
+ cyclesDeliberate = cycles;
+ }
+ if (cyclesAct == 0) {
+ cyclesAct = cycles;
+ }
+ cycles = 1;
}
} else if (agentConf == RConf.ASYNCH || agentConf == RConf.ASYNCH_SHARED_POOLS) {
- agArch = new CentralisedAgArchAsynchronous();
+ agArch = new CentralisedAgArchAsynchronous();
if (cycles != 0) {
- if (cyclesSense == 0) {
- cyclesSense = cycles;
- }
- if (cyclesDeliberate == 0) {
- cyclesDeliberate = cycles;
- }
- if (cyclesAct == 0) {
- cyclesAct = cycles;
- }
- cycles = 1;
- }
+ if (cyclesSense == 0) {
+ cyclesSense = cycles;
+ }
+ if (cyclesDeliberate == 0) {
+ cyclesDeliberate = cycles;
+ }
+ if (cyclesAct == 0) {
+ cyclesAct = cycles;
+ }
+ cycles = 1;
+ }
} else {
agArch = new CentralisedAgArch();
if (cycles != 0) {
- if (cyclesSense == 0) {
- cyclesSense = cycles;
- }
- if (cyclesDeliberate == 0) {
- cyclesDeliberate = cycles;
- }
- if (cyclesAct == 0) {
- cyclesAct = cycles;
- }
- cycles = 1;
+ if (cyclesSense == 0) {
+ cyclesSense = cycles;
+ }
+ if (cyclesDeliberate == 0) {
+ cyclesDeliberate = cycles;
+ }
+ if (cyclesAct == 0) {
+ cyclesAct = cycles;
+ }
+ cycles = 1;
}
}
@@ -621,36 +621,36 @@
logger.fine("Creating agent " + numberedAg + " (" + (cAg + 1) + "/" + ap.getNbInstances() + ")");
CentralisedAgArch agArch;
if (isPool) {
- if (project.getInfrastructure().hasParameter("synch_scheduled")) {
- agArch = new CentralisedAgArchSynchronousScheduled();
- if (ap.getOption("cycles") != null) {
- agArch.setCycles(Integer.valueOf(ap.getOption("cycles")));
- }
- } else {
- agArch = new CentralisedAgArchForPool();
- if (ap.getOption("cycles") != null) {
- agArch.setCycles(Integer.valueOf(ap.getOption("cycles")));
- }
- }
+ if (project.getInfrastructure().hasParameter("synch_scheduled")) {
+ agArch = new CentralisedAgArchSynchronousScheduled();
+ if (ap.getOption("cycles") != null) {
+ agArch.setCycles(Integer.valueOf(ap.getOption("cycles")));
+ }
+ } else {
+ agArch = new CentralisedAgArchForPool();
+ if (ap.getOption("cycles") != null) {
+ agArch.setCycles(Integer.valueOf(ap.getOption("cycles")));
+ }
+ }
} else if (isAsynch) {
- agArch = new CentralisedAgArchAsynchronous();
-
- int cyclesSense = 0;
- int cyclesDeliberate = 0;
- int cyclesAct = 0;
-
- if (ap.getOption("cycles") != null) {
- cyclesSense = cyclesDeliberate = cyclesAct = Integer.valueOf(ap.getOption("cycles"));
- }
-
+ agArch = new CentralisedAgArchAsynchronous();
+
+ int cyclesSense = 0;
+ int cyclesDeliberate = 0;
+ int cyclesAct = 0;
+
+ if (ap.getOption("cycles") != null) {
+ cyclesSense = cyclesDeliberate = cyclesAct = Integer.valueOf(ap.getOption("cycles"));
+ }
+
if (ap.getOption("cycles_sense") != null) {
- cyclesSense = Integer.valueOf(ap.getOption("cycles_sense"));
+ cyclesSense = Integer.valueOf(ap.getOption("cycles_sense"));
}
if (ap.getOption("cycles_deliberate") != null) {
- cyclesDeliberate = Integer.valueOf(ap.getOption("cycles_deliberate"));
+ cyclesDeliberate = Integer.valueOf(ap.getOption("cycles_deliberate"));
}
if (ap.getOption("cycles_act") != null) {
- cyclesAct = Integer.valueOf(ap.getOption("cycles_act"));
+ cyclesAct = Integer.valueOf(ap.getOption("cycles_act"));
}
((CentralisedAgArchAsynchronous) agArch).getSenseComponent().setCycles(cyclesSense);
@@ -660,7 +660,7 @@
} else {
agArch = new CentralisedAgArch();
if (ap.getOption("cycles") != null) {
- agArch.setCycles(Integer.valueOf(ap.getOption("cycles")));
+ agArch.setCycles(Integer.valueOf(ap.getOption("cycles")));
}
}
agArch.setAgName(numberedAg);
@@ -721,23 +721,23 @@
/** creates one thread per agent */
private void createAgsThreads() {
-
- int cyclesSense = 1;
- int cyclesDeliberate = 1;
- int cyclesAct = 5;
-
- if (project.getInfrastructure().hasParameters()) {
+
+ int cyclesSense = 1;
+ int cyclesDeliberate = 1;
+ int cyclesAct = 5;
+
+ if (project.getInfrastructure().hasParameters()) {
if (project.getInfrastructure().getParametersArray().length > 2) {
- cyclesSense = Integer.parseInt(project.getInfrastructure().getParameter(1));
- cyclesDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(2));
- cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(3));
+ cyclesSense = Integer.parseInt(project.getInfrastructure().getParameter(1));
+ cyclesDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(2));
+ cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(3));
} else if (project.getInfrastructure().getParametersArray().length > 1) {
- cyclesSense = cyclesDeliberate = cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(1));
- }
+ cyclesSense = cyclesDeliberate = cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(1));
+ }
//logger.info("Creating a threaded agents." + "Cycles: " + cyclesSense + ", " + cyclesDeliberate + ", " + cyclesAct);
- }
-
+ }
+
for (CentralisedAgArch ag : ags.values()) {
ag.setControlInfraTier(control);
@@ -755,7 +755,7 @@
//logger.info("Creating threaded agents. Cycles: " + agTemp.getCyclesSense() + ", " + agTemp.getCyclesDeliberate() + ", " + agTemp.getCyclesAct());
for (CentralisedAgArch ag : ags.values()) {
- ag.startThread();
+ ag.startThread();
}
}
@@ -786,63 +786,63 @@
try {
if (project.getInfrastructure().hasParameters()) {
-
- if (project.getInfrastructure().hasParameter("asynch")) {
- configuration = 1;
- maxthreadsSense = Integer.parseInt(project.getInfrastructure().getParameter(1));
- maxthreadsDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(2));
- maxthreadsAct = Integer.parseInt(project.getInfrastructure().getParameter(3));
- if (project.getInfrastructure().getParametersArray().length > 5) {
- cyclesSense = Integer.parseInt(project.getInfrastructure().getParameter(4));
- cyclesDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(5));
- cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(6));
- } else if (project.getInfrastructure().getParametersArray().length > 4) {
- cyclesSense = cyclesDeliberate = cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(4));
- }
- logger.info("Creating agents with asynchronous reasoning cycle. Sense (" + maxthreadsSense + "), Deliberate (" + maxthreadsDeliberate + "), Act (" + maxthreadsAct + ")" + "Cycles: " + cyclesSense + ", " + cyclesDeliberate + ", " + cyclesAct);
- } else if (project.getInfrastructure().hasParameter("asynch_shared")) {
- configuration = 2;
- maxthreads = Integer.parseInt(project.getInfrastructure().getParameter(1));
- if (project.getInfrastructure().getParametersArray().length > 3) {
- cyclesSense = Integer.parseInt(project.getInfrastructure().getParameter(2));
- cyclesDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(3));
- cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(4));
- } else if (project.getInfrastructure().getParametersArray().length > 2) {
- cyclesSense = cyclesDeliberate = cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(2));
- }
- logger.info("Creating agents with asynchronous reasoning cycle (shared). Sense, Deliberate, Act (" + maxthreads + ")" + "Cycles: " + cyclesSense + ", " + cyclesDeliberate + ", " + cyclesAct);
- } else if (project.getInfrastructure().hasParameter("synch_scheduled")) {
+
+ if (project.getInfrastructure().hasParameter("asynch")) {
+ configuration = 1;
+ maxthreadsSense = Integer.parseInt(project.getInfrastructure().getParameter(1));
+ maxthreadsDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(2));
+ maxthreadsAct = Integer.parseInt(project.getInfrastructure().getParameter(3));
+ if (project.getInfrastructure().getParametersArray().length > 5) {
+ cyclesSense = Integer.parseInt(project.getInfrastructure().getParameter(4));
+ cyclesDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(5));
+ cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(6));
+ } else if (project.getInfrastructure().getParametersArray().length > 4) {
+ cyclesSense = cyclesDeliberate = cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(4));
+ }
+ logger.info("Creating agents with asynchronous reasoning cycle. Sense (" + maxthreadsSense + "), Deliberate (" + maxthreadsDeliberate + "), Act (" + maxthreadsAct + ")" + "Cycles: " + cyclesSense + ", " + cyclesDeliberate + ", " + cyclesAct);
+ } else if (project.getInfrastructure().hasParameter("asynch_shared")) {
+ configuration = 2;
maxthreads = Integer.parseInt(project.getInfrastructure().getParameter(1));
+ if (project.getInfrastructure().getParametersArray().length > 3) {
+ cyclesSense = Integer.parseInt(project.getInfrastructure().getParameter(2));
+ cyclesDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(3));
+ cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(4));
+ } else if (project.getInfrastructure().getParametersArray().length > 2) {
+ cyclesSense = cyclesDeliberate = cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(2));
+ }
+ logger.info("Creating agents with asynchronous reasoning cycle (shared). Sense, Deliberate, Act (" + maxthreads + ")" + "Cycles: " + cyclesSense + ", " + cyclesDeliberate + ", " + cyclesAct);
+ } else if (project.getInfrastructure().hasParameter("synch_scheduled")) {
+ maxthreads = Integer.parseInt(project.getInfrastructure().getParameter(1));
if (project.getInfrastructure().getParametersArray().length > 3) {
- cyclesSense = Integer.parseInt(project.getInfrastructure().getParameter(2));
- cyclesDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(3));
- cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(4));
+ cyclesSense = Integer.parseInt(project.getInfrastructure().getParameter(2));
+ cyclesDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(3));
+ cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(4));
} else if (project.getInfrastructure().getParametersArray().length > 2) {
- cyclesSense = cyclesDeliberate = cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(2));
- }
+ cyclesSense = cyclesDeliberate = cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(2));
+ }
- logger.info("Creating a thread pool with "+maxthreads+" thread(s)." + "Cycles: " + cyclesSense + ", " + cyclesDeliberate + ", " + cyclesAct + " Reasoning Cycles: " + cycles);
- } else {
+ logger.info("Creating a thread pool with "+maxthreads+" thread(s)." + "Cycles: " + cyclesSense + ", " + cyclesDeliberate + ", " + cyclesAct + " Reasoning Cycles: " + cycles);
+ } else {
maxthreads = Integer.parseInt(project.getInfrastructure().getParameter(1));
if (project.getInfrastructure().getParametersArray().length > 3) {
- cyclesSense = Integer.parseInt(project.getInfrastructure().getParameter(2));
- cyclesDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(3));
- cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(4));
- if (project.getInfrastructure().getParametersArray().length > 4) {
- cycles = Integer.parseInt(project.getInfrastructure().getParameter(5));
- } else {
- cycles = 5;
- }
+ cyclesSense = Integer.parseInt(project.getInfrastructure().getParameter(2));
+ cyclesDeliberate = Integer.parseInt(project.getInfrastructure().getParameter(3));
+ cyclesAct = Integer.parseInt(project.getInfrastructure().getParameter(4));
+ if (project.getInfrastructure().getParametersArray().length > 4) {
+ cycles = Integer.parseInt(project.getInfrastructure().getParameter(5));
+ } else {
+ cycles = 5;
+ }
} else if (project.getInfrastructure().getParametersArray().length > 2) {
- cycles = Integer.parseInt(project.getInfrastructure().getParameter(2));
- } else {
- cycles = 5;
- }
+ cycles = Integer.parseInt(project.getInfrastructure().getParameter(2));
+ } else {
+ cycles = 5;
+ }
logger.info("Creating a thread pool with "+maxthreads+" thread(s)." + "Cycles: " + cyclesSense + ", " + cyclesDeliberate + ", " + cyclesAct + " Reasoning Cycles: " + cycles);
- }
+ }
}
} catch (Exception e) {
logger.warning("Error getting the number of thread for the pool.");
@@ -869,37 +869,37 @@
}
} else {
-
- //TODO shared thread pool among the stages
- if (configuration == 2) {
- executorSense = executorDeliberate = executorAct = Executors.newFixedThreadPool(maxthreads);
- } else {
- executorSense = Executors.newFixedThreadPool(maxthreadsSense);
- executorDeliberate = Executors.newFixedThreadPool(maxthreadsDeliberate);
- executorAct = Executors.newFixedThreadPool(maxthreadsAct);
- }
+ //TODO shared thread pool among the stages
+ if (configuration == 2) {
+ executorSense = executorDeliberate = executorAct = Executors.newFixedThreadPool(maxthreads);
+ } else {
+ executorSense = Executors.newFixedThreadPool(maxthreadsSense);
+ executorDeliberate = Executors.newFixedThreadPool(maxthreadsDeliberate);
+ executorAct = Executors.newFixedThreadPool(maxthreadsAct);
+ }
+
//ThreadMonitorAgents mon = new ThreadMonitorAgents();
// initially, add all agents in the tasks
for (CentralisedAgArch ag : ags.values()) {
- CentralisedAgArchAsynchronous ag2 = (CentralisedAgArchAsynchronous) ag;
-
- ag2.addListenerToC(new CircumstanceListenerComponents(ag2));
-
- ag2.setExecutorAct(executorAct);
- ag2.setCyclesAct(cyclesAct);
- executorAct.execute(ag2.getActComponent());
-
- ag2.setExecutorDeliberate(executorDeliberate);
- ag2.setCyclesDeliberate(cyclesDeliberate);
- executorDeliberate.execute(ag2.getDeliberateComponent());
-
- ag2.setExecutorSense(executorSense);
- ag2.setCyclesSense(cyclesSense);
- executorSense.execute(ag2.getSenseComponent());
-
- //mon.lst.add(ag2);
+ CentralisedAgArchAsynchronous ag2 = (CentralisedAgArchAsynchronous) ag;
+
+ ag2.addListenerToC(new CircumstanceListenerComponents(ag2));
+
+ ag2.setExecutorAct(executorAct);
+ ag2.setCyclesAct(cyclesAct);
+ executorAct.execute(ag2.getActComponent());
+
+ ag2.setExecutorDeliberate(executorDeliberate);
+ ag2.setCyclesDeliberate(cyclesDeliberate);
+ executorDeliberate.execute(ag2.getDeliberateComponent());
+
+ ag2.setExecutorSense(executorSense);
+ ag2.setCyclesSense(cyclesSense);
+ executorSense.execute(ag2.getSenseComponent());
+
+ //mon.lst.add(ag2);
}
//new Thread(mon).start();
@@ -919,65 +919,65 @@
@Override
public void wake() {
if (sleepingAgs.remove(this)) {
- executor.execute(this);
+ executor.execute(this);
} else {
runWakeAfterTS = true;
}
}
public void sense() {
- int number_cycles = getCyclesSense();
- int i = 0;
-
+ int number_cycles = getCyclesSense();
+ int i = 0;
+
while (isRunning() && i < number_cycles) {
- runWakeAfterTS = false;
- getTS().sense();
+ runWakeAfterTS = false;
+ getTS().sense();
if (getTS().canSleepSense()) {
if (runWakeAfterTS) {
wake();
}
- break;
+ break;
}
i++;
}
if (isRunning()) {
- executor.execute(this);
+ executor.execute(this);
}
}
public void deliberate() {
- super.deliberate();
+ super.deliberate();
if (isRunning()) {
- executor.execute(this);
+ executor.execute(this);
}
}
public void act() {
- super.act();
+ super.act();
if (isRunning()) {
- executor.execute(this);
+ executor.execute(this);
}
}
@Override
public void run() {
- switch (currentStep) {
- case 0:
- sense();
- currentStep = 1;
- break;
- case 1:
- deliberate();
- currentStep = 2;
- break;
- case 2:
- act();
- currentStep = 0;
- break;
- }
+ switch (currentStep) {
+ case 0:
+ sense();
+ currentStep = 1;
+ break;
+ case 1:
+ deliberate();
+ currentStep = 2;
+ break;
+ case 2:
+ act();
+ currentStep = 0;
+ break;
+ }
}
}
Modified: trunk/src/jason/infra/components/ActComponent.java
===================================================================
--- trunk/src/jason/infra/components/ActComponent.java 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/src/jason/infra/components/ActComponent.java 2016-05-17 11:06:45 UTC (rev 1915)
@@ -3,50 +3,50 @@
import jason.infra.centralised.CentralisedAgArchAsynchronous;
public class ActComponent extends AgentComponent {
-
- public ActComponent(CentralisedAgArchAsynchronous centralisedAgArchAsynchronous) {
- super(centralisedAgArchAsynchronous);
- }
-
- public void wakeUp() {
- synchronized (ag.objAct) {
- if (sleeping) {
- sleeping = false;
- enqueueExecutor(false);
- }
- }
- }
-
- public void enqueueExecutor(boolean ts) {
+
+ public ActComponent(CentralisedAgArchAsynchronous centralisedAgArchAsynchronous) {
+ super(centralisedAgArchAsynchronous);
+ }
+
+ public void wakeUp() {
+ synchronized (ag.objAct) {
+ if (sleeping) {
+ sleeping = false;
+ enqueueExecutor(false);
+ }
+ }
+ }
+
+ public void enqueueExecutor(boolean ts) {
if (!inQueue || ts) {
- inQueue = true;
- ag.getExecutorAct().execute(this);
+ inQueue = true;
+ ag.getExecutorAct().execute(this);
}
- }
-
- public boolean canSleep() {
- return ag.getTS().canSleepAct();
- }
-
- public void run() {
- int cycles = ag.getCyclesAct();
- //int number_cycles = 1;
- int i = 0;
+ }
+
+ public boolean canSleep() {
+ return ag.getTS().canSleepAct();
+ }
+
+ public void run() {
+ int cycles = ag.getCyclesAct();
+ //int number_cycles = 1;
+ int i = 0;
while (ag.isRunning() && i < cycles) {
- i++;
- ag.getTS().act();
-
-
- synchronized (ag.objAct) {
- if (canSleep()) {
- inQueue = false;
- sleep();
- return;
- } else if (i == cycles) {
- enqueueExecutor(true);
- return;
- }
- }
+ i++;
+ ag.getTS().act();
+
+
+ synchronized (ag.objAct) {
+ if (canSleep()) {
+ inQueue = false;
+ sleep();
+ return;
+ } else if (i == cycles) {
+ enqueueExecutor(true);
+ return;
+ }
+ }
}
- }
+ }
}
Modified: trunk/src/jason/infra/components/AgentComponent.java
===================================================================
--- trunk/src/jason/infra/components/AgentComponent.java 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/src/jason/infra/components/AgentComponent.java 2016-05-17 11:06:45 UTC (rev 1915)
@@ -3,23 +3,23 @@
import jason.infra.centralised.CentralisedAgArchAsynchronous;
public abstract class AgentComponent implements Runnable {
- protected CentralisedAgArchAsynchronous ag;
- protected boolean inQueue = true;
- protected boolean sleeping = false;
-
- public AgentComponent(CentralisedAgArchAsynchronous ag) {
- this.ag = ag;
- }
-
- public void sleep() {
- sleeping = true;
- }
-
- public boolean isSleeping() {
- return sleeping;
- }
-
- public abstract void wakeUp();
- public abstract void enqueueExecutor(boolean ts);
- public abstract boolean canSleep();
+ protected CentralisedAgArchAsynchronous ag;
+ protected boolean inQueue = true;
+ protected boolean sleeping = false;
+
+ public AgentComponent(CentralisedAgArchAsynchronous ag) {
+ this.ag = ag;
+ }
+
+ public void sleep() {
+ sleeping = true;
+ }
+
+ public boolean isSleeping() {
+ return sleeping;
+ }
+
+ public abstract void wakeUp();
+ public abstract void enqueueExecutor(boolean ts);
+ public abstract boolean canSleep();
}
Modified: trunk/src/jason/infra/components/CircumstanceListenerComponents.java
===================================================================
--- trunk/src/jason/infra/components/CircumstanceListenerComponents.java 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/src/jason/infra/components/CircumstanceListenerComponents.java 2016-05-17 11:06:45 UTC (rev 1915)
@@ -6,38 +6,38 @@
import jason.infra.centralised.CentralisedAgArchAsynchronous;
public class CircumstanceListenerComponents implements CircumstanceListener {
- private CentralisedAgArchAsynchronous ag;
-
- public CircumstanceListenerComponents(CentralisedAgArchAsynchronous ag) {
- this.ag = ag;
- }
+ private CentralisedAgArchAsynchronous ag;
+
+ public CircumstanceListenerComponents(CentralisedAgArchAsynchronous ag) {
+ this.ag = ag;
+ }
- public void notifyDeliberate() {
- ag.wakeUpDeliberate();
- }
-
- public void notifyAct() {
- ag.wakeUpAct();
- }
-
- public void eventAdded(Event e) {
- notifyDeliberate();
- }
+ public void notifyDeliberate() {
+ ag.wakeUpDeliberate();
+ }
+
+ public void notifyAct() {
+ ag.wakeUpAct();
+ }
+
+ public void eventAdded(Event e) {
+ notifyDeliberate();
+ }
- public void intentionAdded(Intention i) {
- notifyAct();
- }
+ public void intentionAdded(Intention i) {
+ notifyAct();
+ }
- public void intentionDropped(Intention i) {
- notifyDeliberate();
- }
+ public void intentionDropped(Intention i) {
+ notifyDeliberate();
+ }
- public void intentionSuspended(Intention i, String reason) {
- notifyDeliberate();
- }
+ public void intentionSuspended(Intention i, String reason) {
+ notifyDeliberate();
+ }
- public void intentionResumed(Intention i) {
- //notifyDeliberate();
- notifyAct();
- }
+ public void intentionResumed(Intention i) {
+ //notifyDeliberate();
+ notifyAct();
+ }
}
Modified: trunk/src/jason/infra/components/DeliberateComponent.java
===================================================================
--- trunk/src/jason/infra/components/DeliberateComponent.java 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/src/jason/infra/components/DeliberateComponent.java 2016-05-17 11:06:45 UTC (rev 1915)
@@ -3,55 +3,55 @@
import jason.infra.centralised.CentralisedAgArchAsynchronous;
public class DeliberateComponent extends AgentComponent {
-
- public DeliberateComponent(CentralisedAgArchAsynchronous centralisedAgArchAsynchronous) {
- super(centralisedAgArchAsynchronous);
- }
-
- public boolean canSleep() {
- return ag.getTS().canSleepDeliberate();
- }
-
- public void wakeUp() {
- synchronized (ag.objDeliberate) {
- if (sleeping) {
- sleeping = false;
- enqueueExecutor(false);
- }
- }
- }
-
- public void enqueueExecutor(boolean ts) {
+
+ public DeliberateComponent(CentralisedAgArchAsynchronous centralisedAgArchAsynchronous) {
+ super(centralisedAgArchAsynchronous);
+ }
+
+ public boolean canSleep() {
+ return ag.getTS().canSleepDeliberate();
+ }
+
+ public void wakeUp() {
+ synchronized (ag.objDeliberate) {
+ if (sleeping) {
+ sleeping = false;
+ enqueueExecutor(false);
+ }
+ }
+ }
+
+ public void enqueueExecutor(boolean ts) {
if (!inQueue || ts) {
- inQueue = true;
- ag.getExecutorDeliberate().execute(this);
+ inQueue = true;
+ ag.getExecutorDeliberate().execute(this);
} else {
- System.out.println("It's already in the queue! DELIBERATE");
+ System.out.println("It's already in the queue! DELIBERATE");
}
- }
-
- public void run() {
- int cycles = ag.getCyclesDeliberate();
- //int number_cycles = 1;
- int i = 0;
-
- while (ag.isRunning() && i < cycles) {
- i++;
-
- ag.getTS().deliberate();
-
- synchronized (ag.objDeliberate) {
-
- if (canSleep()) {
- inQueue = false;
- sleep();
- return;
- } else if (i == cycles) {
- enqueueExecutor(true);
- return;
- }
- }
+ }
+
+ public void run() {
+ int cycles = ag.getCyclesDeliberate();
+ //int number_cycles = 1;
+ int i = 0;
+
+ while (ag.isRunning() && i < cycles) {
+ i++;
+
+ ag.getTS().deliberate();
+
+ synchronized (ag.objDeliberate) {
+
+ if (canSleep()) {
+ inQueue = false;
+ sleep();
+ return;
+ } else if (i == cycles) {
+ enqueueExecutor(true);
+ return;
+ }
+ }
}
- }
+ }
}
Modified: trunk/src/jason/infra/components/SenseComponent.java
===================================================================
--- trunk/src/jason/infra/components/SenseComponent.java 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/src/jason/infra/components/SenseComponent.java 2016-05-17 11:06:45 UTC (rev 1915)
@@ -3,60 +3,60 @@
import jason.infra.centralised.CentralisedAgArchAsynchronous;
public class SenseComponent extends AgentComponent {
-
- public SenseComponent(CentralisedAgArchAsynchronous centralisedAgArchAsynchronous) {
- super(centralisedAgArchAsynchronous);
- }
-
- public boolean canSleep() {
- return ag.getTS().canSleepSense();
- }
-
- public void wakeUp() {
- synchronized (ag.objSense) {
- if (sleeping) {
- sleeping = false;
- enqueueExecutor(false);
- }
- }
- }
-
- /*
- public void wakeUp(boolean ts) {
- synchronized (ag.objSense) {
- if (ts || sleeping) {
- sleeping = false;
- enqueueExecutor(ts);
- }
- }
- }*/
-
- public void enqueueExecutor(boolean ts) {
+
+ public SenseComponent(CentralisedAgArchAsynchronous centralisedAgArchAsynchronous) {
+ super(centralisedAgArchAsynchronous);
+ }
+
+ public boolean canSleep() {
+ return ag.getTS().canSleepSense();
+ }
+
+ public void wakeUp() {
+ synchronized (ag.objSense) {
+ if (sleeping) {
+ sleeping = false;
+ enqueueExecutor(false);
+ }
+ }
+ }
+
+ /*
+ public void wakeUp(boolean ts) {
+ synchronized (ag.objSense) {
+ if (ts || sleeping) {
+ sleeping = false;
+ enqueueExecutor(ts);
+ }
+ }
+ }*/
+
+ public void enqueueExecutor(boolean ts) {
if (!inQueue || ts) {
- inQueue = true;
- ag.getExecutorSense().execute(this);
+ inQueue = true;
+ ag.getExecutorSense().execute(this);
}
- }
-
- public void run() {
- int cycles = ag.getCyclesSense();
- //int number_cycles = 1;
- int i = 0;
-
- while (ag.isRunning() && i < cycles) {
- i++;
- ag.getTS().sense();
-
- synchronized (ag.objSense) {
- if (canSleep()) {
- inQueue = false;
- sleep();
- return;
- } else if (i == cycles) {
- enqueueExecutor(true);
- return;
- }
- }
+ }
+
+ public void run() {
+ int cycles = ag.getCyclesSense();
+ //int number_cycles = 1;
+ int i = 0;
+
+ while (ag.isRunning() && i < cycles) {
+ i++;
+ ag.getTS().sense();
+
+ synchronized (ag.objSense) {
+ if (canSleep()) {
+ inQueue = false;
+ sleep();
+ return;
+ } else if (i == cycles) {
+ enqueueExecutor(true);
+ return;
+ }
+ }
}
- }
+ }
}
Modified: trunk/src/jason/util/Config.java
===================================================================
--- trunk/src/jason/util/Config.java 2016-05-13 13:26:28 UTC (rev 1914)
+++ trunk/src/jason/util/Config.java 2016-05-17 11:06:45 UTC (rev 1915)
@@ -176,7 +176,7 @@
try {
return new File(getJasonJar()).getParentFile().getParent();
} catch (Exception e) {
- e.printStackTrace();
+ //e.printStackTrace();
}
return "";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|