我使用 C# 在 CPLEX 中编写了一个 MIP。我声明了变量和约束并添加了目标,但我无法得到正确的答案。有没有办法将模型打印到字符串变量或类似的东西中,以检查我是否正确编码了我想要的模型?
请您参考如下方法:
您可以尝试将其导出为人类可读的 CPLEX LP 格式。
我既不使用 CPLEX 也不使用 .NET,但是根据 this website您正在寻找的功能是:
LOG CPLEX .NET Reference Manual
Cplex.ExportModelMethodWrites the active model to the file specified by filename.
public virtual void ExportModel( String name );Parameters
name
The name of the file to which the model is written. The extension of the filename determines the format in which to write the model file.Remarks
The file format is determined by the extension of the filename. The following extensions are recognized on most platforms:
.sav .mps .Lp [...]
希望这对您有所帮助。
