Frames

Workframe

A workframe is an action rule for an agent or object. It is a declarative description of under what conditions the agent/object will perform the activities specified in the body of the rule. For an agent, rules match on beliefs within the agent. For an object, rules match on facts in the world or beliefs within the object depending on the declared type (factframe or dataframe) of the workframe. Workframes are treated like data-driven (forward chaining) production rules. However, workframes are different from production rules, in that they specify activities that agents and objects can perform (are engaged in) - production rules specify what conclusions can be drawn based on the conditions that are met.

In Brahms we separate facts in the world from beliefs that agents have. For example, in Brahms we can have a fact 'the color of John's Car is red'. Agent John might have the belief 'the color of John's Car is red', but agent Caroline might have the belief 'the color of John's Car is green'. Agent workframes get 'worked on' (in production rules systems we call this 'get fired') based on the beliefs that agents have. This means that, in the example above, if John and Caroline have the same workframe using the belief of John's Car is red as a condition for the activation of the workframe; John will start working on the workframe, whereas Caroline will not start working on the workframe. Using this separation of beliefs and facts in the world allows Brahms to model agent's activities, based on changes in the world (facts) detected through detectables, and the agent-specific beliefs that are created. For objects beliefs are the information that an object carries. By default workframes for objects are only triggered by facts in the world, the type of the workframe is by default 'factframe'. If the type of the workframe is set to 'dataframe' then the workframe will be triggered by the beliefs of the object. The workframe is in that case an information processing frame. It is not possible to specify the type of the workframes for agents. Agent's workframes are only activated by beliefs matching the preconditions.

Syntax

workframe::=workframe workframe-name
{
{ display : ID.literal-string ; }
{ type : factframe | dataframe ; }
{ repeat : ID.truth-value ; }
{ priority : ID.unsigned ; }
{ variable-decl }
{ detectable-decl }
{ [ precondition-decl workframe-body-decl ] | workframe-body-decl }
}
workframe-name::=ID.name
variable-decl::=variables : [ VAR.variable ]*
detectable-decl::=detectables : [ DET.detectable ]*
precondition-decl::=when ( { [ PRE.precondition ][ and PRE.precondition ]* } )
workframe-body-decl::=do ( { [ workframe-body-element ]* } )
workframe-body-element::=[ PAC.activity-ref | CON.consequence | DEL.delete-operation ]

Semantics

Type

The type attribute can only be set for workframes defined for classes and objects. The value for the type attribute can be one of 'factframe' or 'dataframe'. The default value is 'factframe' If the value is 'factframe' then the workframe's preconditions are matched against the facts in the world. If the value is 'dataframe' then the workframe's preconditions are matched against the beliefs of the object for which the workframe is specified. A dataframe is a workframe processing the data/information maintained by an object allowing the processed data/information to result in actions that change the state in the world.

Repeat

A workframe can be performed one or more times depending on the value of the 'repeat' attribute. A workframe can be performed repeatedly if the repeat attribute is set to true. When the repeat attribute is set to false, the workframe will be performed exactly once for the specific binding of the variables at run-time. However, only for top-level workframes are the bindings tracked during a simulation run. The scope of a workframe defined as part of a composite activity is limited to when the composite activity is active, meaning that the workframe executes for each specific binding of the variables to facts/beliefs while the composite activity is active. As soon as the composite activity is ended the bindings are reset and in the next execution of the activity it is possible for the workframe to execute on the same variable bindings depending on facts and beliefs.

Priority

The workframe priority can be set in one of two ways. The priority can be set by setting the value for the priority attribute or the priority can be deduced based on the priorities of the activities defined within the workframe, the workframe will get the priority of the activity with the highest priority. If no priority is specified the priority will be deduced from the activities, otherwise the specified priority is used.

Example

workframe AttachFlyerToWindshield {
    repeat: false;
    variables:
      foreach(Car) car;
    when ( (car.color = "red") )
    do {
      putFlyerOnCarWindshield();
    }
  }

Defaults

  • display = <workframe-name>
  • type = factframe
  • repeat = false
  • priority = 0

Constraints

The workframe name has to be unique within the definition of a group, agent, object-class or object.

Thoughtframe

A thoughtframe is the Brahms equivalent of a production rule for an agent or object. A thoughtframe allows an agent or object to deduce new beliefs from existing beliefs. The difference between a thoughtframe and a workframe is that a thoughtframe can only have consequences in its body. A thoughtframe consists of preconditions and consequences.

Syntax

thoughtframe::=thoughtframe thoughtframe-name
{
{ display : ID.literal-string ; }
{ repeat : ID.truth-value ; }
{ priority : ID.unsigned ; }
{ WFR.variable-decl }
{ [ WFR.precondition-decl thoughtframe-body-decl ] | thoughtframe-body-decl }
}
thoughtframe-name::=ID.name
thoughtframe-body-decl::=do ( { [ thoughtframe-body-element ]* } )
thoughtframe-body-element::=CON.consequence

Semantics

Repeat

A thoughtframe can be triggered one or more times depending on the value of the 'repeat' attribute. A thoughtframe can be triggered repeatedly if the repeat attribute is set to true. When the repeat attribute is set to false, the thoughtframe will be performed once for each specific binding of the variables at run-time. However, only for top-level thoughtframes are variable bindings tracked during a simulation run. The scope of a thoughtframe, defined as part of a composite activity, is limited to the time the composite activity is active, meaning that the thoughtframe triggers for specific bindings of the variables to beliefs while the composite activity is active. As soon as the composite activity has ended, the bindings are reset and in the next execution of the composite activity, a thoughtframe with the same bindings of the variables to beliefs can trigger.

Priority

Setting the thoughtframe priority allows the model builder to control the execution sequence of thoughtframes if more then one thoughtframe is available at the same time. The priority can be set by setting it to a value greater than 0. Note that it is not recommended to use priorities to control the sequence of thoughtframe execution. A better modeling practice is to define better preconditions for the thoughtframes.

Example

thoughtframe tf_chooseBlakes {
      repeat: true;
      variables:
        forone(Cash) cs;
    when(knownval(current hasCash cs) and
        knownval(cs.amount > 15.00) and
        knownval(current.checkedDiner = false) and
        knownval(Campanile_Clock.time < 20))
    do {
      conclude((current.chosenDiner = Blakes_Diner), bc:100);
      conclude((current.checkedDiner = true), bc:100);
    }
  }

Defaults

  • display = <thoughtframe-name>
  • repeat = false
  • priority = 0

Constraints

The thoughtframe name has to be unique within the definition of a group, agent, object-class or object.

It is not possible to use unassigned variables in thoughtframes, therefore the definition of these variables is not allowed.

The consequences in thoughtframes can only conclude beliefs.