Hi Artelys Knitro team,
Greetings. I am writing to inquire two problems about using Knitro with Python Interface, especially the Scipy interface.
The knitro version I am using is knitro-13.1.0-Linux-64, running on Linux Ubuntu 22.04, Python 3.9.
The first problem is about using the Python scipy interface with user-defined exact constraint jacobian function. It turns out that even if the user specifies a constraint jacobian function (say cons_J(x)) and declar the constraint to be
nonlinear_constraint = NonlinearConstraint(cons_f, cL, cU, jac=cons_J, hess=cons_H),
then call the optimization function
res = minimize(
fun=objective,
x0=x0,
method=kn_minimize,
jac=objGrad,
hess=objHess,
constraints=[nonlinear_constraint],
bounds=bounds,
options={‘outlev’:0}
),
the cons_J() function won’t be called even if it should be. The optimizer seems to be using numerical differential and therefore runs slower. The problem can be reproduced using any example problem defined in knitro-13.1.0-Linux-64/examples/Python/examples/exampleSciPy.py, by have a printing message in cons_J(x) or running a profile application to check how many times cons_J(x) is entered.
The second problem is about using the Python scipy interface and specifying a printing level. It seems like even if the user specifies ‘disp’ = False (and ‘outlev’ = 0) option, when the optimize function is called, there would still be a few lines (undesiredly) being printed. As a comparison, for other methods in Scipy, specifying ‘disp’ = False will lead to completely no output. This problem can be reproduced by having opt={‘disp’:False} when calling minimize(options=opts). It may correspond to 1289-1293 lines in knitro-13.1.0-Linux-64/examples/Python/knitro/scipy/scipy_wrapper.py where the printing lines are not monitored by the disp variable.
Thank you very much for your great product. I hope my inquiries would make sense - please kindly let me know if more information or clarification is needed.
Best regards,
Qingyi