[Ipopt] Redirecting the IPOPT output to mexPrintf

Stefan Vigerske stefan at math.hu-berlin.de
Thu Jun 25 07:04:26 EDT 2015


you can pass your own output handler (called a Journal) to Ipopt and 
disable the default Journal.
So, for example

ipopt = new IpoptApplication(false);
SmartPtr<Journal> jrnl = new MyJournal();
jrnl->SetPrintLevel(J_DBG, J_NONE);

And the MyJournal should be derived from the Ipopt::Journal class. In 
there, you can redirect to mexPrintf.

Hope that helps,

On 06/25/2015 11:39 AM, Joel Andersson wrote:
> Hi,
> I'm working on completing the addition of a MATLAB interface to CasADi, but
> I'm struggling finding a way to send the text output from IPOPT to MATLAB's
> mexPrintf. Is it possible to somehow set a user-defined function for
> printing log messages? Or, alternatively, to have IPOPT write output to
> C++'s iostream (i.e. std::cout and std::cerr) instead of C's printf (i.e.
> stdout and stderr)? The former is much easier to redirect to a custom
> function.
> In general, since Ipopt is a C++ code, I would expect iostream to be used
> for printing, but I guess it uses printf because of the linear solvers
> underneath.
> If anyone is interested, you can find an example of how to solve an NLP
> using IPOPT with CasADi-MATLAB here:
> https://github.com/casadi/casadi/blob/develop/test/matlab/rosenbrock.m.
> This is complete with efficient calculation of sparse Hessians and
> Jacobians but unless you start MATLAB from the command line without the
> GUI, you'll lose the IPOPT text output due to the above issue. I'll get
> back to this mailing list as soon as we make a stable release.
> Best regards,
> Joel
> _______________________________________________
> Ipopt mailing list
> Ipopt at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/ipopt

More information about the Ipopt mailing list