简体   繁体   English

在C#中从Cplex预先获取结果

[英]Getting results from Cplex presolve in C#

Is there a way to obtain the results of the presolve analysis that Cplex does when starting to solve an LP? 当开始求解LP时,有没有办法获得Cplex进行的预求解分析的结果? In particular, I am looking for information about redundant rows. 特别是,我正在寻找有关冗余行的信息。 If possible, it would be useful to run only the presolve, without solving the LP. 如果可能的话,仅运行预解决而不解决LP将很有用。 I am using Cplex 12.5 from a C# application. 我正在从C#应用程序使用Cplex 12.5。

You can generate the cplex presolved model by using the ExportModel on the Cplex object with the a file extension ".pre". 您可以在文件扩展名为“ .pre”的Cplex对象上使用ExportModel生成cplex预处理模型。 That will cause presolve to run and make cplex write the presolved model to a file. 这将导致presolve运行,并使cplex将预解决的模型写入文件。 The format of the output is a "sav" format, which is a lossless, but not human-readable. 输出的格式是“ sav”格式,这是无损的,但不是人类可读的。 You can convert it to a readable ".lp" format, but importing it back into another fresh Cplex object, then exporting that model as a .lp file. 您可以将其转换为可读的“ .lp”格式,但可以将其重新导入到另一个新的Cplex对象中,然后将该模型导出为.lp文件。

cplex.ExportModel("myModel.pre");

// convert to .lp file  
// Could also do this with interactive cplex
Cplex lp_converter = new Cplex();
lp_converter.ImportModel("myModel.pre");
lp_converter.ExportModel("myModelPresolved.lp");

Then you can read the presolved lp file and get an idea of what cplex does to your model at that stage. 然后,您可以阅读预先解析的lp文件,并了解在那个阶段cplex对您的模型有什么作用。 You will likely be surprised by the extent of what cplex does and you may even have a hard time reconciling the presolved model with your original. 您可能会对cplex的作用范围感到惊讶,甚至可能很难将预先解决的模型与原始模型进行协调。 You can experiment with changing the extent of presolve by setting parameters. 您可以尝试通过设置参数来更改预求解的程度。 For example, setting the parameter PreLinear to 1 will likely make the model more recognizable. 例如,将参数PreLinear设置为1可能会使模型更易于识别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM