SML: A New Interface Into Soar Douglas Pearson + Bob, Jon, Karen, Trevor, Devvan, John

Slides:



Advertisements
Similar presentations
COM vs. CORBA.
Advertisements

Operating-System Structures
Feature requests for Case Manager By Spar Nord Bank A/S IBM Insight 2014 Spar Nord Bank A/S1.
The Inside Story on the Java Debugger Douglas Pearson
Chapter 1 and 2 Computer System and Operating System Overview
Soar Command Line Interface Soar 8.6 Jonathan Voigt University of Michigan Soar Workshop 25.
A New Soar Debugger in Java Douglas Pearson ThreePenny Software
Guide To UNIX Using Linux Third Edition
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: Operating-System Structures Modified from the text book.
A New Soar Debugger In Java Douglas Pearson
Fundamentals of Python: From First Programs Through Data Structures
Layer 2 Switch  Layer 2 Switching is hardware based.  Uses the host's Media Access Control (MAC) address.  Uses Application Specific Integrated Circuits.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
CVSQL 2 The Design. System Overview System Components CVSQL Server –Three network interfaces –Modular data source provider framework –Decoupled SQL parsing.
Concurrency Recitation – 2/24 Nisarg Raval Slides by Prof. Landon Cox.
INTRODUCTION TO WEB DATABASE PROGRAMMING
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
AJAX Chat Analysis and Design Rui Zhao CS SPG UCCS.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
AIT 616 Fall 2002 PHP. AIT 616 Fall 2002 PHP  Special scripting language used to dynamically generate web documents  Open source – Free!!!  Performs.
Presented by: Katie Milanowski. 2  Formed in 1982  Bruce Barrington (HBO & Company)  Apply RAD technology to IBM PC  1986: Clarion Version 1.0, Atlanta,
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
JAS3 + AIDA LC Simulations Workshop SLAC 19 th May 2003.
PHP TUTORIAL. HISTORY OF PHP  PHP as it's known today is actually the successor to a product named PHP/FI.  Created in 1994 by Rasmus Lerdorf, the very.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
FTP Client Application CSC 8560 Brian Jorgage 4/27/2004.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Processes & Threads Emery Berger and Mark Corner University.
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
Soar Mazin Assanie, John Laird, Joseph Xu 1.
Concurrent Programming. Concurrency  Concurrency means for a program to have multiple paths of execution running at (almost) the same time. Examples:
Interrupts By Ryan Morris. Overview ● I/O Paradigm ● Synchronization ● Polling ● Control and Status Registers ● Interrupt Driven I/O ● Importance of Interrupts.
Problem of the Day  Why are manhole covers round?
10/24/2015Rex Oleson II SOAR and Video Games By Rex Oleson II.
Cohesion and Coupling CS 4311
Editing & Compiling: UNIX vs. IDE and an Intro to Architecture.
CS 346 – Chapter 4 Threads –How they differ from processes –Definition, purpose Threads of the same process share: code, data, open files –Types –Support.
Eagle: Maturation and Evolution 17th Annual Tcl Conference Joe Mistachkin.
A Tutorial on Introduction to gdb By Sasanka Madiraju Graduate Assistant Center for Computation and Technology.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Silberschatz, Galvin and Gagne  Operating System Concepts UNIT II Operating System Services.
A Pure Java Implementation of Soar Dave Ray
Introduction Selenium IDE is a Firefox extension that allows you to record, edit, and debug tests for HTML Easy record and playback Intelligent field selection.
August 2003 At A Glance The IRC is a platform independent, extensible, and adaptive framework that provides robust, interactive, and distributed control.
K. Harrison CERN, 22nd September 2004 GANGA: ADA USER INTERFACE - Ganga release status - Job-Options Editor - Python support for AJDL - Job Builder - Python.
An Uncoupled Interface to Soar using SML Pearson, Marinier, Stokes Dunham, Voigt.
Source Level Debugging of Parallel Programs Roland Wismüller LRR-TUM, TU München Germany.
The Development Process Compilation. Compilation - Dr. Craig A. Struble 2 Programming Process Problem Solving Phase We will spend significant time on.
Web Technology (NCS-504) Prepared By Mr. Abhishek Kesharwani Assistant Professor,UCER Naini,Allahabad.
3/14/20161 SOAR CIS 479/579 Bruce R. Maxim UM-Dearborn.
Chapter 4: server services. The Complete Guide to Linux System Administration2 Objectives Configure network interfaces using command- line and graphical.
Editing and Debugging Mumps with VistA and the Eclipse IDE Joel L. Ivey, Ph.D. Dept. of Veteran Affairs OI&T, Veterans Health IT Infrastructure & Security.
1 Network Access to Charm Programs: CCS Orion Sky Lawlor 2003/10/20.
Visual Programming Borland Delphi. Developing Applications Borland Delphi is an object-oriented, visual programming environment to develop 32-bit applications.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Monitoring Dynamic IOC Installations Using the alive Record Dohn Arms Beamline Controls & Data Acquisition Group Advanced Photon Source.
Environment & Education & More Dan Bothell. Overview Data Teaching Materials Environment Other ACT-R 5.0 and RPM issues.
Introduction to Operating Systems Concepts
Development Environment
Chapter 3: Process Concept
Chapter 2: System Structures
Introduction to Events
Issues in Client/Server Programming
Eagle: Maturation and Evolution
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes)
Why Threads Are A Bad Idea (for most purposes)
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

SML: A New Interface Into Soar Douglas Pearson + Bob, Jon, Karen, Trevor, Devvan, John

2 Short-Term Problem New debugger –Avoid string parsing –Use Java for faster tool development –Dynamic attachment to existing processes –High performance gSKI integration –Removal of existing command line Redux choice to use JESS for rule matcher

3 Long-Term Problem Interfacing to Soar has always been hard –Initially limited to implementation language (LISP/C) –Extended to Tcl but lead to dependencies on Tcl –SGIO supported embedded kernels but only for I/O –gSKI added clean interface to kernel but multiple languages, debugging and remote I/O unimplemented.

4 Key Properties of our Solution Supports multiple languages (Java, C++, Tcl currently) while removing Tcl dependency Supports uniform interface for I/O (environments) and commands (debuggers) Supports embedding kernel within debugger or environment with remote connections between them Supports multiple clients (environments, tools, debuggers etc.) connecting to a single kernel Supports dynamic connection and disconnection of tools (esp. debuggers) from a running kernel Provides a uniform, high-level, data-driven model for the entire Soar interface while achieving high performance Moves command line support out of the kernel while providing universal access to it from any client Includes a new cleaned up command line interface Lots of new capabilities yet in most cases the new interface is substantially faster than No production level changes (except ‘tcl’ -> ‘exec’)

5 Connecting to Soar

6 Connecting to Soar Direct Link to Kernel Soar 6/7 gSKI Soar 8.4/8.5

7 Connecting to Soar SGIO Style Code forks between embedded and remote Client (environment) unaware Only I/O

8 Connecting to Soar ATE Style? Primarily I/O but includes higher level concepts? Custom code per language? Proprietary

9 Connecting to Soar SML Style – Soar Markup Language Uniform for entire interface

10 Connecting to Soar SML Style – Soar Markup Language Internally use socket or function call Client, Kernel and (99%) SML code all unaware

11 Connecting to Soar SML Style – Soar Markup Language

12 Connecting to Soar SML Style – Soar Markup Language

13 Possibly useful ways to think about SML An XML interface into the kernel –A data-driven approach rather than function calls A remote procedure call protocol for the kernel –Although it’s not just for remote calls A language independent way to access the kernel SOAP/Web Service for the kernel –Although again not limited to remote access

14 De-Coupling from the Kernel Two central tenets for good software design –High cohesion Each class does one thing not several things –Loosely coupled Each class knows as little as possible about the classes they interact with What is good for classes is good for modules

15 SML Makes Systems More Loosely Coupled to Soar 8.5/gSKI Interface size (# functions which break client if changed and not recompiled) ~= 1000 SML reduces this to 2 (+ about 20 for ElementXML) Why does this matter? Supports a larger community building clients – may not have source available Allows a single client to support multiple different kernel versions because data-driven By default builds to 2 libraries with no dependencies So less coupled to Tcl or other stuff

16 SML Example Packets “Print chunk-1” agent-1 chunk-1 “Output (O1 ^turn T1) (T1 ^heading 045 ^speed 225)” agent-1

17 Maximizing XML performance Standard Approach for passing XML -- Always requires parsing step

18 Maximizing XML performance SML Approach – create DOM representation directly - only convert to XML string if needed Speed benefit ~50x if always use socket Speed benefit ~10x if pass string directly

19 Building an SML Client Option A: Just send XML strings to socket –Format: 4 byte length + XML string –Not recommended, lose embedded speed and need details on XML packets but an option Option B: Use client SML functions we provide in –C++ –Java –Tcl –more…

20 Creating Kernel and Agents Local Kernel –Kernel* pKernel = CreateKernelInNewThread() Generally recommended –Kernel* pKernel = CreateKernelInCurrentThread() Tcl only supports this form (so far) Call CheckForIncomingCommands() periodically Remote Kernel –Kernel* pKernel = CreateRemoteConnection(ipAddress, port) Pass null for ipAddress => same machine Agents –CreateAgent() –DestroyAgent() Shutdown –delete pKernel object –disconnects –cleans up all memory

21 Local vs Remote Kernels CreateKernel InNewThread() CreateRemote Connection() CreateRemote Connection() CreateRemote Connection()

22 Local vs Remote Kernels CreateRemote Connection() CreateKernel InNewThread() CreateRemote Connection() CreateRemote Connection() Change one line of code Internally different execution paths –XML objects + local functions vs XML strings + sockets To the client, same interface and capabilities No special access for debugger

23 Input Add structures to input link representation –Identifier* pInputLink = pAgent->GetInputLink() –Identifier* pID = pAgent->CreateIdWME(pInputLink, "plane") ; –StringElement* pWME1 = pAgent->CreateStringWME(pID, "type", "Boeing747") ; Result: (I1 ^input-link I2) (I2 ^plane P1) (P1 ^type Boeing747) Send changes to kernel –pAgent->Commit() ; –Actual wmes added during next input phase Update or remove in future cycles –pAgent->Update(pWME1, “Cessa”) ; NOTE: init-soar works and comes for free. –Sends over current input state automatically so you can pick up reasoning

24 Output Check for output commands (since last check) –Based on “command” notion on output link –E.g. (I1 ^output-link I3) (I3 ^move M1) (M1 ^speed 20) –pAgent->GetNumberCommands() ; –Identifier* pCommand = pAgent->GetCommand(i) ; –string name = pCommand->GetCommandName() ; –string speed = pCommand->GetParameter(“Speed”) ; –pCommand->AddStatusComplete() ; Same as pAgent->CreateStringWME(pCommand, “status”, “complete”) ; But not forced to use this model –GetCommand() returns Identifier*. Can access substructure directly. –GetOutputLink() and walk output link directly. –GetOutputLinkChange() to walk list of WMEs changed Call ClearOutputLinkChanges() after reading the output link –Allows SML to only report changes to the output link.

25 Running Soar Run –Kernel->RunAllAgentsForever() –Kernel->RunAllAgents(steps, stepSize) –Agent->RunSelfForever() –Agent->RunSelf(steps, stepSize) Stop –Kernel->StopAllAgents() –Agent->StopSelf()

26 Debugging commands ExecuteCommandLine(commandLine) –ExecuteCommandLine(“watch 3”) ; –ExecuteCommandLine(“print o1”) ; –ExecuteCommandLine(“excise –all”) ; Simple form returns a string –“set-library-location” –returns: “Current library location: e:\soarmich\soar-library” Alternative form returns XML –“set-library-location” e:\soarmich\soar-library –GetArgValue(“directory”) [smlNames::kParamDirectory] Why not implement all as methods in the client interface? –Just saving work –Some clients (lots?) will want to embed command line windows –XML all documented on Wiki (

27 Event Handling Register callback handler for an event pAgent->RegisterForRunEvent(smlEVENT_AFTER_DECISION_CYCLE, MyRunEventHandler, 0) ; Called back when event occurs: void MyRunEventHandler(smlRunEventId id, void* pUserData, Agent* pAgent, smlPhase phase) ; Supports all gSKI events (plus a few additions) –Long list Events can be handled over remote connections the same as local ones

28 RHS Functions Register RHS function pKernel->AddRhsFunction("test-rhs", &MyRhsFunctionHandler, 0) ; Referred to via “exec” in production (just like “tcl”) sp {apply*user*exec (state ^operator ^io.output-link ) ( ^name move ^space ) ( ^row ^col ) --> ( ^test (exec test-rhs | hello | | world |))} Calls RHS function handler std::string MyRhsFunctionHandler(smlRhsEventId id, void* pUserData, Agent* pAgent, char const* pFunctionName, char const* pArgument) ; “cmd” allows access to command line as built in command set --> (cmd print ) Handler can be in any language (e.g. register from Java, handler in Java) RHS functions can be handled over remote connections the same as local ones –If same function registered locally and remote, calls local one

29 Threads CreateKernelInNewThread() –Runs kernel in its own thread –Means kernel can respond to remote commands (over socket) on its own –Otherwise need to call “CheckForIncomingCommands()” periodically Also EventThread helps client remain responsive –Register for an event (e.g. AFTER_DECISION_CYCLE) –Go to sleep => entire system locks up waiting for this client –Solution is a thread which receives these events and pushes them through client callback to get response Both just make it easier to build a client –Neither thread is required – CreateClientInCurrentThread() –For maximum performance turn them off and handle these issues yourself

30 SWIG and Language Support SWIG –Automatic generation of Java and Tcl implementations –Fast to create and maintain –Custom code added to handle callbacks –Code looks the same in each language C++ sml::Kernel* pKernel = Kernel::CreateRemoteConnection(true, null, Kernel::GetDefaultPort()) ; if (pKernel->HadError()) { cout GetLastErrorDescription() << endl ; return false ; } Java sml.Kernel kernel = Kernel.CreateRemoteConnection(true, null, Kernel.GetDefaultPort()) ; if (kernel.HadError()) { System.out.println(kernel.GetLastErrorDescription()); return false ; }

31 Common Environment Control Loop Asychronous environments Act as soon as output is sent from an agent Synchronous environments Fixed amount of Soar processing before update world while (!stopped) Run(1) (or Run-til-output) Collect-output Update-state-of-world Send-input Assumes environment triggers run. Assumes run(1) completes a decision Assumes user doesn’t issue “stop-soar” (needs to pause/stop environment)

32 Preferred Environment Control Structure 1.Register for “update world” event (e.g. AFTER_ALL_OUTPUT_PHASES) 2.Handler takes form: Collect-output Update-state-of-world Send-input 3.Run controls Kernel::RunAllAgentsForever() Kernel::RunAllAgents(1) As agents run, fire event as reach end of output phases. Allows run to come from debugger or environment or other tools. Allows for arbitrary interruption of run commands (e.g. breakpoints/stop-soar).

33 Debugger Performance Comparison Towers of HanoiTSI (8.5.2)Java Debugger (Text) Java Debugger (Tree) Watch 1 (Run 100) 1.25 secs0.73 secs0.75 secs Watch 5 (Run 100) secs2.14 secs1.51 secs 0.58 secs (full filtering) Within process faster than (for the debugger) Embedding Soar in environment so remote => local –Not measured yet, but huge speed up

34 Documentation PDFs included in Release –SML Quick Start Guide –Moving from SGIO to SML –Soar XML Interface Specification –Intro to the Soar Debugger –How to guide – adding an event to gSKI and SML Online on the Wiki – Questions, bugs, building something cool, need help?

35 Nuggets Supports multiple languages (Java, C++, Tcl currently) while removing Tcl dependency Supports uniform interface for I/O (environments) and commands (debuggers) Supports embedding kernel within debugger or environment with remote connections between them Supports multiple clients (environments, tools, debuggers etc.) connecting to a single kernel Supports dynamic connection and disconnection of tools (esp. debuggers) from a running kernel Provides a uniform, high-level, data-driven model for the entire Soar interface while achieving high performance Moves command line support out of the kernel while providing universal access to it from any client Includes a new cleaned up command line interface Lots of new capabilities yet in most cases the new interface is substantially faster than 8.5.2

36 Nuggets Building a command line interface in a client is pretty simple –Allows embedding console windows into environment (e.g. games) Readily supports other solutions –Other debuggers (e.g. TSI-8.6) –Other editors (edit-production is generic) will be out by end of June –Linux and Mac support –Soar7 mode –Tcl Eaters –Java Missionaries and Cannibals –New environment event model –Kernel XML generation much faster –New debugger features (fast tree view, filtering etc.) –Lots of other bug fixes 8.6.1r5 Used for tutorial at the workshop w/o problems –Tcl Eaters with Java Debugger with C++ Kernel

37 Coal Not all commands generate fully structured XML –Esp. print, but should do so shortly –Still XML but not as rich as we’d like Threading models not completely resolved yet –Esp. Tcl Lots of new code –There will be some bugs lurking –Not all combinations fully tested yet –Interfaces will probably change a bit as everything settles