Adding constraints and bounds
To add constraints or bounds to a problem in the Interactive Optimizer, use these commands and options.
If you wish to add either new constraints or bounds to
your problem, use the add command. This
command is similar to the enter command
in the way it is used, but it has one important difference: the enter command
is used to start a brand new problem, whereas the add command
only adds new information to the current problem.
Suppose that in the example you need to add a third constraint:
x1 + 2x2 + 3x3 ≥ 50
You may do either interactively or from a file.
Adding interactively
Type the add command, then
enter the new constraint on the blank line. After validating the constraint,
the cursor moves to the next line. You are in an environment identical
to that of the enter command after having
issued subject to . At this point you may
continue to add constraints or you may type bounds and
enter new bounds for the problem. For the present example, type end to
exit the add command. Your session should
look like this:
add
Enter new constraints and bounds [‘end’ terminates]:
x1 + 2x2 + 3x3 >= 50
end
Problem addition successful.
When the problem is displayed again, the new constraint appears, like this:
display problem all
Maximize
obj: x1 + 2 x2 + 3 x3
Subject To
c1: - x1 + x2 + x3 <= 20
c2: x1 - 3 x2 + x3 <= 30
c3: x1 + 2 x2 + 3 x3 >= 50
Bounds
0 <= x1 <= 40
All other variables are >= 0.
end
Adding from a file
Alternatively, you may read in new constraints and bounds
from a file. If you enter a file name after the add command,
CPLEX will read a file matching that name. The file contents must
comply with standard CPLEX LP format. CPLEX does not prompt for a
file name if none is entered. Without a file name, interactive entry
is assumed.
Summary
The general syntax for the add command
is:
add
or
add filename