SlideShare ist ein Scribd-Unternehmen logo
1 von 79
Downloaden Sie, um offline zu lesen
Clingo = Answer Set Programming + Control
Martin Gebser Roland Kaminski
Benjamin Kaufmann Torsten Schaub
University of Potsdam
Aalto University
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 1 / 20
Motivation
ASP is an approach to declarative problem solving, combining
a rich yet simple modeling language
with high-performance solving capacities
tailored to Knowledge Representation and Reasoning
Elaborate reasoning processes feature
incremental solving, as in planning or finite model finding, or even
reactive solving, as in robotics or query-answering
Problem
Logic
Program Grounder Solver Stable
Models
Solutions
- - -
?
6
One-shot ASP Solving
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 2 / 20
Motivation
ASP is an approach to declarative problem solving, combining
a rich yet simple modeling language
with high-performance solving capacities
tailored to Knowledge Representation and Reasoning
Elaborate reasoning processes feature
incremental solving, as in planning or finite model finding, or even
reactive solving, as in robotics or query-answering
Problem
Logic
Program Grounder Solver Stable
Models
Solutions
- - -
?
6
Incremental ASP Solving
6
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 2 / 20
Motivation
ASP is an approach to declarative problem solving, combining
a rich yet simple modeling language
with high-performance solving capacities
tailored to Knowledge Representation and Reasoning
Elaborate reasoning processes feature
incremental solving, as in planning or finite model finding, or even
reactive solving, as in robotics or query-answering
Problem
Logic
Program Grounder Solver Stable
Models
Solutions
- - -
?
6
Reactive ASP Solving
66
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 2 / 20
Outline
1 Background
2 (More) Control
3 Summary
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 3 / 20
Background
Outline
1 Background
2 (More) Control
3 Summary
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 4 / 20
Background
Clingo 3 Series
One-shot ASP solving by means of grounder gringo and solver clasp
Clingo: gringo | clasp
Incremental ASP solving by dedicated handling of three program parts
iClingo: Clingo [base ∪ n
i=1cumulative(i) ∪ volatile(n)]∗
n=1
base: grounded once and stored by solver
cumulative(i): grounded for increasing i-values and stored by solver
volatile(i): grounded like cumulative(i) but not stored by solver
Reactive ASP solving by further incorporating external program parts
oClingo: iClingo [ m
j=1external(j)]∗
m=1
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 5 / 20
Background
Clingo 3 Series
One-shot ASP solving by means of grounder gringo and solver clasp
Clingo: gringo | clasp
Incremental ASP solving by dedicated handling of three program parts
iClingo: Clingo [base ∪ n
i=1cumulative(i) ∪ volatile(n)]∗
n=1
base: grounded once and stored by solver
cumulative(i): grounded for increasing i-values and stored by solver
volatile(i): grounded like cumulative(i) but not stored by solver
Reactive ASP solving by further incorporating external program parts
oClingo: iClingo [ m
j=1external(j)]∗
m=1
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 5 / 20
Background
Clingo 3 Series
One-shot ASP solving by means of grounder gringo and solver clasp
Clingo: gringo | clasp
Incremental ASP solving by dedicated handling of three program parts
iClingo: Clingo [base ∪ n
i=1cumulative(i) ∪ volatile(n)]∗
n=1
base: grounded once and stored by solver
cumulative(i): grounded for increasing i-values and stored by solver
volatile(i): grounded like cumulative(i) but not stored by solver
Reactive ASP solving by further incorporating external program parts
oClingo: iClingo [ m
j=1external(j)]∗
m=1
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 5 / 20
Background
Elevator Control Example
Setup:
floor(1..3).
at(1,0).
Request 1:
request(2,1,1).
Request 2:
request(3,1,2).
1
2
3
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 6 / 20
Background
Elevator Control Example
Setup:
floor(1..3).
at(1,0).
Request 1:
request(2,1,1).
Request 2:
request(3,1,2).
1
2
3
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 6 / 20
Background
Elevator Control Example
Setup:
floor(1..3).
at(1,0).
Request 1:
request(2,1,1).
Request 2:
request(3,1,2).
1
2
3
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 6 / 20
Background
Elevator Control Example
Setup:
floor(1..3).
at(1,0).
Request 1:
request(2,1,1).
Request 2:
request(3,1,2).
1
2
3
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 6 / 20
Background
Elevator Control Example
Setup:
floor(1..3).
at(1,0).
Request 1:
request(2,1,1).
Request 2:
request(3,1,2).
1
2
3
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 6 / 20
Background
Encoding for One-shot ASP Solving
diff(-1;1).
{ move(D,T) : diff(D) } 1 :- time(T).
move(T) :- move(D,T).
% State update
at(F, T) :- at(F,T-1), time(T), not move(T).
at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D).
:- time(T), not 1 { at(F,T) } 1.
% Pending requests
task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T).
% Started tasks must be processed till completion
exec(F1,F2,D,T) :- task(F1,F2,D,T-1), at(F1,T-1), move(D,T).
exec(F2,D,T) :- exec(F1,F2,D,T).
exec(F2,D,T) :- exec(F2,D,T-1), time(T), not at(F2,T-1).
exec(D,T) :- exec(F2,D,T).
:- exec(D,T), not move(D,T).
:- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1).
% Move iff there is some task to process
open(T) :- task(F1,F2,D,T).
open(T) :- exec(F2,D,T), not at(F2,T).
:- move(T), not open(T-1).
:- open(T), not move(T+1).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 7 / 20
Background
One-shot ASP Solving
Request 1: clingo-3 <files> <(echo "time(1..3).")
Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2: clingo-3 <files> <(echo "time(1..5).")
Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 8 / 20
Background
One-shot ASP Solving
Request 1: clingo-3 <files> <(echo "time(1..3).")
Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2: clingo-3 <files> <(echo "time(1..5).")
Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 8 / 20
Background
One-shot ASP Solving
Request 1: clingo-3 <files> <(echo "time(1..3).")
Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2: clingo-3 <files> <(echo "time(1..5).")
Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 8 / 20
Background
One-shot ASP Solving
Request 1: clingo-3 <files> <(echo "time(1..3).")
Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2: clingo-3 <files> <(echo "time(1..5).")
Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 8 / 20
Background
Encoding for Incremental ASP Solving
#base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,T) : diff(D) } 1 :- time(T).
move(T) :- move(D,T).
% State update
at(F, T) :- at(F,T-1), time(T), not move(T).
at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D).
:- time(T), not 1 { at(F,T) } 1.
% Pending requests
task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T).
% Started tasks must be processed till completion
...
:- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1).
% Move iff there is some task to process
...
:- open(T), not move(T+1).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
Background
Encoding for Incremental ASP Solving
#base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,T) : diff(D) } 1 :- time(T).
move(T) :- move(D,T).
% State update
at(F, T) :- at(F,T-1), time(T), not move(T).
at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D).
:- time(T), not 1 { at(F,T) } 1.
% Pending requests
task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T).
% Started tasks must be processed till completion
...
:- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1).
% Move iff there is some task to process
...
:- open(T), not move(T+1).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
Background
Encoding for Incremental ASP Solving
#base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,T) : diff(D) } 1 :- time(T).
move(T) :- move(D,T).
% State update
at(F, T) :- at(F,T-1), time(T), not move(T).
at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D).
:- time(T), not 1 { at(F,T) } 1.
% Pending requests
task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T).
% Started tasks must be processed till completion
...
:- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1).
% Move iff there is some task to process
...
:- open(T), not move(T+1).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
Background
Encoding for Incremental ASP Solving
#base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,T) : diff(D) } 1 :- time(T).
move(T) :- move(D,T).
% State update
at(F, T) :- at(F,T-1), time(T), not move(T).
at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D).
:- time(T), not 1 { at(F,T) } 1.
% Pending requests
task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T).
% Started tasks must be processed till completion
...
:- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1).
% Move iff there is some task to process
...
:- open(T), not move(T+1).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
Background
Encoding for Incremental ASP Solving
#base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,T) : diff(D) } 1 :- time(T).
move(T) :- move(D,T).
% State update
at(F, T) :- at(F,T-1), time(T), not move(T).
at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D).
:- time(T), not 1 { at(F,T) } 1.
% Pending requests
task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T).
% Started tasks must be processed till completion
...
:- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1).
% Move iff there is some task to process
...
:- open(T), not move(T+1).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
Background
Encoding for Incremental ASP Solving
#base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
at(F, t) :- at(F,t-1), not move(t).
at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D).
:- not 1 { at(F,t) } 1.
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t), not move(D,t+1), not exec(D,t), not exec(-D,t+1).
% Move iff there is some task to process
...
:- open(t), not move(t+1).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
Background
Encoding for Incremental ASP Solving
#base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
at(F, t) :- at(F,t-1), not move(t).
at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D).
:- not 1 { at(F,t) } 1.
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t), not move(D,t+1), not exec(D,t), not exec(-D,t+1).
% Move iff there is some task to process
...
:- open(t), not move(t+1).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
Background
Encoding for Incremental ASP Solving
#base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
at(F, t) :- at(F,t-1), not move(t).
at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D).
:- not 1 { at(F,t) } 1.
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
...
:- open(t-1), not move(t).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
Background
Encoding for Incremental ASP Solving
#base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
at(F, t) :- at(F,t-1), not move(t).
at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D).
:- not 1 { at(F,t) } 1.
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
...
:- open(t-1), not move(t).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
Background
Incremental ASP Solving
Request 1: iclingo-3 <files>
Solving... Solving... Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2: iclingo-3 <files>
Solving... Solving... Solving... Solving... Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 10 / 20
Background
Incremental ASP Solving
Request 1: iclingo-3 <files>
Solving... Solving... Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2: iclingo-3 <files>
Solving... Solving... Solving... Solving... Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 10 / 20
Background
Incremental ASP Solving
Request 1: iclingo-3 <files>
Solving... Solving... Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2: iclingo-3 <files>
Solving... Solving... Solving... Solving... Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 10 / 20
Background
Incremental ASP Solving
Request 1: iclingo-3 <files>
Solving... Solving... Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2: iclingo-3 <files>
Solving... Solving... Solving... Solving... Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 10 / 20
Background
Encoding for Reactive ASP Solving
#base.
#external request(F1,F2,0) : floor(F1) : floor(F2) : F1 != F2.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
#external request(F1,F2,t) : floor(F1) : floor(F2) : F1 != F2.
...
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
...
Inputs:
#step 1.
request(2,1,1).
#endstep.
#step 2.
request(3,1,2).
#endstep.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 11 / 20
Background
Encoding for Reactive ASP Solving
#base.
#external request(F1,F2,0) : floor(F1) : floor(F2) : F1 != F2.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
#external request(F1,F2,t) : floor(F1) : floor(F2) : F1 != F2.
...
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
...
Inputs:
#step 1.
request(2,1,1).
#endstep.
#step 2.
request(3,1,2).
#endstep.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 11 / 20
Background
Encoding for Reactive ASP Solving
#base.
#external request(F1,F2,0) : floor(F1) : floor(F2) : F1 != F2.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
#external request(F1,F2,t) : floor(F1) : floor(F2) : F1 != F2.
...
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
...
Inputs:
#step 1.
request(2,1,1).
#endstep.
#step 2.
request(3,1,2).
#endstep.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 11 / 20
Background
Encoding for Reactive ASP Solving
#base.
#external request(F1,F2,0) : floor(F1) : floor(F2) : F1 != F2.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
#external request(F1,F2,t) : floor(F1) : floor(F2) : F1 != F2.
...
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
...
Inputs:
#step 1.
request(2,1,1).
#endstep.
#step 2.
request(3,1,2).
#endstep.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 11 / 20
Background
Reactive ASP Solving
oclingo-3 <files> + controller.py
Request 1:
Solving... Solving... Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2:
Solving... Solving... Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 12 / 20
Background
Reactive ASP Solving
oclingo-3 <files> + controller.py
Request 1:
Solving... Solving... Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2:
Solving... Solving... Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 12 / 20
Background
Reactive ASP Solving
oclingo-3 <files> + controller.py
Request 1:
Solving... Solving... Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2:
Solving... Solving... Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 12 / 20
Background
Reactive ASP Solving
oclingo-3 <files> + controller.py
Request 1:
Solving... Solving... Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2:
Solving... Solving... Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 12 / 20
Background
Reactive ASP Solving
oclingo-3 <files> + controller.py
Request 1:
Solving... Solving... Solving...
Answer: 1
move(1,2) move(-1,3)
Request 2:
Solving... Solving... Solving...
Answer: 1
move(1,2) move(1,3) move(-1,4) move(-1,5)
1
2
3
1
2
3
1
1
2
3
1 2 3
1
2
3
1
2
1
2
3
1
2
2
3 4
5
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 12 / 20
(More) Control
Outline
1 Background
2 (More) Control
3 Summary
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 13 / 20
(More) Control
Clingo 4 Approach
Custom grounding and solving via embedded scripting languages
Lua: main(prg), prg:ground(parts), prg:solve(), . . .
Python: main(prg), prg.ground(parts), prg.solve(), . . .
Library: prg.ground(parts), prg.solve(), . . .
Predecessor systems can easily be scripted
One-shot ASP solving (default): (ground | solve)
Incremental ASP solving: (ground | solve)∗
Reactive ASP solving: (ground∗
| solve)∗
. . .
Clingo: ASP + Control
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 14 / 20
(More) Control
Clingo 4 Approach
Custom grounding and solving via embedded scripting languages
Lua: main(prg), prg:ground(parts), prg:solve(), . . .
Python: main(prg), prg.ground(parts), prg.solve(), . . .
Library: prg.ground(parts), prg.solve(), . . .
Predecessor systems can easily be scripted
One-shot ASP solving (default): (ground | solve)
Incremental ASP solving: (ground | solve)∗
Reactive ASP solving: (ground∗
| solve)∗
. . .
Clingo: ASP + Control
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 14 / 20
(More) Control
Clingo 4 Approach
Custom grounding and solving via embedded scripting languages
Lua: main(prg), prg:ground(parts), prg:solve(), . . .
Python: main(prg), prg.ground(parts), prg.solve(), . . .
Library: prg.ground(parts), prg.solve(), . . .
Predecessor systems can easily be scripted
One-shot ASP solving (default): (ground | solve)
Incremental ASP solving: (ground | solve)∗
Reactive ASP solving: (ground∗
| solve)∗
. . .
Clingo: ASP + Control
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 14 / 20
(More) Control
Clingo 4 Approach
Custom grounding and solving via embedded scripting languages
Lua: main(prg), prg:ground(parts), prg:solve(), . . .
Python: main(prg), prg.ground(parts), prg.solve(), . . .
Library: prg.ground(parts), prg.solve(), . . .
Predecessor systems can easily be scripted
One-shot ASP solving (default): (ground | solve)
Incremental ASP solving: (ground | solve)∗
Reactive ASP solving: (ground∗
| solve)∗
. . .
Clingo: ASP + Control
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 14 / 20
(More) Control
Clingo 4 Approach
Custom grounding and solving via embedded scripting languages
Lua: main(prg), prg:ground(parts), prg:solve(), . . .
Python: main(prg), prg.ground(parts), prg.solve(), . . .
Library: prg.ground(parts), prg.solve(), . . .
Predecessor systems can easily be scripted
One-shot ASP solving (default): (ground | solve)
Incremental ASP solving: (ground | solve)∗
Reactive ASP solving: (ground∗
| solve)∗
. . .
Clingo: ASP + Control
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 14 / 20
(More) Control
Encoding for Incremental ASP Solving
#base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
at(F, t) :- at(F,t-1), not move(t).
at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D).
:- not 1 { at(F,t) } 1.
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
...
:- open(t-1), not move(t).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
(More) Control
Encoding for Incremental ASP Solving
#base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
at(F, t) :- at(F,t-1), not move(t).
at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D).
:- not 1 { at(F,t) } 1.
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
...
:- open(t-1), not move(t).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
(More) Control
Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
at(F, t) :- at(F,t-1), not move(t).
at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D).
:- not 1 { at(F,t) } 1.
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
...
:- open(t-1), not move(t).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
(More) Control
Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#cumulative t.
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
at(F, t) :- at(F,t-1), not move(t).
at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D).
:- not 1 { at(F,t) } 1.
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
...
:- open(t-1), not move(t).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
(More) Control
Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#program cumulative(t).
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
at(F, t) :- at(F,t-1), not move(t).
at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D).
:- not 1 { at(F,t) } 1.
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
...
:- open(t-1), not move(t).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
(More) Control
Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#program cumulative(t).
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
at(F, t) :- at(F,t-1), not move(t).
at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D).
:- not 1 { at(F,t) } 1.
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
...
:- open(t-1), not move(t).
#volatile t.
:- open(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
(More) Control
Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#program cumulative(t).
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
at(F, t) :- at(F,t-1), not move(t).
at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D).
:- not 1 { at(F,t) } 1.
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
...
:- open(t-1), not move(t).
#external query(t).
:- open(t), query(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
(More) Control
Script for Incremental ASP Solving
#script(python)
from gringo import *
def main(prg):
imin = prg.get const("imin")
if imin == None: imin = 1
step = 0
parts = [("base", [])]
while True:
if step < imin:
step = step+1
parts.append(("cumulative", [step]))
if step == imin:
prg.ground(parts)
parts = []
prg.assign external(Fun("query", [step]), True)
ret = prg.solve()
if ret == SolveResult.SAT: break
prg.release external(Fun("query", [step]))
imin = imin+1
#end.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
(More) Control
Script for Incremental ASP Solving
#script(python)
from gringo import *
def main(prg):
imin = prg.get const("imin")
if imin == None: imin = 1
step = 0
parts = [("base", [])]
while True:
if step < imin:
step = step+1
parts.append(("cumulative", [step]))
if step == imin:
prg.ground(parts)
parts = []
prg.assign external(Fun("query", [step]), True)
ret = prg.solve()
if ret == SolveResult.SAT: break
prg.release external(Fun("query", [step]))
imin = imin+1
#end.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
(More) Control
Script for Incremental ASP Solving
#script(python)
from gringo import *
def main(prg):
imin = prg.get const("imin")
if imin == None: imin = 1
step = 0
parts = [("base", [])]
while True:
if step < imin:
step = step+1
parts.append(("cumulative", [step]))
if step == imin:
prg.ground(parts)
parts = []
prg.assign external(Fun("query", [step]), True)
ret = prg.solve()
if ret == SolveResult.SAT: break
prg.release external(Fun("query", [step]))
imin = imin+1
#end.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
(More) Control
Script for Incremental ASP Solving
#script(python)
from gringo import *
def main(prg):
imin = prg.get const("imin")
if imin == None: imin = 1
step = 0
parts = [("base", [])]
while True:
if step < imin:
step = step+1
parts.append(("cumulative", [step]))
if step == imin:
prg.ground(parts)
parts = []
prg.assign external(Fun("query", [step]), True)
ret = prg.solve()
if ret == SolveResult.SAT: break
prg.release external(Fun("query", [step]))
imin = imin+1
#end.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
(More) Control
Script for Incremental ASP Solving
#script(python)
from gringo import *
def main(prg):
imin = prg.get const("imin")
if imin == None: imin = 1
step = 0
parts = [("base", [])]
while True:
if step < imin:
step = step+1
parts.append(("cumulative", [step]))
if step == imin:
prg.ground(parts)
parts = []
prg.assign external(Fun("query", [step]), True)
ret = prg.solve()
if ret == SolveResult.SAT: break
prg.release external(Fun("query", [step]))
imin = imin+1
#end.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
(More) Control
Script for Incremental ASP Solving
#script(python)
from gringo import *
def main(prg):
imin = prg.get const("imin")
if imin == None: imin = 1
step = 0
parts = [("base", [])]
while True:
if step < imin:
step = step+1
parts.append(("cumulative", [step]))
if step == imin:
prg.ground(parts)
parts = []
prg.assign external(Fun("query", [step]), True)
ret = prg.solve()
if ret == SolveResult.SAT: break
prg.release external(Fun("query", [step]))
imin = imin+1
#end.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
(More) Control
Script for Incremental ASP Solving
#script(python)
from gringo import *
def main(prg):
imin = prg.get const("imin")
if imin == None: imin = 1
step = 0
parts = [("base", [])]
while True:
if step < imin:
step = step+1
parts.append(("cumulative", [step]))
if step == imin:
prg.ground(parts)
parts = []
prg.assign external(Fun("query", [step]), True)
ret = prg.solve()
if ret == SolveResult.SAT: break
prg.release external(Fun("query", [step]))
imin = imin+1
#end.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
(More) Control
Script for Incremental ASP Solving
#script(python)
from gringo import *
def main(prg):
imin = prg.get const("imin")
if imin == None: imin = 1
step = 0
parts = [("base", [])]
while True:
if step < imin:
step = step+1
parts.append(("cumulative", [step]))
if step == imin:
prg.ground(parts)
parts = []
prg.assign external(Fun("query", [step]), True)
ret = prg.solve()
if ret == SolveResult.SAT: break
prg.release external(Fun("query", [step]))
imin = imin+1
#end.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
(More) Control
My Script for Incremental ASP Solving
#script(python)
from gringo import *
def main(prg):
imin = prg.get const("imin")
if imin == None: imin = 1
step = 0
parts = [("base", [])]
while True:
if step < imin:
step = step+1
parts.append(("cumulative", [step]))
if step == imin:
prg.ground(parts)
parts = []
prg.assign external(Fun("query", [step]), True)
ret = prg.solve()
if ret == SolveResult.SAT: break
prg.release external(Fun("query", [step]))
imin = imin+1
#end.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
(More) Control
My Script for Incremental ASP Solving
#script(python)
from gringo import *
def main(prg):
imin = prg.get const("imin")
if imin == None: imin = 1
step = 0
parts = [("base", []), ("task", [step])]
while True:
if step < imin:
step = step+1
parts.append(("cumulative", [step]))
parts.append(("task", [step]))
if step == imin:
prg.ground(parts)
parts = []
ret = prg.solve()
if ret == SolveResult.SAT: break
imin = imin+1
#end.
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
(More) Control
My Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#program cumulative(t).
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
...
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
open(t) :- task(F1,F2,D,t).
open(t) :- exec(F2,D,t), not at(F2,t).
:- move(t), not open(t-1).
:- open(t-1), not move(t).
#external query(t).
:- open(t), query(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
(More) Control
My Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#program cumulative(t).
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
...
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
open(t) :- task(F1,F2,D,t).
open(t) :- exec(F2,D,t), not at(F2,t).
:- move(t), not open(t-1).
:- open(t-1), not move(t).
#external query(t).
:- open(t), query(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
(More) Control
My Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|.
#program cumulative(t).
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
...
% Pending requests
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
open(t) :- task(F1,F2,D,t).
open(t) :- exec(F2,D,t), not at(F2,t).
:- move(t), not open(t-1).
:- open(t-1), not move(t).
#external query(t).
:- open(t), query(t).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
(More) Control
My Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
#program task(t).
#external move(t+1).
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
open(t) :- task(F1,F2,D,t).
:- open(t), not move(t+1).
#program cumulative(t).
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
...
% Pending requests
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
open(t) :- exec(F2,D,t), not at(F2,t).
:- move(t), not open(t-1).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
(More) Control
My Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
#program task(t).
#external move(t+1).
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
open(t) :- task(F1,F2,D,t).
:- open(t), not move(t+1).
#program cumulative(t).
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
...
% Pending requests
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
open(t) :- exec(F2,D,t), not at(F2,t).
:- move(t), not open(t-1).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
(More) Control
My Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
#program task(t).
#external move(t+1).
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
open(t) :- task(F1,F2,D,t).
:- open(t), not move(t+1).
#program cumulative(t).
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
...
% Pending requests
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t).
% Move iff there is some task to process
open(t) :- exec(F2,D,t), not at(F2,t).
:- move(t), not open(t-1).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
(More) Control
My Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
#program task(t).
#external move(t+1).
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
open(t) :- task(F1,F2,D,t).
:- open(t), not move(t+1).
#program cumulative(t).
#external move(D,t+1) : diff(D).
#external exec(D,t+1) : diff(D).
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
...
% Pending requests
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t), not move(D,t+1), not exec(D,t), not exec(-D,t+1).
% Move iff there is some task to process
open(t) :- exec(F2,D,t), not at(F2,t).
:- move(t), not open(t-1).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
(More) Control
My Encoding for Incremental ASP Solving
#program base.
diff(-1;1).
#program task(t).
#external move(t+1).
task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|.
open(t) :- task(F1,F2,D,t).
:- open(t), not move(t+1).
#program cumulative(t).
#external move(D,t+1) : diff(D).
#external exec(D,t+1) : diff(D).
{ move(D,t) : diff(D) } 1.
move(t) :- move(D,t).
% State update
...
% Pending requests
task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t).
% Started tasks must be processed till completion
...
:- move(D,t), not move(D,t+1), not exec(D,t), not exec(-D,t+1).
% Move iff there is some task to process
open(t) :- exec(F2,D,t), not at(F2,t).
:- move(t), not open(t-1).
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
(More) Control
Custom ASP Solving
Encoding consisting of named and parameterizable subprograms
#program base. (default), #program cumulative(t)., . . .
External (yet undefined) atoms provide input interface to other parts
#external <atom> [ : <body> ].
Embedded scripts allow for flexible grounding and solving control
#script(python | lua) . . . main(prg) . . . #end.
Instantiation triggered by passing subprogram names plus arguments
prg.ground([("base", []), ("task", [step])])
Ground program parts constitute modules (with disjoint head atoms)
Search for stable models of ground program parts stored by solver
prg.solve(), prg.solve(on model = pretty print), . . .
Incremental and/or reactive ASP solving via “i/oClingo” scripts
#include <iclingo>.
prg.add("request1", [], "request(2,1,1).")
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 18 / 20
(More) Control
Custom ASP Solving
Encoding consisting of named and parameterizable subprograms
#program base. (default), #program cumulative(t)., . . .
External (yet undefined) atoms provide input interface to other parts
#external <atom> [ : <body> ].
Embedded scripts allow for flexible grounding and solving control
#script(python | lua) . . . main(prg) . . . #end.
Instantiation triggered by passing subprogram names plus arguments
prg.ground([("base", []), ("task", [step])])
Ground program parts constitute modules (with disjoint head atoms)
Search for stable models of ground program parts stored by solver
prg.solve(), prg.solve(on model = pretty print), . . .
Incremental and/or reactive ASP solving via “i/oClingo” scripts
#include <iclingo>.
prg.add("request1", [], "request(2,1,1).")
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 18 / 20
(More) Control
Custom ASP Solving
Encoding consisting of named and parameterizable subprograms
#program base. (default), #program cumulative(t)., . . .
External (yet undefined) atoms provide input interface to other parts
#external <atom> [ : <body> ].
Embedded scripts allow for flexible grounding and solving control
#script(python | lua) . . . main(prg) . . . #end.
Instantiation triggered by passing subprogram names plus arguments
prg.ground([("base", []), ("task", [step])])
Ground program parts constitute modules (with disjoint head atoms)
Search for stable models of ground program parts stored by solver
prg.solve(), prg.solve(on model = pretty print), . . .
Incremental and/or reactive ASP solving via “i/oClingo” scripts
#include <iclingo>.
prg.add("request1", [], "request(2,1,1).")
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 18 / 20
Summary
Outline
1 Background
2 (More) Control
3 Summary
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 19 / 20
Summary
Summary
ASP as an under-the-hood technology !
Clingo 4
Multi-shot ASP solving
Continuously changing programs
Opens up new areas of applications
Agents
Policies
Planning
Robotics
Interaction
Theory solving
Query-answering
. . .
http://potassco.sourceforge.net
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 20 / 20
Summary
Summary
ASP as an under-the-hood technology !
Clingo 4
Multi-shot ASP solving
Continuously changing programs
Opens up new areas of applications
Agents
Policies
Planning
Robotics
Interaction
Theory solving
Query-answering
. . .
http://potassco.sourceforge.net
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 20 / 20
Summary
Summary
ASP as an under-the-hood technology !
Clingo 4
Multi-shot ASP solving
Continuously changing programs
Opens up new areas of applications
Agents
Policies
Planning
Robotics
Interaction
Theory solving
Query-answering
. . .
http://potassco.sourceforge.net
M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 20 / 20

Weitere ähnliche Inhalte

Was ist angesagt?

Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)SHAMJITH KM
 
Register Allocation
Register AllocationRegister Allocation
Register AllocationEelco Visser
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic NotationsRishabh Soni
 
asymptotic notations i
asymptotic notations iasymptotic notations i
asymptotic notations iAli mahmood
 
Lec 5 asymptotic notations and recurrences
Lec 5 asymptotic notations and recurrencesLec 5 asymptotic notations and recurrences
Lec 5 asymptotic notations and recurrencesAnkita Karia
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsMamta Pandey
 
Python programs - PPT file (Polytechnics)
Python programs - PPT file (Polytechnics)Python programs - PPT file (Polytechnics)
Python programs - PPT file (Polytechnics)SHAMJITH KM
 
Lisp programming
Lisp programmingLisp programming
Lisp programmingilias ahmed
 
Algorithm Analysis
Algorithm AnalysisAlgorithm Analysis
Algorithm AnalysisMegha V
 
Dsoop (co 221) 1
Dsoop (co 221) 1Dsoop (co 221) 1
Dsoop (co 221) 1Puja Koch
 
Summary topic 5 functions&amp;graph
Summary topic 5 functions&amp;graphSummary topic 5 functions&amp;graph
Summary topic 5 functions&amp;graphjessylingmy
 

Was ist angesagt? (17)

Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)Python programs - first semester computer lab manual (polytechnics)
Python programs - first semester computer lab manual (polytechnics)
 
Register Allocation
Register AllocationRegister Allocation
Register Allocation
 
Algorithum Analysis
Algorithum AnalysisAlgorithum Analysis
Algorithum Analysis
 
Asymptotic Notations
Asymptotic NotationsAsymptotic Notations
Asymptotic Notations
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
asymptotic notations i
asymptotic notations iasymptotic notations i
asymptotic notations i
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Lec 5 asymptotic notations and recurrences
Lec 5 asymptotic notations and recurrencesLec 5 asymptotic notations and recurrences
Lec 5 asymptotic notations and recurrences
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Python programs - PPT file (Polytechnics)
Python programs - PPT file (Polytechnics)Python programs - PPT file (Polytechnics)
Python programs - PPT file (Polytechnics)
 
Lisp programming
Lisp programmingLisp programming
Lisp programming
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
Algorithm Class at KPHB (C, C++ Course Training Institute in KPHB, Kukatpally...
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
Algorithm Analysis
Algorithm AnalysisAlgorithm Analysis
Algorithm Analysis
 
Dsoop (co 221) 1
Dsoop (co 221) 1Dsoop (co 221) 1
Dsoop (co 221) 1
 
Summary topic 5 functions&amp;graph
Summary topic 5 functions&amp;graphSummary topic 5 functions&amp;graph
Summary topic 5 functions&amp;graph
 

Ähnlich wie 2015 01 09 - Rende - Unical - Martin Gebser: Clingo = Answer Set Programming + Control

dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting classgiridaroori
 
The Concurrent Constraint Programming Research Programmes -- Redux (part2)
The Concurrent Constraint Programming Research Programmes -- Redux (part2)The Concurrent Constraint Programming Research Programmes -- Redux (part2)
The Concurrent Constraint Programming Research Programmes -- Redux (part2)Pierre Schaus
 
A study of the worst case ratio of a simple algorithm for simple assembly lin...
A study of the worst case ratio of a simple algorithm for simple assembly lin...A study of the worst case ratio of a simple algorithm for simple assembly lin...
A study of the worst case ratio of a simple algorithm for simple assembly lin...narmo
 
lecture01_lecture01_lecture0001_ceva.pdf
lecture01_lecture01_lecture0001_ceva.pdflecture01_lecture01_lecture0001_ceva.pdf
lecture01_lecture01_lecture0001_ceva.pdfAnaNeacsu5
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance HaskellJohan Tibell
 
Symbolic Execution as DPLL Modulo Theories
Symbolic Execution as DPLL Modulo TheoriesSymbolic Execution as DPLL Modulo Theories
Symbolic Execution as DPLL Modulo TheoriesQuoc-Sang Phan
 
Need for Controllers having Integer Coefficients in Homomorphically Encrypted D...
Need for Controllers having Integer Coefficients in Homomorphically Encrypted D...Need for Controllers having Integer Coefficients in Homomorphically Encrypted D...
Need for Controllers having Integer Coefficients in Homomorphically Encrypted D...CDSL_at_SNU
 
Analysis Of Algorithms I
Analysis Of Algorithms IAnalysis Of Algorithms I
Analysis Of Algorithms ISri Prasanna
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1Dynamic Programming - Part 1
Dynamic Programming - Part 1Amrinder Arora
 
dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)Mumtaz Ali
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihmSajid Marwat
 

Ähnlich wie 2015 01 09 - Rende - Unical - Martin Gebser: Clingo = Answer Set Programming + Control (20)

1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx1. Ch_1 SL_1_Intro to Matlab.pptx
1. Ch_1 SL_1_Intro to Matlab.pptx
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
 
Computer Network Assignment Help
Computer Network Assignment HelpComputer Network Assignment Help
Computer Network Assignment Help
 
Matlab integration
Matlab integrationMatlab integration
Matlab integration
 
Dynamic programing
Dynamic programingDynamic programing
Dynamic programing
 
The Concurrent Constraint Programming Research Programmes -- Redux (part2)
The Concurrent Constraint Programming Research Programmes -- Redux (part2)The Concurrent Constraint Programming Research Programmes -- Redux (part2)
The Concurrent Constraint Programming Research Programmes -- Redux (part2)
 
A study of the worst case ratio of a simple algorithm for simple assembly lin...
A study of the worst case ratio of a simple algorithm for simple assembly lin...A study of the worst case ratio of a simple algorithm for simple assembly lin...
A study of the worst case ratio of a simple algorithm for simple assembly lin...
 
lecture01_lecture01_lecture0001_ceva.pdf
lecture01_lecture01_lecture0001_ceva.pdflecture01_lecture01_lecture0001_ceva.pdf
lecture01_lecture01_lecture0001_ceva.pdf
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
Symbolic Execution as DPLL Modulo Theories
Symbolic Execution as DPLL Modulo TheoriesSymbolic Execution as DPLL Modulo Theories
Symbolic Execution as DPLL Modulo Theories
 
Programming Exam Help
 Programming Exam Help Programming Exam Help
Programming Exam Help
 
Need for Controllers having Integer Coefficients in Homomorphically Encrypted D...
Need for Controllers having Integer Coefficients in Homomorphically Encrypted D...Need for Controllers having Integer Coefficients in Homomorphically Encrypted D...
Need for Controllers having Integer Coefficients in Homomorphically Encrypted D...
 
Analysis Of Algorithms I
Analysis Of Algorithms IAnalysis Of Algorithms I
Analysis Of Algorithms I
 
Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 
Algorithms Design Exam Help
Algorithms Design Exam HelpAlgorithms Design Exam Help
Algorithms Design Exam Help
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1Dynamic Programming - Part 1
Dynamic Programming - Part 1
 
1.6 all notes
1.6 all notes1.6 all notes
1.6 all notes
 
dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)dynamic programming complete by Mumtaz Ali (03154103173)
dynamic programming complete by Mumtaz Ali (03154103173)
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
 
Algorithms Design Homework Help
Algorithms Design Homework HelpAlgorithms Design Homework Help
Algorithms Design Homework Help
 

Mehr von kaliaragorn

angryhex_slides2014.pdf
angryhex_slides2014.pdfangryhex_slides2014.pdf
angryhex_slides2014.pdfkaliaragorn
 
Architettura dei calcolatori
Architettura dei calcolatoriArchitettura dei calcolatori
Architettura dei calcolatorikaliaragorn
 
2016 attestati partecipazione m01
2016   attestati partecipazione m012016   attestati partecipazione m01
2016 attestati partecipazione m01kaliaragorn
 
2016 04 - Attestati Partecipazione Seminario "L'informatica oggi: applicazion...
2016 04 - Attestati Partecipazione Seminario "L'informatica oggi: applicazion...2016 04 - Attestati Partecipazione Seminario "L'informatica oggi: applicazion...
2016 04 - Attestati Partecipazione Seminario "L'informatica oggi: applicazion...kaliaragorn
 
Nuvola rosa 2016
Nuvola rosa 2016Nuvola rosa 2016
Nuvola rosa 2016kaliaragorn
 
Introduzione alla logica
Introduzione alla logicaIntroduzione alla logica
Introduzione alla logicakaliaragorn
 
Flier cuda - Dipartimento di matematica e informatica - Università della Cala...
Flier cuda - Dipartimento di matematica e informatica - Università della Cala...Flier cuda - Dipartimento di matematica e informatica - Università della Cala...
Flier cuda - Dipartimento di matematica e informatica - Università della Cala...kaliaragorn
 
2015 01 22 - Rende - Unical - Angelo Fanelli: An Overview of Congestion Games
2015 01 22 - Rende - Unical - Angelo Fanelli: An Overview of Congestion Games2015 01 22 - Rende - Unical - Angelo Fanelli: An Overview of Congestion Games
2015 01 22 - Rende - Unical - Angelo Fanelli: An Overview of Congestion Gameskaliaragorn
 

Mehr von kaliaragorn (8)

angryhex_slides2014.pdf
angryhex_slides2014.pdfangryhex_slides2014.pdf
angryhex_slides2014.pdf
 
Architettura dei calcolatori
Architettura dei calcolatoriArchitettura dei calcolatori
Architettura dei calcolatori
 
2016 attestati partecipazione m01
2016   attestati partecipazione m012016   attestati partecipazione m01
2016 attestati partecipazione m01
 
2016 04 - Attestati Partecipazione Seminario "L'informatica oggi: applicazion...
2016 04 - Attestati Partecipazione Seminario "L'informatica oggi: applicazion...2016 04 - Attestati Partecipazione Seminario "L'informatica oggi: applicazion...
2016 04 - Attestati Partecipazione Seminario "L'informatica oggi: applicazion...
 
Nuvola rosa 2016
Nuvola rosa 2016Nuvola rosa 2016
Nuvola rosa 2016
 
Introduzione alla logica
Introduzione alla logicaIntroduzione alla logica
Introduzione alla logica
 
Flier cuda - Dipartimento di matematica e informatica - Università della Cala...
Flier cuda - Dipartimento di matematica e informatica - Università della Cala...Flier cuda - Dipartimento di matematica e informatica - Università della Cala...
Flier cuda - Dipartimento di matematica e informatica - Università della Cala...
 
2015 01 22 - Rende - Unical - Angelo Fanelli: An Overview of Congestion Games
2015 01 22 - Rende - Unical - Angelo Fanelli: An Overview of Congestion Games2015 01 22 - Rende - Unical - Angelo Fanelli: An Overview of Congestion Games
2015 01 22 - Rende - Unical - Angelo Fanelli: An Overview of Congestion Games
 

Kürzlich hochgeladen

Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)DHURKADEVIBASKAR
 
‏‏VIRUS - 123455555555555555555555555555555555555555
‏‏VIRUS -  123455555555555555555555555555555555555555‏‏VIRUS -  123455555555555555555555555555555555555555
‏‏VIRUS - 123455555555555555555555555555555555555555kikilily0909
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxyaramohamed343013
 
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptxRESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptxFarihaAbdulRasheed
 
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...lizamodels9
 
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxLIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxmalonesandreagweneth
 
Manassas R - Parkside Middle School 🌎🏫
Manassas R - Parkside Middle School 🌎🏫Manassas R - Parkside Middle School 🌎🏫
Manassas R - Parkside Middle School 🌎🏫qfactory1
 
Welcome to GFDL for Take Your Child To Work Day
Welcome to GFDL for Take Your Child To Work DayWelcome to GFDL for Take Your Child To Work Day
Welcome to GFDL for Take Your Child To Work DayZachary Labe
 
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCRCall Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCRlizamodels9
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024AyushiRastogi48
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxSwapnil Therkar
 
Call Girls in Hauz Khas Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Hauz Khas Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Hauz Khas Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Hauz Khas Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Nistarini College, Purulia (W.B) India
 
zoogeography of pakistan.pptx fauna of Pakistan
zoogeography of pakistan.pptx fauna of Pakistanzoogeography of pakistan.pptx fauna of Pakistan
zoogeography of pakistan.pptx fauna of Pakistanzohaibmir069
 
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |aasikanpl
 
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real timeSatoshi NAKAHIRA
 

Kürzlich hochgeladen (20)

Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)Recombinant DNA technology( Transgenic plant and animal)
Recombinant DNA technology( Transgenic plant and animal)
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
‏‏VIRUS - 123455555555555555555555555555555555555555
‏‏VIRUS -  123455555555555555555555555555555555555555‏‏VIRUS -  123455555555555555555555555555555555555555
‏‏VIRUS - 123455555555555555555555555555555555555555
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
Volatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -IVolatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -I
 
Scheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docxScheme-of-Work-Science-Stage-4 cambridge science.docx
Scheme-of-Work-Science-Stage-4 cambridge science.docx
 
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptxRESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
 
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
Best Call Girls In Sector 29 Gurgaon❤️8860477959 EscorTs Service In 24/7 Delh...
 
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptxLIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
LIGHT-PHENOMENA-BY-CABUALDIONALDOPANOGANCADIENTE-CONDEZA (1).pptx
 
Manassas R - Parkside Middle School 🌎🏫
Manassas R - Parkside Middle School 🌎🏫Manassas R - Parkside Middle School 🌎🏫
Manassas R - Parkside Middle School 🌎🏫
 
Welcome to GFDL for Take Your Child To Work Day
Welcome to GFDL for Take Your Child To Work DayWelcome to GFDL for Take Your Child To Work Day
Welcome to GFDL for Take Your Child To Work Day
 
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCRCall Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
 
Call Girls in Hauz Khas Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Hauz Khas Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Hauz Khas Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Hauz Khas Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 
Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...Bentham & Hooker's Classification. along with the merits and demerits of the ...
Bentham & Hooker's Classification. along with the merits and demerits of the ...
 
zoogeography of pakistan.pptx fauna of Pakistan
zoogeography of pakistan.pptx fauna of Pakistanzoogeography of pakistan.pptx fauna of Pakistan
zoogeography of pakistan.pptx fauna of Pakistan
 
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Lajpat Nagar (Delhi) |
 
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real time
 

2015 01 09 - Rende - Unical - Martin Gebser: Clingo = Answer Set Programming + Control

  • 1. Clingo = Answer Set Programming + Control Martin Gebser Roland Kaminski Benjamin Kaufmann Torsten Schaub University of Potsdam Aalto University M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 1 / 20
  • 2. Motivation ASP is an approach to declarative problem solving, combining a rich yet simple modeling language with high-performance solving capacities tailored to Knowledge Representation and Reasoning Elaborate reasoning processes feature incremental solving, as in planning or finite model finding, or even reactive solving, as in robotics or query-answering Problem Logic Program Grounder Solver Stable Models Solutions - - - ? 6 One-shot ASP Solving M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 2 / 20
  • 3. Motivation ASP is an approach to declarative problem solving, combining a rich yet simple modeling language with high-performance solving capacities tailored to Knowledge Representation and Reasoning Elaborate reasoning processes feature incremental solving, as in planning or finite model finding, or even reactive solving, as in robotics or query-answering Problem Logic Program Grounder Solver Stable Models Solutions - - - ? 6 Incremental ASP Solving 6 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 2 / 20
  • 4. Motivation ASP is an approach to declarative problem solving, combining a rich yet simple modeling language with high-performance solving capacities tailored to Knowledge Representation and Reasoning Elaborate reasoning processes feature incremental solving, as in planning or finite model finding, or even reactive solving, as in robotics or query-answering Problem Logic Program Grounder Solver Stable Models Solutions - - - ? 6 Reactive ASP Solving 66 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 2 / 20
  • 5. Outline 1 Background 2 (More) Control 3 Summary M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 3 / 20
  • 6. Background Outline 1 Background 2 (More) Control 3 Summary M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 4 / 20
  • 7. Background Clingo 3 Series One-shot ASP solving by means of grounder gringo and solver clasp Clingo: gringo | clasp Incremental ASP solving by dedicated handling of three program parts iClingo: Clingo [base ∪ n i=1cumulative(i) ∪ volatile(n)]∗ n=1 base: grounded once and stored by solver cumulative(i): grounded for increasing i-values and stored by solver volatile(i): grounded like cumulative(i) but not stored by solver Reactive ASP solving by further incorporating external program parts oClingo: iClingo [ m j=1external(j)]∗ m=1 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 5 / 20
  • 8. Background Clingo 3 Series One-shot ASP solving by means of grounder gringo and solver clasp Clingo: gringo | clasp Incremental ASP solving by dedicated handling of three program parts iClingo: Clingo [base ∪ n i=1cumulative(i) ∪ volatile(n)]∗ n=1 base: grounded once and stored by solver cumulative(i): grounded for increasing i-values and stored by solver volatile(i): grounded like cumulative(i) but not stored by solver Reactive ASP solving by further incorporating external program parts oClingo: iClingo [ m j=1external(j)]∗ m=1 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 5 / 20
  • 9. Background Clingo 3 Series One-shot ASP solving by means of grounder gringo and solver clasp Clingo: gringo | clasp Incremental ASP solving by dedicated handling of three program parts iClingo: Clingo [base ∪ n i=1cumulative(i) ∪ volatile(n)]∗ n=1 base: grounded once and stored by solver cumulative(i): grounded for increasing i-values and stored by solver volatile(i): grounded like cumulative(i) but not stored by solver Reactive ASP solving by further incorporating external program parts oClingo: iClingo [ m j=1external(j)]∗ m=1 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 5 / 20
  • 10. Background Elevator Control Example Setup: floor(1..3). at(1,0). Request 1: request(2,1,1). Request 2: request(3,1,2). 1 2 3 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 6 / 20
  • 11. Background Elevator Control Example Setup: floor(1..3). at(1,0). Request 1: request(2,1,1). Request 2: request(3,1,2). 1 2 3 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 6 / 20
  • 12. Background Elevator Control Example Setup: floor(1..3). at(1,0). Request 1: request(2,1,1). Request 2: request(3,1,2). 1 2 3 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 6 / 20
  • 13. Background Elevator Control Example Setup: floor(1..3). at(1,0). Request 1: request(2,1,1). Request 2: request(3,1,2). 1 2 3 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 6 / 20
  • 14. Background Elevator Control Example Setup: floor(1..3). at(1,0). Request 1: request(2,1,1). Request 2: request(3,1,2). 1 2 3 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 6 / 20
  • 15. Background Encoding for One-shot ASP Solving diff(-1;1). { move(D,T) : diff(D) } 1 :- time(T). move(T) :- move(D,T). % State update at(F, T) :- at(F,T-1), time(T), not move(T). at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D). :- time(T), not 1 { at(F,T) } 1. % Pending requests task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|. task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T). % Started tasks must be processed till completion exec(F1,F2,D,T) :- task(F1,F2,D,T-1), at(F1,T-1), move(D,T). exec(F2,D,T) :- exec(F1,F2,D,T). exec(F2,D,T) :- exec(F2,D,T-1), time(T), not at(F2,T-1). exec(D,T) :- exec(F2,D,T). :- exec(D,T), not move(D,T). :- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1). % Move iff there is some task to process open(T) :- task(F1,F2,D,T). open(T) :- exec(F2,D,T), not at(F2,T). :- move(T), not open(T-1). :- open(T), not move(T+1). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 7 / 20
  • 16. Background One-shot ASP Solving Request 1: clingo-3 <files> <(echo "time(1..3).") Solving... Answer: 1 move(1,2) move(-1,3) Request 2: clingo-3 <files> <(echo "time(1..5).") Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 8 / 20
  • 17. Background One-shot ASP Solving Request 1: clingo-3 <files> <(echo "time(1..3).") Solving... Answer: 1 move(1,2) move(-1,3) Request 2: clingo-3 <files> <(echo "time(1..5).") Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 8 / 20
  • 18. Background One-shot ASP Solving Request 1: clingo-3 <files> <(echo "time(1..3).") Solving... Answer: 1 move(1,2) move(-1,3) Request 2: clingo-3 <files> <(echo "time(1..5).") Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 8 / 20
  • 19. Background One-shot ASP Solving Request 1: clingo-3 <files> <(echo "time(1..3).") Solving... Answer: 1 move(1,2) move(-1,3) Request 2: clingo-3 <files> <(echo "time(1..5).") Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 8 / 20
  • 20. Background Encoding for Incremental ASP Solving #base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,T) : diff(D) } 1 :- time(T). move(T) :- move(D,T). % State update at(F, T) :- at(F,T-1), time(T), not move(T). at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D). :- time(T), not 1 { at(F,T) } 1. % Pending requests task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|. task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T). % Started tasks must be processed till completion ... :- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1). % Move iff there is some task to process ... :- open(T), not move(T+1). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
  • 21. Background Encoding for Incremental ASP Solving #base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,T) : diff(D) } 1 :- time(T). move(T) :- move(D,T). % State update at(F, T) :- at(F,T-1), time(T), not move(T). at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D). :- time(T), not 1 { at(F,T) } 1. % Pending requests task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|. task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T). % Started tasks must be processed till completion ... :- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1). % Move iff there is some task to process ... :- open(T), not move(T+1). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
  • 22. Background Encoding for Incremental ASP Solving #base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,T) : diff(D) } 1 :- time(T). move(T) :- move(D,T). % State update at(F, T) :- at(F,T-1), time(T), not move(T). at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D). :- time(T), not 1 { at(F,T) } 1. % Pending requests task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|. task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T). % Started tasks must be processed till completion ... :- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1). % Move iff there is some task to process ... :- open(T), not move(T+1). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
  • 23. Background Encoding for Incremental ASP Solving #base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,T) : diff(D) } 1 :- time(T). move(T) :- move(D,T). % State update at(F, T) :- at(F,T-1), time(T), not move(T). at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D). :- time(T), not 1 { at(F,T) } 1. % Pending requests task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|. task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T). % Started tasks must be processed till completion ... :- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1). % Move iff there is some task to process ... :- open(T), not move(T+1). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
  • 24. Background Encoding for Incremental ASP Solving #base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,T) : diff(D) } 1 :- time(T). move(T) :- move(D,T). % State update at(F, T) :- at(F,T-1), time(T), not move(T). at(F+D,T) :- at(F,T-1), move(D,T), floor(F+D). :- time(T), not 1 { at(F,T) } 1. % Pending requests task(F1,F2,D,T) :- request(F1,F2,T), D = (F2-F1)/|F2-F1|. task(F1,F2,D,T) :- task(F1,F2,D,T-1), time(T), not exec(F1,F2,D,T). % Started tasks must be processed till completion ... :- move(D,T), not move(D,T+1), not exec(D,T), not exec(-D,T+1). % Move iff there is some task to process ... :- open(T), not move(T+1). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
  • 25. Background Encoding for Incremental ASP Solving #base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update at(F, t) :- at(F,t-1), not move(t). at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D). :- not 1 { at(F,t) } 1. % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t), not move(D,t+1), not exec(D,t), not exec(-D,t+1). % Move iff there is some task to process ... :- open(t), not move(t+1). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
  • 26. Background Encoding for Incremental ASP Solving #base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update at(F, t) :- at(F,t-1), not move(t). at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D). :- not 1 { at(F,t) } 1. % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t), not move(D,t+1), not exec(D,t), not exec(-D,t+1). % Move iff there is some task to process ... :- open(t), not move(t+1). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
  • 27. Background Encoding for Incremental ASP Solving #base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update at(F, t) :- at(F,t-1), not move(t). at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D). :- not 1 { at(F,t) } 1. % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process ... :- open(t-1), not move(t). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
  • 28. Background Encoding for Incremental ASP Solving #base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update at(F, t) :- at(F,t-1), not move(t). at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D). :- not 1 { at(F,t) } 1. % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process ... :- open(t-1), not move(t). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 9 / 20
  • 29. Background Incremental ASP Solving Request 1: iclingo-3 <files> Solving... Solving... Solving... Answer: 1 move(1,2) move(-1,3) Request 2: iclingo-3 <files> Solving... Solving... Solving... Solving... Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 10 / 20
  • 30. Background Incremental ASP Solving Request 1: iclingo-3 <files> Solving... Solving... Solving... Answer: 1 move(1,2) move(-1,3) Request 2: iclingo-3 <files> Solving... Solving... Solving... Solving... Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 10 / 20
  • 31. Background Incremental ASP Solving Request 1: iclingo-3 <files> Solving... Solving... Solving... Answer: 1 move(1,2) move(-1,3) Request 2: iclingo-3 <files> Solving... Solving... Solving... Solving... Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 10 / 20
  • 32. Background Incremental ASP Solving Request 1: iclingo-3 <files> Solving... Solving... Solving... Answer: 1 move(1,2) move(-1,3) Request 2: iclingo-3 <files> Solving... Solving... Solving... Solving... Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 10 / 20
  • 33. Background Encoding for Reactive ASP Solving #base. #external request(F1,F2,0) : floor(F1) : floor(F2) : F1 != F2. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. #external request(F1,F2,t) : floor(F1) : floor(F2) : F1 != F2. ... % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). ... Inputs: #step 1. request(2,1,1). #endstep. #step 2. request(3,1,2). #endstep. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 11 / 20
  • 34. Background Encoding for Reactive ASP Solving #base. #external request(F1,F2,0) : floor(F1) : floor(F2) : F1 != F2. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. #external request(F1,F2,t) : floor(F1) : floor(F2) : F1 != F2. ... % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). ... Inputs: #step 1. request(2,1,1). #endstep. #step 2. request(3,1,2). #endstep. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 11 / 20
  • 35. Background Encoding for Reactive ASP Solving #base. #external request(F1,F2,0) : floor(F1) : floor(F2) : F1 != F2. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. #external request(F1,F2,t) : floor(F1) : floor(F2) : F1 != F2. ... % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). ... Inputs: #step 1. request(2,1,1). #endstep. #step 2. request(3,1,2). #endstep. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 11 / 20
  • 36. Background Encoding for Reactive ASP Solving #base. #external request(F1,F2,0) : floor(F1) : floor(F2) : F1 != F2. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. #external request(F1,F2,t) : floor(F1) : floor(F2) : F1 != F2. ... % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). ... Inputs: #step 1. request(2,1,1). #endstep. #step 2. request(3,1,2). #endstep. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 11 / 20
  • 37. Background Reactive ASP Solving oclingo-3 <files> + controller.py Request 1: Solving... Solving... Solving... Answer: 1 move(1,2) move(-1,3) Request 2: Solving... Solving... Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 12 / 20
  • 38. Background Reactive ASP Solving oclingo-3 <files> + controller.py Request 1: Solving... Solving... Solving... Answer: 1 move(1,2) move(-1,3) Request 2: Solving... Solving... Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 12 / 20
  • 39. Background Reactive ASP Solving oclingo-3 <files> + controller.py Request 1: Solving... Solving... Solving... Answer: 1 move(1,2) move(-1,3) Request 2: Solving... Solving... Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 12 / 20
  • 40. Background Reactive ASP Solving oclingo-3 <files> + controller.py Request 1: Solving... Solving... Solving... Answer: 1 move(1,2) move(-1,3) Request 2: Solving... Solving... Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 12 / 20
  • 41. Background Reactive ASP Solving oclingo-3 <files> + controller.py Request 1: Solving... Solving... Solving... Answer: 1 move(1,2) move(-1,3) Request 2: Solving... Solving... Solving... Answer: 1 move(1,2) move(1,3) move(-1,4) move(-1,5) 1 2 3 1 2 3 1 1 2 3 1 2 3 1 2 3 1 2 1 2 3 1 2 2 3 4 5 M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 12 / 20
  • 42. (More) Control Outline 1 Background 2 (More) Control 3 Summary M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 13 / 20
  • 43. (More) Control Clingo 4 Approach Custom grounding and solving via embedded scripting languages Lua: main(prg), prg:ground(parts), prg:solve(), . . . Python: main(prg), prg.ground(parts), prg.solve(), . . . Library: prg.ground(parts), prg.solve(), . . . Predecessor systems can easily be scripted One-shot ASP solving (default): (ground | solve) Incremental ASP solving: (ground | solve)∗ Reactive ASP solving: (ground∗ | solve)∗ . . . Clingo: ASP + Control M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 14 / 20
  • 44. (More) Control Clingo 4 Approach Custom grounding and solving via embedded scripting languages Lua: main(prg), prg:ground(parts), prg:solve(), . . . Python: main(prg), prg.ground(parts), prg.solve(), . . . Library: prg.ground(parts), prg.solve(), . . . Predecessor systems can easily be scripted One-shot ASP solving (default): (ground | solve) Incremental ASP solving: (ground | solve)∗ Reactive ASP solving: (ground∗ | solve)∗ . . . Clingo: ASP + Control M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 14 / 20
  • 45. (More) Control Clingo 4 Approach Custom grounding and solving via embedded scripting languages Lua: main(prg), prg:ground(parts), prg:solve(), . . . Python: main(prg), prg.ground(parts), prg.solve(), . . . Library: prg.ground(parts), prg.solve(), . . . Predecessor systems can easily be scripted One-shot ASP solving (default): (ground | solve) Incremental ASP solving: (ground | solve)∗ Reactive ASP solving: (ground∗ | solve)∗ . . . Clingo: ASP + Control M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 14 / 20
  • 46. (More) Control Clingo 4 Approach Custom grounding and solving via embedded scripting languages Lua: main(prg), prg:ground(parts), prg:solve(), . . . Python: main(prg), prg.ground(parts), prg.solve(), . . . Library: prg.ground(parts), prg.solve(), . . . Predecessor systems can easily be scripted One-shot ASP solving (default): (ground | solve) Incremental ASP solving: (ground | solve)∗ Reactive ASP solving: (ground∗ | solve)∗ . . . Clingo: ASP + Control M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 14 / 20
  • 47. (More) Control Clingo 4 Approach Custom grounding and solving via embedded scripting languages Lua: main(prg), prg:ground(parts), prg:solve(), . . . Python: main(prg), prg.ground(parts), prg.solve(), . . . Library: prg.ground(parts), prg.solve(), . . . Predecessor systems can easily be scripted One-shot ASP solving (default): (ground | solve) Incremental ASP solving: (ground | solve)∗ Reactive ASP solving: (ground∗ | solve)∗ . . . Clingo: ASP + Control M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 14 / 20
  • 48. (More) Control Encoding for Incremental ASP Solving #base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update at(F, t) :- at(F,t-1), not move(t). at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D). :- not 1 { at(F,t) } 1. % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process ... :- open(t-1), not move(t). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
  • 49. (More) Control Encoding for Incremental ASP Solving #base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update at(F, t) :- at(F,t-1), not move(t). at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D). :- not 1 { at(F,t) } 1. % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process ... :- open(t-1), not move(t). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
  • 50. (More) Control Encoding for Incremental ASP Solving #program base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update at(F, t) :- at(F,t-1), not move(t). at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D). :- not 1 { at(F,t) } 1. % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process ... :- open(t-1), not move(t). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
  • 51. (More) Control Encoding for Incremental ASP Solving #program base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #cumulative t. { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update at(F, t) :- at(F,t-1), not move(t). at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D). :- not 1 { at(F,t) } 1. % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process ... :- open(t-1), not move(t). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
  • 52. (More) Control Encoding for Incremental ASP Solving #program base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #program cumulative(t). { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update at(F, t) :- at(F,t-1), not move(t). at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D). :- not 1 { at(F,t) } 1. % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process ... :- open(t-1), not move(t). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
  • 53. (More) Control Encoding for Incremental ASP Solving #program base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #program cumulative(t). { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update at(F, t) :- at(F,t-1), not move(t). at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D). :- not 1 { at(F,t) } 1. % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process ... :- open(t-1), not move(t). #volatile t. :- open(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
  • 54. (More) Control Encoding for Incremental ASP Solving #program base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #program cumulative(t). { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update at(F, t) :- at(F,t-1), not move(t). at(F+D,t) :- at(F,t-1), move(D,t), floor(F+D). :- not 1 { at(F,t) } 1. % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process ... :- open(t-1), not move(t). #external query(t). :- open(t), query(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 15 / 20
  • 55. (More) Control Script for Incremental ASP Solving #script(python) from gringo import * def main(prg): imin = prg.get const("imin") if imin == None: imin = 1 step = 0 parts = [("base", [])] while True: if step < imin: step = step+1 parts.append(("cumulative", [step])) if step == imin: prg.ground(parts) parts = [] prg.assign external(Fun("query", [step]), True) ret = prg.solve() if ret == SolveResult.SAT: break prg.release external(Fun("query", [step])) imin = imin+1 #end. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
  • 56. (More) Control Script for Incremental ASP Solving #script(python) from gringo import * def main(prg): imin = prg.get const("imin") if imin == None: imin = 1 step = 0 parts = [("base", [])] while True: if step < imin: step = step+1 parts.append(("cumulative", [step])) if step == imin: prg.ground(parts) parts = [] prg.assign external(Fun("query", [step]), True) ret = prg.solve() if ret == SolveResult.SAT: break prg.release external(Fun("query", [step])) imin = imin+1 #end. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
  • 57. (More) Control Script for Incremental ASP Solving #script(python) from gringo import * def main(prg): imin = prg.get const("imin") if imin == None: imin = 1 step = 0 parts = [("base", [])] while True: if step < imin: step = step+1 parts.append(("cumulative", [step])) if step == imin: prg.ground(parts) parts = [] prg.assign external(Fun("query", [step]), True) ret = prg.solve() if ret == SolveResult.SAT: break prg.release external(Fun("query", [step])) imin = imin+1 #end. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
  • 58. (More) Control Script for Incremental ASP Solving #script(python) from gringo import * def main(prg): imin = prg.get const("imin") if imin == None: imin = 1 step = 0 parts = [("base", [])] while True: if step < imin: step = step+1 parts.append(("cumulative", [step])) if step == imin: prg.ground(parts) parts = [] prg.assign external(Fun("query", [step]), True) ret = prg.solve() if ret == SolveResult.SAT: break prg.release external(Fun("query", [step])) imin = imin+1 #end. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
  • 59. (More) Control Script for Incremental ASP Solving #script(python) from gringo import * def main(prg): imin = prg.get const("imin") if imin == None: imin = 1 step = 0 parts = [("base", [])] while True: if step < imin: step = step+1 parts.append(("cumulative", [step])) if step == imin: prg.ground(parts) parts = [] prg.assign external(Fun("query", [step]), True) ret = prg.solve() if ret == SolveResult.SAT: break prg.release external(Fun("query", [step])) imin = imin+1 #end. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
  • 60. (More) Control Script for Incremental ASP Solving #script(python) from gringo import * def main(prg): imin = prg.get const("imin") if imin == None: imin = 1 step = 0 parts = [("base", [])] while True: if step < imin: step = step+1 parts.append(("cumulative", [step])) if step == imin: prg.ground(parts) parts = [] prg.assign external(Fun("query", [step]), True) ret = prg.solve() if ret == SolveResult.SAT: break prg.release external(Fun("query", [step])) imin = imin+1 #end. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
  • 61. (More) Control Script for Incremental ASP Solving #script(python) from gringo import * def main(prg): imin = prg.get const("imin") if imin == None: imin = 1 step = 0 parts = [("base", [])] while True: if step < imin: step = step+1 parts.append(("cumulative", [step])) if step == imin: prg.ground(parts) parts = [] prg.assign external(Fun("query", [step]), True) ret = prg.solve() if ret == SolveResult.SAT: break prg.release external(Fun("query", [step])) imin = imin+1 #end. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
  • 62. (More) Control Script for Incremental ASP Solving #script(python) from gringo import * def main(prg): imin = prg.get const("imin") if imin == None: imin = 1 step = 0 parts = [("base", [])] while True: if step < imin: step = step+1 parts.append(("cumulative", [step])) if step == imin: prg.ground(parts) parts = [] prg.assign external(Fun("query", [step]), True) ret = prg.solve() if ret == SolveResult.SAT: break prg.release external(Fun("query", [step])) imin = imin+1 #end. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
  • 63. (More) Control My Script for Incremental ASP Solving #script(python) from gringo import * def main(prg): imin = prg.get const("imin") if imin == None: imin = 1 step = 0 parts = [("base", [])] while True: if step < imin: step = step+1 parts.append(("cumulative", [step])) if step == imin: prg.ground(parts) parts = [] prg.assign external(Fun("query", [step]), True) ret = prg.solve() if ret == SolveResult.SAT: break prg.release external(Fun("query", [step])) imin = imin+1 #end. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
  • 64. (More) Control My Script for Incremental ASP Solving #script(python) from gringo import * def main(prg): imin = prg.get const("imin") if imin == None: imin = 1 step = 0 parts = [("base", []), ("task", [step])] while True: if step < imin: step = step+1 parts.append(("cumulative", [step])) parts.append(("task", [step])) if step == imin: prg.ground(parts) parts = [] ret = prg.solve() if ret == SolveResult.SAT: break imin = imin+1 #end. M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 16 / 20
  • 65. (More) Control My Encoding for Incremental ASP Solving #program base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #program cumulative(t). { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update ... % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process open(t) :- task(F1,F2,D,t). open(t) :- exec(F2,D,t), not at(F2,t). :- move(t), not open(t-1). :- open(t-1), not move(t). #external query(t). :- open(t), query(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
  • 66. (More) Control My Encoding for Incremental ASP Solving #program base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #program cumulative(t). { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update ... % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process open(t) :- task(F1,F2,D,t). open(t) :- exec(F2,D,t), not at(F2,t). :- move(t), not open(t-1). :- open(t-1), not move(t). #external query(t). :- open(t), query(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
  • 67. (More) Control My Encoding for Incremental ASP Solving #program base. diff(-1;1). task(F1,F2,D,0) :- request(F1,F2,0), D = (F2-F1)/|F2-F1|. #program cumulative(t). { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update ... % Pending requests task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process open(t) :- task(F1,F2,D,t). open(t) :- exec(F2,D,t), not at(F2,t). :- move(t), not open(t-1). :- open(t-1), not move(t). #external query(t). :- open(t), query(t). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
  • 68. (More) Control My Encoding for Incremental ASP Solving #program base. diff(-1;1). #program task(t). #external move(t+1). task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. open(t) :- task(F1,F2,D,t). :- open(t), not move(t+1). #program cumulative(t). { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update ... % Pending requests task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process open(t) :- exec(F2,D,t), not at(F2,t). :- move(t), not open(t-1). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
  • 69. (More) Control My Encoding for Incremental ASP Solving #program base. diff(-1;1). #program task(t). #external move(t+1). task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. open(t) :- task(F1,F2,D,t). :- open(t), not move(t+1). #program cumulative(t). { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update ... % Pending requests task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process open(t) :- exec(F2,D,t), not at(F2,t). :- move(t), not open(t-1). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
  • 70. (More) Control My Encoding for Incremental ASP Solving #program base. diff(-1;1). #program task(t). #external move(t+1). task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. open(t) :- task(F1,F2,D,t). :- open(t), not move(t+1). #program cumulative(t). { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update ... % Pending requests task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t-1), not move(D,t), not exec(D,t-1), not exec(-D,t). % Move iff there is some task to process open(t) :- exec(F2,D,t), not at(F2,t). :- move(t), not open(t-1). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
  • 71. (More) Control My Encoding for Incremental ASP Solving #program base. diff(-1;1). #program task(t). #external move(t+1). task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. open(t) :- task(F1,F2,D,t). :- open(t), not move(t+1). #program cumulative(t). #external move(D,t+1) : diff(D). #external exec(D,t+1) : diff(D). { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update ... % Pending requests task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t), not move(D,t+1), not exec(D,t), not exec(-D,t+1). % Move iff there is some task to process open(t) :- exec(F2,D,t), not at(F2,t). :- move(t), not open(t-1). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
  • 72. (More) Control My Encoding for Incremental ASP Solving #program base. diff(-1;1). #program task(t). #external move(t+1). task(F1,F2,D,t) :- request(F1,F2,t), D = (F2-F1)/|F2-F1|. open(t) :- task(F1,F2,D,t). :- open(t), not move(t+1). #program cumulative(t). #external move(D,t+1) : diff(D). #external exec(D,t+1) : diff(D). { move(D,t) : diff(D) } 1. move(t) :- move(D,t). % State update ... % Pending requests task(F1,F2,D,t) :- task(F1,F2,D,t-1), not exec(F1,F2,D,t). % Started tasks must be processed till completion ... :- move(D,t), not move(D,t+1), not exec(D,t), not exec(-D,t+1). % Move iff there is some task to process open(t) :- exec(F2,D,t), not at(F2,t). :- move(t), not open(t-1). M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 17 / 20
  • 73. (More) Control Custom ASP Solving Encoding consisting of named and parameterizable subprograms #program base. (default), #program cumulative(t)., . . . External (yet undefined) atoms provide input interface to other parts #external <atom> [ : <body> ]. Embedded scripts allow for flexible grounding and solving control #script(python | lua) . . . main(prg) . . . #end. Instantiation triggered by passing subprogram names plus arguments prg.ground([("base", []), ("task", [step])]) Ground program parts constitute modules (with disjoint head atoms) Search for stable models of ground program parts stored by solver prg.solve(), prg.solve(on model = pretty print), . . . Incremental and/or reactive ASP solving via “i/oClingo” scripts #include <iclingo>. prg.add("request1", [], "request(2,1,1).") M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 18 / 20
  • 74. (More) Control Custom ASP Solving Encoding consisting of named and parameterizable subprograms #program base. (default), #program cumulative(t)., . . . External (yet undefined) atoms provide input interface to other parts #external <atom> [ : <body> ]. Embedded scripts allow for flexible grounding and solving control #script(python | lua) . . . main(prg) . . . #end. Instantiation triggered by passing subprogram names plus arguments prg.ground([("base", []), ("task", [step])]) Ground program parts constitute modules (with disjoint head atoms) Search for stable models of ground program parts stored by solver prg.solve(), prg.solve(on model = pretty print), . . . Incremental and/or reactive ASP solving via “i/oClingo” scripts #include <iclingo>. prg.add("request1", [], "request(2,1,1).") M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 18 / 20
  • 75. (More) Control Custom ASP Solving Encoding consisting of named and parameterizable subprograms #program base. (default), #program cumulative(t)., . . . External (yet undefined) atoms provide input interface to other parts #external <atom> [ : <body> ]. Embedded scripts allow for flexible grounding and solving control #script(python | lua) . . . main(prg) . . . #end. Instantiation triggered by passing subprogram names plus arguments prg.ground([("base", []), ("task", [step])]) Ground program parts constitute modules (with disjoint head atoms) Search for stable models of ground program parts stored by solver prg.solve(), prg.solve(on model = pretty print), . . . Incremental and/or reactive ASP solving via “i/oClingo” scripts #include <iclingo>. prg.add("request1", [], "request(2,1,1).") M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 18 / 20
  • 76. Summary Outline 1 Background 2 (More) Control 3 Summary M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 19 / 20
  • 77. Summary Summary ASP as an under-the-hood technology ! Clingo 4 Multi-shot ASP solving Continuously changing programs Opens up new areas of applications Agents Policies Planning Robotics Interaction Theory solving Query-answering . . . http://potassco.sourceforge.net M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 20 / 20
  • 78. Summary Summary ASP as an under-the-hood technology ! Clingo 4 Multi-shot ASP solving Continuously changing programs Opens up new areas of applications Agents Policies Planning Robotics Interaction Theory solving Query-answering . . . http://potassco.sourceforge.net M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 20 / 20
  • 79. Summary Summary ASP as an under-the-hood technology ! Clingo 4 Multi-shot ASP solving Continuously changing programs Opens up new areas of applications Agents Policies Planning Robotics Interaction Theory solving Query-answering . . . http://potassco.sourceforge.net M. Gebser, R. Kaminski, B. Kaufmann, T. Schaub Clingo = ASP + Control 20 / 20