0

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|_]).

false
  • 10,264
  • 13
  • 101
  • 209

1 Answers1

1

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|_]).
gusbro
  • 22,357
  • 35
  • 46