我正在使用 IBM cplex 优化器来求解 MIP 模型。我想要的是 cplex 不记录到控制台,而是记录到 .txt 文件。我在这里找到了一个提到这一点的方法:http: //yalma.fime.uanl.mx/cplex11-manual/refdotnetcplex/html/ILOG.CPLEX.Cplex.SetOut.html
Cplex.SetOut(TextWriter s)
但是当我这样调用方法时,文本文件仍然为空:
public Cplex Model= new Cplex();
TextWriter TWoutput = File.CreateText("RunOutput.txt"));
//Add variables, constraints and solve the model
Model.SetOut(TWoutput);
我找不到我应该如何使用这种方法。我是 c# 和 cplex 的新手,所以请尽可能简单地解释一下:)