|
Why
use GUI for cplex
The lab owns cplex, a program that solves linear programming problems.
It is a powerful program but its user interface requires each term
in every constraint to be typed in explicitly. Since a linear programming
problem can consist of thousands of constraints typing them in explicitly
would be time consuming. The GUI can understand typed equations
of a form very similar to those submitted in papers. The GUI can
expand these constraints into the thousands of constraints that
cplex needs to do its work.
In the expanding process the GUI uses the cplex DLL to write out
the problem to a file that cplex can understand. This has the side
effect that cplex.exe cannot be in use at the same time the GUI
is expanding a problem into a form cplex understands.
Once a problem has been written out in a form cplex understands
one must use cplex.exe to solve it. Start cplex.exe and issue the
command “read” followed by the filename ,including the
path, of the problem statement written by the GUI. The GUI writes
the problem twice, once as an lp and once as an mps file, it is
recommended that the mps file be the one read in. After reading
in the problem file, enter the command “optimize”. Once
cplex.exe has finished optimizing type “write” then
a file name with path to write out to. A good extension to give
this file is “.mst“. For further discussion on using
cplex.exe see the cplex users manual.
The lp file is much easier for a human to read so while reading
the mps file is recommended the lp file is used in examples in this
manual.
GUI designed to look like a paper
For easy of use the cplex GUI has been designed to look like the
formulation of an integer linear programming problem as it might
appear in a paper. In a paper the reader is first told what the
constants are. They are then given the data and variables, each
having one or more idiocy. The objective function and constraints
are given only after all terms have been defined. This is also the
order in which information is entered into the GUI. In addition
to the above the GUI requires the minimum and maximum values of
the indices to be given explicitly. This is done after the constants
but before variables and data section. A sample problem and its
entry into the GUI are given below. The syntax for entering expressions
into the GUI is explained in the next section.
A sample paper could read as follows:
Problem statements: To maximize number of ice cream products sold.
Parameters:
N : Number of cities where ice cream products are sold.
B : The amount of money available for advertising
Pi : Cost of an ad in the paper in city i
Ri : Cost of a radio commercial in city i
Xi : Sales per paper ad in city i
Yi : Sales per radio commercial in city i
Variables:
(integer) is the number of paper ads run in city i
(integer) is the number of radio commercials run in city i
Objective is to maximize the number of sales
MAX
The constraint is to not exceed the advertising budget.
The problem would be entered as shown below.

GUI Syntax
A few words on how the GUI looks at text. The GUI is case sensitive
so it see’s “SUM”, “Sum”, and “sum”
as different words. The word “SUM” is reserved and cannot
be used as a Name for a Constant, Index, Variable, or Data. The
word “CD” is also reserved. Names cannot be reused between
different fields. For instance “i” cannot be used both
as an index and a variable name. Not all fields in the GUI can handle
a negative sign. A negative sign should only be used in the Constants,
Objective, and Constraints boxes. A negative sign in the Indexes
or Variables fields will cause the program to fail. However one
is free to use negative numbers in these fields by defining a negative
number in the Constants field.
To define a constant: Type one string for its name, followed by
one number. The string must be made of any combination of lower
case letters, uppercase letters, and underscores. The number can
be ether positive or negative.
To define an index: On one line, give the indexes name followed
by its lower limit then upper its limit. The limits may be a symbolic
constant defined in the constants section or as a positive integer
using characters 0 to 9.
To define a variable: Each variable has a type, range, name, and
normally indices, which must be specified in this order. The type
is given by one letter. The possible values are: C for continuous,
B for binary, I for integer, S for semi-continuous, N for semi-integer.
The range is given inside a set of square brackets, with the lower
value listed first and separated from the higher value by a comma.
The limits of the range may be given by ether a number typed from
the key 0 to 9 or by a symbolic constant defined in the constant
section. If a negative value is desired then the number must be
given as a symbolic constant.
Following the range is the variable name. After that is the list
of indices for the variable. The list is terminated by hitting enter.
Currently a variable can only have up to four indices.
To define data: Give a name for the data, the file the data is located
in, and the indices used to access the data The Reading Data From
Files section will explain format of the data file.
Objective function and constraints: The objective function and constraints
use the same syntax with only two minor differences. The objective
function cannot contain >, =, < but the constraints must contain
exactly one of these per constraint. To fully specify the objective
one of the radial buttons in the optimize box must be checked.
These boxes are where the actual mathematics is given. The boxes
can evaluate math expressions involving addition, subtraction, multiplication,
and division. Parentheses may also be used. All math being used
to calculate variable’s co-efficient must be done before the
variable is typed and then multiplied with the variable, this includes
closing all parentheses. If a number is intended as a pure number
instead of a variables co-efficient it must be multiplied by a pound
sign, i.e. #, to tell the GUI that a number has just been given.
As with the variable all parenthesis must be closed before the multiply
by pound is given.
To write a summation one types the word SUM , in all caps, followed
by the index being used in the summation, the initial value of the
index, a semi-colon, and then the final value. Initial and final
value’s may be given by a math expression evaluated at run
time. Math operations acting on a summation will be distributed
inside according to the rules of math. Summations must be treated
like variables and # signs in that all parentheses must be closed
before a summation.
Indexes may be used in math operations. The value of an index is
the same value as is being substituted into variables when it is
used as a subscript.
The GUI has one built in math function, the chronic delta. By definition
the chronic delta has the value of one if its two indices match
and is otherwise zero. If the terms in a double summation are multiplied
by (1-cronic delta) it makes the statement equivalent to a summation
where the two indices involved never have the same value. To make
a chronic delta type the reserved word CD followed by the two indices
that go on it.
Complex example
This example show’s how to enter complex equations. The equations
entered into the GUI are:

The second equation needs to be re-expressed as a summation where
i and k can hold the same value. This can be done using the one
minus chronic delta to pick out the equations where i = k and make
the variable co-efficient zero in this case. Once re-written the
second equation reads:

Note that this example also uses some symbolic constants, and demo’s
the use of negative values in the index and variable fields.

Error messages
When the GUI finds an error in the input it informs the user with
an error message and stops work on the problem. Error messages are
fairly detailed so most errors will not be listed here. Below are
a listing of errors that will not be caught by the error messages,
some extra information about a few of the error messages, and an
additional comment.
The following will not trigger an error message but will produce
incorrect results.
• Having the co-efficient follow the variable instead of preceding
it.
• Not including *# after an expression not part of a co-efficient
(sometimes doesn’t cause error)
• Placing # in the wrong place or using it without *
• Not including * between a variable and its co-efficient.
• Listing same index more than once on the same variable.
(Equations will expand but lots non-existent variable will appear)
• Using “SUM” or “CD” as the name
for a constant, index, variable, or data.
• In general failing to include + - / * somewhere that requires
them.
Clarification on errors:
Use of a negative sign where only positive numbers are expected
can produce incorrect error messages. For instance if in the variable
section the following is given “I [-5, 15] M a b” the
GUI will report “Missing the ] to close the range for variable
number ” instead of the true cause which is an illegal negative
sign. Using invalid characters in a variable name can also produce
this error message.
One possible cause of the error “I opened file filename just
fine but something went wrong while reading it.” is a line
with only a comment not preceded by a data point.
The error “CPLEX Error 32201: ilm: CPLEX: cannot connect to
token server on” followed by a computer name means that ilmid.exe
is not running and needs to be launched.
The error “CPLEX Error 32201: ilm: CPLEX: no license available.”
Means that cplex.exe or another program is already using the cplex
DLL, so no more programs can use it. If one confuses this error
with the previous error and tries to launch a second copy of ilmd.exe
to correct the problem, both copies of ilmd.exe will close, and
it may be necessary to log off and log back in before ilmd.exe will
behave correctly.
Error messages are also written to a file called ExpandingLog.txt.
The GUI always creates this file when it runs, even if no errors
are found.
Miscellaneous
The name that the expanded equations should be saved under is not
saved as part of the problem formulation or anywhere else. This
means it must be reset every time a problem statement is reloaded.
The cplex license manager must be running in order to expand equations
or to use cplex.exe. This program is called ilmd.exe
The GUI requests the cplex.dll. The GUI is compiled under Visual
C++ 6.0. This means it relies on a number of dll’s that may
not be present on some windows machines. They are however present
on the machine in the lab that has the license manager.
|