Hi Josef.
I'm not sure I understand what you want to do here.
The Coords you are forcing to be set ((3,2), (4,1), (5,2), (5,5)) does not make a strongly connected undirected graph and thus scc_grid(Board,4) - which forces to exactly 4 vertices to be set - will fail.
Here are these coords printed in the matrix.
[0,0,0,0,0]
[0,0,0,0,0]
[0,1,0,0,0]
[1,0,0,0,0]
[0,1,0,0,1]
Using
% ...
scc_grid(Board),
solve($[min(sum(Bvars))],Vars),
% ...
yields this minimal solution:
[0,0,0,0,0]
[0,0,0,0,0]
[0,1,0,0,0]
[1,1,0,0,0]
[0,1,1,1,1]
I.e. it requires 7 1s to be a scc.
Also, what do you mean by "called repeatedly" in
"""
solve([$min(sum(Bvars))], Bvars++[Onoff]) works, but the solver is called repeatedly.
"""
Does your program has some non-deterministic component, such as member/2, which might explain "called repeatedly"?
The problem, as you state it (or rather: as I understand it), does indeed suggest using min() in solve/2.
(Also, I'd suggest that you also add the domain to Board:
% ...
Board = new_array(Dim,Dim),
Board :: 0..1,
% ... ,
though in this case Picat can figure out the domain since scc/1-2 happens to force it to 0..1.
)
Best,
Hakan