minimize
A function to specify an optimization problem. It asks CP Optimizer to seek to minimize the value of an expression.
Syntax
objective minimize(floatExpr expr)
Parameters
-
expr: The expression whose value is to be minimized.
Description
The function minimize specifies to CP Optimizer a floating-point expression
whose value is sought to be minimized. When this function is used and
the problem is feasible, CP Optimizer will generate
one or more feasible solutions to the problem, with subsequent solutions having
a smaller value of expr than preceding ones. The search terminates when
either the optimality of the last solution is proved, a search limit is
exhausted, or the search is aborted.
Example
t1 = intVar(0..1000);
t2 = intVar(0..1000);
t3 = intVar(0..1000);
// ...
timeValue = max([t1, t2, t3]);
penalty = (t1 > 500) + (t2 > 300) + (t3 > 600);
minimize(timeValue + 100 * penalty);
Here, we perform some actions as early as we can by minimizing the latest time of some tasks. Additionally, we would like to have those tasks occur before a particular time and add a penalty cost (with coefficient 100) when this does not happen.
Requirements
Only one instance of maximize, minimize, maximizeStaticLex, or minimizeStaticLex is allowed per model.