Using Interactive Optimizer commands from your operating system
The Interactive Optimizer accepts a file or double-quoted commands from your operating system.
cplex [-i] [-f commandfile | -c "command1" "command2" . . . ]
In fact, CPLEX recognizes two approaches:
- You can create a file of commands.
- You can double-quote Interactive commands on your operating system command line.
Using a file of Interactive Optimizer commands
You can create a file of Interactive Optimizer commands to use from your operating system. CPLEX accepts this file and executes the commands in a session of the Interactive Optimizer. This strategy is available on operating systems, such as Microsoft Windows, GNU/Linux, or IBM z/OS.
To use this feature of the Interactive Optimizer, first create the file as you normally create a new file on your operating system. Put each Interactive Optimizer command on a separate line in the file, as you would type commands to enter in the Interactive Optimizer.
To invoke your file of commands, use the following syntax
at the command line of your operating system, where cplex is
the command to invoke the Interactive Optimizer, -f is
the option to specify a filename, and filename is the name
of your file:
cplex -f filename
If the name of the file containing commands includes spaces, be sure to
enclose the name of the file in double quotation marks when you pass it to
the -f option. This technique of quoting file names that include
spaces works for the command-line option; however, the read command
inside the Interactive Optimizer does not recognize file names including spaces,
even when the file names are quoted.
Using double-quotation marks around Interactive Optimizer commands from the OS command line
In fact, if you enclose each of the Interactive Optimizer commands separately in double quotation marks, you are not obliged to collect them in a file. You can simply pass a series of commands (each enclosed in double quotation marks) to the Interactive Optimizer on the command line of your operating system, like this example:
cplex -c "read a_problem_name.lp" "optimize" "display solution variables -"
Or, with abbreviations, the same series of commands looks like this:
cplex -c "read a_problem_name.lp" "opt" "disp sol var -"
In that example, a_problem_name represents the name of a file containing a formatted
model and data, opt is the acceptable abbreviation of the command to optimize
the input, and disp sol var - tells CPLEX to display the variables of the solution.
Keeping a session active
To tell CPLEX to keep an open session active (prompting you for commands) after it executes
the commands listed on the command line (if you are using -c) or in a file of commands (if using -f),
use the option -i as the first option that you pass to the cplex
command. (If neither -c nor -f are present, CPLEX ignores the -i option.) For example:
cplex -i -f myfile
That sample command launches the CPLEX Interactive Optimizer, reads commands from the specified file, and keeps the session open with a prompt for further Interactive Optimizer commands.
Summary
cplex
command from your operating-system
command-line to manage a session of the Interactive Optimizer.
- -i tells CPLEX to keep an open session of the Interactive Optimizer active.
- -f specifies that a filename for CPLEX to read follows.
- -c specifies that a command for the Interactive Optimizer follows.
The order of those options is significant: you must launch a session (for example, with the cplex command) before you issue a command in that session.
To close a session and exit from the Interactive Optimizer, issue control-d on the operating-system command-line or from a file of commands.