% minof(Choice,Exp,Report) % solve Choice such that Exp is minimized. For each solution, call Report. minof(Goal,Exp,Report):- X #= Exp, fd_max(X,Up), (maxint(Up)->InitBest is Up;InitBest is Up+1), global_set(current_best_bound,InitBest), global_set(current_best_sol,[]), minof_repeat(Goal,X,Report). minof_repeat(Goal,X,Report):- \+ \+ minof_aux(Goal,X,Report),!, minof_repeat(Goal,X,Report). minof_repeat(Goal,X,_):- global_get(current_best_sol,Goal), global_get(current_best_bound,X). minof_aux(Goal,X,Report):- global_get(current_best_bound,Best), X #=< Best-1, call(Goal), call(Report), global_set(current_best_bound,X), global_set(current_best_sol,Goal).