jfowkes / pycutest

Python interface to CUTEst
https://jfowkes.github.io/pycutest/
GNU General Public License v3.0
28 stars 11 forks source link

Add access to unconstrained gradient only #69

Closed jfowkes closed 9 months ago

jfowkes commented 9 months ago

Resolves #40 by adding direct access to the unconstrained gradient via CUTEST_ugr.

Unfortunately there is not CUTEst function for direct access to the constrained gradient only but I can't really think of a use-case where this would actually be required.

lindonroberts commented 9 months ago

@jfowkes - thanks, this is a nice improvement! All looks good, I would only suggest adding the same grad(x) tests to the other test classes ALLINITC_with_fixed and ALLINITC_with_free (in test_basic_functionality.py). This tests the fixed vs free variable functionality in the new function works properly too.

jfowkes commented 9 months ago

@lindonroberts thank you, unfortunately this grad(x) only works for unconstrained problems so the ALLINITC_with_fixed and ALLINITC_with_free functions wouldn't work, but I could add some ALLINIT_with_fixed and ALLINIT_with_free tests?

lindonroberts commented 9 months ago

Thanks @jfowkes. In that case it's probably fine, because the fixed vs free comes from identifying where variables where lower bound = upper bound (i.e. there is only a difference for bound constrained problems). I assume CUTEst considers pure bound constrained problems still as "constrained", so grad(x) isn't available for these? If yes, I can merge the pull request

jfowkes commented 9 months ago

Ah of course, I checked with Nick and problems with bound constraints (B) and fixed variables (X) are considered unconstrained by CUTEst, so I guess we should add a test for this? The issue is finding a suitable CUTEst problem to test on, there aren't that many problems with only fixed variables and most are quite sizeable...

lindonroberts commented 9 months ago

It probably is a good idea if we can - do you know if there is an easy way to search maybe just the fixed variable problems, for one that isn't too large (perhaps if we add extra parameters to adjust it down)?

jfowkes commented 9 months ago

Yes pycutest.find_problems(constraints='fixed') finds the problems with just fixed constraints. I've just realised that BOX2 will work, although it is a nonlinear least squares problem it's not encoded as such in CUTEst so it will have an objective function.

jfowkes commented 9 months ago

@lindonroberts I have now added some tests with BOX2 🙂

lindonroberts commented 9 months ago

Perfect - merged!