I want to find the minimun number of errors for a lot of schedules. I produce a schedule, take it's errors, store all Errors in a list and take the first element(MinError). The MinError is >=0, so I wonder if I can stop this process when a random schedule get Errors=0 and return the MinError.
setof(Errors,A^B^C^(schedule(A,B,C),schedule_errors(A,B,C,Errors)),[MinError|_]).
You may use an if-then-else with a cut to stop processing further solutions when you found your minima:
setof(Errors,
A^B^C^(
schedule(A,B,C),
schedule_errors(A,B,C,Errors),
(Errors=0 -> ! ; true)
),
[MinError|_]).