LogicalFormula.logicalConsequence is quite slow?

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

LogicalFormula.logicalConsequence is quite slow?

Alan Gordon White
Just sort of a quick question / observation... I've been modelling  
planning operator type information (i.e. preconditions, effects) for  
the actions used by agents, in order to test the validity of plan  
actions during their execution.  I've been using a string, parseable  
into a LogicalFormula object, to evaluate the  preconditions of each  
plan action (i.e. preconditions hold if logicalConsequence(a, u) !=  
null)

(the purpose of all this is to allow dynamic plan repair/replanning  
where the environment has changed and will thus stymie execution of  
future actions)

However, I've noted that this represents a relatively significant time  
delay (around 100ms or more) within my code; is this normal?

I'm making multiple logicalConsequences calls, at each selectIntention  
call and for each action associated with the current intention, so  
this creates a noticeable time lag compared against a 'default' agent.  
  When I'm running benchmark test simulations, this poses a major  
problem as any advantages of my approach are likely to be swallowed up  
by the processing delay.

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



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: LogicalFormula.logicalConsequence is quite slow?

Rafael H Bordini-2
Hi Alan,

Yes, unfortunately that is very much expected. Even though we use some
data structure to try and make the testing for logical consequence
faster, this is an inherently slow process (it's in fact high complexity
and therefore you should be careful in general when writing long logical
expressions in the plan context in "normal" AgentSpeak too). Specially
when the result is "fail", i.e., the expression is not a logical
consequence, because that means we'll have to try all possible
unifications and make sure neither of them satisfy the whole formula
(the process involves trying one possible unification, when we find a
problem we need to backtrack to the previous point where we made a
choice for one of various possible unifications, etc... you get the
picture).

If it helps, in straightforward benchmarking of course your approach
will be much slower, but you could argue, and even show particular
instances by designing your simulations for that (not cheating if you
phrase it right in terms of saying it CAN be useful rather than making
more general claims), that if a lot of plain failure is going to occur,
the time spend checking (perhaps not too complex) logical expressions  -
which might be all that is needed in many practical cases - is worth it.

Cheers,

Rafael

On 28/08/2012 10:42, Alan Gordon White wrote:

> Just sort of a quick question / observation... I've been modelling
> planning operator type information (i.e. preconditions, effects) for
> the actions used by agents, in order to test the validity of plan
> actions during their execution.  I've been using a string, parseable
> into a LogicalFormula object, to evaluate the  preconditions of each
> plan action (i.e. preconditions hold if logicalConsequence(a, u) !=
> null)
>
> (the purpose of all this is to allow dynamic plan repair/replanning
> where the environment has changed and will thus stymie execution of
> future actions)
>
> However, I've noted that this represents a relatively significant time
> delay (around 100ms or more) within my code; is this normal?
>
> I'm making multiple logicalConsequences calls, at each selectIntention
> call and for each action associated with the current intention, so
> this creates a noticeable time lag compared against a 'default' agent.
>    When I'm running benchmark test simulations, this poses a major
> problem as any advantages of my approach are likely to be swallowed up
> by the processing delay.
>


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: LogicalFormula.logicalConsequence is quite slow?

Alan Gordon White
Hi Rafael

Thanks.

I've been mostly using logicalConsequence to test for the truth of a  
ground statement (i.e. at(\"a\") | at(\"b\")) when checking  
preconditions... have I missed an easier mechanism in the API to  
simply evaluate that?

Thanks,
Alan

Quoting Rafael H Bordini <[hidden email]> on Wed, 29 Aug 2012  
16:14:37 -0300:

> Hi Alan,
>
> Yes, unfortunately that is very much expected. Even though we use some
> data structure to try and make the testing for logical consequence
> faster, this is an inherently slow process (it's in fact high complexity
> and therefore you should be careful in general when writing long logical
> expressions in the plan context in "normal" AgentSpeak too). Specially
> when the result is "fail", i.e., the expression is not a logical
> consequence, because that means we'll have to try all possible
> unifications and make sure neither of them satisfy the whole formula
> (the process involves trying one possible unification, when we find a
> problem we need to backtrack to the previous point where we made a
> choice for one of various possible unifications, etc... you get the
> picture).
>
> If it helps, in straightforward benchmarking of course your approach
> will be much slower, but you could argue, and even show particular
> instances by designing your simulations for that (not cheating if you
> phrase it right in terms of saying it CAN be useful rather than making
> more general claims), that if a lot of plain failure is going to occur,
> the time spend checking (perhaps not too complex) logical expressions  -
> which might be all that is needed in many practical cases - is worth it.
>
> Cheers,
>
> Rafael
>
> On 28/08/2012 10:42, Alan Gordon White wrote:
>> Just sort of a quick question / observation... I've been modelling
>> planning operator type information (i.e. preconditions, effects) for
>> the actions used by agents, in order to test the validity of plan
>> actions during their execution.  I've been using a string, parseable
>> into a LogicalFormula object, to evaluate the  preconditions of each
>> plan action (i.e. preconditions hold if logicalConsequence(a, u) !=
>> null)
>>
>> (the purpose of all this is to allow dynamic plan repair/replanning
>> where the environment has changed and will thus stymie execution of
>> future actions)
>>
>> However, I've noted that this represents a relatively significant time
>> delay (around 100ms or more) within my code; is this normal?
>>
>> I'm making multiple logicalConsequences calls, at each selectIntention
>> call and for each action associated with the current intention, so
>> this creates a noticeable time lag compared against a 'default' agent.
>>    When I'm running benchmark test simulations, this poses a major
>> problem as any advantages of my approach are likely to be swallowed up
>> by the processing delay.
>>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Jason-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jason-users
>
>



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



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|

Re: LogicalFormula.logicalConsequence is quite slow?

Jomi Hubner
Hi Alan,

indeed, in your case (ground formulae), logCons is usually quite fast since there is no backtracking. At least there is nothing in the API that is better then logCons.

if you need to improve performance, you should do it on your side :-) For instance, evaluating only some (relevant) actions, or using a kind of RETE algorithm, ...

HTH,

Jomi

On 30/08/2012, at 06:28, Alan Gordon White wrote:

> Hi Rafael
>
> Thanks.
>
> I've been mostly using logicalConsequence to test for the truth of a  
> ground statement (i.e. at(\"a\") | at(\"b\")) when checking  
> preconditions... have I missed an easier mechanism in the API to  
> simply evaluate that?
>
> Thanks,
> Alan
>
> Quoting Rafael H Bordini <[hidden email]> on Wed, 29 Aug 2012  
> 16:14:37 -0300:
>
>> Hi Alan,
>>
>> Yes, unfortunately that is very much expected. Even though we use some
>> data structure to try and make the testing for logical consequence
>> faster, this is an inherently slow process (it's in fact high complexity
>> and therefore you should be careful in general when writing long logical
>> expressions in the plan context in "normal" AgentSpeak too). Specially
>> when the result is "fail", i.e., the expression is not a logical
>> consequence, because that means we'll have to try all possible
>> unifications and make sure neither of them satisfy the whole formula
>> (the process involves trying one possible unification, when we find a
>> problem we need to backtrack to the previous point where we made a
>> choice for one of various possible unifications, etc... you get the
>> picture).
>>
>> If it helps, in straightforward benchmarking of course your approach
>> will be much slower, but you could argue, and even show particular
>> instances by designing your simulations for that (not cheating if you
>> phrase it right in terms of saying it CAN be useful rather than making
>> more general claims), that if a lot of plain failure is going to occur,
>> the time spend checking (perhaps not too complex) logical expressions  -
>> which might be all that is needed in many practical cases - is worth it.
>>
>> Cheers,
>>
>> Rafael
>>
>> On 28/08/2012 10:42, Alan Gordon White wrote:
>>> Just sort of a quick question / observation... I've been modelling
>>> planning operator type information (i.e. preconditions, effects) for
>>> the actions used by agents, in order to test the validity of plan
>>> actions during their execution.  I've been using a string, parseable
>>> into a LogicalFormula object, to evaluate the  preconditions of each
>>> plan action (i.e. preconditions hold if logicalConsequence(a, u) !=
>>> null)
>>>
>>> (the purpose of all this is to allow dynamic plan repair/replanning
>>> where the environment has changed and will thus stymie execution of
>>> future actions)
>>>
>>> However, I've noted that this represents a relatively significant time
>>> delay (around 100ms or more) within my code; is this normal?
>>>
>>> I'm making multiple logicalConsequences calls, at each selectIntention
>>> call and for each action associated with the current intention, so
>>> this creates a noticeable time lag compared against a 'default' agent.
>>>   When I'm running benchmark test simulations, this poses a major
>>> problem as any advantages of my approach are likely to be swallowed up
>>> by the processing delay.
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Jason-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/jason-users
>>
>>
>
>
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> 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


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users