[ library(fd) | Reference Manual | Alphabetic Index ]

# minimize(?Goal, ?C, +Lower, +Upper, +Percent, +Timeout)

Find the solution of Goal that minimizes C, within the bounds set by Lower, Upper and Percent in time not longer than Timeout.

?Goal
  A callable term.
?C
  A linear term.
+Lower
  Integer.
+Upper
  Integer.
+Percent
  Integer.
+Timeout
  A number.

## Description

A solution of the goal Goal is found that minimizes the value of C. The solution is found using the branch and bound method. Whenever a better solution is found, the upper cost bound is tightened and the search for a better solution continues.

The starting assumption is that the value to minimize is less than Upper and that any value less than Lower can be considered as a solution. Moreover, solutions whose minimized values are closer than Percent % are considered equal. Every time a new better solution is found, the event 280 is raised, its default handler prints the current cost.

If Timeout is not zero, the predicate will stop after Timeout seconds and report the best solution it has found so far. Calls with specified Timeout cannot be nested.

This predicate is to be used for optimization problems when the whole search space is too large or when a suboptimal solution is sufficient.

### Fail Conditions

Fails if Goal fails.

### Resatisfiable

No.

## See Also

min_max / 2, min_max / 4, min_max / 5, min_max / 6, min_max / 8, minimize / 2, minimize / 4, minimize / 5, minimize / 8, minimize_bound_check / 0