问题
I coded an MIP in CPLEX with C#. I declared variables and constraints and added the objective but I cannot get the correct answer. Is there a way to print the model into a string variable or something like in order to check whether I coded correctly the model I had in mind?
回答1:
You could try exporting it in CPLEX LP format, that is human readable.
I use neither CPLEX nor .NET, but according this website the function you are looking for is:
LOG CPLEX .NET Reference Manual
Cplex.ExportModel
MethodWrites 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 [...]
Hope this helps.
来源:https://stackoverflow.com/questions/23447636/how-to-check-whether-the-model-coded-in-cplex-in-net-is-the-true-model