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...> - 2014-10-17 15:44:15
|
Revision: 1815 http://sourceforge.net/p/jason/svn/1815 Author: jomifred Date: 2014-10-17 15:44:12 +0000 (Fri, 17 Oct 2014) Log Message: ----------- improve compareTo methods to profit the performance of Java 8 hash maps Modified Paths: -------------- trunk/src/jason/asSemantics/Intention.java trunk/src/jason/asSyntax/PredicateIndicator.java trunk/src/jason/bb/DefaultBeliefBase.java trunk/src/test/TermTest.java Modified: trunk/src/jason/asSemantics/Intention.java =================================================================== --- trunk/src/jason/asSemantics/Intention.java 2014-10-07 18:23:22 UTC (rev 1814) +++ trunk/src/jason/asSemantics/Intention.java 2014-10-17 15:44:12 UTC (rev 1815) @@ -167,6 +167,9 @@ public int compareTo(Intention o) { if (o.atomicCount > this.atomicCount) return 1; if (this.atomicCount > o.atomicCount) return -1; + + if (o.id > this.id) return 1; + if (this.id > o.id) return -1; return 0; } @@ -178,7 +181,7 @@ } public int hashCode() { - return String.valueOf(id).hashCode(); + return new Integer(id).hashCode(); } public Intention clone() { Modified: trunk/src/jason/asSyntax/PredicateIndicator.java =================================================================== --- trunk/src/jason/asSyntax/PredicateIndicator.java 2014-10-07 18:23:22 UTC (rev 1814) +++ trunk/src/jason/asSyntax/PredicateIndicator.java 2014-10-17 15:44:12 UTC (rev 1815) @@ -7,7 +7,7 @@ * * @author jomi */ -public final class PredicateIndicator implements Serializable { +public final class PredicateIndicator implements Comparable<PredicateIndicator>, Serializable { private final String functor; private final int arity; @@ -47,6 +47,15 @@ return hash; } + @Override + public int compareTo(PredicateIndicator pi) { + int c = this.functor.compareTo(pi.functor); + if (c != 0) return c; + if (pi.arity > this.arity) return -1; + if (this.arity > pi.arity) return 1; + return 0; + } + private int calcHash() { final int PRIME = 31; int t = PRIME * arity; Modified: trunk/src/jason/bb/DefaultBeliefBase.java =================================================================== --- trunk/src/jason/bb/DefaultBeliefBase.java 2014-10-07 18:23:22 UTC (rev 1814) +++ trunk/src/jason/bb/DefaultBeliefBase.java 2014-10-17 15:44:12 UTC (rev 1815) @@ -362,12 +362,13 @@ } /** a literal that uses equalsAsTerm for equals */ - final class LiteralWrapper { + final class LiteralWrapper implements Comparable<LiteralWrapper> { final private Literal l; public LiteralWrapper(Literal l) { this.l = l; } public int hashCode() { return l.hashCode(); } public boolean equals(Object o) { return o instanceof LiteralWrapper && l.equalsAsStructure(((LiteralWrapper)o).l); } public String toString() { return l.toString(); } + public int compareTo(LiteralWrapper o) { return l.compareTo(o.l); } } } } Modified: trunk/src/test/TermTest.java =================================================================== --- trunk/src/test/TermTest.java 2014-10-07 18:23:22 UTC (rev 1814) +++ trunk/src/test/TermTest.java 2014-10-17 15:44:12 UTC (rev 1815) @@ -16,6 +16,7 @@ import jason.asSyntax.ObjectTermImpl; import jason.asSyntax.Plan; import jason.asSyntax.Pred; +import jason.asSyntax.PredicateIndicator; import jason.asSyntax.StringTermImpl; import jason.asSyntax.Structure; import jason.asSyntax.Term; @@ -658,6 +659,18 @@ assertTrue(new ListTermImpl().compareTo(new StringTermImpl("string")) > 0); } + public void testComparePI() { + List<PredicateIndicator> l = new ArrayList<PredicateIndicator>(); + l.add(new PredicateIndicator("b", 2)); + l.add(new PredicateIndicator("b", 7)); + l.add(new PredicateIndicator("a", 2)); + l.add(new PredicateIndicator("a", 4)); + l.add(new PredicateIndicator("a", 1)); + l.add(new PredicateIndicator("b", 5)); + Collections.sort(l); + assertEquals("[a/1, a/2, a/4, b/2, b/5, b/7]", l.toString()); + } + public void testUnify4() throws ParseException { Term a1 = ASSyntax.parseTerm("a(1)"); Term a2 = ASSyntax.parseTerm("a(X+1)"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-10-07 18:23:25
|
Revision: 1814 http://sourceforge.net/p/jason/svn/1814 Author: jomifred Date: 2014-10-07 18:23:22 +0000 (Tue, 07 Oct 2014) Log Message: ----------- improve write ant scripts API Modified Paths: -------------- trunk/src/jason/asSemantics/Agent.java trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java trunk/src/jason/jeditplugin/Config.java trunk/src/jason/jeditplugin/JasonID.java trunk/src/jason/jeditplugin/MASLauncherInfraTier.java trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc trunk/src/jason/mas2j/parser/mas2j.java trunk/src/jason/util/ConfigGUI.java Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/asSemantics/Agent.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -102,7 +102,7 @@ private boolean hasCustomSelOp = true; - private static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(20); //null; + private static ScheduledExecutorService scheduler = null; //private QueryCache qCache = null; private QueryCacheSimple qCache = null; @@ -344,9 +344,16 @@ return logger; } - public ScheduledExecutorService getScheduler() { - //if (scheduler == null) - // scheduler = Executors.newScheduledThreadPool(2); + public static synchronized ScheduledExecutorService getScheduler() { + if (scheduler == null) { + int n; + try { + n = new Integer( Config.get().get(Config.NB_TH_SCH).toString() ); + } catch (Exception e) { + n = 2; + } + scheduler = Executors.newScheduledThreadPool(n); + } return scheduler; } Modified: trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java =================================================================== --- trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -26,6 +26,8 @@ protected boolean stop = false; protected Process masProcess = null; protected OutputStream processOut; + + protected boolean useBuildFileName = true; public static String bindir = "bin"+File.separator; @@ -118,8 +120,8 @@ /** returns the operating system command that runs the MAS */ public String[] getStartCommandArray() { - String build = bindir+"build.xml"; - if (hasCBuild()) build = bindir+"c-build.xml"; + String build = bindir+getBuildFileName();; + if (hasCBuild()) build = bindir+getCustomBuildFileName(); return new String[] { Config.get().getJavaHome() + "bin" + File.separator + "java", "-classpath", @@ -127,8 +129,25 @@ "-e", "-f", build, task}; } + public String getBuildFileName() { + if (useBuildFileName) { + return "build.xml"; + } else { + return project.getSocName()+".xml"; + } + } + public String getCustomBuildFileName() { + if (useBuildFileName) { + return "c-build.xml"; + } else { + return "c-"+project.getSocName()+".xml"; + } + } + /** write the scripts necessary to run the project */ - public boolean writeScripts(boolean debug) { + public boolean writeScripts(boolean debug, boolean useBuildFileName) { + this.useBuildFileName = useBuildFileName; + //if (hasCBuild()) { // System.out.println("The build.xml file is not being created, the user c-build.xml file is used instead."); // return true; // if the user has a c-build.xml file, use his build @@ -147,7 +166,7 @@ } // write the script - FileWriter out = new FileWriter(project.getDirectory() + File.separator + bindir + "build.xml"); + FileWriter out = new FileWriter(project.getDirectory() + File.separator + bindir + getBuildFileName()); out.write(script); out.close(); return true; @@ -239,7 +258,7 @@ } protected boolean hasCBuild() { - return new File(project.getDirectory() + File.separator + bindir + "c-build.xml").exists(); + return new File(project.getDirectory() + File.separator + bindir + getCustomBuildFileName()).exists(); } } Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/jeditplugin/Config.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -86,6 +86,8 @@ public static final String SHORT_UNNAMED_VARS = "shortUnnamedVars"; public static final String START_WEB_MI = "startWebMindInspector"; + public static final String NB_TH_SCH = "numberOfThreadsForScheduler"; + private static Config singleton = null; public static Config get() { @@ -321,6 +323,10 @@ if (getProperty(START_WEB_MI) == null) { put(START_WEB_MI, "true"); } + + if (getProperty(NB_TH_SCH) == null) { + put(NB_TH_SCH, "2"); + } // Default infrastructures put("infrastructure.Centralised", CentralisedFactory.class.getName()); Modified: trunk/src/jason/jeditplugin/JasonID.java =================================================================== --- trunk/src/jason/jeditplugin/JasonID.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/jeditplugin/JasonID.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -525,7 +525,7 @@ masLauncher = project.getInfrastructureFactory().createMASLauncher(); masLauncher.setProject(project); masLauncher.setListener(JasonID.this); - if (masLauncher.writeScripts(debug)) { + if (masLauncher.writeScripts(debug, true)) { new Thread(masLauncher, "MAS-Launcher").start(); } } catch (Exception ex) { @@ -665,7 +665,7 @@ return; CentralisedMASLauncherAnt script = new CentralisedMASLauncherAnt(task); script.setProject(project); - if (script.writeScripts(false)) { + if (script.writeScripts(false, true)) { new Thread(script, "Ant-Task").start(); } Modified: trunk/src/jason/jeditplugin/MASLauncherInfraTier.java =================================================================== --- trunk/src/jason/jeditplugin/MASLauncherInfraTier.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/jeditplugin/MASLauncherInfraTier.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -33,7 +33,7 @@ * Writes the script(s), normally Ant scripts, used to launch the * MAS. */ - public boolean writeScripts(boolean debug); + public boolean writeScripts(boolean debug, boolean useBuildFileName); /** * Stops the MAS execution. Modified: trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc =================================================================== --- trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc 2014-10-07 18:23:22 UTC (rev 1814) @@ -80,7 +80,7 @@ System.out.println("mas2j: "+name+" parsed successfully!\n"); MASLauncherInfraTier launcher = project.getInfrastructureFactory().createMASLauncher(); launcher.setProject(project); - launcher.writeScripts(debugmas); + launcher.writeScripts(debugmas, true); if (runmas) { new Thread(launcher, "MAS-Launcher").start(); Modified: trunk/src/jason/mas2j/parser/mas2j.java =================================================================== --- trunk/src/jason/mas2j/parser/mas2j.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/mas2j/parser/mas2j.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -50,7 +50,7 @@ System.out.println("mas2j: "+name+" parsed successfully!\n"); MASLauncherInfraTier launcher = project.getInfrastructureFactory().createMASLauncher(); launcher.setProject(project); - launcher.writeScripts(debugmas); + launcher.writeScripts(debugmas, true); if (runmas) { new Thread(launcher, "MAS-Launcher").start(); Modified: trunk/src/jason/util/ConfigGUI.java =================================================================== --- trunk/src/jason/util/ConfigGUI.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/util/ConfigGUI.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -107,6 +107,13 @@ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel pBt = new JPanel(new FlowLayout()); + JButton bQuit = new JButton("Exit without saving"); + bQuit.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + System.exit(0); + } + }); + pBt.add(bQuit); JButton bSave = new JButton("Save configuration and Exit"); bSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { @@ -115,14 +122,7 @@ } }); pBt.add(bSave); - JButton bQuit = new JButton("Exit without saving"); - bQuit.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent arg0) { - System.exit(0); - } - }); - pBt.add(bQuit); - + JPanel p = new JPanel(new BorderLayout()); p.add(BorderLayout.CENTER, jid.getJasonConfigPanel()); p.add(BorderLayout.SOUTH, pBt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-30 18:25:15
|
Revision: 1813 http://sourceforge.net/p/jason/svn/1813 Author: jomifred Date: 2014-09-30 18:25:07 +0000 (Tue, 30 Sep 2014) Log Message: ----------- change visibility of methods in jade infra Modified Paths: -------------- trunk/src/jason/infra/jade/RunJadeMAS.java Modified: trunk/src/jason/infra/jade/RunJadeMAS.java =================================================================== --- trunk/src/jason/infra/jade/RunJadeMAS.java 2014-09-30 18:03:36 UTC (rev 1812) +++ trunk/src/jason/infra/jade/RunJadeMAS.java 2014-09-30 18:25:07 UTC (rev 1813) @@ -115,7 +115,7 @@ } @Override - protected void createButtons() { + public void createButtons() { createStopButton(); createPauseButton(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-30 18:03:43
|
Revision: 1812 http://sourceforge.net/p/jason/svn/1812 Author: jomifred Date: 2014-09-30 18:03:36 +0000 (Tue, 30 Sep 2014) Log Message: ----------- change visibility of some methods in jade infra Modified Paths: -------------- trunk/src/jason/infra/centralised/RunCentralisedMAS.java trunk/src/jason/infra/jade/RunJadeMAS.java Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-09-26 12:05:02 UTC (rev 1811) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-09-30 18:03:36 UTC (rev 1812) @@ -402,6 +402,9 @@ public MAS2JProject getProject() { return project; } + public void setProject(MAS2JProject p) { + project = p; + } public void createEnvironment() throws JasonException { logger.fine("Creating environment " + project.getEnvClass()); Modified: trunk/src/jason/infra/jade/RunJadeMAS.java =================================================================== --- trunk/src/jason/infra/jade/RunJadeMAS.java 2014-09-26 12:05:02 UTC (rev 1811) +++ trunk/src/jason/infra/jade/RunJadeMAS.java 2014-09-30 18:03:36 UTC (rev 1812) @@ -145,7 +145,7 @@ } - protected boolean startContainer() { + public boolean startContainer() { try { // source based on jade.Boot try { @@ -221,7 +221,7 @@ try { // set the aslSrcPath in the include ((Include)DirectiveProcessor.getDirective("include")).setSourcePath(getProject().getSourcePaths()); - + // create the agents for (AgentParameters ap : getProject().getAgents()) { try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-26 12:05:06
|
Revision: 1811 http://sourceforge.net/p/jason/svn/1811 Author: jomifred Date: 2014-09-26 12:05:02 +0000 (Fri, 26 Sep 2014) Log Message: ----------- add trigonometric functions Added Paths: ----------- trunk/src/jason/functions/acos.java trunk/src/jason/functions/asin.java trunk/src/jason/functions/atan.java trunk/src/jason/functions/cos.java trunk/src/jason/functions/sin.java trunk/src/jason/functions/tan.java Added: trunk/src/jason/functions/acos.java =================================================================== --- trunk/src/jason/functions/acos.java (rev 0) +++ trunk/src/jason/functions/acos.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.acos(N)</code></b>: encapsulates java Math.acos(N), + returns the arc cosine of a value; the returned angle is in the range 0.0 through pi. + + @author Jomi +*/ +public class acos extends DefaultArithFunction { + + public String getName() { + return "math.acos"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.acos(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} Added: trunk/src/jason/functions/asin.java =================================================================== --- trunk/src/jason/functions/asin.java (rev 0) +++ trunk/src/jason/functions/asin.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.asin(N)</code></b>: encapsulates java Math.asin(N), + returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2. + + @author Jomi +*/ +public class asin extends DefaultArithFunction { + + public String getName() { + return "math.asin"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.asin(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} Added: trunk/src/jason/functions/atan.java =================================================================== --- trunk/src/jason/functions/atan.java (rev 0) +++ trunk/src/jason/functions/atan.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.atan(N)</code></b>: encapsulates java Math.atan(N), + returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2. + + @author Jomi +*/ +public class atan extends DefaultArithFunction { + + public String getName() { + return "math.atan"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.atan(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} Added: trunk/src/jason/functions/cos.java =================================================================== --- trunk/src/jason/functions/cos.java (rev 0) +++ trunk/src/jason/functions/cos.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.cos(N)</code></b>: encapsulates java Math.cos(N), + returns the trigonometric cosine of an angle. + + @author Jomi +*/ +public class cos extends DefaultArithFunction { + + public String getName() { + return "math.cos"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.cos(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} Added: trunk/src/jason/functions/sin.java =================================================================== --- trunk/src/jason/functions/sin.java (rev 0) +++ trunk/src/jason/functions/sin.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.sin(N)</code></b>: encapsulates java Math.sin(N), + returns the trigonometric sine of an angle. + + @author Jomi +*/ +public class sin extends DefaultArithFunction { + + public String getName() { + return "math.sin"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.sin(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} Added: trunk/src/jason/functions/tan.java =================================================================== --- trunk/src/jason/functions/tan.java (rev 0) +++ trunk/src/jason/functions/tan.java 2014-09-26 12:05:02 UTC (rev 1811) @@ -0,0 +1,35 @@ +package jason.functions; + +import jason.JasonException; +import jason.asSemantics.DefaultArithFunction; +import jason.asSemantics.TransitionSystem; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +/** + <p>Function: <b><code>math.tan(N)</code></b>: encapsulates java Math.tan(N), + returns the trigonometric tangent of an angle. + + @author Jomi +*/ +public class tan extends DefaultArithFunction { + + public String getName() { + return "math.tan"; + } + + @Override + public double evaluate(TransitionSystem ts, Term[] args) throws Exception { + if (args[0].isNumeric()) { + return Math.tan(((NumberTerm)args[0]).solve()); + } else { + throw new JasonException("The argument '"+args[0]+"' is not numeric!"); + } + } + + @Override + public boolean checkArity(int a) { + return a == 1; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-24 17:12:57
|
Revision: 1810 http://sourceforge.net/p/jason/svn/1810 Author: jomifred Date: 2014-09-24 17:12:50 +0000 (Wed, 24 Sep 2014) Log Message: ----------- fix bug in example cnp Modified Paths: -------------- trunk/examples/contract-net-protocol/c.asl Modified: trunk/examples/contract-net-protocol/c.asl =================================================================== --- trunk/examples/contract-net-protocol/c.asl 2014-09-24 12:59:32 UTC (rev 1809) +++ trunk/examples/contract-net-protocol/c.asl 2014-09-24 17:12:50 UTC (rev 1810) @@ -9,12 +9,13 @@ /* Initial goals */ !startCNP(1,fix(computer)). +//!startCNP(2,banana). /* Plans */ // start the CNP +!startCNP(Id,Task) - <- .print("Waiting participants..."); + <- .print(" Waiting participants for task ",Task,"..."); .wait(2000); // wait participants introduction +cnp_state(Id,propose); // remember the state of the CNP .findall(Name,introduction(participant,Name),LP); @@ -41,7 +42,8 @@ @lc1[atomic] +!contract(CNPId) : cnp_state(CNPId,propose) - <- -+cnp_state(CNPId,contract); + <- -cnp_state(CNPId,_); + +cnp_state(CNPId,contract); .findall(offer(O,A),propose(CNPId,O)[source(A)],L); .print("Offers are ",L); L \== []; // constraint the plan execution to at least one offer This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-24 12:59:36
|
Revision: 1809 http://sourceforge.net/p/jason/svn/1809 Author: jomifred Date: 2014-09-24 12:59:32 +0000 (Wed, 24 Sep 2014) Log Message: ----------- improve include to include from a jar file Modified Paths: -------------- trunk/examples/auction/auction.mas2j trunk/examples/contract-net-protocol/p.asl trunk/src/jason/asSyntax/directives/Include.java Modified: trunk/examples/auction/auction.mas2j =================================================================== --- trunk/examples/auction/auction.mas2j 2014-09-23 17:37:34 UTC (rev 1808) +++ trunk/examples/auction/auction.mas2j 2014-09-24 12:59:32 UTC (rev 1809) @@ -1,4 +1,4 @@ -// creates an MAS called auction +// simple implementation of first-price sealed-bid auction MAS auction { Modified: trunk/examples/contract-net-protocol/p.asl =================================================================== --- trunk/examples/contract-net-protocol/p.asl 2014-09-23 17:37:34 UTC (rev 1808) +++ trunk/examples/contract-net-protocol/p.asl 2014-09-24 12:59:32 UTC (rev 1809) @@ -19,8 +19,7 @@ @r1 +accept_proposal(CNPId) : proposal(CNPId,Task,Offer) - <- .print("My proposal '",Offer,"' won CNP ",CNPId, - " for ",Task,"!"). + <- .print("My proposal '",Offer,"' won CNP ",CNPId, " for ",Task,"!"). // do the task and report to initiator @r2 +reject_proposal(CNPId) Modified: trunk/src/jason/asSyntax/directives/Include.java =================================================================== --- trunk/src/jason/asSyntax/directives/Include.java 2014-09-23 17:37:34 UTC (rev 1808) +++ trunk/src/jason/asSyntax/directives/Include.java 2014-09-24 12:59:32 UTC (rev 1809) @@ -4,6 +4,7 @@ import jason.asSyntax.Pred; import jason.asSyntax.StringTerm; import jason.asSyntax.parser.as2j; +import jason.jeditplugin.Config; import java.io.File; import java.io.FileInputStream; @@ -29,40 +30,48 @@ return null; String file = ((StringTerm)directive.getTerm(0)).getString().replaceAll("\\\\", "/"); try { - String outerPrefix = outerContent.getASLSrc(); // the source file that has the include directive - InputStream in; - if (outerContent != null && outerPrefix != null) { - // check if the outer is URL - if (outerPrefix.startsWith("jar")) { - outerPrefix = outerPrefix.substring(0,outerPrefix.indexOf("!")+1) + "/"; - file = checkPathAndFixWithSourcePath(file, aslSourcePath, outerPrefix); - in = new URL(file).openStream(); - - } if (outerPrefix.startsWith(CRPrefix)) { - // outer is loaded from a resource ("application".jar) file, used for java web start - int posSlash = outerPrefix.lastIndexOf("/"); - - List<String> newpath = new ArrayList<String>(); - if (outerPrefix.indexOf("/") != posSlash) { // has only one slash - newpath.add(outerPrefix.substring(CRPrefix.length()+1,posSlash)); + InputStream in = null; + // test include from jar + if (file.startsWith("$")) { // the case of "$jasonJar/src/a.asl" + String jar = file.substring(1,file.indexOf("/")); + String path = Config.get().get(jar).toString(); + file = "jar:file:" + path + "!" + file.substring(file.indexOf("/")); + in = new URL(file).openStream(); + } else { + String outerPrefix = outerContent.getASLSrc(); // the source file that has the include directive + if (outerContent != null && outerPrefix != null) { + // check if the outer is URL + if (outerPrefix.startsWith("jar")) { + outerPrefix = outerPrefix.substring(0,outerPrefix.indexOf("!")+1) + "/"; + file = checkPathAndFixWithSourcePath(file, aslSourcePath, outerPrefix); + in = new URL(file).openStream(); + + } if (outerPrefix.startsWith(CRPrefix)) { + // outer is loaded from a resource ("application".jar) file, used for java web start + int posSlash = outerPrefix.lastIndexOf("/"); + + List<String> newpath = new ArrayList<String>(); + if (outerPrefix.indexOf("/") != posSlash) { // has only one slash + newpath.add(outerPrefix.substring(CRPrefix.length()+1,posSlash)); + } + newpath.addAll(aslSourcePath); + + file = checkPathAndFixWithSourcePath(file, newpath, CRPrefix+"/"); + in = Agent.class.getResource(file.substring(CRPrefix.length())).openStream(); + } else { + // get the directory of the source of the outer agent and + // try to find the included source in the same directory + // or in the source paths + List<String> newpath = new ArrayList<String>(); + newpath.add(new File(outerPrefix).getAbsoluteFile().getParent()); + if (aslSourcePath != null) + newpath.addAll(aslSourcePath); + file = checkPathAndFixWithSourcePath(file, newpath, null); + in = new FileInputStream(file); } - newpath.addAll(aslSourcePath); - - file = checkPathAndFixWithSourcePath(file, newpath, CRPrefix+"/"); - in = Agent.class.getResource(file.substring(CRPrefix.length())).openStream(); } else { - // get the directory of the source of the outer agent and - // try to find the included source in the same directory - // or in the source paths - List<String> newpath = new ArrayList<String>(); - newpath.add(new File(outerPrefix).getAbsoluteFile().getParent()); - if (aslSourcePath != null) - newpath.addAll(aslSourcePath); - file = checkPathAndFixWithSourcePath(file, newpath, null); - in = new FileInputStream(file); + in = new FileInputStream(checkPathAndFixWithSourcePath(file, aslSourcePath, null)); } - } else { - in = new FileInputStream(checkPathAndFixWithSourcePath(file, aslSourcePath, null)); } Agent ag = new Agent(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-23 17:37:41
|
Revision: 1808 http://sourceforge.net/p/jason/svn/1808 Author: jomifred Date: 2014-09-23 17:37:34 +0000 (Tue, 23 Sep 2014) Log Message: ----------- udpate FAQ and exercise answers (considering !! and TRO) Modified Paths: -------------- trunk/doc/faq/faq.tex trunk/doc/mini-tutorial/labs.css trunk/doc/mini-tutorial/src/getting-started/exercise-answers.txt trunk/doc/mini-tutorial/src/getting-started/getting-started.tex trunk/lib/moise.jar Modified: trunk/doc/faq/faq.tex =================================================================== --- trunk/doc/faq/faq.tex 2014-09-22 17:56:19 UTC (rev 1807) +++ trunk/doc/faq/faq.tex 2014-09-23 17:37:34 UTC (rev 1808) @@ -1007,9 +1007,18 @@ \end{verbatim} In this case, the !! is used to avoid Jason creating long stacks of (empty) plans, so the operator just allows Jason to process the -recursion more efficiently. +recursion more efficiently. +Jason 1.4.0 implements \textbf{tail recursion optimisation} and thus +we don't need to worry about the stack size anymore. The above code +should be written as: +\begin{verbatim} ++!g : end_recursion_context. ++!g : true <- action1; !g. +\end{verbatim} + + \subsection{Why is \jason's plan failure mechanism different from other agent platforms?} Modified: trunk/doc/mini-tutorial/labs.css =================================================================== --- trunk/doc/mini-tutorial/labs.css 2014-09-22 17:56:19 UTC (rev 1807) +++ trunk/doc/mini-tutorial/labs.css 2014-09-23 17:37:34 UTC (rev 1808) @@ -1,6 +1,6 @@ body { background-color: white; - font-family: Arial, Verdana, Tahoma, Helvetica, Sans-Serif; + font-family: Optima, Arial, Verdana, Tahoma, Helvetica, Sans-Serif; text-align:left; /*margin-left: 3em; margin-right: 1em;*/ Modified: trunk/doc/mini-tutorial/src/getting-started/exercise-answers.txt =================================================================== --- trunk/doc/mini-tutorial/src/getting-started/exercise-answers.txt 2014-09-22 17:56:19 UTC (rev 1807) +++ trunk/doc/mini-tutorial/src/getting-started/exercise-answers.txt 2014-09-23 17:37:34 UTC (rev 1808) @@ -110,9 +110,9 @@ ---------------------------------------- !clean. // initial goal -+!clean : clean <- !move; !!clean. -+!clean : dirty <- suck; !move; !!clean. --!clean <- !!clean. ++!clean : clean <- !move; !clean. ++!clean : dirty <- suck; !move; !clean. +-!clean <- !clean. +!move : pos(1) <- right. +!move : pos(2) <- down. @@ -136,8 +136,6 @@ circumstances (note the empty plan context); this is what causes the "blind commitment" behaviour mentioned above - this agent is thus more 'robust' against action failures -- '!!' is used in the recursions for efficiency, see - http://jason.sourceforge.net/faq/faq.html#SECTION00075000000000000000 - the use of goals also allows us to easily code plans that handle other goals. For instance, suppose we want to code the robot in a way @@ -149,9 +147,9 @@ !clean. // initial goal to clean !pause. // initial goal to break -+!clean : clean <- !move; !!clean. -+!clean : dirty <- suck; !move; !!clean. --!clean <- !!clean. ++!clean : clean <- !move; !clean. ++!clean : dirty <- suck; !move; !clean. +-!clean <- !clean. +!move : pos(1) <- right. +!move : pos(2) <- down. @@ -165,7 +163,7 @@ .wait(1000); // suspend this intention again for 1 second .print(cleaning); .resume(clean); // resume the clean intention - !!pause. + !pause. ---------------------------------------- Just to see how flexible it is to program with goals, you might want Modified: trunk/doc/mini-tutorial/src/getting-started/getting-started.tex =================================================================== --- trunk/doc/mini-tutorial/src/getting-started/getting-started.tex 2014-09-22 17:56:19 UTC (rev 1807) +++ trunk/doc/mini-tutorial/src/getting-started/getting-started.tex 2014-09-23 17:37:34 UTC (rev 1808) @@ -29,7 +29,7 @@ \section{Installation and Configuration} \begin{enumerate} -\item Java JDK >= 5.0 is required (\url{http://java.sun.com}); +\item Java JDK >= 6.0 is required (\url{http://java.sun.com}); \item Download \Jason from \url{http://jason.sf.net}; \item Create a folder for your \Jason installation and decompress the distribution file in it; Modified: trunk/lib/moise.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...> - 2014-09-22 17:56:28
|
Revision: 1807 http://sourceforge.net/p/jason/svn/1807 Author: jomifred Date: 2014-09-22 17:56:19 +0000 (Mon, 22 Sep 2014) Log Message: ----------- fix bug related to unique IDs for unnamed vars Modified Paths: -------------- trunk/lib/jacamo.jar trunk/src/jason/asSemantics/Intention.java trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/asSemantics/Unifier.java trunk/src/jason/asSyntax/Structure.java trunk/src/jason/asSyntax/UnnamedVar.java trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc trunk/src/jason/asSyntax/parser/as2j.java trunk/src/test/VarTermTest.java Modified: trunk/lib/jacamo.jar =================================================================== (Binary files differ) Modified: trunk/src/jason/asSemantics/Intention.java =================================================================== --- trunk/src/jason/asSemantics/Intention.java 2014-09-19 12:34:07 UTC (rev 1806) +++ trunk/src/jason/asSemantics/Intention.java 2014-09-22 17:56:19 UTC (rev 1807) @@ -198,7 +198,7 @@ for (IntendedMeans im: intendedMeans) { s.append(" " + im + "\n"); if (i++ > 40) { - s.append("..... to more "+ (size()-40) + " intended means!\n"); + s.append("... more "+ (size()-40) + " intended means!\n"); break; } } Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2014-09-19 12:34:07 UTC (rev 1806) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2014-09-22 17:56:19 UTC (rev 1807) @@ -717,7 +717,7 @@ im.unif = iu.next(); updateIntention(); } else { - String msg = "Constraint "+h+" was not satisfied ("+h.getSrcInfo()+")."; + String msg = "Constraint "+h+" was not satisfied ("+h.getSrcInfo()+") un="+u; generateGoalDeletion(conf.C.SI, JasonException.createBasicErrorAnnots(new Atom("constraint_failed"), msg)); logger.fine(msg); } Modified: trunk/src/jason/asSemantics/Unifier.java =================================================================== --- trunk/src/jason/asSemantics/Unifier.java 2014-09-19 12:34:07 UTC (rev 1806) +++ trunk/src/jason/asSemantics/Unifier.java 2014-09-22 17:56:19 UTC (rev 1807) @@ -364,7 +364,7 @@ Term vl = function.get(k).clone(); if (vl instanceof Literal) ((Literal)vl).makeVarsAnnon(); - Structure pair = ASSyntax.createStructure("map", new UnnamedVar("_"+UnnamedVar.getUniqueId()+k), vl); // the var must be changed to avoid cyclic references latter + Structure pair = ASSyntax.createStructure("map", UnnamedVar.create(k.toString()), vl); // the var must be changed to avoid cyclic references latter tail = tail.append(pair); } return lf; Modified: trunk/src/jason/asSyntax/Structure.java =================================================================== --- trunk/src/jason/asSyntax/Structure.java 2014-09-19 12:34:07 UTC (rev 1806) +++ trunk/src/jason/asSyntax/Structure.java 2014-09-22 17:56:19 UTC (rev 1807) @@ -355,7 +355,7 @@ // if the variable hasn't been renamed given the input unifier, then rename it. if (deref.equals(vt)) { // forget the name - UnnamedVar var = useShortUnnamedVars ? new UnnamedVar() : new UnnamedVar("_" + UnnamedVar.getUniqueId() + t); + UnnamedVar var = useShortUnnamedVars ? new UnnamedVar() : UnnamedVar.create(t.toString()); //var.setFromMakeVarAnnon(); // if deref has annotations then we need to replicate these in the new variable Modified: trunk/src/jason/asSyntax/UnnamedVar.java =================================================================== --- trunk/src/jason/asSyntax/UnnamedVar.java 2014-09-19 12:34:07 UTC (rev 1806) +++ trunk/src/jason/asSyntax/UnnamedVar.java 2014-09-22 17:56:19 UTC (rev 1807) @@ -23,6 +23,8 @@ package jason.asSyntax; +import java.util.concurrent.atomic.AtomicInteger; + /** * Represents an unnamed variable '_'. * @@ -32,56 +34,53 @@ private static final long serialVersionUID = 1L; - private static int varCont = 1; - private int myId; - //private boolean fromRename = false; + private static AtomicInteger varCont = new AtomicInteger(0); + public int myId; public UnnamedVar() { - super("_" + (varCont++)); - myId = varCont; + this(varCont.incrementAndGet()); } - public UnnamedVar(String name) { - super( name.length() == 1 ? "_" + (varCont++) : name); - myId = varCont; - } - public UnnamedVar(int id) { super("_" + id); myId = id; } - - public static int getUniqueId() { - return varCont++; + + // do not allow the creation of unnamed var by name since the myId attribute should be defined! + // this constructor is for internal use (see create below) + private UnnamedVar(String name) { + super(name); } - /* - public void setFromMakeVarAnnon() { - fromRename = true; + public static UnnamedVar create(String name) { + if (name.length() == 1) { // the case of "_" + return new UnnamedVar(); + } else { + int id = varCont.incrementAndGet(); + UnnamedVar v = new UnnamedVar("_"+id+name); + v.myId = id; + return v; + } } - - public boolean isFromMakeVarAnnon() { - return fromRename; + + public Term clone() { + UnnamedVar newv = new UnnamedVar(getFunctor()); + newv.myId = this.myId; + if (hasAnnot()) + newv.addAnnots(this.getAnnots().cloneLT()); + return newv; } - */ - public Term clone() { - /*if (hasValue()) { - return getValue().clone(); - } else {*/ - UnnamedVar newv = new UnnamedVar(getFunctor()); - newv.myId = this.myId; - //newv.fromRename = this.fromRename; - if (hasAnnot()) - newv.addAnnots(this.getAnnots().cloneLT()); - return newv; - //} + @Override + public boolean equals(Object t) { + if (t == null) return false; + if (t == this) return true; + if (t instanceof UnnamedVar) return ((UnnamedVar)t).myId == this.myId; + return false; } public int compareTo(Term t) { - /*if (hasValue()) { - return super.compareTo(t); - } else */if (t instanceof UnnamedVar) { + if (t instanceof UnnamedVar) { if (myId > ((UnnamedVar)t).myId) return 1; else if (myId < ((UnnamedVar)t).myId) @@ -97,6 +96,6 @@ @Override public boolean isUnnamedVar() { - return true; //!hasValue(); + return true; } } Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc =================================================================== --- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2014-09-19 12:34:07 UTC (rev 1806) +++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2014-09-22 17:56:19 UTC (rev 1807) @@ -629,7 +629,7 @@ ( "," f=term_in_list() { last = last.append(f); } )* [ "|" ( K=<VAR> { last.setNext(new VarTerm(K.image)); } - | K=<UNNAMEDVAR> { last.setNext(new UnnamedVar(K.image)); } + | K=<UNNAMEDVAR> { last.setNext(UnnamedVar.create(K.image)); } | f=list() { last = last.concat((ListTerm)f); } ) ] @@ -818,7 +818,7 @@ VarTerm var(): { Token K; VarTerm v; ListTerm lt; } { ( K = <VAR> { v = new VarTerm(K.image); v.setSrcInfo(new SourceInfo(asSource, K.beginLine));} - | K = <UNNAMEDVAR> { v = new UnnamedVar(K.image); } + | K = <UNNAMEDVAR> { v = UnnamedVar.create(K.image); } ) [ lt = list() { v.setAnnots(lt); } Modified: trunk/src/jason/asSyntax/parser/as2j.java =================================================================== --- trunk/src/jason/asSyntax/parser/as2j.java 2014-09-19 12:34:07 UTC (rev 1806) +++ trunk/src/jason/asSyntax/parser/as2j.java 2014-09-22 17:56:19 UTC (rev 1807) @@ -1034,7 +1034,7 @@ break; case UNNAMEDVAR: K = jj_consume_token(UNNAMEDVAR); - last.setNext(new UnnamedVar(K.image)); + last.setNext(UnnamedVar.create(K.image)); break; case 48: f = list(); @@ -1482,7 +1482,7 @@ break; case UNNAMEDVAR: K = jj_consume_token(UNNAMEDVAR); - v = new UnnamedVar(K.image); + v = UnnamedVar.create(K.image); break; default: jj_la1[58] = jj_gen; Modified: trunk/src/test/VarTermTest.java =================================================================== --- trunk/src/test/VarTermTest.java 2014-09-19 12:34:07 UTC (rev 1806) +++ trunk/src/test/VarTermTest.java 2014-09-22 17:56:19 UTC (rev 1807) @@ -500,6 +500,12 @@ Collections.sort(l); //assertEquals("[B, F, _11, _6, _5]", l.toString()); // this order is VERY important for unification! assertEquals("[B, F, _5, _6, _11]", l.toString()); // this order is VERY important for unification! + + VarTerm v1 = new UnnamedVar(); + VarTerm v2 = new UnnamedVar(); + assertTrue(v1.clone().compareTo(v2.clone()) < 0); + assertTrue(v1.clone().compareTo(v1.clone()) == 0); + assertTrue(v2.clone().compareTo(v1.clone()) > 0); } public void testCopy() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-19 12:34:10
|
Revision: 1806 http://sourceforge.net/p/jason/svn/1806 Author: jomifred Date: 2014-09-19 12:34:07 +0000 (Fri, 19 Sep 2014) Log Message: ----------- improve exception on web mind inspector (as suggested by Kenneth Johnson) Modified Paths: -------------- trunk/src/jason/architecture/MindInspectorWeb.java Modified: trunk/src/jason/architecture/MindInspectorWeb.java =================================================================== --- trunk/src/jason/architecture/MindInspectorWeb.java 2014-09-19 01:51:08 UTC (rev 1805) +++ trunk/src/jason/architecture/MindInspectorWeb.java 2014-09-19 12:34:07 UTC (rev 1806) @@ -76,7 +76,7 @@ } catch (BindException e) { httpServerPort++; return startHttpServer(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-19 01:51:14
|
Revision: 1805 http://sourceforge.net/p/jason/svn/1805 Author: jomifred Date: 2014-09-19 01:51:08 +0000 (Fri, 19 Sep 2014) Log Message: ----------- fix bug related to atomic intention suspended by PA Modified Paths: -------------- trunk/src/jason/asSemantics/Circumstance.java trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/runtime/MASConsoleColorGUI.java trunk/src/jason/runtime/MASConsoleGUI.java Modified: trunk/src/jason/asSemantics/Circumstance.java =================================================================== --- trunk/src/jason/asSemantics/Circumstance.java 2014-09-18 21:20:47 UTC (rev 1804) +++ trunk/src/jason/asSemantics/Circumstance.java 2014-09-19 01:51:08 UTC (rev 1805) @@ -341,7 +341,7 @@ public Intention removeAtomicIntention() { if (AI != null) { - if (atomicIntSuspended) { + if (atomicIntSuspended) { //throw new JasonException("Internal error: trying to remove the atomic intention, but it is suspended! it should be removed only when back to I!"); return null; } @@ -369,7 +369,7 @@ } public boolean hasPendingIntention() { - return PI != null && PI.size() > 0; + return PI != null && !PI.isEmpty(); } public void clearPendingIntentions() { @@ -499,10 +499,11 @@ if (act.getIntention() != null) { synchronized (FA) { FA.add(act); + /*if (act.getIntention().isAtomic()) { + ts.getLogger().info("feedback atomic "+act.getIntention().getId()); + //atomicIntSuspended = false; // TODO: here is the bug (reported by Olivier @ ALTISSIMO) + }*/ } - if (act.getIntention().isAtomic()) { - atomicIntSuspended = false; - } } } @@ -537,7 +538,7 @@ } public boolean hasPendingAction() { - return PA != null && PA.size() > 0; + return PA != null && !PA.isEmpty(); } Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2014-09-18 21:20:47 UTC (rev 1804) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2014-09-19 01:51:08 UTC (rev 1805) @@ -552,10 +552,13 @@ private void applyProcAct() throws JasonException { confP.step = State.SelInt; // default next step if (conf.C.hasFeedbackAction()) { - ActionExec a = conf.ag.selectAction(conf.C.getFeedbackActions()); + ActionExec a = null; + synchronized (conf.C.getFeedbackActions()) { + a = conf.ag.selectAction(conf.C.getFeedbackActions()); + } if (a != null) { confP.C.SI = a.getIntention(); - + // remove the intention from PA (PA has all pending action, including those in FA; // but, if the intention is not in PA, it means that the intention was dropped // and should not return to I) @@ -1315,7 +1318,7 @@ } public boolean canSleep() { - return (C.isAtomicIntentionSuspended() && !conf.C.hasMsg()) + return (C.isAtomicIntentionSuspended() && !C.hasFeedbackAction() && !conf.C.hasMsg()) || (!conf.C.hasEvent() && !conf.C.hasIntention() && !conf.C.hasFeedbackAction() && !conf.C.hasMsg() && Modified: trunk/src/jason/runtime/MASConsoleColorGUI.java =================================================================== --- trunk/src/jason/runtime/MASConsoleColorGUI.java 2014-09-18 21:20:47 UTC (rev 1804) +++ trunk/src/jason/runtime/MASConsoleColorGUI.java 2014-09-19 01:51:08 UTC (rev 1805) @@ -106,10 +106,12 @@ } synchronized (this) { output.append(c, s); - output.setCaretPosition(l); + try { + output.setCaretPosition(l); + } catch (IllegalArgumentException e) {} } } catch (Exception e) { - close(); + //close(); System.out.println(e); e.printStackTrace(); } Modified: trunk/src/jason/runtime/MASConsoleGUI.java =================================================================== --- trunk/src/jason/runtime/MASConsoleGUI.java 2014-09-18 21:20:47 UTC (rev 1804) +++ trunk/src/jason/runtime/MASConsoleGUI.java 2014-09-19 01:51:08 UTC (rev 1805) @@ -210,10 +210,12 @@ } synchronized (this) { output.append(s); - output.setCaretPosition(l); + try { + output.setCaretPosition(l); + } catch (java.lang.IllegalArgumentException e) {} } } catch (Exception e) { - close(); + //close(); System.out.println(e); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-18 21:20:55
|
Revision: 1804 http://sourceforge.net/p/jason/svn/1804 Author: jomifred Date: 2014-09-18 21:20:47 +0000 (Thu, 18 Sep 2014) Log Message: ----------- new constructor for ag parameters Modified Paths: -------------- trunk/build.xml trunk/src/jason/mas2j/AgentParameters.java trunk/src/jason/mas2j/MAS2JProject.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2014-09-18 13:40:54 UTC (rev 1803) +++ trunk/build.xml 2014-09-18 21:20:47 UTC (rev 1804) @@ -346,7 +346,7 @@ <!-- distribution related tasks --> - <target name="dist" depends="cleanExamples,plugin" description="Build distribution."> + <target name="dist" depends="cleanExamples,plugin,repl" description="Build distribution."> <echo message="Generating Jason ${version}.${release}" /> Modified: trunk/src/jason/mas2j/AgentParameters.java =================================================================== --- trunk/src/jason/mas2j/AgentParameters.java 2014-09-18 13:40:54 UTC (rev 1803) +++ trunk/src/jason/mas2j/AgentParameters.java 2014-09-18 21:20:47 UTC (rev 1804) @@ -35,6 +35,11 @@ setupDefault(); } + public AgentParameters(AgentParameters a) { + this(); + a.copyTo(this); + } + public AgentParameters copy() { AgentParameters newap = new AgentParameters(); copyTo(newap); Modified: trunk/src/jason/mas2j/MAS2JProject.java =================================================================== --- trunk/src/jason/mas2j/MAS2JProject.java 2014-09-18 13:40:54 UTC (rev 1803) +++ trunk/src/jason/mas2j/MAS2JProject.java 2014-09-18 21:20:47 UTC (rev 1804) @@ -73,7 +73,7 @@ return null; } } - + public void setupDefault() { if (envClass == null) { envClass = new ClassParameters(jason.environment.Environment.class.getName()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-18 13:40:57
|
Revision: 1803 http://sourceforge.net/p/jason/svn/1803 Author: jomifred Date: 2014-09-18 13:40:54 +0000 (Thu, 18 Sep 2014) Log Message: ----------- use shared scheduler for all agents (see bug reported by Grimaldo) Modified Paths: -------------- trunk/lib/jacamo.jar trunk/src/jason/asSemantics/Agent.java Modified: trunk/lib/jacamo.jar =================================================================== (Binary files differ) Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2014-09-14 17:29:02 UTC (rev 1802) +++ trunk/src/jason/asSemantics/Agent.java 2014-09-18 13:40:54 UTC (rev 1803) @@ -102,7 +102,7 @@ private boolean hasCustomSelOp = true; - private ScheduledExecutorService scheduler = null; + private static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(20); //null; //private QueryCache qCache = null; private QueryCacheSimple qCache = null; @@ -254,8 +254,8 @@ if (qProfiling != null) qProfiling.show(); - if (scheduler != null) - scheduler.shutdownNow(); + //if (scheduler != null) + // scheduler.shutdownNow(); for (InternalAction ia: internalActions.values()) try { @@ -345,8 +345,8 @@ } public ScheduledExecutorService getScheduler() { - if (scheduler == null) - scheduler = Executors.newScheduledThreadPool(2); + //if (scheduler == null) + // scheduler = Executors.newScheduledThreadPool(2); return scheduler; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-14 17:29:05
|
Revision: 1802 http://sourceforge.net/p/jason/svn/1802 Author: jomifred Date: 2014-09-14 17:29:02 +0000 (Sun, 14 Sep 2014) Log Message: ----------- use courier in repl gui :-) Modified Paths: -------------- trunk/build.xml trunk/release-notes.txt trunk/src/jason/infra/centralised/RunCentralisedMAS.java trunk/src/jason/infra/repl/ReplAg.java Added Paths: ----------- trunk/src/jason/infra/repl/ReplAgGUI.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2014-09-13 23:50:27 UTC (rev 1801) +++ trunk/build.xml 2014-09-14 17:29:02 UTC (rev 1802) @@ -174,7 +174,7 @@ <copy file="${jasonJar}" tofile="${replJar}" /> <echo file="default.mas2j"> MAS repl { - agents: repl_agent agentClass jason.infra.repl.ReplAg; + agents: repl_agent agentClass jason.infra.repl.ReplAgGUI; } </echo> <jar update="yes" jarfile="${replJar}" > Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2014-09-13 23:50:27 UTC (rev 1801) +++ trunk/release-notes.txt 2014-09-14 17:29:02 UTC (rev 1802) @@ -1,4 +1,14 @@ --------------------------- +version 1.4.2 + +revision XXX on SVN +--------------------------- + +New features +- REPL button on MASConsole and jason-repl.jar + + +--------------------------- version 1.4.1 revision 1792 on SVN Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-09-13 23:50:27 UTC (rev 1801) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-09-14 17:29:02 UTC (rev 1802) @@ -28,7 +28,7 @@ import jason.asSyntax.directives.DirectiveProcessor; import jason.asSyntax.directives.Include; import jason.control.ExecutionControlGUI; -import jason.infra.repl.ReplAg; +import jason.infra.repl.ReplAgGUI; import jason.jeditplugin.Config; import jason.mas2j.AgentParameters; import jason.mas2j.ClassParameters; @@ -367,7 +367,7 @@ agArch.setAgName(n.getText()); agArch.setEnvInfraTier(env); try { - agArch.createArchs(null, ReplAg.class.getName(), null, null, new Settings(), RunCentralisedMAS.this); + agArch.createArchs(null, ReplAgGUI.class.getName(), null, null, new Settings(), RunCentralisedMAS.this); Thread agThread = new Thread(agArch); agArch.setThread(agThread); agThread.start(); Modified: trunk/src/jason/infra/repl/ReplAg.java =================================================================== --- trunk/src/jason/infra/repl/ReplAg.java 2014-09-13 23:50:27 UTC (rev 1801) +++ trunk/src/jason/infra/repl/ReplAg.java 2014-09-14 17:29:02 UTC (rev 1802) @@ -10,32 +10,12 @@ import jason.asSyntax.Plan; import jason.asSyntax.PlanBody; import jason.asSyntax.Trigger; -import jason.util.asl2html; -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.logging.LogRecord; -import java.util.logging.StreamHandler; - -import javax.swing.JFrame; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.JTextPane; - -import org.w3c.dom.Document; - -public class ReplAg extends Agent { +public abstract class ReplAg extends Agent { - asl2html agTransformer = new asl2html("/xml/agInspection.xsl"); - JTextPane mindPanel = null; - JTextField command = null; - JTextArea output = null; - String[] replCmds = { clear.class.getName(), - verbose.class.getName(), + //verbose.class.getName(), mi.class.getName()}; int cmdCounter = 0; @@ -43,34 +23,8 @@ @Override public void initAg() { super.initAg(); - initGui(); - initLogger(); - if (mindPanel != null) { - new Thread("update mind thread") { - public void run() { - while (getTS().getUserAgArch().isRunning()) { - try { - updateMindView(); - sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }; - }.start(); - } } - void initLogger() { - getTS().getLogger().addHandler( new StreamHandler() { - @Override - public synchronized void publish(LogRecord l) { - output.append(l.getMessage()+"\n"); - output.setCaretPosition( output.getDocument().getLength()); - } - }); - } - @Override public void load(String asSrc) throws JasonException { super.load(null); @@ -81,9 +35,8 @@ }*/ } - void execCmd() { + void execCmd(String sCmd) { try { - String sCmd = command.getText().trim(); if (sCmd.endsWith(".")) sCmd = sCmd.substring(0,sCmd.length()-1); for (String c: replCmds) { @@ -109,73 +62,18 @@ //getTS().getC().addAchvGoal(g, null); getTS().getC().addIntention(i); cmdCounter++; - command.setText(""); + clear(); getTS().getUserAgArch().wake(); } catch (Exception e) { - output.setText("Error parsing "+command.getText()+"\n"+e); + print("Error parsing "+sCmd+"\n"+e); } } - - static int lastPos = 30; - - void initGui() { - command = new JTextField(40); - command.setToolTipText("Type a Jason operation here."); - command.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent arg0) { - execCmd(); - } - }); - //mindPanel = new JTextPane(); - //mindPanel.setEditable(false); - //mindPanel.setContentType("text/html"); - - output = new JTextArea(5,50); - output.setEditable(false); - output.setText("Example of operations you can type:\n +bel; !goal; .add_plan({+!goal <- .print(ok) }); !!goal; \n .send(bob,tell,hello);\n"); - output.append(" ?bel(A); .findall(X,bel(X),L); \n"); - output.append(" .mi // to open mind inspector\n"); - output.append(" .verbose(2) // to show debug messages\n"); - output.append(" .clear // clean console\n"); - output.append("\nYou can add more agents using the button 'new REPL ag' in MAS Console."); - - output.append("\n"); - - - JFrame f = new JFrame(".:: REPL Interface for "+getTS().getUserAgArch().getAgName()+" ::."); - f.getContentPane().setLayout(new BorderLayout()); - f.getContentPane().add(BorderLayout.NORTH,command); - //f.getContentPane().add(BorderLayout.CENTER, new JScrollPane(mindPanel)); - f.getContentPane().add(BorderLayout.CENTER,new JScrollPane(output)); - - f.pack(); - int h = 200; - int w = (int)(h*2*1.618); - f.setBounds((int)(h*0.618), 20, w, h); - f.setLocation(lastPos, 200+lastPos); - lastPos += 50; - f.setVisible(true); + public void print(String s) { + System.out.println(s+"\n"); } public void clear() { - output.setText(""); } - private String lastMind = ""; - - void updateMindView() { - getTS().getUserAgArch().setCycleNumber(cmdCounter); - Document agState = getAgState(); // the XML representation of the agent's mind - try { - String sMind = agTransformer.transform(agState); // transform to HTML - if (!sMind.equals(lastMind)) - mindPanel.setText(sMind); // show the HTML in the screen - lastMind = sMind; - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } } Added: trunk/src/jason/infra/repl/ReplAgGUI.java =================================================================== --- trunk/src/jason/infra/repl/ReplAgGUI.java (rev 0) +++ trunk/src/jason/infra/repl/ReplAgGUI.java 2014-09-14 17:29:02 UTC (rev 1802) @@ -0,0 +1,127 @@ +package jason.infra.repl; + +import java.awt.BorderLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.logging.LogRecord; +import java.util.logging.StreamHandler; + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +public class ReplAgGUI extends ReplAg { + + JTextField command = null; + JTextArea output = null; + + //asl2html agTransformer = new asl2html("/xml/agInspection.xsl"); + //JTextPane mindPanel = null; + + @Override + public void initAg() { + super.initAg(); + initGui(); + initLogger(); + /*if (mindPanel != null) { + new Thread("update mind thread") { + public void run() { + while (getTS().getUserAgArch().isRunning()) { + try { + updateMindView(); + sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }; + }.start(); + }*/ + } + + void initLogger() { + getTS().getLogger().addHandler( new StreamHandler() { + @Override + public synchronized void publish(LogRecord l) { + output.append(l.getMessage()+"\n"); + output.setCaretPosition( output.getDocument().getLength()); + } + }); + } + + + static int lastPos = 30; + + void initGui() { + Font font = new Font("Courier", Font.PLAIN, 14); + command = new JTextField(40); + command.setFont(font); + command.setToolTipText("Type a Jason operation here."); + command.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + execCmd(command.getText().trim()); + } + }); + + //mindPanel = new JTextPane(); + //mindPanel.setEditable(false); + //mindPanel.setContentType("text/html"); + + output = new JTextArea(5,50); + output.setFont(font); + output.setEditable(false); + output.setText("Example of operations you can type:\n +bel; !goal; .add_plan({+!goal <- .print(ok) }); !!goal; \n .send(bob,tell,hello);\n"); + output.append(" ?bel(A); .findall(X,bel(X),L); \n"); + output.append(" .mi // to open mind inspector\n"); + output.append(" .verbose(2) // to show debug messages\n"); + output.append(" .clear // clean console\n"); + output.append("\nYou can add more agents using the button 'new REPL ag' in MAS Console."); + + output.append("\n"); + + + JFrame f = new JFrame(".:: REPL Interface for "+getTS().getUserAgArch().getAgName()+" ::."); + f.getContentPane().setLayout(new BorderLayout()); + f.getContentPane().add(BorderLayout.NORTH,command); + //f.getContentPane().add(BorderLayout.CENTER, new JScrollPane(mindPanel)); + f.getContentPane().add(BorderLayout.CENTER,new JScrollPane(output)); + + f.pack(); + int h = 200; + int w = (int)(h*2*1.618); + f.setBounds((int)(h*0.618), 20, w, h); + f.setLocation(lastPos, 200+lastPos); + lastPos += 50; + f.setVisible(true); + } + + @Override + public void clear() { + output.setText(""); + } + + @Override + public void print(String s) { + output.append(s+"\n"); + } + + /* + private String lastMind = ""; + + void updateMindView() { + getTS().getUserAgArch().setCycleNumber(cmdCounter); + Document agState = getAgState(); // the XML representation of the agent's mind + try { + String sMind = agTransformer.transform(agState); // transform to HTML + if (!sMind.equals(lastMind)) + mindPanel.setText(sMind); // show the HTML in the screen + lastMind = sMind; + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }*/ +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-13 23:50:31
|
Revision: 1801 http://sourceforge.net/p/jason/svn/1801 Author: jomifred Date: 2014-09-13 23:50:27 +0000 (Sat, 13 Sep 2014) Log Message: ----------- initial impl of REPL for Jason Modified Paths: -------------- trunk/build.xml trunk/src/jason/asSemantics/Agent.java trunk/src/jason/infra/centralised/RunCentralisedMAS.java Added Paths: ----------- trunk/src/jason/infra/repl/ trunk/src/jason/infra/repl/ReplAg.java trunk/src/jason/infra/repl/clear.java trunk/src/jason/infra/repl/mi.java trunk/src/jason/infra/repl/print_unifier.java trunk/src/jason/infra/repl/verbose.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2014-09-11 12:20:36 UTC (rev 1800) +++ trunk/build.xml 2014-09-13 23:50:27 UTC (rev 1801) @@ -7,6 +7,7 @@ <property name="jasonJar" value="${basedir}/lib/jason.jar" /> <property name="jadeJar" value="${basedir}/lib/jade.jar" /> <property name="jasonSJar" value="${basedir}/lib/s-jason.jar" /> + <property name="replJar" value="${basedir}/lib/jason-repl.jar" /> <property name="build.dir" value="${basedir}/bin/classes" /> @@ -167,6 +168,25 @@ </jar> <!-- copy file="${jasonJar}" todir="applications/jason-eclipse-plugin/lib" /--> </target> + + <target name="repl" depends="jar" > + <delete file="${replJar}" /> + <copy file="${jasonJar}" tofile="${replJar}" /> + <echo file="default.mas2j"> + MAS repl { + agents: repl_agent agentClass jason.infra.repl.ReplAg; + } + </echo> + <jar update="yes" jarfile="${replJar}" > + <fileset dir="${basedir}"> + <include name="default.mas2j" /> + </fileset> + <manifest> + <attribute name="Main-Class" value="jason.infra.centralised.RunCentralisedMAS"/> + </manifest> + </jar> + <!--delete file="default.mas2j" /--> + </target> <target name="signjar" depends="jar"> <copy file="${jasonJar}" tofile="${jasonSJar}" /> Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2014-09-11 12:20:36 UTC (rev 1800) +++ trunk/src/jason/asSemantics/Agent.java 2014-09-13 23:50:27 UTC (rev 1801) @@ -127,15 +127,21 @@ new TransitionSystem(ag, null, stts, arch); - BeliefBase bb = (BeliefBase) Class.forName(bbPars.getClassName()).newInstance(); + BeliefBase bb = null; + if (bbPars == null) + bb = new DefaultBeliefBase(); + else + bb = (BeliefBase) Class.forName(bbPars.getClassName()).newInstance(); + ag.setBB(bb); // the agent's BB have to be already set for the BB initialisation ag.initAg(); - bb.init(ag, bbPars.getParametersArray()); + if (bbPars != null) + bb.init(ag, bbPars.getParametersArray()); ag.load(asSrc); // load the source code of the agent return ag; } catch (Exception e) { - throw new JasonException("as2j: error creating the customised Agent class! - ", e); + throw new JasonException("as2j: error creating the customised Agent class! - "+agClass, e); } } Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-09-11 12:20:36 UTC (rev 1800) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-09-13 23:50:27 UTC (rev 1801) @@ -28,6 +28,7 @@ import jason.asSyntax.directives.DirectiveProcessor; import jason.asSyntax.directives.Include; import jason.control.ExecutionControlGUI; +import jason.infra.repl.ReplAg; import jason.jeditplugin.Config; import jason.mas2j.AgentParameters; import jason.mas2j.ClassParameters; @@ -38,6 +39,7 @@ import jason.runtime.MASConsoleLogHandler; import jason.runtime.Settings; +import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; @@ -67,6 +69,7 @@ import javax.swing.JScrollPane; import javax.swing.JTabbedPane; import javax.swing.JTextArea; +import javax.swing.JTextField; /** * Runs MASProject using centralised infrastructure. @@ -311,7 +314,9 @@ new KillAgentGUI(MASConsoleGUI.get().getFrame(), "Kill an agent of the current MAS"); } }); - MASConsoleGUI.get().addButton(btKillAg); + MASConsoleGUI.get().addButton(btKillAg); + + createNewReplAgButton(); } protected void createPauseButton() { @@ -343,6 +348,45 @@ MASConsoleGUI.get().addButton(btStop); } + protected void createNewReplAgButton() { + // add Button debug + final JButton btStartAg = new JButton("New REPL agent", new ImageIcon(RunCentralisedMAS.class.getResource("/images/newAgent.gif"))); + btStartAg.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + final JFrame f = new JFrame("New REPL Agent, give it a name"); + //f.getContentPane().setLayout(new BorderLayout()); + //f.getContentPane().add(BorderLayout.NORTH,command); + //f.getContentPane().add(BorderLayout.CENTER,mindPanel); + final JTextField n = new JTextField(30); + n.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + f.setVisible(false); + + CentralisedAgArch agArch = new CentralisedAgArch(); + agArch.setAgName(n.getText()); + agArch.setEnvInfraTier(env); + try { + agArch.createArchs(null, ReplAg.class.getName(), null, null, new Settings(), RunCentralisedMAS.this); + Thread agThread = new Thread(agArch); + agArch.setThread(agThread); + agThread.start(); + } catch (JasonException e1) { + e1.printStackTrace(); + } + addAg(agArch); + } + }); + f.setLayout(new FlowLayout()); + f.add(n); + f.pack(); + f.setLocation((int)btStartAg.getLocationOnScreen().x, (int)btStartAg.getLocationOnScreen().y+30); + f.setVisible(true); + } + }); + MASConsoleGUI.get().addButton(btStartAg); + } + public static RunCentralisedMAS getRunner() { return runner; } Added: trunk/src/jason/infra/repl/ReplAg.java =================================================================== --- trunk/src/jason/infra/repl/ReplAg.java (rev 0) +++ trunk/src/jason/infra/repl/ReplAg.java 2014-09-13 23:50:27 UTC (rev 1801) @@ -0,0 +1,181 @@ +package jason.infra.repl; + +import jason.JasonException; +import jason.asSemantics.Agent; +import jason.asSemantics.IntendedMeans; +import jason.asSemantics.Intention; +import jason.asSemantics.Option; +import jason.asSemantics.Unifier; +import jason.asSyntax.ASSyntax; +import jason.asSyntax.Plan; +import jason.asSyntax.PlanBody; +import jason.asSyntax.Trigger; +import jason.util.asl2html; + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.logging.LogRecord; +import java.util.logging.StreamHandler; + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; + +import org.w3c.dom.Document; + +public class ReplAg extends Agent { + + asl2html agTransformer = new asl2html("/xml/agInspection.xsl"); + JTextPane mindPanel = null; + JTextField command = null; + JTextArea output = null; + + String[] replCmds = { + clear.class.getName(), + verbose.class.getName(), + mi.class.getName()}; + + int cmdCounter = 0; + + @Override + public void initAg() { + super.initAg(); + initGui(); + initLogger(); + if (mindPanel != null) { + new Thread("update mind thread") { + public void run() { + while (getTS().getUserAgArch().isRunning()) { + try { + updateMindView(); + sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }; + }.start(); + } + } + + void initLogger() { + getTS().getLogger().addHandler( new StreamHandler() { + @Override + public synchronized void publish(LogRecord l) { + output.append(l.getMessage()+"\n"); + output.setCaretPosition( output.getDocument().getLength()); + } + }); + } + + @Override + public void load(String asSrc) throws JasonException { + super.load(null); + /*try { + getPL().add(ASSyntax.parsePlan("+!run_repl_expr(Cmd__TR) <- Cmd__TR; jason.infra.repl.print_unifier.")); + } catch (ParseException e) { + e.printStackTrace(); + }*/ + } + + void execCmd() { + try { + String sCmd = command.getText().trim(); + if (sCmd.endsWith(".")) + sCmd = sCmd.substring(0,sCmd.length()-1); + for (String c: replCmds) { + if (c.endsWith(sCmd) && sCmd.startsWith(".")) { + sCmd = c; + break; + } + } + if (sCmd.startsWith(".verbose")) { + sCmd = verbose.class.getPackage().getName() + sCmd; + } + sCmd += ";"+print_unifier.class.getName(); + PlanBody lCmd = ASSyntax.parsePlanBody(sCmd); + Trigger te = ASSyntax.parseTrigger("+!run_repl_expr"); + Intention i = new Intention(); + i.push(new IntendedMeans( + new Option( + new Plan(null,te,null,lCmd), + new Unifier()), + te)); + //Literal g = ASSyntax.createLiteral("run_repl_expr", lCmd); + //getTS().getLogger().info("running "+i); + //getTS().getC().addAchvGoal(g, null); + getTS().getC().addIntention(i); + cmdCounter++; + command.setText(""); + getTS().getUserAgArch().wake(); + } catch (Exception e) { + output.setText("Error parsing "+command.getText()+"\n"+e); + } + } + + static int lastPos = 30; + + void initGui() { + command = new JTextField(40); + command.setToolTipText("Type a Jason operation here."); + command.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + execCmd(); + } + }); + + //mindPanel = new JTextPane(); + //mindPanel.setEditable(false); + //mindPanel.setContentType("text/html"); + + output = new JTextArea(5,50); + output.setEditable(false); + output.setText("Example of operations you can type:\n +bel; !goal; .add_plan({+!goal <- .print(ok) }); !!goal; \n .send(bob,tell,hello);\n"); + output.append(" ?bel(A); .findall(X,bel(X),L); \n"); + output.append(" .mi // to open mind inspector\n"); + output.append(" .verbose(2) // to show debug messages\n"); + output.append(" .clear // clean console\n"); + output.append("\nYou can add more agents using the button 'new REPL ag' in MAS Console."); + + output.append("\n"); + + + JFrame f = new JFrame(".:: REPL Interface for "+getTS().getUserAgArch().getAgName()+" ::."); + f.getContentPane().setLayout(new BorderLayout()); + f.getContentPane().add(BorderLayout.NORTH,command); + //f.getContentPane().add(BorderLayout.CENTER, new JScrollPane(mindPanel)); + f.getContentPane().add(BorderLayout.CENTER,new JScrollPane(output)); + + f.pack(); + int h = 200; + int w = (int)(h*2*1.618); + f.setBounds((int)(h*0.618), 20, w, h); + f.setLocation(lastPos, 200+lastPos); + lastPos += 50; + f.setVisible(true); + } + + public void clear() { + output.setText(""); + } + + private String lastMind = ""; + + void updateMindView() { + getTS().getUserAgArch().setCycleNumber(cmdCounter); + Document agState = getAgState(); // the XML representation of the agent's mind + try { + String sMind = agTransformer.transform(agState); // transform to HTML + if (!sMind.equals(lastMind)) + mindPanel.setText(sMind); // show the HTML in the screen + lastMind = sMind; + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} Added: trunk/src/jason/infra/repl/clear.java =================================================================== --- trunk/src/jason/infra/repl/clear.java (rev 0) +++ trunk/src/jason/infra/repl/clear.java 2014-09-13 23:50:27 UTC (rev 1801) @@ -0,0 +1,16 @@ +package jason.infra.repl; + +import jason.asSemantics.DefaultInternalAction; +import jason.asSemantics.TransitionSystem; +import jason.asSemantics.Unifier; +import jason.asSyntax.Term; + +public class clear extends DefaultInternalAction { + + @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { + ReplAg ag = (ReplAg)ts.getAg(); + ag.clear(); + return true; + } + +} Added: trunk/src/jason/infra/repl/mi.java =================================================================== --- trunk/src/jason/infra/repl/mi.java (rev 0) +++ trunk/src/jason/infra/repl/mi.java 2014-09-13 23:50:27 UTC (rev 1801) @@ -0,0 +1,20 @@ +package jason.infra.repl; + +import jason.architecture.MindInspectorWeb; +import jason.asSemantics.DefaultInternalAction; +import jason.asSemantics.TransitionSystem; +import jason.asSemantics.Unifier; +import jason.asSyntax.Term; + +import java.awt.Desktop; +import java.net.URI; + +public class mi extends DefaultInternalAction { + + @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { + String url = MindInspectorWeb.getURL()+"/agent-mind/"+ts.getUserAgArch().getAgName(); + Desktop.getDesktop().browse(new URI(url)); + return true; + } + +} Added: trunk/src/jason/infra/repl/print_unifier.java =================================================================== --- trunk/src/jason/infra/repl/print_unifier.java (rev 0) +++ trunk/src/jason/infra/repl/print_unifier.java 2014-09-13 23:50:27 UTC (rev 1801) @@ -0,0 +1,19 @@ +package jason.infra.repl; + +import jason.asSemantics.DefaultInternalAction; +import jason.asSemantics.TransitionSystem; +import jason.asSemantics.Unifier; +import jason.asSyntax.Term; +import jason.asSyntax.VarTerm; + +public class print_unifier extends DefaultInternalAction { + + @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { + for (VarTerm v : un) { + //if (! v.getFunctor().equals("Cmd__TR")) + ts.getLogger().info(v+"="+un.get(v)); + } + return true; + } + +} Added: trunk/src/jason/infra/repl/verbose.java =================================================================== --- trunk/src/jason/infra/repl/verbose.java (rev 0) +++ trunk/src/jason/infra/repl/verbose.java 2014-09-13 23:50:27 UTC (rev 1801) @@ -0,0 +1,27 @@ +package jason.infra.repl; + +import java.util.logging.Level; + +import jason.asSemantics.DefaultInternalAction; +import jason.asSemantics.TransitionSystem; +import jason.asSemantics.Unifier; +import jason.asSyntax.NumberTerm; +import jason.asSyntax.Term; + +public class verbose extends DefaultInternalAction { + + @Override public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { + if (args.length>0 && args[0].isNumeric()) { + NumberTerm n = (NumberTerm)args[0]; + switch ((int)n.solve()) { + case 0: ts.getLogger().setLevel(Level.SEVERE); break; + case 1: ts.getLogger().setLevel(Level.INFO); break; + case 2: ts.getLogger().setLevel(Level.FINE); System.out.println("*****");break; + } + return true; + } else { + return false; + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-11 12:20:39
|
Revision: 1800 http://sourceforge.net/p/jason/svn/1800 Author: jomifred Date: 2014-09-11 12:20:36 +0000 (Thu, 11 Sep 2014) Log Message: ----------- improve fix config Modified Paths: -------------- trunk/src/jason/asSemantics/Intention.java trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/jeditplugin/Config.java trunk/src/jason/stdlib/create_agent.java Modified: trunk/src/jason/asSemantics/Intention.java =================================================================== --- trunk/src/jason/asSemantics/Intention.java 2014-09-03 19:14:49 UTC (rev 1799) +++ trunk/src/jason/asSemantics/Intention.java 2014-09-11 12:20:36 UTC (rev 1800) @@ -194,8 +194,14 @@ public String toString() { StringBuilder s = new StringBuilder("intention "+id+": \n"); - for (IntendedMeans im: intendedMeans) + int i = 0; + for (IntendedMeans im: intendedMeans) { s.append(" " + im + "\n"); + if (i++ > 40) { + s.append("..... to more "+ (size()-40) + " intended means!\n"); + break; + } + } if (isFinished()) s.append("<finished intention>"); return s.toString(); Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2014-09-03 19:14:49 UTC (rev 1799) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2014-09-11 12:20:36 UTC (rev 1800) @@ -408,9 +408,19 @@ confP.step = State.ProcAct; // default next step if (conf.C.SE.trigger.isGoal() && !conf.C.SE.trigger.isMetaEvent()) { // can't carry on, no relevant/applicable plan. - String msg = "Found a goal for which there is no "+m+" plan:" + conf.C.SE; - if (!generateGoalDeletionFromEvent(JasonException.createBasicErrorAnnots("no_"+m, msg))) - logger.warning(msg); + try { + if (conf.C.SE.getIntention() != null && conf.C.SE.getIntention().size() > 3000) { + logger.warning("we are likely in a problem with event "+conf.C.SE.getTrigger()+" the intention stack has already "+conf.C.SE.getIntention().size()+" intended means!"); + } + String msg = "Found a goal for which there is no "+m+" plan:" + conf.C.SE.getTrigger(); + if (!generateGoalDeletionFromEvent(JasonException.createBasicErrorAnnots("no_"+m, msg))) { + logger.warning(msg); + } + } catch (Exception e) { + e.printStackTrace(); + return; + } + } else if (conf.C.SE.isInternal()) { // e.g. belief addition as internal event, just go ahead // but note that the event was relevant, yet it is possible Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2014-09-03 19:14:49 UTC (rev 1799) +++ trunk/src/jason/jeditplugin/Config.java 2014-09-11 12:20:36 UTC (rev 1800) @@ -227,6 +227,7 @@ tryToFixJarFileConf(JADE_JAR, "jade.jar", 2000000); tryToFixJarFileConf(MOISE_JAR, "moise.jar", 300000); tryToFixJarFileConf(JACAMO_JAR, "jacamo.jar", 5000); + tryToFixJarFileConf(JASON_JAR, "jason.jar", 700000); // in case jacamo is found // fix java home if (get(JAVA_HOME) == null || !checkJavaHomePath(getProperty(JAVA_HOME))) { @@ -271,6 +272,7 @@ } } } catch (Exception e) { + System.out.println("Error setting ant lib!"); e.printStackTrace(); } } @@ -418,10 +420,32 @@ jarFile = getJavaHomePathFromClassPath(jarName); if (checkJar(jarFile, minSize)) { put(jarEntry, jarFile); - System.out.println("found at " + jarFile); + System.out.println("found at " + jarFile+" by classpath"); return; } + + try { + // try jason jar + File jasonjardir = new File(getJasonJar()).getAbsoluteFile().getCanonicalFile().getParentFile(); + jarFile = jasonjardir+File.separator+jarName; + if (checkJar(jarFile, minSize)) { + put(jarEntry, jarFile); + System.out.println("found at " + jarFile+" by jason.jar directory"); + return; + } + } catch (Exception e) {} + try { + // try jacamo jar + File jacamojardir= new File(getProperty(JACAMO_JAR)).getAbsoluteFile().getCanonicalFile().getParentFile(); + jarFile = jacamojardir+File.separator+jarName; + if (checkJar(jarFile, minSize)) { + put(jarEntry, jarFile); + System.out.println("found at " + jarFile+" by jacamo.jar directory"); + return; + } + } catch (Exception e) {} + // try current dir jarFile = "." + File.separator + jarName; if (checkJar(jarFile, minSize)) { Modified: trunk/src/jason/stdlib/create_agent.java =================================================================== --- trunk/src/jason/stdlib/create_agent.java 2014-09-03 19:14:49 UTC (rev 1799) +++ trunk/src/jason/stdlib/create_agent.java 2014-09-11 12:20:36 UTC (rev 1800) @@ -51,7 +51,7 @@ If this parameter is a variable, it will be unified with the name given to the agent. The agent's name will be the name of the variable and some number that makes it unique.<br/> - <li>+ source (string): path to the file where the AgentSpeak code + <li><i>+ source</i> (string): path to the file where the AgentSpeak code for the new agent can be found.<br/> <li><i>+ customisations</i> (list -- optional): list of optional parameters @@ -93,12 +93,12 @@ */ public class create_agent extends DefaultInternalAction { - @Override public int getMinArgs() { return 2; } + @Override public int getMinArgs() { return 1; } @Override public int getMaxArgs() { return 3; } @Override protected void checkArguments(Term[] args) throws JasonException { super.checkArguments(args); // check number of arguments - if (!args[1].isString()) + if (args.length > 1 && !args[1].isString()) throw JasonException.createWrongArgument(this,"second argument must be a string"); if (args.length == 3 && !args[2].isList()) throw JasonException.createWrongArgument(this,"third argument must be a list"); @@ -117,15 +117,22 @@ if (args[0].isVar()) name = name.substring(0,1).toLowerCase() + name.substring(1); - StringTerm source = (StringTerm)args[1]; + String source = null; + if (args.length > 1) { - File fSource = new File(source.getString()); - if (!fSource.exists()) { - fSource = new File("src/asl/"+source.getString()); + File fSource = new File( ((StringTerm)args[1]).getString()); if (!fSource.exists()) { - throw new JasonException("The source file " + source + " was not found!"); + fSource = new File("src/asl/"+((StringTerm)args[1]).getString()); + if (!fSource.exists()) { + fSource = new File("src/agt/"+((StringTerm)args[1]).getString()); + if (!fSource.exists()) { + throw new JasonException("The source file " + source + " was not found!"); + } + } } + source = fSource.getAbsolutePath(); } + String agClass = null; List<String> agArchClasses = new ArrayList<String>(); ClassParameters bbPars = null; @@ -145,7 +152,7 @@ } } RuntimeServicesInfraTier rs = ts.getUserAgArch().getRuntimeServices(); - name = rs.createAgent(name, fSource.getAbsolutePath(), agClass, agArchClasses, bbPars, ts.getSettings()); + name = rs.createAgent(name, source, agClass, agArchClasses, bbPars, ts.getSettings()); rs.startAgent(name); if (args[0].isVar()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-09-03 19:14:57
|
Revision: 1799 http://sourceforge.net/p/jason/svn/1799 Author: jomifred Date: 2014-09-03 19:14:49 +0000 (Wed, 03 Sep 2014) Log Message: ----------- small improvement in sleep/wake Modified Paths: -------------- trunk/src/jason/infra/centralised/CentralisedAgArch.java Modified: trunk/src/jason/infra/centralised/CentralisedAgArch.java =================================================================== --- trunk/src/jason/infra/centralised/CentralisedAgArch.java 2014-08-28 21:22:45 UTC (rev 1798) +++ trunk/src/jason/infra/centralised/CentralisedAgArch.java 2014-09-03 19:14:49 UTC (rev 1799) @@ -210,13 +210,16 @@ } private Object sleepSync = new Object(); + private int sleepTime = 50; public void sleep() { try { if (!getTS().getSettings().isSync()) { logger.fine("Entering in sleep mode...."); synchronized (sleepSync) { - sleepSync.wait(500); // wait for messages + sleepSync.wait(sleepTime); // wait for messages + if (sleepTime < 1000) + sleepTime += 100; } } } catch (InterruptedException e) { @@ -227,6 +230,7 @@ public void wake() { synchronized (sleepSync) { + sleepTime = 50; sleepSync.notifyAll(); // notify sleep method } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-08-28 21:22:53
|
Revision: 1798 http://sourceforge.net/p/jason/svn/1798 Author: jomifred Date: 2014-08-28 21:22:45 +0000 (Thu, 28 Aug 2014) Log Message: ----------- improve API for Config class Modified Paths: -------------- trunk/src/jason/jeditplugin/Config.java Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2014-08-25 21:21:16 UTC (rev 1797) +++ trunk/src/jason/jeditplugin/Config.java 2014-08-28 21:22:45 UTC (rev 1798) @@ -33,6 +33,7 @@ import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; @@ -608,7 +609,12 @@ if (bt.exists()) { in = new BufferedReader(new FileReader(bt)); } else { - in = new BufferedReader(new InputStreamReader(TransitionSystem.class.getResource("/templates/"+templateName).openStream())); + bt = new File(Config.get().getJasonHome()+"/src/templates/"+templateName); + if (bt.exists()) { + in = new BufferedReader(new FileReader(bt)); + } else { + in = new BufferedReader(new InputStreamReader(getDetaultResource(templateName))); + } } } @@ -626,6 +632,10 @@ } } + public InputStream getDetaultResource(String templateName) throws IOException { + return TransitionSystem.class.getResource("/templates/"+templateName).openStream(); + } + public static void main(String[] args) { Config.get().fix(); Config.get().store(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-08-25 21:21:18
|
Revision: 1797 http://sourceforge.net/p/jason/svn/1797 Author: jomifred Date: 2014-08-25 21:21:16 +0000 (Mon, 25 Aug 2014) Log Message: ----------- fix a typp in the name of a method Modified Paths: -------------- trunk/src/jason/infra/centralised/RunCentralisedMAS.java Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-08-21 23:41:49 UTC (rev 1796) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-08-25 21:21:16 UTC (rev 1797) @@ -43,6 +43,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; @@ -233,7 +234,11 @@ } } else { try { - LogManager.getLogManager().readConfiguration(RunCentralisedMAS.class.getResource("/templates/" + logPropFile).openStream()); + if (runner != null) { + LogManager.getLogManager().readConfiguration(runner.getDefaultLogProperties()); + } else { + LogManager.getLogManager().readConfiguration(RunCentralisedMAS.class.getResource("/templates/" + logPropFile).openStream()); + } } catch (Exception e) { System.err.println("Error setting up logger:" + e); e.printStackTrace(); @@ -242,6 +247,10 @@ } } + protected InputStream getDefaultLogProperties() throws IOException { + return RunCentralisedMAS.class.getResource("/templates/" + logPropFile).openStream(); + } + public static void setupDefaultConsoleLogger() { Handler[] hs = Logger.getLogger("").getHandlers(); for (int i = 0; i < hs.length; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-08-21 23:41:51
|
Revision: 1796 http://sourceforge.net/p/jason/svn/1796 Author: jomifred Date: 2014-08-21 23:41:49 +0000 (Thu, 21 Aug 2014) Log Message: ----------- add useful method (for jacamo) in classparameters Modified Paths: -------------- trunk/src/jason/mas2j/ClassParameters.java trunk/src/test/MAS2JParserTest.java Modified: trunk/src/jason/mas2j/ClassParameters.java =================================================================== --- trunk/src/jason/mas2j/ClassParameters.java 2014-08-19 11:32:39 UTC (rev 1795) +++ trunk/src/jason/mas2j/ClassParameters.java 2014-08-21 23:41:49 UTC (rev 1796) @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import jason.asSyntax.*; /** @@ -73,6 +74,33 @@ } return p; } + + public Object[] getTypedParametersArray() { + Object[] p = new Object[parameters.size()]; + int i=0; + for (String s: parameters) { + s = removeQuotes(s); + try { + p[i] = Integer.parseInt(s); + } catch (Exception e) { + try { + p[i] = Double.parseDouble(s); + } catch (Exception e3) { + if (s.equals("true")) + p[i] = true; + else if (s.equals("false")) + p[i] = false; + else + p[i] = s; + } + } + + i++; + } + return p; + } + + /** returns parameters with space as separator */ public String getParametersStr(String sep) { StringBuilder out = new StringBuilder(); Modified: trunk/src/test/MAS2JParserTest.java =================================================================== --- trunk/src/test/MAS2JParserTest.java 2014-08-19 11:32:39 UTC (rev 1795) +++ trunk/src/test/MAS2JParserTest.java 2014-08-21 23:41:49 UTC (rev 1796) @@ -1,6 +1,8 @@ package test; +import jason.asSyntax.ASSyntax; import jason.asSyntax.Literal; +import jason.asSyntax.Structure; import jason.bb.ChainBB; import jason.mas2j.ClassParameters; import jason.mas2j.MAS2JProject; @@ -78,9 +80,7 @@ ChainBB bb = new ChainBB(); bb.init(null, project.getAg("bob").getBBClass().getParametersArray()); - /* - - bb.add(Literal.parseLiteral("b(1)"));*/ + bb.add(Literal.parseLiteral("b(1)")); } public void testClassDef1() throws ParseException { @@ -90,11 +90,14 @@ assertEquals("my.Arch", c.getClassName()); assertEquals(1,c.getParametersArray().length); } - public void testClassDef2() throws ParseException { + public void testClassDef2() throws ParseException, jason.asSyntax.parser.ParseException { String archClass = "my.Arch()"; mas2j parser = new mas2j(new StringReader(archClass)); ClassParameters c = parser.classDef(); assertEquals("my.Arch", c.getClassName()); assertEquals(0,c.getParametersArray().length); + + Structure s = ASSyntax.parseStructure(c.toString()); // a classDef should be parsed as a structure + assertEquals("my.Arch", s.toString()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-08-19 11:32:43
|
Revision: 1795 http://sourceforge.net/p/jason/svn/1795 Author: jomifred Date: 2014-08-19 11:32:39 +0000 (Tue, 19 Aug 2014) Log Message: ----------- revert changes in Classparameters Modified Paths: -------------- trunk/release-notes.txt trunk/src/jason/mas2j/ClassParameters.java trunk/src/jason/stdlib/suspend.java trunk/src/test/MAS2JParserTest.java Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2014-08-18 21:37:10 UTC (rev 1794) +++ trunk/release-notes.txt 2014-08-19 11:32:39 UTC (rev 1795) @@ -1,12 +1,12 @@ --------------------------- version 1.4.1 -revision X on SVN +revision 1792 on SVN --------------------------- New features -- web view of agent's mind (url usually is http://localhost:3272) +- web view of agent's mind (the url usually is http://localhost:3272) --------------------------- Modified: trunk/src/jason/mas2j/ClassParameters.java =================================================================== --- trunk/src/jason/mas2j/ClassParameters.java 2014-08-18 21:37:10 UTC (rev 1794) +++ trunk/src/jason/mas2j/ClassParameters.java 2014-08-19 11:32:39 UTC (rev 1795) @@ -99,8 +99,8 @@ public String toString() { StringBuilder out = new StringBuilder(className); - out.append("("); if (parameters.size() > 0) { + out.append("("); Iterator<String> i = parameters.iterator(); while (i.hasNext()) { out.append(i.next()); @@ -108,8 +108,8 @@ out.append(","); } } + out.append(")"); } - out.append(")"); return out.toString(); } Modified: trunk/src/jason/stdlib/suspend.java =================================================================== --- trunk/src/jason/stdlib/suspend.java 2014-08-18 21:37:10 UTC (rev 1794) +++ trunk/src/jason/stdlib/suspend.java 2014-08-19 11:32:39 UTC (rev 1795) @@ -137,7 +137,7 @@ // suspending the current intention? Intention i = C.getSelectedIntention(); - if (i.hasTrigger(g, un)) { + if (i != null && i.hasTrigger(g, un)) { suspendIntention = true; i.setSuspended(true); C.addPendingIntention(SELF_SUSPENDED_INT+i.getId(), i); Modified: trunk/src/test/MAS2JParserTest.java =================================================================== --- trunk/src/test/MAS2JParserTest.java 2014-08-18 21:37:10 UTC (rev 1794) +++ trunk/src/test/MAS2JParserTest.java 2014-08-19 11:32:39 UTC (rev 1795) @@ -19,9 +19,9 @@ protected void setUp() throws Exception { super.setUp(); - StringBuffer source = new StringBuffer("MAS auctionCent { "); - source.append("infrastructure: Centralised "); - source.append("environment: myEnv at \"x.edu\" "); + StringBuffer source = new StringBuffer("MAS auctionCent { \n"); + source.append("infrastructure: Centralised \n"); + source.append("environment: myEnv at \"x.edu\" \n"); source.append("executionControl: myController "); source.append("agents: ag1 [events=discard,intBels=newFocus,osfile=\"a/x.xml\"]; ag2 /home/agTest.asl agentClass mypkg.MyAgent #2; ag3 at \"x.edu\"; auctionner agentArchClass AuctionnerGUI;"); source.append("directives: md1=mypkg.DebugDirective; md2=mypkg.LogDirective;"); @@ -74,20 +74,27 @@ parser = new mas2j(new StringReader(source.toString())); MAS2JProject project = parser.mas(); - assertEquals(2, project.getAg("bob").getBBClass().getParametersArray().length); ChainBB bb = new ChainBB(); bb.init(null, project.getAg("bob").getBBClass().getParametersArray()); + /* - bb.add(Literal.parseLiteral("b(1)")); + bb.add(Literal.parseLiteral("b(1)"));*/ } - public void testClassDef() throws ParseException { + public void testClassDef1() throws ParseException { String archClass = "my.Arch(test)"; mas2j parser = new mas2j(new StringReader(archClass)); ClassParameters c = parser.classDef(); assertEquals("my.Arch", c.getClassName()); assertEquals(1,c.getParametersArray().length); } + public void testClassDef2() throws ParseException { + String archClass = "my.Arch()"; + mas2j parser = new mas2j(new StringReader(archClass)); + ClassParameters c = parser.classDef(); + assertEquals("my.Arch", c.getClassName()); + assertEquals(0,c.getParametersArray().length); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-08-18 21:37:19
|
Revision: 1794 http://sourceforge.net/p/jason/svn/1794 Author: jomifred Date: 2014-08-18 21:37:10 +0000 (Mon, 18 Aug 2014) Log Message: ----------- other improvements in the API for parsing project files Modified Paths: -------------- trunk/src/jason/infra/centralised/RunCentralisedMAS.java trunk/src/jason/mas2j/AgentParameters.java trunk/src/jason/mas2j/ClassParameters.java Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-08-17 17:54:33 UTC (rev 1793) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-08-18 21:37:10 UTC (rev 1794) @@ -376,6 +376,13 @@ // cannot add zeros before, it causes many compatibility problems and breaks dynamic creation // numberedAg += String.format("%0"+String.valueOf(ap.qty).length()+"d", cAg + 1); } + + String nb = ""; + int n = 1; + while (getAg(numberedAg+nb) != null) + nb = "_" + (n++); + numberedAg += nb; + logger.fine("Creating agent " + numberedAg + " (" + (cAg + 1) + "/" + ap.getNbInstances() + ")"); CentralisedAgArch agArch; if (isPool) { @@ -518,7 +525,7 @@ } /** an agent architecture for the infra based on thread pool */ - private final class CentralisedAgArchForPool extends CentralisedAgArch { + protected final class CentralisedAgArchForPool extends CentralisedAgArch { private volatile boolean runWakeAfterTS = false; Modified: trunk/src/jason/mas2j/AgentParameters.java =================================================================== --- trunk/src/jason/mas2j/AgentParameters.java 2014-08-17 17:54:33 UTC (rev 1793) +++ trunk/src/jason/mas2j/AgentParameters.java 2014-08-18 21:37:10 UTC (rev 1794) @@ -37,6 +37,10 @@ public AgentParameters copy() { AgentParameters newap = new AgentParameters(); + copyTo(newap); + return newap; + } + protected void copyTo(AgentParameters newap) { newap.name = this.name; newap.asSource = new File(this.asSource.toString()); newap.agClass = this.agClass.copy(); @@ -46,7 +50,6 @@ newap.options = new HashMap<String, String>(this.options); newap.archClasses = new ArrayList<ClassParameters>(this.archClasses); newap.host = this.host; - return newap; } public String toString() { @@ -210,6 +213,7 @@ if (forceSync || debug) { stts.setSync(true); } + stts.addOption("project-parameter", this); // place of copy of this object anyway return stts; } Modified: trunk/src/jason/mas2j/ClassParameters.java =================================================================== --- trunk/src/jason/mas2j/ClassParameters.java 2014-08-17 17:54:33 UTC (rev 1793) +++ trunk/src/jason/mas2j/ClassParameters.java 2014-08-18 21:37:10 UTC (rev 1794) @@ -99,8 +99,8 @@ public String toString() { StringBuilder out = new StringBuilder(className); + out.append("("); if (parameters.size() > 0) { - out.append("("); Iterator<String> i = parameters.iterator(); while (i.hasNext()) { out.append(i.next()); @@ -108,8 +108,8 @@ out.append(","); } } - out.append(")"); } + out.append(")"); return out.toString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-08-17 17:54:36
|
Revision: 1793 http://sourceforge.net/p/jason/svn/1793 Author: jomifred Date: 2014-08-17 17:54:33 +0000 (Sun, 17 Aug 2014) Log Message: ----------- improve the API to help parsing JaCaMo project files Modified Paths: -------------- trunk/demos/distributed-jade/case2/myAllocator.java trunk/src/jason/architecture/MindInspectorWeb.java trunk/src/jason/asSemantics/Agent.java trunk/src/jason/infra/centralised/RunCentralisedMAS.java trunk/src/jason/infra/centralised/StartNewAgentGUI.java trunk/src/jason/infra/jade/JadeMASLauncherAnt.java trunk/src/jason/infra/jade/RunJadeMAS.java trunk/src/jason/mas2j/AgentParameters.java trunk/src/jason/mas2j/ClassParameters.java trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc trunk/src/jason/mas2j/parser/mas2j.java Modified: trunk/demos/distributed-jade/case2/myAllocator.java =================================================================== --- trunk/demos/distributed-jade/case2/myAllocator.java 2014-08-05 18:38:39 UTC (rev 1792) +++ trunk/demos/distributed-jade/case2/myAllocator.java 2014-08-17 17:54:33 UTC (rev 1793) @@ -35,7 +35,7 @@ // computes the number of agents in the project int nbAgs = 0; for (AgentParameters ap : project.getAgents()) { - nbAgs += ap.qty; + nbAgs += ap.getNbInstances(); } int agsByContainer = nbAgs / containers.size(); @@ -45,9 +45,9 @@ int i=0; for (AgentParameters ap : project.getAgents()) { String agName = ap.name; - for (int cAg = 0; cAg < ap.qty; cAg++) { + for (int cAg = 0; cAg < ap.getNbInstances(); cAg++) { String numberedAg = agName; - if (ap.qty > 1) { + if (ap.getNbInstances() > 1) { numberedAg += (cAg + 1); } String c = containers.get( i % containers.size()); Modified: trunk/src/jason/architecture/MindInspectorWeb.java =================================================================== --- trunk/src/jason/architecture/MindInspectorWeb.java 2014-08-05 18:38:39 UTC (rev 1792) +++ trunk/src/jason/architecture/MindInspectorWeb.java 2014-08-17 17:54:33 UTC (rev 1793) @@ -122,8 +122,9 @@ } private String getAgNameFromPath(String path) { - int nameStart = path.indexOf("agent-mind")+11; + int nameStart = path.indexOf("agent-mind"); if (nameStart < 0) return null; + nameStart += "agent-mind".length() + 1; int nameEnd = path.indexOf("/",nameStart+1); if (nameEnd >= 0) return path.substring(nameStart,nameEnd).trim(); @@ -138,7 +139,7 @@ AgArch arch = ag.getTS().getUserAgArch(); if (arch != null) { // should add a new conf for mindinspector, otherwise will start a new gui for the agent - arch.getTS().getSettings().addOption("mindinspector","web(cycle,html,history)"); + arch.getTS().getSettings().addOption("mindinspector","web(cycle,html,no_history)"); MindInspectorAgArch miArch = new MindInspectorAgArch(); arch.insertAgArch(miArch); miArch.init(); Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2014-08-05 18:38:39 UTC (rev 1792) +++ trunk/src/jason/asSemantics/Agent.java 2014-08-17 17:54:33 UTC (rev 1793) @@ -540,7 +540,7 @@ if (sGoals != null) { try { for (Term t: ASSyntax.parseList("["+sGoals+"]")) { - Literal g = (Literal)t; + Literal g = ((Literal)t).forceFullLiteralImpl(); g.makeVarsAnnon(); if (! g.hasSource()) g.addAnnot(BeliefBase.TSelf); Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-08-05 18:38:39 UTC (rev 1792) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-08-17 17:54:33 UTC (rev 1793) @@ -76,16 +76,16 @@ public final static String stopMASFileName = ".stop___MAS"; public final static String defaultProjectFileName = "default.mas2j"; - private static Logger logger = Logger.getLogger(RunCentralisedMAS.class.getName()); + protected static Logger logger = Logger.getLogger(RunCentralisedMAS.class.getName()); protected static RunCentralisedMAS runner = null; - private static String urlPrefix = ""; - private static boolean readFromJAR = false; - private static MAS2JProject project; - private static boolean debug = false; + protected static String urlPrefix = ""; + protected static boolean readFromJAR = false; + protected static MAS2JProject project; + protected static boolean debug = false; - private CentralisedEnvironment env = null; - private CentralisedExecutionControl control = null; - private Map<String,CentralisedAgArch> ags = new ConcurrentHashMap<String,CentralisedAgArch>(); + protected CentralisedEnvironment env = null; + protected CentralisedExecutionControl control = null; + protected Map<String,CentralisedAgArch> ags = new ConcurrentHashMap<String,CentralisedAgArch>(); public JButton btDebug; @@ -112,7 +112,7 @@ } else { System.out.println("Jason "+Config.get().getJasonRunningVersion()); System.err.println("You should inform the MAS project file."); - JOptionPane.showMessageDialog(null,"Jason version "+Config.get().getJasonRunningVersion()+" library built on "+Config.get().getJasonBuiltDate(),"Jason", JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog(null,"You should inform the project file as a parameter.\n\nJason version "+Config.get().getJasonRunningVersion()+" library built on "+Config.get().getJasonBuiltDate(),"Jason", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } } else { @@ -367,16 +367,16 @@ String agName = ap.name; - for (int cAg = 0; cAg < ap.qty; cAg++) { + for (int cAg = 0; cAg < ap.getNbInstances(); cAg++) { nbAg++; String numberedAg = agName; - if (ap.qty > 1) { + if (ap.getNbInstances() > 1) { numberedAg += (cAg + 1); // cannot add zeros before, it causes many compatibility problems and breaks dynamic creation // numberedAg += String.format("%0"+String.valueOf(ap.qty).length()+"d", cAg + 1); } - logger.fine("Creating agent " + numberedAg + " (" + (cAg + 1) + "/" + ap.qty + ")"); + logger.fine("Creating agent " + numberedAg + " (" + (cAg + 1) + "/" + ap.getNbInstances() + ")"); CentralisedAgArch agArch; if (isPool) { agArch = new CentralisedAgArchForPool(); Modified: trunk/src/jason/infra/centralised/StartNewAgentGUI.java =================================================================== --- trunk/src/jason/infra/centralised/StartNewAgentGUI.java 2014-08-05 18:38:39 UTC (rev 1792) +++ trunk/src/jason/infra/centralised/StartNewAgentGUI.java 2014-08-17 17:54:33 UTC (rev 1793) @@ -116,9 +116,9 @@ if (ap.agClass != null) { agClass = ap.agClass.getClassName(); } - for (int i = 0; i < ap.qty; i++) { + for (int i = 0; i < ap.getNbInstances(); i++) { String name = ap.name; - if (ap.qty > 1) { + if (ap.getNbInstances() > 1) { name = name + (i + 1); } // TODO: implements bb class @@ -164,7 +164,7 @@ } if (!nbAgs.getText().trim().equals("1")) { try { - ap.qty = Integer.parseInt(nbAgs.getText().trim()); + ap.setNbInstances( Integer.parseInt(nbAgs.getText().trim()) ); } catch (Exception e) { System.err.println("Number of hosts is not a number!"); } Modified: trunk/src/jason/infra/jade/JadeMASLauncherAnt.java =================================================================== --- trunk/src/jason/infra/jade/JadeMASLauncherAnt.java 2014-08-05 18:38:39 UTC (rev 1792) +++ trunk/src/jason/infra/jade/JadeMASLauncherAnt.java 2014-08-17 17:54:33 UTC (rev 1793) @@ -172,9 +172,9 @@ args += " -gui "; } for (AgentParameters ap: project.getAgents()) { - for (int cAg = 0; cAg < ap.qty; cAg++) { + for (int cAg = 0; cAg < ap.getNbInstances(); cAg++) { String numberedAg = ap.getAgName(); - if (ap.qty > 1) + if (ap.getNbInstances() > 1) numberedAg += (cAg + 1); if ( (container.equals("Main-Container") && ap.getHost() == null && allocator == null) || (ap.getHost() != null && ap.getHost().equals(container)) || Modified: trunk/src/jason/infra/jade/RunJadeMAS.java =================================================================== --- trunk/src/jason/infra/jade/RunJadeMAS.java 2014-08-05 18:38:39 UTC (rev 1792) +++ trunk/src/jason/infra/jade/RunJadeMAS.java 2014-08-17 17:54:33 UTC (rev 1793) @@ -236,11 +236,11 @@ ap.addArchClass(MindInspectorAgArch.class.getName()); } - for (int cAg = 0; cAg < ap.qty; cAg++) { + for (int cAg = 0; cAg < ap.getNbInstances(); cAg++) { String numberedAg = agName; - if (ap.qty > 1) + if (ap.getNbInstances() > 1) numberedAg += (cAg + 1); //String.format("%0"+String.valueOf(ap.qty).length()+"d", cAg + 1); - logger.info("Creating agent " + numberedAg + " (" + (cAg + 1) + "/" + ap.qty + ")"); + logger.info("Creating agent " + numberedAg + " (" + (cAg + 1) + "/" + ap.getNbInstances() + ")"); AgentController ac = cc.createNewAgent(numberedAg, JadeAgArch.class.getName(), new Object[] { ap, isDebug(), getProject().getControlClass() != null }); ags.put(numberedAg,ac); } Modified: trunk/src/jason/mas2j/AgentParameters.java =================================================================== --- trunk/src/jason/mas2j/AgentParameters.java 2014-08-05 18:38:39 UTC (rev 1792) +++ trunk/src/jason/mas2j/AgentParameters.java 2014-08-17 17:54:33 UTC (rev 1793) @@ -25,15 +25,30 @@ public File asSource = null; public ClassParameters agClass = null; public ClassParameters bbClass = null; - private List<ClassParameters> archClasses = new ArrayList<ClassParameters>(); - public int qty = 1; - private Map<String, String> options = null; - private String host = null; + protected int nbInstances = 1; + protected Map<String, String> options = null; + protected List<ClassParameters> archClasses = new ArrayList<ClassParameters>(); + + protected String host = null; public AgentParameters() { setupDefault(); } + public AgentParameters copy() { + AgentParameters newap = new AgentParameters(); + newap.name = this.name; + newap.asSource = new File(this.asSource.toString()); + newap.agClass = this.agClass.copy(); + newap.bbClass = this.bbClass.copy(); + newap.nbInstances = this.nbInstances; + if (this.options != null) + newap.options = new HashMap<String, String>(this.options); + newap.archClasses = new ArrayList<ClassParameters>(this.archClasses); + newap.host = this.host; + return newap; + } + public String toString() { return getAsInMASProject(); } @@ -63,8 +78,15 @@ return bbClass; } + public void setNbInstances(int i) { + nbInstances = i; + } + public int getNbInstances() { + return nbInstances; + } + public void setHost(String h) { - if (h.startsWith("\"")) + if (h != null && h.startsWith("\"")) host = h.substring(1,h.length()-1); else host = h; @@ -156,8 +178,8 @@ if (bbClass != null && bbClass.getClassName().length() > 0 && !bbClass.getClassName().equals(DefaultBeliefBase.class.getName())) { s.append("beliefBaseClass "+bbClass+" "); } - if (qty > 1) { - s.append("#"+qty+" "); + if (nbInstances > 1) { + s.append("#"+nbInstances+" "); } if (host != null && host.length() > 0) { s.append("at \""+host+"\""); @@ -168,13 +190,17 @@ public Settings getAsSetts(boolean debug, boolean forceSync) { Settings stts = new Settings(); if (options != null) { - String s = ""; String v = ""; + Map<String,Object> opt = new HashMap<String, Object>(); + //String s = ""; String v = ""; for (String key: options.keySet()) { - s += v + key + "=" + options.get(key); - v = ","; + opt.put(key, options.get(key)); + //s += v + key + "=" + options.get(key); + //v = ","; } - if (s.length() > 0) { - stts.setOptions("["+s+"]"); + if (!opt.isEmpty()) { + stts.setOptions(opt); + //if (s.length() > 0) { + // stts.setOptions("["+s+"]"); } } if (debug) { Modified: trunk/src/jason/mas2j/ClassParameters.java =================================================================== --- trunk/src/jason/mas2j/ClassParameters.java 2014-08-05 18:38:39 UTC (rev 1792) +++ trunk/src/jason/mas2j/ClassParameters.java 2014-08-17 17:54:33 UTC (rev 1793) @@ -32,6 +32,13 @@ } } + public ClassParameters copy() { + ClassParameters newcp = new ClassParameters(this.className); + newcp.parameters = new ArrayList<String>(this.parameters); + newcp.host = this.host; + return newcp; + } + public void setClassName(String cn) { className = cn; } Modified: trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc =================================================================== --- trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc 2014-08-05 18:38:39 UTC (rev 1792) +++ trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc 2014-08-17 17:54:33 UTC (rev 1793) @@ -242,7 +242,7 @@ | <BBCLASS> ag.bbClass = classDef() | - "#" qty = <NUMBER> { ag.qty = Integer.parseInt(qty.image); } + "#" qty = <NUMBER> { ag.setNbInstances( Integer.parseInt(qty.image) ); } | <AT> host = <STRING> { ag.setHost(host.image); } )* Modified: trunk/src/jason/mas2j/parser/mas2j.java =================================================================== --- trunk/src/jason/mas2j/parser/mas2j.java 2014-08-05 18:38:39 UTC (rev 1792) +++ trunk/src/jason/mas2j/parser/mas2j.java 2014-08-17 17:54:33 UTC (rev 1793) @@ -174,7 +174,7 @@ case 40: jj_consume_token(40); qty = jj_consume_token(NUMBER); - ag.qty = Integer.parseInt(qty.image); + ag.setNbInstances( Integer.parseInt(qty.image) ); break; case AT: jj_consume_token(AT); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-08-05 18:38:43
|
Revision: 1792 http://sourceforge.net/p/jason/svn/1792 Author: jomifred Date: 2014-08-05 18:38:39 +0000 (Tue, 05 Aug 2014) Log Message: ----------- release 1.4.1 Modified Paths: -------------- trunk/build.xml trunk/lib/c4jason.jar trunk/src/jason/runtime/MASConsoleColorGUI.java trunk/src/jason/stdlib/intend.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2014-06-27 22:57:36 UTC (rev 1791) +++ trunk/build.xml 2014-08-05 18:38:39 UTC (rev 1792) @@ -12,7 +12,7 @@ <property name="dist.properties" value="${basedir}/bin/dist.properties" /> <property name="version" value="1" /> - <property name="release" value="4.0a" /> + <property name="release" value="4.1" /> <property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" /> <property name="distFile" value="${env.HOME}/Jason-${version}.${release}" /> Modified: trunk/lib/c4jason.jar =================================================================== (Binary files differ) Modified: trunk/src/jason/runtime/MASConsoleColorGUI.java =================================================================== --- trunk/src/jason/runtime/MASConsoleColorGUI.java 2014-06-27 22:57:36 UTC (rev 1791) +++ trunk/src/jason/runtime/MASConsoleColorGUI.java 2014-08-05 18:38:39 UTC (rev 1792) @@ -122,7 +122,7 @@ Color.blue, Color.red, Color.gray, - Color.cyan, + //Color.cyan, Color.magenta, //Color.orange, //Color.pink, Modified: trunk/src/jason/stdlib/intend.java =================================================================== --- trunk/src/jason/stdlib/intend.java 2014-06-27 22:57:36 UTC (rev 1791) +++ trunk/src/jason/stdlib/intend.java 2014-08-05 18:38:39 UTC (rev 1792) @@ -46,8 +46,8 @@ <p>Description: checks if <i>I</i> is an intention: <i>I</i> is an intention if there is a triggering event <code>+!I</code> in any plan within an - intention; just note that intentions can be suspended and appear in E, PA, - and PI as well. + intention; just note that intentions can appear in E (list of events), PA (intentions with pending actions), + and PI (intentions waiting for something) as well. <p>Example:<ul> @@ -144,6 +144,7 @@ } */ + // data structures where intentions can be found enum Step { selEvt, selInt, evt, pendEvt, pendAct, pendInt, intentions, end } //private static Logger logger = Logger.getLogger(intend.class.getName()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-06-27 22:57:38
|
Revision: 1791 http://sourceforge.net/p/jason/svn/1791 Author: jomifred Date: 2014-06-27 22:57:36 +0000 (Fri, 27 Jun 2014) Log Message: ----------- improve jade run mas Modified Paths: -------------- trunk/src/jason/infra/jade/RunJadeMAS.java Modified: trunk/src/jason/infra/jade/RunJadeMAS.java =================================================================== --- trunk/src/jason/infra/jade/RunJadeMAS.java 2014-06-10 15:00:32 UTC (rev 1790) +++ trunk/src/jason/infra/jade/RunJadeMAS.java 2014-06-27 22:57:36 UTC (rev 1791) @@ -32,6 +32,9 @@ import jade.wrapper.StaleProxyException; import jason.JasonException; import jason.architecture.MindInspectorAgArch; +import jason.asSyntax.ASSyntax; +import jason.asSyntax.Literal; +import jason.asSyntax.StringTerm; import jason.asSyntax.directives.DirectiveProcessor; import jason.asSyntax.directives.Include; import jason.control.ExecutionControlGUI; @@ -54,6 +57,7 @@ import javax.swing.ImageIcon; import javax.swing.JButton; + /** * Runs MASProject using JADE infrastructure. * @@ -96,7 +100,6 @@ targetContainer = args[i+1]; } } - return super.init(args); } @@ -145,12 +148,30 @@ protected boolean startContainer() { try { // source based on jade.Boot + try { + String m = getProject().getInfrastructure().getParameter("main_container_host"); + if (m != null) { + Literal ml = ASSyntax.parseLiteral(m); + m = ((StringTerm)(ml.getTerm(0))).getString(); + int pos = m.indexOf(":"); + if (pos > 0) { + try { + initArgs.add("-port"); initArgs.add(m.substring(pos+1)); + initArgs.add("-host"); initArgs.add(m.substring(0,pos)); + initArgs.add("-container"); initArgs.add(m.substring(0,pos)); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } catch (Exception e) {} profile = new BootProfileImpl(prepareArgs( (String[])initArgs.toArray(new String[0]))); - + //System.out.println(profile); if (profile.getBooleanProperty(Profile.MAIN, true)) { cc = Runtime.instance().createMainContainer(profile); } else { cc = Runtime.instance().createAgentContainer(profile); + logger.info("Agent Container started with "+profile); } //Runtime.instance().setCloseVM(true); // Exit the JVM when there are no more containers around return cc != null; @@ -219,7 +240,7 @@ String numberedAg = agName; if (ap.qty > 1) numberedAg += (cAg + 1); //String.format("%0"+String.valueOf(ap.qty).length()+"d", cAg + 1); - logger.fine("Creating agent " + numberedAg + " (" + (cAg + 1) + "/" + ap.qty + ")"); + logger.info("Creating agent " + numberedAg + " (" + (cAg + 1) + "/" + ap.qty + ")"); AgentController ac = cc.createNewAgent(numberedAg, JadeAgArch.class.getName(), new Object[] { ap, isDebug(), getProject().getControlClass() != null }); ags.put(numberedAg,ac); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |