IBM Support

How to save the best solution found from a MIP with ILOG CPLEX Interactive Optimizer

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.

[{"Product":{"code":"SSSA5P","label":"IBM ILOG CPLEX Optimization Studio"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Interactive Optimizer","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"8.0;8.1;9.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Product":{"code":"SSSA5P","label":"IBM ILOG CPLEX Optimization Studio"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"},{"code":"PF017","label":"Mac OS"}],"Version":"12.2","Edition":"All Editions","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

cplex/FAQ/92

Document Information

Modified date:
16 June 2018

UID

swg21400009