Loge: ASP smoke test
root = Path.expand("..", __DIR__)
Mix.install([
{:loge, path: Path.join(root, "loge"), override: true},
{:loge_asp, path: Path.join(root, "loge_asp")},
{:kino_loge, path: Path.join(root, "kino_loge")}
])
Solving
Expected: Satisfiable, one model, colour(1,red) colour(2,green) colour(3,blue) or another
proper colouring.
Loge.run!(
Loge.Asp.Engines.Clingo,
"node(1..3). edge(1,2). edge(2,3). edge(1,3).\ncol(red; green; blue).\n1 { colour(N, C) : col(C) } 1 :- node(N).\n:- edge(X, Y), colour(X, C), colour(Y, C).\n#show colour/2.\n",
time_limit: 10
)
Models 0 enumerates all of them. Expected: Satisfiable, six models.
Loge.run!(
Loge.Asp.Engines.Clingo,
"node(1..3). edge(1,2). edge(2,3). edge(1,3).\ncol(red; green; blue).\n1 { colour(N, C) : col(C) } 1 :- node(N).\n:- edge(X, Y), colour(X, C), colour(Y, C).\n#show colour/2.\n",
models: 0,
time_limit: 10
)
An optimisation runs to its optimum when no model count is set. Expected: Satisfiable,
the last model in(b) and the raw output's result OPTIMUM FOUND.
Loge.run!(
Loge.Asp.Engines.Clingo,
"item(a, 3). item(b, 1). item(c, 2).\n{ in(I) : item(I, _) }.\n:- not in(_).\n#minimize { W, I : in(I), item(I, W) }.\n#show in/1.\n",
time_limit: 10
)
Expected: Unsatisfiable, no models.
Loge.run!(Loge.Asp.Engines.Clingo, "a.\n:- a.\n", time_limit: 10)
Grounding this never ends. Expected: Timeout after two seconds; the lint gives up after ten.
Loge.run!(Loge.Asp.Engines.Clingo, "nat(0).\nnat(N + 1) :- nat(N).\n", time_limit: 2)
Linting
Expected: under the editor, a syntax error on line 2; evaluating raises Loge.Error with it.
Corrected to b :- c, d., line 3 is reported instead: X is unsafe, with the position of X.
With X removed, c and d occur in no rule head (info).
Loge.run!(Loge.Asp.Engines.Clingo, "a :- b.\nb :- c d.\np(X) :- a.\n", time_limit: 10)