You can do parallel solving using OS commands. Suppose you have the following program file "prog.pi":
main([Solver]) =>
N = 10,
Qs = new_array(N),
Qs :: 1..N,
foreach (I in 1..N-1, J in I+1..N)
Qs[I] #!= Qs[J],
abs(Qs[I]-Qs[J]) #!= J-I
end,
solve(Qs),
println(Qs),
printf("finished %s\n",Solver).
Note that no solver module is imported. You can run it using the following Picat script:
main =>
run_prog("cp"),
run_prog("sat"),
run_prog("mip").
run_prog(SolverName) =>
FileName = "prog_" ++ SolverName ++ ".pi",
FD = open(FileName,write),
println(FD,"import " ++ SolverName ++ "."),
nl(FD),
printf(FD,"main => main([\"%s\"]).\n",SolverName),
nl(FD),
Lines = read_file_lines("prog.pi"),
foreach (Line in Lines)
(Line == [] -> nl(FD); println(FD,Line))
end,
close(FD),
_ = command("picat " ++ FileName ++ "&").
For each solver, the program makes a copy of "prog.pi" with the solver name imported, and runs the copy as a background process.
Best regards,
NF