[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Thu, 8 Apr 2004 13:19:14 +0000 (UTC) 
Subject:Re: Is there special point(s) at using INDATA? 
From:A . Sloman 
Volume-ID: 

I guess not many pop-forum readers can help as they would need
knowledge of poprulebase and simagent

> I use INDATA at conditions for checking database of another object that is a
> sim_movable. Currently, sim_rulesystem of the obj. is [](for test step by
> step). I use the following format:
> [LVARS [obj_data=sim_data(valof(obj_name))]]
> [INDATA ?obj_data [== data ==]]

I can't see anything wrong with that. It conforms to the format
specified for 'INDATA' in HELP POPRULEBASE

> But, when I add ruleset that includes INDATA, simulation is not run without
> any error (of course objects are created).

If you post the error message from the MISHAP line to the end of
the DOING list, that may make it easier to diagnose.

You can also add temporary conditions to do extra tracing, because
poprulebase allows arbitrary pop11 code to be used in conditions
and actions. This is often very useful for debugging, as well
as supporting generality in the programs.

But make sure that any 'tracing' condition returns true as a result so
that the rule can proceed.

E.g.

;;; introduce new condition variable and give it a value
;;; which should, in this case, be a property table
    [LVARS [obj_data=sim_data(valof(obj_name))]]

;;; add a testing condition
    [POP11
        'Displaying obj_name and its valof' =>
        obj_name =>
        valof(obj_name) =>
        'Displaying obj_data' =>
        obj_data =>
        prb_print_table(obj_data);
        ;;; The above could produce a huge amount of printing. You can
        ;;; use the second format for prb_print_table(database, keys)
        ;;; to constrain the printing to a subset of the database that
        ;;; you want to check

        ;;; you can also use things like this:
        ;;; temporarily make obj_data the default database
        dlocal prb_database = obj_data;
        prb_present([ <... some pattern...> ]) =>

        ;;; final result for this condition
        true;
    ]
;;; continue as before
    [INDATA ?obj_data [== data ==]]



> Even, I defined the obj. based on
> sim_movable_agent, but it was not useful. Also, I assigned a list to its
> sense data, and result was same. To assign [] to sim_data of the obj. did
> not have any result, also.

The value of sim_data(obj) must be a property, not a list.

The default value, in the sim_object class definition, is the result of
doing this, which creates a new empty database using a property
table of the default size:

    prb_newdatabase(sim_dbsize, []);

(See LIB sim_agent, HELP PROPERTIES).

Warning: in a [POP11 ...] or [WHERE ...] condition, if you use
list expressions containing '%' or '^' or '^^' you can get counter
intuitive results, because the evaluation of the list expression may
not be when you expect. So you can write a separately compiled
procedure which works as you wish and then *call* it inside the
pop11 condition or action code.

That is why in the example above I did not use something like
this, which would work in a separate procedure:

        'Displaying obj_name and its valof and obj_data' =>
        [^obj_name ^(valof(obj_name)) ^obj_data] ==>

Aaron