> Discrete Optimization > Solving Mixed Integer Programming Problems (MIP) > Using the MIP Solution |
Using the MIP Solution |
INDEX PREVIOUS NEXT |
After you have solved a MIP, you will usually want to make use of the solution in some way. If you are interested only in the values of the variables at the optimum, then you can perform some simple steps to get that information:
getValues
accesses this information.
CPXgetmipx
.
After your program has placed the solution values into arrays in this way, it can print the values to the screen, write the values to a file, perform computations using the values, and so forth.
In the Interactive Optimizer, you can print the nonzero solution values to the screen with the command display solution variables
. A copy of this information goes to the log file, named cplex.log
by default. Thus one way to print your solution to a file is to temporarily rename the log file. For example, the following series of commands in the Interactive Optimizer will place the solution values of all variables whose values are not zero into a file named solution.asc
:
set logfile solution.asc display solution variables set logfile cplex.log |
For any of the MIP problem types, the following additional solution information is available after optimization:
If you request other solution information than these items for a MIP, an error status will be issued. For example, in the Interactive Optimizer, you would get the following message:
Not available for mixed integer problems- use CHANGE PROBLEM to change the problem type |
Such post-solution information does not have the same meaning in a mixed integer program (MIP) as in a linear program (LP) because of the special nature of the integer variables in the MIP. The reduced costs, dual values, and sensitivity ranges give you information about the effect of making small changes in problem data so long as feasibility is maintained. Integer variables, however, lose feasibility if a small change is made in their value, so this post-solution information cannot be used to evaluate changes in problem data in the usual way of continuous models.
Integer variables often represent major structural decisions in a model, and many continuous variables of the model may be related to these major decisions. With that observation in mind, if you take the integer variable solution values as given, then you can obtain useful post-solution information, applying only to the continuous variables, in the usual way. This is the idea behind the so-called "fixed MIP" problem, a version of the MIP problem where all of the discrete variables are placed at values corresponding to the MIP solution, and thus it is a continuous problem though not strictly a relaxation of the MIP.
Interpreting Solution Statistics explains how to use the display command in the Interactive Optimizer to see post-solution information from the linear optimizers. In particular, an LP model having a basic solution (that is, a solution obtained by one of the simplex optimizers, or by the barrier optimizer using crossover) can have its solution written to a file in a standard ASCII-text format, referred to as TXT format. If your discrete model is MILP, then it is natural to wish to use the TXT format for your integer solution, too. However, the TXT format contains information about the dual values of a solution, which you have just seen are not directly available for a MIP solution.
What is needed is to construct the fixed MIP problem, solve it, and then use that solution. (Typically, solving the fixed MIP problem is very rapid compared to solving the MIP itself.)
solution.txt
: change problem fixed_milp optimize write solution.txt |
CPXchgprobtype
, passing the value CPXPROB_FIXEDMILP
as the value for the type
argument, and then calling CPXlpopt
to re-optimize the resulting LP problem, and finally calling CPXwritesol
to create your TXT file.
solveFixed
followed by the method writeTextSolution
.
If your problem type is MIQP or MIQCP then this discussion of TXT files is not applicable, because TXT format does not support the underlying QP and QCP continuous problem types. Indeed, there does not even exist a problem type of FIXEDMIQCP
because a continous QCP solution does not contain appropriate dual information. For MIQP, the associated FIXEDMIQP
problem type is useful for sensitivity analysis, as is the case for FIXEDMILP
.
Copyright © 1987-2003 ILOG, S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |