Modifying the A-Prolog files
New features can be added to the action description or to the reasoning
modules by modifying the corresponding A-Prolog files.
To see how this works, let us modify file "3bulbs-plan-diag.dmn". We will
add a new fluent "battery_present", and a new action "install_battery".
Begin by running the APLAgent Manager, then load agent "plan-diag.agt"
and domain "3bulbs-plan-diag.dmn", and click "Run" to complete the setup.
Once the control windows pop up, click on menu "Domain", in the main window,
and then on "Edit...".
The APLAgent Manager will bring up the Domain Files Dialog. Make sure
that the "Action Description" Tab is selected, as that is where fluents
and actions should be defined.
Let us start by adding fluent "battery_present". The set of fluents of the
domain is defined by predicate "fluent" (it is visible near the bottom of
the Domain Files Dialog). Locate the three rules defining fluent (the first
starts with "fluent(on(B)) :-") and add the following fourth rule:
(do not forget the trailing dot)
This tells the APLAgent Manager that "battery_present" is the name of a fluent.
Now we need to update the description of the (indirect) effects of
actions flip(sw(N)) so that the corresponding bulb is turned on only if the
battery is present. Scroll down in the editor area until you find the
"Action Description" section.
The last rule in the picture below says that, when switch E is up, bulb E is on, unless
bulb E is malfunctioning. You will need to add the following condition right
(do not forget the trailing comma)
Next, we need to add action "install_battery". The set of actions that the
agent can perform (agent actions) is represented by predicate "agent_act".
Scroll to the beginning of the file and add the following fact to the
set of rules whose head is formed by predicate "agent_act" (they should
be right under where you added "fluent(battery_present)"):
Now we need to add a new dynamic law saying that, whenever action "install_battery"
is performed, fluent battery_present becomes true. Scroll down back to the
Action Description section of the file, and add the rule:
h(battery_present,T2) :- time(T1), time(T2),
T2 = T1 + 1,
This completes the changes to the action description. Click on "Ok" and the
APLAgent Manager will ask you for a confirmation to save the modified file.
Confirm by clicking on "Yes". Since changes to the action description
affect substantially the APLAgent Manager, the agent will need to be restarted.
The manager will ask for a confirmation before restarting the agent.
Once again, confirm by clicking "Yes". The changes to the action description
have now been loaded. You can check that by clicking "Set Observations",
in the History Window. A new fluent "battery_present" should be present
in the Enter Observations Dialog.
To see if the changes work as expected, let us run a few iterations of the agent.
Start by setting the observed value of up(sw(1)), up(sw(2)), and up(sw(3)) to
true and all fluents to false.
Notice that the bulbs are not on because the battery is not present.
Now close the Enter Observations Dialog, select goal "allBulbsOn", and click
"Iterate". If our modified domain works as expected, the only way for the agent
to turn on all bulbs is performing action "install_battery". The main window
should look like this:
Modifying the agent goals is equally simple. Agent goals are normally contained
in the Problem Description tab of the Domain Files Dialog. You can look at the demo
files to see how goals are represented. Notice that, if only goals are modified,
the agent does not need to be restarted, which makes it easy to add
goals on the fly during an experiment.
Modifying the reasoning modules requires a good knowledge of answer set programming
techniques, and is out of the scope of this tutorial. See below for pointers to
more detailed information on this and other topics.
You completed this section. Click here to move to the
next section. You can also go back to the main
For details on the representation formalism used, please refer to
Marcello Balduccini and Michael Gelfond.
Logic Programs with Consistency-Restoring Rules.
In AAAI Spring 2003 Symposium, 2003.
The paper is available from the Papers
section of the Knowledge Representation Lab
web site at Texas Tech University.