Thinking… …inside the box

Behavior : Engineering Human Behavior Representations Glenn Taylor Robert Wray Soar Workshop 24 10 June 2004

Research sponsored by Defense Advanced Research Projects Agency, Contract DAAH01-03-C-R242

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 1 Problem

ƒ Reuse of HBR knowledge representations is difficult y even when tasks/domains are similar ƒ We recognize as behavior developers that there are recurring design problems & solutions ƒ How do we more easily reuse previous solutions? y Focus: Previous designs

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 2 Foundations ƒ Design Patterns (Gamma, et al) y Abstractions to address common OO reuse problems y Independent of specific application domains y , proxy, factory method, etc… ƒ Generic Tasks (Chandrasekaran) y General patterns of problem solving and representation: Hierarchical classification, hypothesis matching, knowledge-directed information passing, synthesis by plan selection and refinement, abductive hypothesis assembly ƒ Taxonomy of Human Behaviors (Fineberg) y Catalogue of human behavior “primitives”: Sensation, mediation, reaction, interaction

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 3 Assumptions ƒ Design patterns may not be applicable for cognitive models y Architectural dependencies & idiom y Quantitative human data drives low-level details ƒ Design patterns appear to be relevant in human behavior representation y Focus often more on knowledge level behavior than immediate behavior (“psychology”) y Qualitative/descriptive validation is the norm y Aggregations (entity vs. individual) ƒ “Engineering” philosophy y Define & capture recurrent behavior design patterns y Use cognitive architectures to guide solution patterns (psychological constraint)

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 4 Design Patterns ƒ Reusable software elements that describe a common problem and solution (Gamma et al.) y Generally: ™ 1) pattern name (for communication/reference) ™ 2) clear definition of the problem ™ 3) clear definition of the solution ™ 4) consequences of using the pattern y Pattern captures aspects of behavior/structure that are invariant, and call out/encapsulate aspects that vary y DPs language-neutral; details/cost may differ across languages/architectures y Specific paradigm (OOP) y Specific goal (reuse)

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 5 Design Pattern example

ƒ Name: Strategy ƒ Problem Addressed: y Need multiple variants of an algorithm y Have many modules that execute similar algorithms ƒ Solution: y Encapsulate a family of related algorithms from the objects that invoke them. Allows implementation to vary independently from object ƒ Consequences: y Reduces conditional statements in modules y Increased communication overhead ƒ Example: different memory management styles, etc.

Strategy pattern is similar to the notion of a generic task

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 6 “Behavior” Design Patterns (BDPs) ƒ Patterns that describe common problems and solutions in building human behavior representations ƒ Human behavior representation programming paradigm (from cognitive architectures): y Agent must strike balance between reactive and goal- directed behavior ™ Associative control flow (re-entrant execution is a basic requirement) y Least-commitment execution ™ Run-time decision making and conflict resolution ™ Weak encapsulation y Large, (possibly) changing knowledge bases y Human fidelity constraints

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 7 Classes of BDPs (1) ƒ Architectural: patterns for underlying processes, assumptions, constraints y Pattern matching, automatic subgoaling, etc. y Cognitive architectures ™ assume patterns of processing are fixed (or vary parametrically) ™ can be viewed as attempts to define collections of architectural patterns that are sufficient to describe human behavior

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 8 Classes of BDPs (2) ƒ Computational patterns: capture and represent low-level, domain-independent recurring computations y Iteration (perform f(x) on all objects x with property y) y Deliberate memory management y Compute vs. retrieve decisions y Process annotation ƒ Similar to (Gamma et al) patterns: y Abstractions from common problems arising from a particular language/design paradigm y May indicate directions for language/architecture evolution

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 9 Classes of BDPs (3) ƒ Behavior-level: knowledge, processes, tasks related to the specific individual and task being modeled y Domain Patterns – focus on domain/class- specific problems/tasks ™ Examples: Mission (air-to-ground attack), tactical (maneuver) y Interface Patterns – focus on entity interactions ™ Virtual vehicles, communications interfaces (eg, FIPA- ACL), perception, proprioception, etc.

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 10 Potential benefits of behavior level BDPs? ƒ Provide language neutrality y Focus on domain-specific (task) patterns, not patterns of implementation within a language y Transfer of design to other platforms ƒ Improve understandability y Concise descriptions of solutions y Make design elements & decisions explicit y Increased transparency (to developers & users)

ƒ Potential results: y More reuse y Devote more effort to novel aspects of behavior representation y Improve capability/investment ratio

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 11 Describing patterns? ƒ Natural Language ƒ Diagrams y UML (State Diagrams, Sequence Diagrams, etc.) is standard in OOP Software Engineering, may not have right primitives; AUML may not be expressive enough y Bottom line: Multiple diagrammatic views are needed for many patterns ƒ Language-specific examples y Multiple language implementations of the same pattern can help make design trade-offs more explicit

ƒ All are needed to fully capture a pattern for reuse

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 12 Patterns in existing HBRs ƒ Analysis of TacAir-Soar y Comprehensive suite of FWA missions and aircraft: Tactical air combat, close-air support, refueling, etc. y Focus: close-air support mission ™ mission phases, roles, entities, domain concepts ƒ Methodology y Look for generalities, repetition in processes, structures y Isolate functionality, encapsulate, generalize y Describe as patterns

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 13 Close-air support

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 14 TacAir-Soar analysis ƒ Assigned individual knowledge representations into eight classes: y Communications: How and when to talk to other agents, and how to interpret incoming communications y Missions: Mission-specific behaviors, such as for air-to- ground missions (CAS) or air-to-air missions (DCA) y Control: How to direct other units to take action y Coordination: How to work with other friendly agents y Flying: How to fly a plane y Navigation: How to decide where to go and how to get there y Situational Awareness: How to manage information about the environment y Action: Atomic interactions with the simulation platform ƒ Are there patterns within the categories?

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 15 TacAir-Soar analysis ƒ Potential patterns at many different levels of abstraction: y Mission-level patterns ™ Air-to-ground attack y Tactical patterns ™ Chase-target y Multi-agent interaction patterns ™ Directive pattern (command/response) ™ Patterns adopted from MAS/AOP community (ACLs, conversation policies) y Information processing patterns ™ Situation awareness y Interaction patterns ™ Vehicle/movement control

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 16 Movement behaviors

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 17 Behavior interactions ƒ Many interactions between behaviors/patterns ƒ Many patterns are cross-cutting (“aspectual”) y comms y situational awareness

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 18 Chase-Target pattern

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 19 Air-to-Ground Attack

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 20 Air-to-Ground Attack

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 21 How to use patterns? ƒ Indirectly: read the “BDP Catalog”, find pattern that fit your problem, and use the design solution to build your own implementation

ƒ (more) Directly: Use generative programming techniques to create templates for generating solution instances y Tcl -> Soar

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 22 Simple example: Iterator Pattern ƒ Purpose: Provide a way to access the elements of an aggregate sequentially without exposing its underlying representation (GOF)

List List List List List Item Item Item Item Item

ƒ Example: processing elements in a list

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 23 Possible Iterator Variations ƒ Sequential order pre-determined (list) ƒ Sequential order not pre-determined, but not important (unordered set) ƒ Sequential order determined as part of processing (search) ƒ …

ƒ Examples in HBR: y route following y iterating over targets y dealing with messages in priority order y etc.

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 24 Iterator Pattern Template

ƒ Use iterator object to keep track of current element ƒ Create a new context in which to iterate y Explicit operator for iterating to encapsulate process from unrelated operators (template) y Proposal based on matching against existing iterator y Retraction based on iterator absence y Use other sub-operators for processing on current element ƒ User responsible for creating iterator instance (template) ƒ Auto-generate iterator destructor (template) ƒ User responsible for either telling iterator how to find the next element as part of instantiation (if well defined), or actually determining the next element as part of processing

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 25 Template continued…

ƒ Create the iterator structure (as production RHS): iterator-constructor \ location iterator-name \ first-element External processing ƒ Base iterator template generator: of element… iterator-template \ production-base-name \ opname lhstest rhsset \ iterator-name {next-test NULL}

Î Generates 3-4 productions to deal with iteration over specific structure

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 26 Current & future work ƒ Refine/extend/define notation for behavior design patterns y Define “interacts with” subclasses/relationships ™ Hierarchical ™ Compositional ™ Aspectual y Evaluate/extend pattern definition y Create additional diagrammatic views ™ Task priority (potential interruptions) ™ Communication protocols ™ Tension: succinctness <--> behavior complexity

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 27 Current & future work ƒ Demonstrate (re-)use of patterns in new behavior systems ƒ Demonstrate reuse of patterns for other platforms y Long-term goal: Platform independent catalogue of BDPs ƒ Catalog behavior design patterns ƒ Refine evaluation metrics y What constitutes a “good” pattern? ™ Chase-target pattern: psychological relationship between follow leader and engaging enemy? y What are good/best/most effective ways of cataloging/ communicating patterns ƒ From description to programmability y Improving encapsulation & interfaces for cognitive archs y Template support

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 28 Summary ƒ Demonstrated “behavior design patterns” are evident in existing HBR systems y Analysis/review of TAS made many implicit design patterns evident ƒ Proposed strawman for behavior level BDPs y Computational abstraction: cognitive architecture y Multiple diagrammatic views to convey pattern succinctly y Formal ontology of interaction types to express complex relationships (hierarchical, aspectual, compositional, etc.) between interacting patterns

© 2004 Soar Technology, Inc. Š 10 Jun 2004Š Slide 29