Cognitive Modeling Language
This is a description of the Cognitive Modeling Language used to describe HTNs and other planning models.
Cognitive model source files consist of a package and a set of domains. Follow the links in the diagram to see details about each element.
References to deferred planning and the use of the defer
keyword are forward looking descriptions.
Explicit deferred planning is not yet supported by the planning engine.
Example:
package com.ursafrontier.tutorials
domain games.rings-and-poles
...
Achievement
Action
Example:
action PlaceRing {
integer ring
string pole
}
costs {
time = 1
effort = 1 / ring
}
Action Invocation
And Expression
And Predicates
The comma (,
) separating predicate unions can be spelled and
if desired.
You may have to use paranethesis to avoid ambiguity since
the comma binds looser than the or
keyword but
the and
keyword binds tigher than the or
keyword.
Array Type
Behavior
Example:
behavior PlayRingsAndPoles {
when PlayGame() {
play(rings)
}
}
Binding Variables
Binding variables are used to pull information from the agent state during planning. They may only be used in the preconditions or guards of methods or macros. A collection of guards fails if the binding variables can’t be assigned values that satisfy all the guards.
The planner must be able to assert a set of potential values for each binding variable based on inspecting the predicates in the guard clauses. That is, each binding variable must appear by itself as a predicate argument or as the variable being tested for inclusion in a set. Function calls or other expressions are only used to filter the set of potential values.
Example:
take(block) when clear(block), pos(block, ?pos), ?pos != "table", not holding("hand", _) {
...
}
Calculation
CapName
Choice
Cost
Costs
Costs may be associated with actions, methods, and tasks. Costs for methods and tasks are only used when task expansion is deferred.
You can associate as many costs as needed with an action, method, or task. The planning engine will only calculate those costs necessary to satisfy the cost criteria when planning.
Cost Bound
Cost Limit
Domain
Event
Event Expectation
Event Expectations
Expression
Function
Function Arg
Function Name
Horizon
Implication
Inclusion
Map Type
Method
A method that isn’t tied to a task is considered a macro in automated planning. The planner treats it as if it were a method attached to a task with the same name.
Method Step
Name
Namespace
Perception
Perceptions are not yet used by any system. They are included for future use.
Perceptions define a function that the cognitive model can use to query the environment. The implementation depends on the environment in which the cognitive model runs, similar to how action adjudication is handled.
Postconditions
Preconditions
Preconditions may not have binding variables when associated with a function definition.
Predicate
Predicates
The comma (,
) separating predicate unions can be spelled and
if desired.
You may have to use paranethesis to avoid ambiguity since
the comma binds looser than the or
keyword but
the and
keyword binds tigher than the or
keyword.
Predicate Arg
Predicate arguments in guard clauses may contain binding variables when guarding a method rather than a function. These won’t appear in the syntax diagrams, but they may be used where any variable would be present in the guard expression.
An “unused name” is a placeholdeer variable in a predicate that indicates that the value in that position is not used. That is, when evaluating the predicate, the value in that position is free to be anything. This only works with predicates. For example, the predicate foo(_, 1, _)
matches any value in the first and third positions and only matches the value 1
in the second position. Obviously, this doesn’t work with functions since the function operates on the values in the arguments.
Predicate Union
Property Definition
Relational Expression
Statement
A parenthesized list of statements has its own scope, so any variables set will be unset when leaving the parenthesis. The value of a list of statements is the value of the last statement in the list.
Example:
x = 3
y = (
x = 4
x * 2
)
At the end of this code, x
will be 3
and y
will be 8
.
Sum Expression
Task
When using an HTN planner, task preconditions and postconditions are not evaluated unless the task expansion is explicitely deferred.
Task Invocation
A task, method, or macro invocation looks identical to a function call except that functions may only be called as parts of expressions and tasks, macros, and methods are never part of expressions.
The defer
keyword marks the task, macro, or method so that the planner does not expand it during the planning phase.
If a task is deferred, then the planner will use the preconditions and implications of the task to test and update the hypothetical state of the planner.
If a macro or method is deferred, then the planner will not update any hypothetical state. This may cause the planner to mark the plan as incomplete but successful, with the remaining planning implicitely deferred until execution reaches the deferral point.