Determines the minimum possible value that the variable Cost can attain in any solution of Goal. This value is returned as Optimum. Neither Cost nor any variable in Goal is instantiated. The predicate is useful when one is interested in sub-optimal solutions, see example.
This predicate can be defined as
bb_min_cost(Goal, Cost, Optimum, Options) :- bb_min(Goal, Cost, [], _, Optimum, Options).Options are interpreted in the same way as for bb_min/6 (the solutions-parameter is ignored).
% A predicate to enumerate solutions in increasing cost order :- lib(ic). :- lib(branch_and_bound). ic_increasing_cost(Goal, Cost) :- bb_min_cost(Goal, Cost, Opt, bb_options{report_success:true/0,report_failure:true/0}), ( Cost = Opt, call(Goal) ; Cost #> Opt, ic_increasing_cost(Goal, Cost) ). % sample run: ?- ic_increasing_cost(member(C-X,[9-a,4-b,2-c,4-d]), C). C = 2 X = c Yes (0.00s cpu, solution 1, maybe more) ? ; C = 4 X = b Yes (0.00s cpu, solution 2, maybe more) ? ; C = 4 X = d Yes (0.00s cpu, solution 3, maybe more) ? ; C = 9 X = a Yes (0.00s cpu, solution 4, maybe more) ? ; No (0.00s cpu)