maximize

A function to specify an optimization problem. It asks CP Optimizer to seek to maximize the value of an expression.

Syntax


objective maximize(floatExpr expr)

Parameters

  • expr: The expression whose value is to be maximized.

Description

The function maximize specifies to CP Optimizer a floating-point expression whose value is sought to be maximized. 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 larger 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 = min([t1, t2, t3]);
penalty = (t1 < 500) + (t2 < 300) + (t3 < 600);
maximize(timeValue - 100 * penalty);

Here, we perform some just-in-time actions by maximizing the earliest time of some tasks. Additionally, we would like to have those tasks occur after 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.