Jam agents in a Nutshell Version 65 76i 1



Download 391.89 Kb.
Page7/15
Date09.06.2017
Size391.89 Kb.
#20093
1   2   3   4   5   6   7   8   9   10   ...   15

Plan Precondition


The “precondition:” field is an optional field that is used to specify the initial conditions that must be met before the plan should be considered for execution. The contents of the precondition are identical in form to the context field. Note that the precondition of a plan is checked only when a plan is being considered for inclusion in an APL; unlike a plan’s context, the precondition expression is not checked during runtime. Note also that the precondition may be evaluated more than a single time during each cycle through the interpreter as a plan may be considered at multiple metalevel reasoning levels.

Example: PRECONDITION: (>= (- $CURRENT_PRICE $BUY_PRICE) 5.0);


    1. Plan Utility


The optional “utility:” field of a plan specifies a numeric utility of the instantiated plan (i.e., has values from the current situation assigned to plan variables). The utility can be any valid expression that returns a numeric value. The expression can include plan variables. A plan has a default utility of 0.0 when it is not explicitly specified.

For goal-based plans, the plan’s utility value is combined with the goal’s utility to determine an overall utility for the instantiated plan. The combination function used currently is simple addition. For example, if a top-level goal has a “:utility” expression specified that evaluates to 10.5 and a plan with a matching goal specification has a “utility:” field that evaluates to 1.3, the JAM interpreter considers the plan to have a utility rating of 11.8.

Example: UTILITY: (- 50.0 $DISTANCE);

    1. Plan Attributes


Each plan may have an optional “attributes:” field that provides a place to specify characteristics about the plan that metalevel plans can extract and perform reasoning. The syntax of the attributes field is a simple text string. JAM places no restrictions upon the contents or structure of the string. A primitive action provided with the JAM distribution assumes that the string’s contents are in a list of label/value pairing and provides the functionality to extract the appropriate numeric value given an attribute’s label.

Example: ATTRIBUTES: “Cost 10 Time 14.6”


    1. Plan Effects


Each plan may have an optional “effects:” field that provides a place to specify a procedure that will be executed when the plan completes successfully. The syntax of the effects field’s contents is identical to a plan’s body but is typically used to modify the agent's world model (like an add/delete list in STRIPS [Fikes71:STRIPS]. The only limitation the effects field has with respect to a plan’s body field is that there can be no subgoaling within an effects section. Other than this, everything that can be done within a plan’s body can be done within the plan’s effects. The procedure of the effects section is executed atomically. That is, it cannot be interrupted by the agent interpreter (e.g., in order to switch execution to another, perhaps higher utility, plan)

Note that UMPRS plans have a field with the same name but that the semantics of the UMPRS implementation is quite different. In UMPRS, the effects field is used while the agent is executing in a “simulation” state and is not used during normal execution mode.

Example: EFFECTS: ASSERT ON $BLOCK1 $BLOCK2;

RETRACT ClEAR $BLOCK2;

    1. Plan Failure


The optional “failure:” field of a plan allows the agent designer to specify a procedure to be executed when the plan fails. If the plan fails, for example because the context fails, the agent interpreter will execute the actions found in the failure section before switching to other plans or goals. Execution of this section is performed as if the entire procedure were an atomic action. That is, the procedure is executed without the possibility of interruption by other plans or even from the normal interleaving of execution of actions with normal interpreter activity.

When a plan fails, the agent considers the failed plan and all of the failed plan’s subgoals to have failed. In this case, the failure sections of each of the failed plan’s subgoal’s plans are executed from the “leaf” plan - the plan for the goal at the bottom of the subgoal stack - back “up” to the failed plan. The following plans demonstrate the use of failure sections and, when executed, will illustrate how the failure sections are executed when a plan’s context fails.


GOALS:

ACHIEVE testing_done;


FACTS:

test_done "False";

force_failure 0;

//------------------------------------

// PLAN

//------------------------------------



PLAN {

NAME:


"Test Interpreter on subgoal failure"

DOCUMENTATION:

"Test Interpreter on subgoal failure"

GOAL:


ACHIEVE testing_done;

CONTEXT:


FACT test_done "False";

BODY:


EXECUTE print "Just before top level ACHIEVE.\n";

OR

{



ACHIEVE communicated "In Failure branch1.\n";

ACHIEVE subgoal_failed1;

}

{

ACHIEVE communicated "In branch2.\n";



};

}

//------------------------------------



// PLAN

//------------------------------------

PLAN {

NAME:


"Subgoal to failure1"

DOCUMENTATION:

"Intermediate level subgoal failure."

GOAL:


ACHIEVE subgoal_failed1;

CONTEXT:


FACT test_done "False";

FACT force_failure 0;

BODY:

EXECUTE print "In subgoal_failed1\n";



ACHIEVE subgoal_failed2;

}

//------------------------------------



// PLAN

//------------------------------------

PLAN {

NAME:


"Subgoal to failure"

DOCUMENTATION:

"Make sure subgoal failure 'works'."

GOAL:


ACHIEVE subgoal_failed2;

CONTEXT:


FACT test_done "False";

BODY:


EXECUTE print "In subgoal_failed2\n";

OR

{



ACHIEVE communicated "In Failure branch1 #2.\n";

ACHIEVE plan_failed;

}

{

ACHIEVE communicated "In Failure branch2 #2.\n";



ACHIEVE plan_failed;

};

FAILURE:



EXECUTE print "\nsubgoal_failed2 failed.\n\n";

}

//------------------------------------



// PLAN

//------------------------------------

PLAN {

NAME:


"Simply fail."

DOCUMENTATION:

"Make sure that PLAN fails"

GOAL:


ACHIEVE plan_failed;

CONTEXT:


FACT test_done "False";

BODY:


EXECUTE print "Just before failure.\n";

UPDATE (force_failure) (force_failure 1);

EXECUTE print "Just after failure. Should never get here.\n";

FAILURE:


EXECUTE print "\nplan_failed failed.\n\n";

}

//------------------------------------



// PLAN

//------------------------------------

PLAN {

NAME:


"Communicate the text to the user"

DOCUMENTATION:

"Print and speak the text"

GOAL:


ACHIEVE communicated $TEXT;

CONTEXT:


FACT test_done "False";
BODY:

EXECUTE print $TEXT;

FAILURE:

EXECUTE print "\ncommunicated failed.\n\n";

}
Runtime failure behavior for this set of plans is left to the reader for now. 



  1. Download 391.89 Kb.

    Share with your friends:
1   2   3   4   5   6   7   8   9   10   ...   15




The database is protected by copyright ©ininet.org 2024
send message

    Main page