Removing a rule from an agent's belief base

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Removing a rule from an agent's belief base

Iain Wallace-2
Quick question:

Is it possible to remove a Rule from an agent's belief base?

I think the answer's "no" from some quick testing, but just thought I'd check before I wrote a new internal action to handle this case.

Cheers,

Iain
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


------------------------------------------------------------------------------

_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: Removing a rule from an agent's belief base

Jomi Hubner
Hi Iain,

you are right: you have to write an internal action for that. You can take a look at demos/tell-rule/rules/get_rules.java to get some inspiration.

Cheers,

Jomi

On 19/05/2010, at 13:04, Iain Wallace wrote:

> Quick question:
>
> Is it possible to remove a Rule from an agent's belief base?
>
> I think the answer's "no" from some quick testing, but just thought I'd check before I wrote a new internal action to handle this case.
>
> Cheers,
>
> Iain
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Jason-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jason-users

--
Jomi Fred Hubner
Federal University of Santa Catarina
Department of Automation and Systems Engineering
PO Box 476, Florianópolis, SC
88040-900 Brazil
http://www.das.ufsc.br/~jomi


------------------------------------------------------------------------------

_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: Removing a rule from an agent's belief base

Iain Wallace-2
Thanks for the pointer. In case it helps others, here's my code based on that. It's not very tested at all yet though, so you have been warned...

// .removePlan(x(_)) will remove all plans matching x(_) in this case
//modified from get_rules in the Jason demos
public class removePlans extends DefaultInternalAction {

    @Override
    public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception {
        try {
            Literal pattern = (Literal)args[0];
            Iterator<Literal> i = ts.getAg().getBB().getCandidateBeliefs(pattern, un);
            ListTerm result = new ListTermImpl();
            while (i.hasNext()) {
            Literal l = i.next();
                if (l.isRule()) {
                    if (un.clone().unifies(pattern, l)) {
                    //System.out.println("    REMOVING: "+l);
                        ts.getAg().getBB().remove(l);
                    }
            }
            }
            return true;
        } catch (Exception e) {
        }
        return false;
    }
}


On 19 May 2010, at 17:13, Jomi Hubner wrote:

> Hi Iain,
>
> you are right: you have to write an internal action for that. You can take a look at demos/tell-rule/rules/get_rules.java to get some inspiration.
>
> Cheers,
>
> Jomi
>
> On 19/05/2010, at 13:04, Iain Wallace wrote:
>
>> Quick question:
>>
>> Is it possible to remove a Rule from an agent's belief base?
>>
>> I think the answer's "no" from some quick testing, but just thought I'd check before I wrote a new internal action to handle this case.
>>
>> Cheers,
>>
>> Iain
>> --
>> The University of Edinburgh is a charitable body, registered in
>> Scotland, with registration number SC005336.
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Jason-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/jason-users
>
> --
> Jomi Fred Hubner
> Federal University of Santa Catarina
> Department of Automation and Systems Engineering
> PO Box 476, Florianópolis, SC
> 88040-900 Brazil
> http://www.das.ufsc.br/~jomi
>
>


--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


------------------------------------------------------------------------------

_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users