ralna / CUTEst

The Constrained and Unconstrained Testing Environment with safe threads (CUTEst) for optimization software
Other
83 stars 18 forks source link

Update Knitro interface to current (13.20) version #30

Closed chrhansk closed 1 year ago

chrhansk commented 1 year ago

This update enables the use of CUTEst with the current version of the KNitro NLP solver. Since the old (version < 11.0) API is apparently unsupported, the current API version is used instead.

Missing so far:

I have thus fare not included these changes due to Copyright concerns.

Optional improvements:

nimgould commented 1 year ago

Many thanks. I'll check with the Knitro people to see if it is ok to use their header and options files.

nimgould commented 1 year ago

We have permission from Artelys to use the header and options file. If you can add the latest ones, I'll check and then merge. Thanks!

nimgould commented 1 year ago

There appear to be a couple of issues in the new knitro_main.c

knitro_main.c(415): error: expected an expression 180 for(int i = 0; i < CUTEst_ncon; i++) { 181 ^ 182

==> i is already defined as an int 183 knitro_main.c(467): error: expected an expression 184 // objective 185 ^ ==> need / / comments

chrhansk commented 1 year ago

OK, the errors should be fixed.

One question: There is the v_order parameter in the CUTEST_csetup that allows the user to determine the order in which linear / nonlinear variables occur in the problem. Is there a way to query whether variables appear linearly / nonlinearly in the objective / constraints? That information could be passed on to Knitro as well.

nimgould commented 1 year ago

I'm very sorry it has taken me so long to get back to this, another project has eaten all of my time. To return to this, icc now reports

    knitro_main.c(512): warning #167: argument of type "char *" is incompatible with parameter of type "char *const *"
  CHECK_KNITRO_EXIT_CODE(KN_set_var_names_all(kc, vnames),
  ^

knitro_main.c(519): error: identifier "cnames" is undefined CHECK_KNITRO_EXIT_CODE(KN_set_con_names_all(kc, cnames), ^

knitro_main.c(522): error: identifier "cnames" is undefined FREE(cnames); ^

compilation aborted for knitro_main.c (code 2)

while gcc adds a few others

/home/nimg/fortran/optrove_git/cutest/include/cutest.h:51:9: warning: ISO C90 does not support boolean types [-Wpedantic] 51 typedef _Bool logical; ^~~~~ In file included from knitro_main.c:36: /home/nimg/fortran/optrove_git/cutest/include/knitro.h:50:18: warning: ISO C90 does not support ‘long long’ [-Wlong-long] 50 typedef long long KNLONG; ^~~~ knitro_main.c: In function ‘callbackEvalFC’: knitro_main.c:68:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 68 const double* x = evalRequest->x; ^~~~~ knitro_main.c: In function ‘callbackEvalGA’: knitro_main.c:109:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 109 const double* x = evalRequest->x; ^~~~~ knitro_main.c:125:7: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 125 int offset = 0; ^~~ knitro_main.c: In function ‘main’: knitro_main.c:457:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 457 int consJac_nnz = 0; ^~~ knitro_main.c:512:53: warning: passing argument 2 of ‘KN_set_var_names_all’ from incompatible pointer type [-Wincompatible-pointer-types] 512 CHECK_KNITRO_EXIT_CODE(KN_set_var_names_all(kc, vnames), ^~
char *

knitro_main.c:21:27: note: in definition of macro ‘CHECK_KNITRO_EXIT_CODE’ 21 | const int ExitCode = (command); \ | ^~~ In file included from knitro_main.c:36: /home/nimg/fortran/optrove_git/cutest/include/knitro.h:1866:61: note: expected ‘char const’ but argument is of type ‘char ’ 1866 | char const xNames[]); | ~~~~^~~~ knitro_main.c:519:55: error: ‘cnames’ undeclared (first use in this function); did you mean ‘gnames’? 519 | CHECK_KNITRO_EXIT_CODE(KN_set_con_names_all(kc, cnames), | ^~ knitro_main.c:21:27: note: in definition of macro ‘CHECK_KNITRO_EXIT_CODE’ 21 | const int ExitCode = (command); \ | ^~~ knitro_main.c:519:55: note: each undeclared identifier is reported only once for each function it appears in 519 | CHECK_KNITRO_EXIT_CODE(KN_set_con_names_all(kc, cnames), | ^~ knitro_main.c:21:27: note: in definition of macro ‘CHECK_KNITRO_EXIT_CODE’ 21 | const int ExitCode = (command); \ | ^~~

nimgould commented 1 year ago

You also asked

One question: There is the v_order parameter in the CUTEST_csetup that allows the user to determine the order in which linear / nonlinear variables occur in the problem. Is there a way to query whether variables appear linearly / nonlinearly in the objective / constraints? That information could be passed on to Knitro as well.

The SIF description doesn't do this explicitly, but it may be possible to determine this in future. I'll add it as a TODO