Topics
• Bigpicture• Systemsetup+HelloSoar(homework)• Basicusage• Examplewalkthrough• Additionalresources
July11,2016 SoarMarkupLanguage(SML) 2
Soar9
July11,2016 SoarMarkupLanguage(SML) 3
SymbolicLong-TermMemories
SymbolicWorkingMemory
Procedural
Decision
Procedure
ChunkingReinforcementLearning
Action
Semantic
SemanticLearning
Episodic
EpisodicLearning
Spatial Visual SystemObject-basedcontinuousmetricspace
Perception
SoarBasicFunctions
1. Input fromenvironment2. Elaboratecurrentsituation:parallelrules3. Proposeoperatorsviaacceptable preferences4. Evaluateoperatorsviapreferences:Numericindifferentpreference5. Selectoperator6. Applyoperator:Modifyinternaldatastructures:parallelrules7. Output tomotorsystem[andaccesstolong-termmemories]
OperatorDecisionInput Output
StateElaboration
OperatorProposal
OperatorEvaluation
OperatorElaboration
OperatorApplication
July11,2016 SoarMarkupLanguage(SML) 4
BigPicture:SoarMarkupLanguage• SMLprovidesaprogrammaticinterfaceintoSoarbasedaroundsendingandreceivingcommandspackagedasXMLpackets.Usedfor…– Environments– Debuggers– Automatedexperimentation
• WritteninC++• Exported,viaSWIG(swig.org)to…– Python– Java…
July11,2016 SoarMarkupLanguage(SML) 5
SMLExampleEnvironments
July11,2016 SoarMarkupLanguage(SML) 6
CognitiveRobotics
ActionGames
GameState
Rules
HTTP REQUEST: GAME 5
Server
WebGaming
InteractiveMobileMusicGeneration
SystemSetup(1)
1. OpenEclipse2. NewJavaProject– Name=“MySMLProject”– Finish
3. NewClass– Name=“MySMLClient”– Check:“publicstaticvoidmain…”– Finish
July11,2016 SoarMarkupLanguage(SML) 7
SystemSetup(2)
4. Insidemain…Kernel kernel;
5. Addsml.jar toclasspath– Rightclickproject->Properties– JavaBuildPath– Libraries->AddExternalJar– Locatesml.jar inlib/soar/java,Open,OK
6. Hoverover“Kernel”(redunderline)– Click“Import‘Kernel’(sml)”
July11,2016 SoarMarkupLanguage(SML) 8
SystemSetup(3)
7. Finishmain…Kernel kernel = Kernel.CreateKernelInNewThread();
Agent agent = kernel.CreateAgent("soar");
System.out.println(agent.ExecuteCommandLine("print s1"));
kernel.Shutdown();
8. Runmenu->Run
July11,2016 SoarMarkupLanguage(SML) 9
SystemSetup(4)
9. Runmenu->RunConfigurations– Windows
• Environmenttab• New
– Name=PATH– Value=c:\path\to\lib\soar
–Mac/Linux• Arguments,VMarguments-Djava.library.path=/path/to/lib/soar
– Run
July11,2016 SoarMarkupLanguage(SML) 10
BasicUsagePart1:Automation
– Command execution– Loadingrules– Synchronous runcontrol– Capturingtraceoutput
Part2:BasicIO– ManagingWMEsoninput-link– Readoutput-linkWMEs+feedback
Part3:Event-DrivenEnvironment– Outputhandler
July11,2016 SoarMarkupLanguage(SML) 11
CommandExecution
Syntax“result”=agent.ExecuteCommandLine(“command”);
Try– “stats”– “epmem --stats”– “sp {test(state<s>^superstate nil)-->(<s>^foobar)}”– “printtest”
July11,2016 SoarMarkupLanguage(SML) 12
LoadingRules
SyntaxTrue/False=Agent.LoadProductions(“location”);
Try1. Load:path/to/file.soar2. Execute:“print”
July11,2016 SoarMarkupLanguage(SML) 13
SynchronousRunControl
Syntax– Agent.RunSelf(numberSteps,stepSize=Decision);– Agent.RunSelfForever();– Agent.RunSelfTilOutput();– Agent.ExecuteCommandLine(“run…”);
Try1. Run:forever2. Execute:“print--stack”
July11,2016 SoarMarkupLanguage(SML) 14
CapturingTraceOutput
1. CreateaPrintEventInterface (eventhandler)publicstaticfinalPrintEventInterface myPrinter =newPrintEventInterface(){
publicvoidprintEventHandler(int eventID,Objectdata,Agentagent,Stringmessage){System.out.println("Soarsaid:<"+message+">");
}};
1. RegisterforEventSyntax
Agent.RegisterForPrintEvent(eventId,handler,extraData);Try
agent.RegisterForPrintEvent(smlPrintEventId.smlEVENT_PRINT,myPrinter,null);
July11,2016 SoarMarkupLanguage(SML) 15
ManagingWMEsoninput-link
Syntax– Identifier =Agent.GetInputLink();– Identifier =Identifier.CreateIdWME(“attr”);– FloatElement =Identifier.CreateFloatWME(“attr”, value);– IntElement =Identifier.CreateIntWME(“attr”, value);– WMElement.DestroyWME();
Tryagent.GetInputLink().CreateStringWME("foo", "bar");agent.RunSelf(1);System.out.println(
agent.ExecuteCommandLine("p --depth 3 s1"));
July11,2016 SoarMarkupLanguage(SML) 16
Readoutput-linkWMEs+Feedback
Syntax– Int =Agent.GetNumberCommands();– Identifier=Agent.GetCommand(Int);– String=WMElement.GetAttribute();– Int =Identifier.GetNumberChildren();– WMElement =Identifier.GetChild(Int);– WMElement =Identifier.FindByAttribute(String,Int)– *Element=WMElement.ConvertTo*Element();– Identifier.AddStatus<<CompleteError>>();
July11,2016 SoarMarkupLanguage(SML) 17
OutputHandler
Syntax– Agent.AddOutputHandler(“cmd”,handler,data);
Trypublic static final OutputEventInterface cmdHandler = new OutputEventInterface() {
public void outputEventHandler(Object data, String agentName, String attributeName, WMElement pWmeAdded) {for (int i=0; i<pWmeAdded.ConvertToIdentifier().GetNumberChildren(); i++) {
final WMElement wChild = pWmeAdded.ConvertToIdentifier().GetChild(i);System.out.println("^" + wChild.GetAttribute() + " " + wChild.GetValueAsString());
}}
};
agent.AddOutputHandler("do", cmdHandler, null);agent.ExecuteCommandLine("sp {test (state <s> ^io.output-link <out>) --> (<out> ^do <d>) (<d> ^foo bar ^baz qux)}");agent.RunSelf(2);
July11,2016 SoarMarkupLanguage(SML) 18
AdditionalResources• QuickStartGuidehttp://soar.eecs.umich.edu/articles/articles/soar-markup-language-sml/78-sml-quick-start-guide
• ThreadsinSMLhttp://soar.eecs.umich.edu/articles/articles/soar-markup-language-sml/203-threads-in-sml
• CompilingSMLClientshttp://soar.eecs.umich.edu/articles/articles/soar-markup-language-sml/79-how-to-compile-sml-clients
July11,2016 SoarMarkupLanguage(SML) 20