how to minimize the number of instances of a literal, in clingo 4.5

2.8k views Asked by At

I'm unsure how to write an optimization statement in clingo4 (ASP solver).

I want to minimize the total number of instances of certain literals in each answer set.

I'm simulating a fire-response agent in ASP. The agent can choose to perform certain simple actions at different times, such as:

0{call_fire_department(Area, Time, Time+1)}1:- [preconditions].
0{send_security_guard(Guard, Area, Time, Time+1)}1:- [preconditions].
0{activate_fire_suppression(Area, Time, Time+1)}1:- [preconditions].

The agent has goals, which require a mix of the above actions, at specific times. I want to minimize the number of instances of each of the above, while still achieving the agent goals.

How do I write an appropriate optimization statement? (I'm assuming I will need a 'minimize' statement).

Thanks.

1

There are 1 answers

0
vukk On

How about

#minimize{
    1, call, Area, Time : call_fire_department(Area, Time, Time+1) ;
    1, send, Guard, Area, Time : send_security_guard(Guard, Area, Time, Time+1) ;
    1, activate, Area, Time : activate_fire_suppression(Area, Time, Time+1)
}.
  • 1 means count 1 towards the fact
  • Tag (call, send, activate), Guard, Area and Time make sure each fact is counted. E.g. without the tag activate_file_suppression(foo, 20, 21) and call_fire_department(foo, 20, 21) would be merged in the set.