Question & Answer
Question
How to save the best solution found from a MIP with ILOG CPLEX Interactive Optimizer
Answer
ILOG CPLEX Interactive Optimizer normally allows a user to write the solution of a problem in a .txt
file by means of the following command:
write solution.txt
However, if you try this command just after the resolution of a MIP, you get a message like this:
<<
Not available for mixed integer problems.
Use CHANGE PROBLEM to change problem type.
No file written.
>>
In order to write a solution file in .txt
format after a MIP is solved, you should first change the problem type to fixed by means of this command:
change prob fix
This command results in an LP where the integer variables have been fixed to the integer values of the best solution. You should now solve the problem again, this time using the following command:
opt
This step takes only a few seconds. After this changed problem has been solved, then simply type the following command:
write solution.txt
You'll get a solution file in .txt
format.
The reason you need to go through these steps is that the .txt
files contain dual variables and reduced costs. When ILOG CPLEX finds a solution to a MIP, dual variables and reduced costs are not well defined, so you can't simply write out a .txt
file as you might for other types of problems. By solving the fixed problem, you solve an LP with well defined dual variables and reduced costs.
Note that the same issue exists whether you use the C, C++, Java, or .NET API of ILOG CPLEX. Click here if you need more information about the role of dual variables and reduced costs with respect to MIPs.
Historical Number
cplex/FAQ/92
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21400009