Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow capturing optimization log #159

Open
SPC-code opened this issue Feb 4, 2025 · 2 comments
Open

Allow capturing optimization log #159

SPC-code opened this issue Feb 4, 2025 · 2 comments

Comments

@SPC-code
Copy link

SPC-code commented Feb 4, 2025

This issue arisen during discussion of atraplet/clarabel4j#30

Currently optimization output is hardcoded for stdout:

let mut out = stdio::stdout();

It does not seem to be a way to redirect this output to a file or string without using external process call. Could you please add a handle to redirect a log to a file or pipe, or even better, store it in a separate solver state to be taken directly via interop?

@goulart-paul
Copy link
Member

goulart-paul commented Feb 4, 2025

You are right, there is presently no way of redirecting the solver output. We could probably add something that allows redirecting of the solver output to a file or a string buffer. It's unclear to me if one could enable redirection to a pipe (or socket or whatever) when calling the solver via one of its language interfaces, since I assume (but am not certain) that conversion of general io targets between languages is ugly.

This would probably be easiest to do at module level, i.e. all solvers would write to the same target. Could also be done on a per solver instance basis though.

@SPC-code
Copy link
Author

SPC-code commented Feb 4, 2025

Indeed. In my experience, a proper optimization log is an important part of the result. So in KMath log is the part of the optimization result. It is done a bit differently. Log consumer is passed as an optional parameter to an optimizer, but callbacks are hard to implement on the cross-language boundary. So simple string will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants