[jsoar] 13 new revisions pushed by marin...@gmail.com on 2013-10-02 13:48 GMT

1 view
Skip to first unread message

js...@googlecode.com

unread,
Oct 2, 2013, 9:49:36 AM10/2/13
to jsoa...@googlegroups.com
master moved from 5051eeaf6a43 to e1d9e217464f

13 new revisions:

Revision: 0d43ab80c054
Author: Peter Lindes <peter....@soartech.com>
Date: Wed Aug 28 13:43:59 2013 UTC
Log: Added RLParamTests JUnit file....
http://code.google.com/p/jsoar/source/detail?r=0d43ab80c054

Revision: da367c830924
Author: Peter Lindes <peter....@soartech.com>
Date: Wed Aug 28 13:56:01 2013 UTC
Log: Merge branch 'master' into rl-update
http://code.google.com/p/jsoar/source/detail?r=da367c830924

Revision: 129258dc0dc7
Author: bob.marinier <bob.ma...@soartech.com>
Date: Fri Aug 30 00:24:21 2013 UTC
Log: Fixed npe when an operator doesn't have a name.
http://code.google.com/p/jsoar/source/detail?r=129258dc0dc7

Revision: d6e7f6961a57
Author: ACNickels <alex.n...@soartech.com>
Date: Thu Sep 12 19:12:45 2013 UTC
Log: Fixed a crash bug in epmem caused by removing Y shaped
structures....
http://code.google.com/p/jsoar/source/detail?r=d6e7f6961a57

Revision: d0c9cb3d8224
Author: bob.marinier <bob.ma...@soartech.com>
Date: Fri Sep 13 19:45:27 2013 UTC
Log: Updated epmem test from UM (currently fails due to unknown bug in
jsoa...
http://code.google.com/p/jsoar/source/detail?r=d0c9cb3d8224

Revision: ec230dc4c9d8
Author: Patrick DeHaan <patrick...@soartech.com>
Date: Thu May 23 19:20:04 2013 UTC
Log: avoiding possible NPEs...
http://code.google.com/p/jsoar/source/detail?r=ec230dc4c9d8

Revision: fcef0ef80357
Author: Jonathan Voigt <voi...@gmail.com>
Date: Wed Sep 25 15:30:41 2013 UTC
Log: Convert RL update-log-path to use Java 6 File I/O
http://code.google.com/p/jsoar/source/detail?r=fcef0ef80357

Revision: f9ce0195e28a
Author: bob.marinier <bob.ma...@soartech.com>
Date: Wed Sep 25 20:28:00 2013 UTC
Log: Undid part of commit 07ff79c0510a823e002bf8c34e99923b671af67e in
order...
http://code.google.com/p/jsoar/source/detail?r=f9ce0195e28a

Revision: f6af13630c54
Author: ACNickels <alex.n...@soartech.com>
Date: Fri Sep 27 18:35:31 2013 UTC
Log: smem printing updates
http://code.google.com/p/jsoar/source/detail?r=f6af13630c54

Revision: 8c86e94f8af3
Author: bob.marinier <bob.ma...@soartech.com>
Date: Thu Sep 26 17:00:27 2013 UTC
Log: Updated urls and help command so it brings up the correct pages
http://code.google.com/p/jsoar/source/detail?r=8c86e94f8af3

Revision: 6be715af375a
Author: bob.marinier <bob.ma...@soartech.com>
Date: Thu Sep 26 20:25:41 2013 UTC
Log: Fix bug where smem -p <id> always printed all ltis, not just the
speci...
http://code.google.com/p/jsoar/source/detail?r=6be715af375a

Revision: 21e082d917c9
Author: bob.marinier <bob.ma...@soartech.com>
Date: Sat Sep 28 00:55:22 2013 UTC
Log: Fixed smem command to properly handle bad print commands
http://code.google.com/p/jsoar/source/detail?r=21e082d917c9

Revision: e1d9e217464f
Author: bob.marinier <bob.ma...@soartech.com>
Date: Mon Sep 30 00:52:22 2013 UTC
Log: Finished implementing matches command
http://code.google.com/p/jsoar/source/detail?r=e1d9e217464f

==============================================================================
Revision: 0d43ab80c054
Author: Peter Lindes <peter....@soartech.com>
Date: Wed Aug 28 13:43:59 2013 UTC
Log: Added RLParamTests JUnit file.
It tests get and set on all 17 RL parameters.
Made a couple of small changes elsewhere to get all these tests to work.

http://code.google.com/p/jsoar/source/detail?r=0d43ab80c054

Added:
/jsoar-core/src/test/java/org/jsoar/kernel/learning/rl/RLParamsTests.java
Modified:

/jsoar-core/src/main/java/org/jsoar/kernel/learning/rl/ReinforcementLearningParams.java
/jsoar-core/src/test/java/org/jsoar/kernel/RLTests.java

/jsoar-core/src/test/java/org/jsoar/kernel/learning/rl/ReinforcementLearningTest.java

=======================================
--- /dev/null
+++
/jsoar-core/src/test/java/org/jsoar/kernel/learning/rl/RLParamsTests.java
Wed Aug 28 13:43:59 2013 UTC
@@ -0,0 +1,434 @@
+/*
+ * Created by Peter Lindes, 28 August 2013
+ *
+ * This test goes through all the RL related parameters
+ * and first tests that the default is set correctly.
+ *
+ * Then it sets the parameter to one or more different
+ * values and reads them back to make sure it was
+ * set correctly.
+ *
+ */
+package org.jsoar.kernel.learning.rl;
+
+
+import static org.junit.Assert.*;
+
+import org.jsoar.kernel.Agent;
+import
org.jsoar.kernel.learning.rl.ReinforcementLearningParams.ApoptosisChoices;
+import org.jsoar.kernel.learning.rl.ReinforcementLearningParams.ChunkStop;
+import org.jsoar.kernel.learning.rl.ReinforcementLearningParams.DecayMode;
+import
org.jsoar.kernel.learning.rl.ReinforcementLearningParams.HrlDiscount;
+import org.jsoar.kernel.learning.rl.ReinforcementLearningParams.Learning;
+import
org.jsoar.kernel.learning.rl.ReinforcementLearningParams.LearningPolicy;
+import org.jsoar.kernel.learning.rl.ReinforcementLearningParams.Meta;
+import
org.jsoar.kernel.learning.rl.ReinforcementLearningParams.TemporalExtension;
+import org.jsoar.kernel.learning.rl.ReinforcementLearningParams.Trace;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class RLParamsTests
+{
+ private Agent agent;
+
+ private final double DELTA = 0.0000000001;
+
+ @Before
+ public void setUp()
+ {
+ this.agent = new Agent();
+ }
+
+ @After
+ public void tearDown()
+ {
+ this.agent.dispose();
+ this.agent = null;
+ }
+
+ @Test
+ public void testRLLearningParameter() throws Exception
+ {
+ // Test the default of off
+ Learning learning =
agent.getProperties().get(ReinforcementLearningParams.LEARNING);
+ assertEquals(Learning.off, learning);
+
+ // Test setting it to on
+ agent.getProperties().set(ReinforcementLearningParams.LEARNING,
Learning.on);
+ learning =
agent.getProperties().get(ReinforcementLearningParams.LEARNING);
+ assertEquals(Learning.on, learning);
+
+ // Test setting it back to off
+ agent.getProperties().set(ReinforcementLearningParams.LEARNING,
Learning.off);
+ learning =
agent.getProperties().get(ReinforcementLearningParams.LEARNING);
+ assertEquals(Learning.off, learning);
+ }
+
+ @Test
+ public void testTemporalExtensionParameter() throws Exception
+ {
+ // Test the default of on
+ TemporalExtension extension = agent.getProperties()
+ .get(ReinforcementLearningParams.TEMPORAL_EXTENSION);
+ assertEquals(TemporalExtension.on, extension);
+
+ // Test setting it to off
+
agent.getProperties().set(ReinforcementLearningParams.TEMPORAL_EXTENSION,
TemporalExtension.off);
+ extension =
agent.getProperties().get(ReinforcementLearningParams.TEMPORAL_EXTENSION);
+ assertEquals(TemporalExtension.off, extension);
+
+ // Test setting it to back to on
+
agent.getProperties().set(ReinforcementLearningParams.TEMPORAL_EXTENSION,
TemporalExtension.on);
+ extension =
agent.getProperties().get(ReinforcementLearningParams.TEMPORAL_EXTENSION);
+ assertEquals(TemporalExtension.on, extension);
+ }
+
+ @Test
+ public void testDiscountRateParameter() throws Exception
+ {
+ // Test the default of 0.9
+ double discount_rate = agent.getProperties()
+ .get(ReinforcementLearningParams.DISCOUNT_RATE);
+ assertEquals(0.9, discount_rate, DELTA);
+
+ // Test setting it 0.1
+ agent.getProperties().set(ReinforcementLearningParams.DISCOUNT_RATE,
0.1);
+ discount_rate =
agent.getProperties().get(ReinforcementLearningParams.DISCOUNT_RATE);
+ assertEquals(0.1, discount_rate, DELTA);
+
+ // Test setting it to 0.0
+ agent.getProperties().set(ReinforcementLearningParams.DISCOUNT_RATE,
0.0);
+ discount_rate =
agent.getProperties().get(ReinforcementLearningParams.DISCOUNT_RATE);
+ assertEquals(0.0, discount_rate, DELTA);
+
+ // Test setting it to back 0.9
+ agent.getProperties().set(ReinforcementLearningParams.DISCOUNT_RATE,
0.9);
+ discount_rate =
agent.getProperties().get(ReinforcementLearningParams.DISCOUNT_RATE);
+ assertEquals(0.9, discount_rate, DELTA);
+ }
+
+ @Test
+ public void testLearningPolicyParameter() throws Exception
+ {
+ // Test the default of sarsa
+ LearningPolicy extension = agent.getProperties()
+ .get(ReinforcementLearningParams.LEARNING_POLICY);
+ assertEquals(LearningPolicy.sarsa, extension);
+
+ // Test setting it to off
+
agent.getProperties().set(ReinforcementLearningParams.LEARNING_POLICY,
LearningPolicy.q);
+ extension =
agent.getProperties().get(ReinforcementLearningParams.LEARNING_POLICY);
+ assertEquals(LearningPolicy.q, extension);
+
+ // Test setting it to back to sarsa
+
agent.getProperties().set(ReinforcementLearningParams.LEARNING_POLICY,
LearningPolicy.sarsa);
+ extension =
agent.getProperties().get(ReinforcementLearningParams.LEARNING_POLICY);
+ assertEquals(LearningPolicy.sarsa, extension);
+ }
+
+ @Test
+ public void testLearningRateParameter() throws Exception
+ {
+ // Test the default of 0.3
+ double learning_rate = agent.getProperties()
+ .get(ReinforcementLearningParams.LEARNING_RATE);
+ assertEquals(0.3, learning_rate, DELTA);
+
+ // Test setting it 0.9
+ agent.getProperties().set(ReinforcementLearningParams.LEARNING_RATE,
0.9);
+ learning_rate =
agent.getProperties().get(ReinforcementLearningParams.LEARNING_RATE);
+ assertEquals(0.9, learning_rate, DELTA);
+
+ // Test setting it to 0.1
+ agent.getProperties().set(ReinforcementLearningParams.LEARNING_RATE,
0.1);
+ learning_rate =
agent.getProperties().get(ReinforcementLearningParams.LEARNING_RATE);
+ assertEquals(0.1, learning_rate, DELTA);
+
+ // Test setting it to back 0.3
+ agent.getProperties().set(ReinforcementLearningParams.LEARNING_RATE,
0.3);
+ learning_rate =
agent.getProperties().get(ReinforcementLearningParams.LEARNING_RATE);
+ assertEquals(0.3, learning_rate, DELTA);
+ }
+
+ @Test
+ public void testHrlDiscountParameter() throws Exception
+ {
+ // Test the default of off
+ HrlDiscount hrl_discount =
agent.getProperties().get(ReinforcementLearningParams.HRL_DISCOUNT);
+ assertEquals(HrlDiscount.off, hrl_discount);
+
+ // Test setting it to on
+ agent.getProperties().set(ReinforcementLearningParams.HRL_DISCOUNT,
HrlDiscount.on);
+ hrl_discount =
agent.getProperties().get(ReinforcementLearningParams.HRL_DISCOUNT);
+ assertEquals(HrlDiscount.on, hrl_discount);
+
+ // Test setting it back to off
+ agent.getProperties().set(ReinforcementLearningParams.HRL_DISCOUNT,
HrlDiscount.off);
+ hrl_discount =
agent.getProperties().get(ReinforcementLearningParams.HRL_DISCOUNT);
+ assertEquals(HrlDiscount.off, hrl_discount);
+ }
+
+ @Test
+ public void testEligibilityTraceDecayRateParameter() throws Exception
+ {
+ // Test the default of 0.0
+ double discount_rate = agent.getProperties()
+ .get(ReinforcementLearningParams.ET_DECAY_RATE);
+ assertEquals(0.0, discount_rate, DELTA);
+
+ // Test setting it 0.9
+ agent.getProperties().set(ReinforcementLearningParams.ET_DECAY_RATE,
0.9);
+ discount_rate =
agent.getProperties().get(ReinforcementLearningParams.ET_DECAY_RATE);
+ assertEquals(0.9, discount_rate, DELTA);
+
+ // Test setting it to 0.1
+ agent.getProperties().set(ReinforcementLearningParams.ET_DECAY_RATE,
0.1);
+ discount_rate =
agent.getProperties().get(ReinforcementLearningParams.ET_DECAY_RATE);
+ assertEquals(0.1, discount_rate, DELTA);
+
+ // Test setting it to back 0.0
+ agent.getProperties().set(ReinforcementLearningParams.ET_DECAY_RATE,
0.0);
+ discount_rate =
agent.getProperties().get(ReinforcementLearningParams.ET_DECAY_RATE);
+ assertEquals(0.0, discount_rate, DELTA);
+ }
+
+ @Test
+ public void testEligibilityTraceToleranceParameter() throws Exception
+ {
+ // Test the default of 0.001
+ double et_tolerance = agent.getProperties()
+ .get(ReinforcementLearningParams.ET_TOLERANCE);
+ assertEquals(0.001, et_tolerance, DELTA);
+
+ // Test setting it to 0.1
+ agent.getProperties().set(ReinforcementLearningParams.ET_TOLERANCE,
0.1);
+ et_tolerance =
agent.getProperties().get(ReinforcementLearningParams.ET_TOLERANCE);
+ assertEquals(0.1, et_tolerance, DELTA);
+
+ // Test setting it to -0.1
+ agent.getProperties().set(ReinforcementLearningParams.ET_TOLERANCE,
-0.1);
+ et_tolerance =
agent.getProperties().get(ReinforcementLearningParams.ET_TOLERANCE);
+ assertEquals(-0.1, et_tolerance, DELTA);
+
+ // Test setting it to back 0.001
+ agent.getProperties().set(ReinforcementLearningParams.ET_TOLERANCE,
0.001);
+ et_tolerance =
agent.getProperties().get(ReinforcementLearningParams.ET_TOLERANCE);
+ assertEquals(0.001, et_tolerance, DELTA);
+ }
+
+ @Test
+ public void testChunkStopParameter() throws Exception
+ {
+ // Test the default of on
+ ChunkStop chunk_stop = agent.getProperties()
+ .get(ReinforcementLearningParams.CHUNK_STOP);
+ assertEquals(ChunkStop.on, chunk_stop);
+
+ // Test setting it to off
+ agent.getProperties().set(ReinforcementLearningParams.CHUNK_STOP,
ChunkStop.off);
+ chunk_stop =
agent.getProperties().get(ReinforcementLearningParams.CHUNK_STOP);
+ assertEquals(ChunkStop.off, chunk_stop);
+
+ // Test setting it to back to on
+ agent.getProperties().set(ReinforcementLearningParams.CHUNK_STOP,
ChunkStop.on);
+ chunk_stop =
agent.getProperties().get(ReinforcementLearningParams.CHUNK_STOP);
+ assertEquals(ChunkStop.on, chunk_stop);
+ }
+
+ @Test
+ public void testDecayModeParameter() throws Exception
+ {
+ // Test the default of normal-decay
+ DecayMode extension = agent.getProperties()
+ .get(ReinforcementLearningParams.DECAY_MODE);
+ assertEquals(DecayMode.normal_decay, extension);
+
+ // Test setting it to exponential_decay
+ agent.getProperties().set(ReinforcementLearningParams.DECAY_MODE,
DecayMode.exponential_decay);
+ extension =
agent.getProperties().get(ReinforcementLearningParams.DECAY_MODE);
+ assertEquals(DecayMode.exponential_decay, extension);
+
+ // Test setting it to logarithmic_decay
+ agent.getProperties().set(ReinforcementLearningParams.DECAY_MODE,
DecayMode.logarithmic_decay);
+ extension =
agent.getProperties().get(ReinforcementLearningParams.DECAY_MODE);
+ assertEquals(DecayMode.logarithmic_decay, extension);
+
+ // Test setting it to delta_bar_delta_decay
+ agent.getProperties().set(ReinforcementLearningParams.DECAY_MODE,
DecayMode.delta_bar_delta_decay);
+ extension =
agent.getProperties().get(ReinforcementLearningParams.DECAY_MODE);
+ assertEquals(DecayMode.delta_bar_delta_decay, extension);
+
+ // Test setting it to back to normal_decay
+ agent.getProperties().set(ReinforcementLearningParams.DECAY_MODE,
DecayMode.normal_decay);
+ extension =
agent.getProperties().get(ReinforcementLearningParams.DECAY_MODE);
+ assertEquals(DecayMode.normal_decay, extension);
+ }
+
+ @Test
+ public void testMetaParameter() throws Exception
+ {
+ // Test the default of off
+ Meta meta =
agent.getProperties().get(ReinforcementLearningParams.META);
+ assertEquals(Meta.off, meta);
+
+ // Test setting it to on
+ agent.getProperties().set(ReinforcementLearningParams.META, Meta.on);
+ meta = agent.getProperties().get(ReinforcementLearningParams.META);
+ assertEquals(Meta.on, meta);
+
+ // Test setting it back to off
+ agent.getProperties().set(ReinforcementLearningParams.META, Meta.off);
+ meta = agent.getProperties().get(ReinforcementLearningParams.META);
+ assertEquals(Meta.off, meta);
+ }
+
+ @Test
+ public void testMetaLearningRateParameter() throws Exception
+ {
+ // Test the default of 0.1
+ double meta_learning_rate = agent.getProperties()
+ .get(ReinforcementLearningParams.META_LEARNING_RATE);
+ assertEquals(0.1, meta_learning_rate, DELTA);
+
+ // Test setting it 0.9
+
agent.getProperties().set(ReinforcementLearningParams.META_LEARNING_RATE,
0.9);
+ meta_learning_rate =
agent.getProperties().get(ReinforcementLearningParams.META_LEARNING_RATE);
+ assertEquals(0.9, meta_learning_rate, DELTA);
+
+ // Test setting it to 0.3
+
agent.getProperties().set(ReinforcementLearningParams.META_LEARNING_RATE,
0.3);
+ meta_learning_rate =
agent.getProperties().get(ReinforcementLearningParams.META_LEARNING_RATE);
+ assertEquals(0.3, meta_learning_rate, DELTA);
+
+ // Test setting it to back 0.1
+
agent.getProperties().set(ReinforcementLearningParams.META_LEARNING_RATE,
0.1);
+ meta_learning_rate =
agent.getProperties().get(ReinforcementLearningParams.META_LEARNING_RATE);
+ assertEquals(0.1, meta_learning_rate, DELTA);
+ }
+
+ @Test
+ public void testUpdateLogPathParameter() throws Exception
+ {
+ // Test the default of ""
+ String update_log_path = agent.getProperties()
+ .get(ReinforcementLearningParams.UPDATE_LOG_PATH);
+ assertEquals("", update_log_path);
+
+ // Test setting it "test.log"
+
agent.getProperties().set(ReinforcementLearningParams.UPDATE_LOG_PATH, "test.log");
+ update_log_path =
agent.getProperties().get(ReinforcementLearningParams.UPDATE_LOG_PATH);
+ assertEquals("test.log", update_log_path);
+
+ // Test setting it to "C:\Soar\Test\test.log"
+
agent.getProperties().set(ReinforcementLearningParams.UPDATE_LOG_PATH, "C:\\Soar\\Test\\test.log");
+ update_log_path =
agent.getProperties().get(ReinforcementLearningParams.UPDATE_LOG_PATH);
+ assertEquals("C:\\Soar\\Test\\test.log", update_log_path);
+
+ // Test setting it to back ""
+
agent.getProperties().set(ReinforcementLearningParams.UPDATE_LOG_PATH, "");
+ update_log_path =
agent.getProperties().get(ReinforcementLearningParams.UPDATE_LOG_PATH);
+ assertEquals("", update_log_path);
+ }
+
+ @Test
+ public void testApoptosisParameter() throws Exception
+ {
+ // Test the default of none
+ ApoptosisChoices apoptosis = agent.getProperties()
+ .get(ReinforcementLearningParams.APOPTOSIS);
+ assertEquals(ApoptosisChoices.none, apoptosis);
+
+ // Test setting it to chunks
+ agent.getProperties().set(ReinforcementLearningParams.APOPTOSIS,
ApoptosisChoices.chunks);
+ apoptosis =
agent.getProperties().get(ReinforcementLearningParams.APOPTOSIS);
+ assertEquals(ApoptosisChoices.chunks, apoptosis);
+
+ // Test setting it to rl-chunks
+ agent.getProperties().set(ReinforcementLearningParams.APOPTOSIS,
ApoptosisChoices.rl_chunks);
+ apoptosis =
agent.getProperties().get(ReinforcementLearningParams.APOPTOSIS);
+ assertEquals(ApoptosisChoices.rl_chunks, apoptosis);
+
+ // Test setting it to back to normal_decay
+ agent.getProperties().set(ReinforcementLearningParams.APOPTOSIS,
ApoptosisChoices.none);
+ apoptosis =
agent.getProperties().get(ReinforcementLearningParams.APOPTOSIS);
+ assertEquals(ApoptosisChoices.none, apoptosis);
+ }
+
+ @Test
+ public void testApoptosisDecayParameter() throws Exception
+ {
+ // Test the default of 0.5
+ double apoptosis_decay = agent.getProperties()
+ .get(ReinforcementLearningParams.APOPTOSIS_DECAY);
+ assertEquals(0.5, apoptosis_decay, DELTA);
+
+ // Test setting it to 0.1
+
agent.getProperties().set(ReinforcementLearningParams.APOPTOSIS_DECAY, 0.1);
+ apoptosis_decay =
agent.getProperties().get(ReinforcementLearningParams.APOPTOSIS_DECAY);
+ assertEquals(0.1, apoptosis_decay, DELTA);
+
+ // Test setting it to 0.0
+
agent.getProperties().set(ReinforcementLearningParams.APOPTOSIS_DECAY, 0.0);
+ apoptosis_decay =
agent.getProperties().get(ReinforcementLearningParams.APOPTOSIS_DECAY);
+ assertEquals(0.0, apoptosis_decay, DELTA);
+
+ // Test setting it to 0.9
+
agent.getProperties().set(ReinforcementLearningParams.APOPTOSIS_DECAY, 0.9);
+ apoptosis_decay =
agent.getProperties().get(ReinforcementLearningParams.APOPTOSIS_DECAY);
+ assertEquals(0.9, apoptosis_decay, DELTA);
+
+ // Test setting it to back 0.5
+
agent.getProperties().set(ReinforcementLearningParams.APOPTOSIS_DECAY, 0.5);
+ apoptosis_decay =
agent.getProperties().get(ReinforcementLearningParams.APOPTOSIS_DECAY);
+ assertEquals(0.5, apoptosis_decay, DELTA);
+ }
+
+ @Test
+ public void testApoptosisThreshParameter() throws Exception
+ {
+ // Test the default of -2.0
+ double apoptosis_thresh = agent.getProperties()
+ .get(ReinforcementLearningParams.APOPTOSIS_THRESH);
+ assertEquals(-2.0, apoptosis_thresh, DELTA);
+
+ // Test setting it to 2.0
+
agent.getProperties().set(ReinforcementLearningParams.APOPTOSIS_THRESH,
2.0);
+ apoptosis_thresh =
agent.getProperties().get(ReinforcementLearningParams.APOPTOSIS_THRESH);
+ assertEquals(2.0, apoptosis_thresh, DELTA);
+
+ // Test setting it to 0.0
+
agent.getProperties().set(ReinforcementLearningParams.APOPTOSIS_THRESH,
0.0);
+ apoptosis_thresh =
agent.getProperties().get(ReinforcementLearningParams.APOPTOSIS_THRESH);
+ assertEquals(0.0, apoptosis_thresh, DELTA);
+
+ // Test setting it to 0.9
+
agent.getProperties().set(ReinforcementLearningParams.APOPTOSIS_THRESH,
0.9);
+ apoptosis_thresh =
agent.getProperties().get(ReinforcementLearningParams.APOPTOSIS_THRESH);
+ assertEquals(0.9, apoptosis_thresh, DELTA);
+
+ // Test setting it to back -2.0
+
agent.getProperties().set(ReinforcementLearningParams.APOPTOSIS_THRESH,
-2.0);
+ apoptosis_thresh =
agent.getProperties().get(ReinforcementLearningParams.APOPTOSIS_THRESH);
+ assertEquals(-2.0, apoptosis_thresh, DELTA);
+ }
+
+ @Test
+ public void testTraceParameter() throws Exception
+ {
+ // Test the default of off
+ Trace trace =
agent.getProperties().get(ReinforcementLearningParams.TRACE);
+ assertEquals(Trace.off, trace);
+
+ // Test setting it to on
+ agent.getProperties().set(ReinforcementLearningParams.TRACE,
Trace.on);
+ trace = agent.getProperties().get(ReinforcementLearningParams.TRACE);
+ assertEquals(Trace.on, trace);
+
+ // Test setting it back to off
+ agent.getProperties().set(ReinforcementLearningParams.TRACE,
Trace.off);
+ trace = agent.getProperties().get(ReinforcementLearningParams.TRACE);
+ assertEquals(Trace.off, trace);
+ }
+
+}
=======================================
---
/jsoar-core/src/main/java/org/jsoar/kernel/learning/rl/ReinforcementLearningParams.java
Tue Aug 27 21:41:42 2013 UTC
+++
/jsoar-core/src/main/java/org/jsoar/kernel/learning/rl/ReinforcementLearningParams.java
Wed Aug 28 13:43:59 2013 UTC
@@ -52,8 +52,43 @@
* logarithmic_decay: rate = rate / log(# updates for this rule)
* Miller, 11/14/2011
*/
- public static enum DecayMode { normal_decay, exponential_decay,
- logarithmic_decay, delta_bar_delta_decay }
+// public static enum DecayMode { normal_decay, exponential_decay,
+// logarithmic_decay, delta_bar_delta_decay }
+ public static enum DecayMode
+ {
+ normal_decay("normal"), exponential_decay("exp"),
+ logarithmic_decay("log"), delta_bar_delta_decay("delta-bar-delta");
+
+ // some options have dashes in them, but we can't put those in the
enum name, so we need a mapping
+ private final String realName;
+
+ private DecayMode()
+ {
+ this.realName = this.name();
+ }
+
+ private DecayMode(String realName)
+ {
+ this.realName = realName;
+ }
+
+ @Override
+ public String toString()
+ {
+ return realName;
+ }
+
+ public static DecayMode getEnum(String value)
+ {
+ if(value == null)
+ throw new IllegalArgumentException();
+ for(DecayMode dm : DecayMode.values())
+ {
+ if(value.equals(dm.toString())) return dm;
+ }
+ throw new IllegalArgumentException();
+ }
+ }

/**
* Options for meta
@@ -67,7 +102,7 @@
* a name with a dash in it.
*/
// static enum ApoptosisChoices { none, chunks, rl_chunks };
- static enum ApoptosisChoices
+ public static enum ApoptosisChoices
{
none, chunks, rl_chunks("rl-chunks");

@@ -107,6 +142,7 @@
*/
public static enum Trace { on, off };

+
private static final String PREFIX = "rl.";

private static <T> PropertyKey.Builder<T> key(String name, Class<T>
type)
=======================================
--- /jsoar-core/src/test/java/org/jsoar/kernel/RLTests.java Wed Aug 21
19:36:54 2013 UTC
+++ /jsoar-core/src/test/java/org/jsoar/kernel/RLTests.java Wed Aug 28
13:43:59 2013 UTC
@@ -1,7 +1,22 @@
/*
* Copyright (c) 2008 Dave Ray <dav...@gmail.com>
+ *
+ * Created on Sep 19, 2008
+ *
+ * Updated by PL, 28 August 2013
*
- * Created on Sep 19, 2008
+ * This test runs some simple Soar code that is found in
+ * /org/jsoar/kernel/RLTests_testRLUnit.soar and then
+ * checks the numerical results.
+ *
+ * Two possible sets of numbers are checked, depending
+ * on whether the hrl-discount parameter is on or off.
+ * Two tests here set the parameter first and then run
+ * and check the resulting numbers.
+ *
+ * This test is somewhat complementary to the one in
+ * org.jsoar.kernel.learning.ReinforcementLearningTest.java,
+ * which uses the same .soar file.
*/
package org.jsoar.kernel;

=======================================
---
/jsoar-core/src/test/java/org/jsoar/kernel/learning/rl/ReinforcementLearningTest.java
Thu Aug 22 19:15:39 2013 UTC
+++
/jsoar-core/src/test/java/org/jsoar/kernel/learning/rl/ReinforcementLearningTest.java
Wed Aug 28 13:43:59 2013 UTC
@@ -1,7 +1,20 @@
/*
* Copyright (c) 2010 Dave Ray <dav...@gmail.com>
+ *
+ * Created on Sep 2, 2010
+ *
+ * Updated by PL, 28 August 2013
*
- * Created on Sep 2, 2010
+ * This test runs some simple Soar code that is found in
+ * /org/jsoar/kernel/RLTests_testRLUnit.soar and then
+ * checks the numerical results.
+ *
+ * Two possible sets of numbers are checked, depending
+ * on whether the hrl-discount parameter is on or off.
+ * You can set this parameter in the Soar file.
+ *
+ * This test is somewhat complementary to the one in
+ * org.jsoar.kernel.RLTests.java, which uses the same .soar file.
*/
package org.jsoar.kernel.learning.rl;


==============================================================================
Revision: da367c830924
Author: Peter Lindes <peter....@soartech.com>
Date: Wed Aug 28 13:56:01 2013 UTC
Log: Merge branch 'master' into rl-update

http://code.google.com/p/jsoar/source/detail?r=da367c830924

Modified:
/jsoar-core/src/main/java/org/jsoar/kernel/Agent.java

=======================================
--- /jsoar-core/src/main/java/org/jsoar/kernel/Agent.java Wed Aug 21
14:57:12 2013 UTC
+++ /jsoar-core/src/main/java/org/jsoar/kernel/Agent.java Wed Aug 28
13:56:01 2013 UTC
@@ -557,7 +557,16 @@
{
return info.getValue();
}
- if(t.length() < 2 || !Character.isLetter(t.charAt(0))) return null;
+
+ if (t.charAt(0) == '@')
+ {
+ t = t.substring(1);
+ }
+
+ if (t.length() < 2 || !Character.isLetter(t.charAt(0)))
+ {
+ return null;
+ }

final char letter = Character.toUpperCase(t.charAt(0));
long number = 1;
@@ -922,6 +931,23 @@
// Temporarily disable tracing
boolean traceState = trace.isEnabled();
trace.setEnabled(false);
+
+ try
+ {
+ epmem.epmem_close();
+ }
+ catch (SoarException e2)
+ {
+ throw new RuntimeException("EpMem failed to close.", e2);
+ }
+ try
+ {
+ smem.smem_close();
+ }
+ catch (SoarException e1)
+ {
+ throw new RuntimeException("SMem failed to close.", e1);
+ }

boolean wma_was_enabled = wma.wma_enabled();
wma.getParams().activation.set(ActivationChoices.off);

==============================================================================
Revision: 129258dc0dc7
Author: bob.marinier <bob.ma...@soartech.com>
Date: Fri Aug 30 00:24:21 2013 UTC
Log: Fixed npe when an operator doesn't have a name.

http://code.google.com/p/jsoar/source/detail?r=129258dc0dc7

Modified:
/jsoar-debugger/src/main/java/org/jsoar/debugger/GoalStackView.java

=======================================
--- /jsoar-debugger/src/main/java/org/jsoar/debugger/GoalStackView.java Mon
Sep 13 00:58:01 2010 UTC
+++ /jsoar-debugger/src/main/java/org/jsoar/debugger/GoalStackView.java Fri
Aug 30 00:24:21 2013 UTC
@@ -142,7 +142,14 @@

final Symbol name = g.getOperatorName();

- return new Entry(op, op + " (" + name.toString() + ")");
+ String label = op.toString();
+
+ if(name != null)
+ {
+ label += " (" + name.toString() + ")";
+ }
+
+ return new Entry(op, label);
}

private void updateModel(List<Entry> newStack)

==============================================================================
Revision: d6e7f6961a57
Author: ACNickels <alex.n...@soartech.com>
Date: Thu Sep 12 19:12:45 2013 UTC
Log: Fixed a crash bug in epmem caused by removing Y shaped structures.
Added a unit test that covers it.

http://code.google.com/p/jsoar/source/detail?r=d6e7f6961a57

Added:

/jsoar-core/src/test/resources/org/jsoar/kernel/epmem/EpMemFunctionalTests_testYRemoval.soar
Modified:
/jsoar-core/src/main/java/org/jsoar/kernel/epmem/DefaultEpisodicMemory.java
/jsoar-core/src/test/java/org/jsoar/kernel/epmem/EpMemFunctionalTests.java

=======================================
--- /dev/null
+++
/jsoar-core/src/test/resources/org/jsoar/kernel/epmem/EpMemFunctionalTests_testYRemoval.soar
Thu Sep 12 19:12:45 2013 UTC
@@ -0,0 +1,148 @@
+watch 1
+epmem --set learning on
+epmem --set trigger dc
+epmem --set phase output
+epmem --set exclusions superstate
+epmem --set exclusions io
+epmem --set exclusions reward-link
+epmem --set exclusions topstate
+epmem --set exclusions type
+
+# elaborations
+
+sp {all*elaborate*topstate
+ (state <s> ^superstate.topstate <val>)
+-->
+ (<s> ^topstate <val>)
+}
+
+sp {all*elaborate*name
+ (state <s> ^superstate.operator.name <name>)
+-->
+ (<s> ^name <name>)
+}
+
+# init-agent
+
+sp {topstate*propose*init-agent
+ (state <s> ^superstate nil
+ -^name)
+-->
+ (<s> ^operator <op> +)
+ (<op> ^name init-agent)
+}
+
+sp {topstate*apply*init-agent
+ (state <s> ^operator.name init-agent)
+-->
+ (<s> ^topstate <s>
+ ^name bolt-agent
+ ^status add)
+}
+
+# add
+
+sp {topstate*propose*add
+ (state <s> ^name bolt-agent
+ ^status add)
+-->
+ (<s> ^operator.name add)
+}
+
+sp {add*elaborate*new-thing
+ (state <s> ^name add
+ ^topstate.new-thing <seg>)
+-->
+ (<s> ^new-thing <seg>)
+}
+
+# add.create
+
+sp {add*propose*create
+ (state <s> ^name add
+ -^interpreted)
+-->
+ (<s> ^operator.name create)
+}
+
+sp {add*apply*create
+ (state <s> ^name add
+ ^operator.name create
+ ^topstate <ts>)
+-->
+ (<ts> ^new-thing.old1.old2 <help>)
+ (<s> ^interpreted yes)
+}
+
+# add.store
+
+sp {add*propose*store
+ (state <s> ^name add
+ ^new-thing <info>)
+-->
+ (<s> ^operator.name store)
+}
+
+sp {add*apply*store
+ (state <s> ^name add
+ ^operator.name store
+ ^new-thing <info>
+ ^topstate <ts>)
+ (<ts> ^new-thing <new-thing>
+ ^status add)
+ (<new-thing> ^old1 <feature>)
+-->
+ (<ts> ^new-thing <info> -
+ ^thing <thing>
+ ^status add -
+ ^status remove)
+ (<thing> ^new1 <new-thing>
+ ^new2 <feature>)
+}
+
+# remove
+
+sp {topstate*propose*remove
+ (state <s> ^name bolt-agent
+ ^status remove)
+-->
+ (<s> ^operator.name remove)
+}
+
+# remove.unstore
+
+sp {remove*propose*unstore
+ (state <s> ^name remove
+ ^topstate <ts>)
+ (<ts> ^thing <thing>)
+-->
+ (<s> ^operator <o> +)
+ (<o> ^name unstore
+ ^thing <thing>)
+}
+
+sp {remove*apply*unstore
+ (state <s> ^name remove
+ ^operator.name unstore
+ ^topstate <ts>)
+ (<ts> ^thing <thing>
+ ^status remove)
+-->
+ (<ts> ^thing <thing> -
+ ^status remove -
+ ^status complete)
+}
+
+sp {topstate*propose*succeed
+ (state <s> ^name bolt-agent
+ ^status complete)
+-->
+ (<s> ^operator <o> +)
+ (<o> ^name succeed)
+}
+
+sp {topstate*apply*succeed
+ (state <s> ^operator.name succeed)
+-->
+ (succeeded)
+}
=======================================
---
/jsoar-core/src/main/java/org/jsoar/kernel/epmem/DefaultEpisodicMemory.java
Thu Aug 22 18:21:25 2013 UTC
+++
/jsoar-core/src/main/java/org/jsoar/kernel/epmem/DefaultEpisodicMemory.java
Thu Sep 12 19:12:45 2013 UTC
@@ -6688,20 +6688,9 @@
if(my_refs.contains(w))
{
my_refs.remove(w);
-
- // recurse if no incoming edges from top-state (i.e.
not in transitive closure of top-state)
- boolean recurse = true;
- for(WmeImpl rc_it : my_refs)
- {
- //if ( ( !(*rc_it) ) || ( (*rc_it)->id->id.level
== my_agent->top_state->id.level ) )
- if(rc_it == null ||
rc_it.id.level==decider.top_state.level)
- {
- recurse = false;
- break;
- }
- }
-
- if ( recurse )
+
+ // recurse if no incoming edges from epmem
+ if(my_refs.isEmpty())
{
my_refs.clear();
epmem_id_removes.push(w.value);
=======================================
---
/jsoar-core/src/test/java/org/jsoar/kernel/epmem/EpMemFunctionalTests.java
Thu Aug 22 18:21:25 2013 UTC
+++
/jsoar-core/src/test/java/org/jsoar/kernel/epmem/EpMemFunctionalTests.java
Thu Sep 12 19:12:45 2013 UTC
@@ -166,6 +166,11 @@
{
runTest("testEpMemEncodeSelection_WMA", 5);
}
+
+ @Test
+ public void testEpMemYRemoval() throws Exception{
+ runTest("testYRemoval", 9);
+ }

public void testEpMemSoarGroupTests() throws Exception
{

==============================================================================
Revision: d0c9cb3d8224
Author: bob.marinier <bob.ma...@soartech.com>
Date: Fri Sep 13 19:45:27 2013 UTC
Log: Updated epmem test from UM (currently fails due to unknown bug in
jsoar). Not actually activated in unit tests since for now.

http://code.google.com/p/jsoar/source/detail?r=d0c9cb3d8224

Modified:

/jsoar-core/src/test/resources/org/jsoar/kernel/epmem/EpMemFunctionalTests_testEpMemSoarGroupTests.soar

=======================================
---
/jsoar-core/src/test/resources/org/jsoar/kernel/epmem/EpMemFunctionalTests_testEpMemSoarGroupTests.soar
Mon Aug 19 16:47:50 2013 UTC
+++
/jsoar-core/src/test/resources/org/jsoar/kernel/epmem/EpMemFunctionalTests_testEpMemSoarGroupTests.soar
Fri Sep 13 19:45:27 2013 UTC
@@ -193,7 +193,8 @@
(<c-14> ^query <q-14>
^before 22)
(<q-14> ^parity <parity>)
- (<r-14> ^failure <q-14>)
+ (<r-14> ^graph-match 0
+ ^match-cardinality 0)

# FIXME activation
}
@@ -431,7 +432,7 @@
^fail 0)
-->
(<s> ^report-status overview -)
- (write (crlf))
+ (write (crlf) succeeeded)
(succeeded)
}

@@ -443,6 +444,6 @@
^fail <> 0)
-->
(<s> ^report-status overview -)
- (write (crlf))
+ (write (crlf) failed)
(failed)
}

==============================================================================
Revision: ec230dc4c9d8
Author: Patrick DeHaan <patrick...@soartech.com>
Date: Thu May 23 19:20:04 2013 UTC
Log: avoiding possible NPEs

- getTagName() shouldn't return null according to documentation but has
been observed to do so
- getTextContent() is documented as returning null under certain
circumstances and has been observed to do so

http://code.google.com/p/jsoar/source/detail?r=ec230dc4c9d8

Modified:
/jsoar-core/src/main/java/org/jsoar/kernel/io/xml/SoarTechXmlToWme.java

=======================================
--- /jsoar-core/src/main/java/org/jsoar/kernel/io/xml/SoarTechXmlToWme.java
Mon Sep 13 14:30:50 2010 UTC
+++ /jsoar-core/src/main/java/org/jsoar/kernel/io/xml/SoarTechXmlToWme.java
Thu May 23 19:20:04 2013 UTC
@@ -121,7 +121,13 @@

final Element kid = (Element) node;
final String linkTo = kid.getAttribute(SoarTechWmeToXml.LINK);
- final Symbol attribute = syms.createString(kid.getTagName());
+ final String tagName = kid.getTagName();
+ if (null == tagName)
+ {
+ logger.warn("null tagName on node " + node);
+ continue;
+ }
+ final Symbol attribute = syms.createString(tagName);
if(linkTo.length() == 0)
{
final Symbol value = getValue(kid);
@@ -160,7 +166,11 @@
value = element.getTextContent();
}

- if(SoarTechWmeToXml.DOUBLE.equals(type))
+ if (null == value)
+ {
+ return syms.createString("");
+ }
+ else if(SoarTechWmeToXml.DOUBLE.equals(type))
{
return syms.createDouble(Double.valueOf(value));
}

==============================================================================
Revision: fcef0ef80357
Author: Jonathan Voigt <voi...@gmail.com>
Date: Wed Sep 25 15:30:41 2013 UTC
Log: Convert RL update-log-path to use Java 6 File I/O

http://code.google.com/p/jsoar/source/detail?r=fcef0ef80357

Modified:

/jsoar-core/src/main/java/org/jsoar/kernel/learning/rl/ReinforcementLearning.java

=======================================
---
/jsoar-core/src/main/java/org/jsoar/kernel/learning/rl/ReinforcementLearning.java
Tue Aug 27 19:36:21 2013 UTC
+++
/jsoar-core/src/main/java/org/jsoar/kernel/learning/rl/ReinforcementLearning.java
Wed Sep 25 15:30:41 2013 UTC
@@ -6,11 +6,9 @@
package org.jsoar.kernel.learning.rl;

import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -1002,12 +1000,12 @@
// Log update to file if the log file has been set
String log_path = params.update_log_path.get();
if (!log_path.isEmpty()) {
- Path log = Paths.get(log_path);
+ File log = new File(log_path);
BufferedWriter writer = null;
try {
// TODO: Does this actually append to the file?
// If not, fix so it does
- writer = Files.newBufferedWriter(log,
StandardCharsets.UTF_8);
+ writer = new BufferedWriter(new
FileWriter(log));
writer.write(String.format("%s%n", ss));
} catch(IOException e) {
e.printStackTrace();

==============================================================================
Revision: f9ce0195e28a
Author: bob.marinier <bob.ma...@soartech.com>
Date: Wed Sep 25 20:28:00 2013 UTC
Log: Undid part of commit 07ff79c0510a823e002bf8c34e99923b671af67e in
order to make source work with spaces in path

That commit claimed that it was fixing a problem with spaces in source
commands, but it appears to have caused this more significant problem.
My specific case was sourcing a file that sourced another file using a
relative path that included a lot of "../" such that, when expanded to an
absolute path, it contained spaces.

http://code.google.com/p/jsoar/source/detail?r=f9ce0195e28a

Modified:
/jsoar-core/src/main/java/org/jsoar/kernel/commands/SourceCommand.java

=======================================
--- /jsoar-core/src/main/java/org/jsoar/kernel/commands/SourceCommand.java
Wed Aug 14 14:15:48 2013 UTC
+++ /jsoar-core/src/main/java/org/jsoar/kernel/commands/SourceCommand.java
Wed Sep 25 20:28:00 2013 UTC
@@ -5,7 +5,6 @@

import java.io.File;
import java.net.MalformedURLException;
-import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
@@ -355,7 +354,7 @@
{
try
{
- return (new URI(null, url.toString(),
null)).normalize().toURL();
+ return url.toURI().normalize().toURL();
}
catch (MalformedURLException e)
{

==============================================================================
Revision: f6af13630c54
Author: ACNickels <alex.n...@soartech.com>
Date: Fri Sep 27 18:35:31 2013 UTC
Log: smem printing updates

http://code.google.com/p/jsoar/source/detail?r=f6af13630c54

Modified:
/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemory.java

/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemoryCommand.java

=======================================
---
/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemory.java
Thu Aug 22 17:14:22 2013 UTC
+++
/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemory.java
Fri Sep 27 18:35:31 2013 UTC
@@ -4685,19 +4685,20 @@
return_val.append(return_val2.toString());
}

- Set<Long /* smem_lti_id */> _smem_print_lti(long /* smem_lti_id
*/lti_id, char lti_letter, long lti_number, double lti_act, ByRef<String>
return_val) throws SQLException
+ Set<Long /* smem_lti_id */> _smem_print_lti(long /* smem_lti_id
*/lti_id, char lti_letter, long lti_number, double lti_act, StringBuilder
return_val) throws SQLException
{
Set<Long /* smem_lti_id */> next = new LinkedHashSet<Long>();

- String temp_str, temp_str2 = null;
+ String temp_str;
+ StringBuilder temp_str2 = null;

Map<String, List<String>> augmentations = new
LinkedHashMap<String, List<String>>();

PreparedStatement expand_q = db.web_expand;

- return_val.value += "(@";
- return_val.value += lti_letter;
- return_val.value += lti_number;
+ return_val.append("(@");
+ return_val.append(lti_letter);
+ return_val.append(lti_number);

expand_q.setLong(1, lti_id);

@@ -4727,13 +4728,13 @@
// identifier vs. constant
if (rs.getLong(6 + 1) != SMEM_AUGMENTATIONS_NULL)
{
- temp_str2 = "@";
+ temp_str2 = new StringBuilder("@");

// soar letter
- temp_str2 += (char) rs.getInt(4 + 1);
+ temp_str2.append((char) rs.getInt(4 + 1));

// number
- temp_str2 += rs.getLong(5 + 1);
+ temp_str2.append(rs.getLong(5 + 1));

// add to next
next.add(rs.getLong(6 + 1));
@@ -4743,13 +4744,13 @@
switch (rs.getInt(2 + 1))
{
case Symbols.SYM_CONSTANT_SYMBOL_TYPE:
- temp_str2 = smem_reverse_hash_str(rs.getLong(3 +
1));
+ temp_str2 = new
StringBuilder(smem_reverse_hash_str(rs.getLong(3 + 1)));
break;
case Symbols.INT_CONSTANT_SYMBOL_TYPE:
- temp_str2 = (new
Integer(smem_reverse_hash_int(rs.getLong(3 + 1)))).toString();
+ temp_str2 = new StringBuilder((new
Integer(smem_reverse_hash_int(rs.getLong(3 + 1)))).toString());
break;
case Symbols.FLOAT_CONSTANT_SYMBOL_TYPE:
- temp_str2 = (new
Double(smem_reverse_hash_float(rs.getLong(3 + 1)))).toString();
+ temp_str2 = new StringBuilder((new
Double(smem_reverse_hash_float(rs.getLong(3 + 1)))).toString());
break;

default:
@@ -4762,8 +4763,11 @@
{
augmentations.put(temp_str, new ArrayList<String>());
}
-
- augmentations.get(temp_str).add(temp_str2);
+ if(temp_str2 != null){
+ augmentations.get(temp_str).add(temp_str2.toString());
+ }else{
+ augmentations.get(temp_str).add(temp_str);
+ }
}
}
finally
@@ -4775,31 +4779,31 @@
{
for (Map.Entry<String, List<String>> lti_slot :
augmentations.entrySet())
{
- return_val.value += " ^";
- return_val.value += lti_slot.getKey();
+ return_val.append(" ^");
+ return_val.append(lti_slot.getKey());

for (String slot_val : lti_slot.getValue())
{
- return_val.value += " ";
- return_val.value += slot_val;
+ return_val.append(" ");
+ return_val.append(slot_val);
}
}
}
augmentations.clear();

- return_val.value += " [";
+ return_val.append(" [");
if (lti_act >= 0)
{
- return_val.value += "+";
+ return_val.append("+");
}
- return_val.value += lti_act;
- return_val.value += "]";
- return_val.value += ")\n";
+ return_val.append(lti_act);
+ return_val.append("]");
+ return_val.append(")\n");

return next;
}

- void smem_print_store(ByRef<String> return_val) throws SoarException
+ void smem_print_store(StringBuilder return_val) throws SoarException
{
// vizualizing the store requires an open semantic database
smem_attach();
@@ -4893,7 +4897,7 @@
}
}

- void smem_print_lti(long /* smem_lti_id */lti_id, int depth,
ByRef<String> return_val) throws SoarException
+ void smem_print_lti(long /* smem_lti_id */lti_id, int depth,
StringBuilder return_val) throws SoarException
{
Set<Long /* smem_lti_id */> visited = new LinkedHashSet<Long>();

@@ -4921,7 +4925,7 @@
// output leading spaces ala depth
for (i = 1; i < c.getDepth(); i++)
{
- return_val.value += " ";
+ return_val.append(" ");
}

// get lti info
=======================================
---
/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemoryCommand.java
Thu Aug 22 17:14:22 2013 UTC
+++
/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemoryCommand.java
Fri Sep 27 18:35:31 2013 UTC
@@ -611,6 +611,8 @@
long /*smem_lti_id*/ lti_id = 0 /*NIL*/;
int depth = 1;

+ smem.smem_attach();
+
if (args.length > i && args.length <= i + 3)
{
char name_letter = 0;
@@ -633,7 +635,8 @@
}
}

- ByRef<String> viz = new ByRef<String>(new String());
+ //ByRef<String> viz = new ByRef<String>(new String());
+ StringBuilder viz = new StringBuilder("");

if (lti_id == 0)
{
@@ -644,13 +647,13 @@
smem.smem_print_lti(lti_id, depth, viz);
}

- if (viz.value.length() == 0)
+ if (viz.length() == 0)
{
throw new SoarException("SMem| Semantic memory is empty.");
}

pw.printf(PrintHelper.generateHeader("Semantic Memory", 40));
- pw.printf(viz.value);
+ pw.printf(viz.toString());
}
else
{

==============================================================================
Revision: 8c86e94f8af3
Author: bob.marinier <bob.ma...@soartech.com>
Date: Thu Sep 26 17:00:27 2013 UTC
Log: Updated urls and help command so it brings up the correct pages

http://code.google.com/p/jsoar/source/detail?r=8c86e94f8af3

Modified:
/jsoar-core/src/main/java/org/jsoar/kernel/commands/HelpCommand.java
/jsoar-core/src/main/resources/jsoar.properties

=======================================
--- /jsoar-core/src/main/java/org/jsoar/kernel/commands/HelpCommand.java
Mon Sep 13 22:36:24 2010 UTC
+++ /jsoar-core/src/main/java/org/jsoar/kernel/commands/HelpCommand.java
Thu Sep 26 17:00:27 2013 UTC
@@ -43,7 +43,7 @@
else
{
String command = args[1];
- url = resources.getString("help.url.base") + "#" + command;
+ url = resources.getString("help.url.base") + command;
}

try
=======================================
--- /jsoar-core/src/main/resources/jsoar.properties Tue May 11 00:26:19
2010 UTC
+++ /jsoar-core/src/main/resources/jsoar.properties Thu Sep 26 17:00:27
2013 UTC
@@ -1,6 +1,6 @@

-jsoar.site.url=http://jsoar.googlecode.com
+jsoar.site.url=http://github.com/soartech/jsoar/wiki
msoar.site.url=http://msoar.org

-help.url.base=http://code.google.com/p/soar/wiki/CommandLineInterface
-help.url.all=http://code.google.com/p/soar/wiki/CommandLineInterface
+help.url.base=http://code.google.com/p/soar/wiki/cmd_
+help.url.all=http://code.google.com/p/soar/wiki/CommandIndex

==============================================================================
Revision: 6be715af375a
Author: bob.marinier <bob.ma...@soartech.com>
Date: Thu Sep 26 20:25:41 2013 UTC
Log: Fix bug where smem -p <id> always printed all ltis, not just the
specified one.

http://code.google.com/p/jsoar/source/detail?r=6be715af375a

Modified:

/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemoryCommand.java

=======================================
---
/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemoryCommand.java
Fri Sep 27 18:35:31 2013 UTC
+++
/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemoryCommand.java
Thu Sep 26 20:25:41 2013 UTC
@@ -615,14 +615,17 @@

if (args.length > i && args.length <= i + 3)
{
- char name_letter = 0;
- long name_number = 0;
-
if (args.length == i + 2)
{
+
+ boolean allowIdsOld = lexer.isAllowIds(); // not sure if
we have to do this, but better safe than sorry -- store old value and
restore it after we're done
+ lexer.setAllowIds(true);
lexer.get_lexeme_from_string(args[i+1]);
if (lexer.getCurrentLexeme().type == LexemeType.IDENTIFIER)
{
+ final char name_letter =
lexer.getCurrentLexeme().id_letter;
+ final long name_number =
lexer.getCurrentLexeme().id_number;
+
if (smem.getDatabase() != null)
{
lti_id = smem.smem_lti_get_id(name_letter,
name_number);
@@ -633,6 +636,7 @@
}
}
}
+ lexer.setAllowIds(allowIdsOld); // restore original value
}

//ByRef<String> viz = new ByRef<String>(new String());

==============================================================================
Revision: 21e082d917c9
Author: bob.marinier <bob.ma...@soartech.com>
Date: Sat Sep 28 00:55:22 2013 UTC
Log: Fixed smem command to properly handle bad print commands

http://code.google.com/p/jsoar/source/detail?r=21e082d917c9

Modified:

/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemoryCommand.java

=======================================
---
/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemoryCommand.java
Thu Sep 26 20:25:41 2013 UTC
+++
/jsoar-core/src/main/java/org/jsoar/kernel/smem/DefaultSemanticMemoryCommand.java
Sat Sep 28 00:55:22 2013 UTC
@@ -615,9 +615,10 @@

if (args.length > i && args.length <= i + 3)
{
- if (args.length == i + 2)
+ StringBuilder viz = new StringBuilder("");
+
+ if (args.length >= i + 2)
{
-
boolean allowIdsOld = lexer.isAllowIds(); // not sure if
we have to do this, but better safe than sorry -- store old value and
restore it after we're done
lexer.setAllowIds(true);
lexer.get_lexeme_from_string(args[i+1]);
@@ -629,26 +630,36 @@
if (smem.getDatabase() != null)
{
lti_id = smem.smem_lti_get_id(name_letter,
name_number);
+ if(lti_id == 0)
+ {
+ throw new SoarException("'" +
lexer.getCurrentLexeme() + "' is not an LTI");
+ }

if ( ( lti_id != 0 /*NIL*/ ) && args.length == i +
3)
{
- depth = Integer.parseInt(args[i+2]);
+ try
+ {
+ depth = Integer.parseInt(args[i+2]);
+ }
+ catch(NumberFormatException e)
+ {
+ throw new SoarException("Expected integer
for depth, got '" + args[i+2] + "'");
+ }
}
}
+ smem.smem_print_lti(lti_id, depth, viz);
}
+ else
+ {
+ throw new SoarException("Expected identifier, got '" +
lexer.getCurrentLexeme() + "'");
+ }
+
lexer.setAllowIds(allowIdsOld); // restore original value
- }
-
- //ByRef<String> viz = new ByRef<String>(new String());
- StringBuilder viz = new StringBuilder("");
-
- if (lti_id == 0)
- {
- smem.smem_print_store(viz);
+
}
else
{
- smem.smem_print_lti(lti_id, depth, viz);
+ smem.smem_print_store(viz);
}

if (viz.length() == 0)
@@ -661,7 +672,7 @@
}
else
{
- throw new SoarException( "Invalid attribute." );
+ throw new SoarException( "Too many arguments." );
}

pw.flush();

==============================================================================
Revision: e1d9e217464f
Author: bob.marinier <bob.ma...@soartech.com>
Date: Mon Sep 30 00:52:22 2013 UTC
Log: Finished implementing matches command

http://code.google.com/p/jsoar/source/detail?r=e1d9e217464f

Modified:
/jsoar-core/src/main/java/org/jsoar/kernel/commands/MatchesCommand.java

=======================================
--- /jsoar-core/src/main/java/org/jsoar/kernel/commands/MatchesCommand.java
Thu Feb 14 19:37:52 2013 UTC
+++ /jsoar-core/src/main/java/org/jsoar/kernel/commands/MatchesCommand.java
Mon Sep 30 00:52:22 2013 UTC
@@ -31,7 +31,13 @@

private enum Options
{
- internal
+ internal,
+ wmes,
+ timetags,
+ assertions,
+ retractions,
+ count,
+ names
}

public MatchesCommand(Agent agent)
@@ -40,6 +46,12 @@

options
.newOption(Options.internal)
+ .newOption(Options.wmes)
+ .newOption(Options.timetags)
+ .newOption(Options.assertions)
+ .newOption(Options.retractions)
+ .newOption(Options.count) // count and names do the same thing,
which is the default, so we're listing them here so we accept them, but we
don't do anything with them
+ .newOption(Options.names)
.done();
}

@@ -49,15 +61,37 @@
List<String> nonOpts = options.process(Lists.newArrayList(args));

boolean internal = false;
+ WmeTraceType wmeTraceType = WmeTraceType.NONE;
+ EnumSet<MatchSetTraceType> mstt =
EnumSet.allOf(MatchSetTraceType.class);
+
if (options.has(Options.internal))
{
internal = true;
}
+
+ if(options.has(Options.wmes))
+ {
+ wmeTraceType = WmeTraceType.FULL;
+ }
+ else if(options.has(Options.timetags))
+ {
+ wmeTraceType = WmeTraceType.TIMETAG;
+ }
+
+ if(options.has(Options.assertions)
&& !options.has(Options.retractions))
+ {
+ mstt.clear();
+ mstt.add(MatchSetTraceType.MS_ASSERT);
+ }
+ else if(options.has(Options.retractions)
&& !options.has(Options.assertions))
+ {
+ mstt.clear();
+ mstt.add(MatchSetTraceType.MS_RETRACT);
+ }

if(nonOpts.isEmpty())
{
- agent.printMatchSet(agent.getPrinter(), WmeTraceType.FULL,
- EnumSet.of(MatchSetTraceType.MS_ASSERT,
MatchSetTraceType.MS_RETRACT));
+ agent.printMatchSet(agent.getPrinter(), wmeTraceType, mstt);
agent.getPrinter().flush();
}
else if(nonOpts.size() == 1)
@@ -72,7 +106,7 @@
{
throw new SoarException("Production '" + prodName + "' is
not in rete");
}
- p.printPartialMatches(agent.getPrinter(), WmeTraceType.FULL,
internal);
+ p.printPartialMatches(agent.getPrinter(), wmeTraceType,
internal);
}
else
{
Reply all
Reply to author
Forward
0 new messages