Skip to content

Conversation

andyfaff
Copy link
Contributor

This PR appends the PRIMA licence to the other bundled licences we use. In addition it adds references to PRIMA. Are you happy with this approach @zaikunzhang and @nbelakovski?

@j-bowhay

@github-actions github-actions bot added scipy.optimize Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org labels Mar 25, 2025
Co-authored-by: Jake Bowhay <60778417+j-bowhay@users.noreply.github.com>
@j-bowhay
Copy link
Member

Maybe we should also put something in https://github.com/scipy/scipy/blob/main/LICENSES_bundled.txt ? I have to admit I didn't know about those 3 other files!

@andyfaff
Copy link
Contributor Author

@j-bowhay that's a better place to make the addition.

@dschmitz89
Copy link
Contributor

Argh, the license issue also totally slipped my mind. Thanks for looking into it @andyfaff .

@zaikunzhang
Copy link
Contributor

zaikunzhang commented Mar 25, 2025

Hello Andrew @andyfaff and others,

Thank you very much for taking care of this. It is highly appreciated.

I would like to suggest some changes. See andyfaff#80

Note that the PRIMA version of COBYLA is significantly different from Powell's original algorithm and code. An example is DELTA_j versus RHO_j as explained here: andyfaff@ae0dbee

I also suggest removing two references that did not discuss COBYLA (Powell 1998 and Powell 2007) --- since COBYLA itself is difficult enough to understand, let's not confuse users with papers that are essentially irrelevant.

I suggest (and humbly request) that the scipy documentations make it as clear as possible that the new version of COBYLA comes from the PRIMA package of Zaikun Zhang, so that people know who (namely, me) to blame if something goes wrong due to my changes to the algorithm.

Forgive me for repeating the following:

Note that PRIMA contains bug fixes and improvements that do not exist in Powell's original implementation of the solvers. Results produced by PRIMA are surely different from those produced by the original solvers by Powell. Therefore, it is simply wrong to pretend that PRIMA is just Powell's solvers.

It took me years to develop PRIMA, which almost cost my career and my life.

As a professor, all I need is a citation / acknowledgment when my work is useful, which is not well recognized in academia when it comes to software development. In addition, for obvious reasons, people tend to cite Powell without mentioning me when they use PRIMA instead of Powell's original solvers. (I have no doubt that my contribution is insignificant compared with Powell's, and I acknowledge this whenever I introduce PRIMA to others. See libprima.net for example). This is crucial for my career.

Thank you very much.

Zaikun

@zaikunzhang
Copy link
Contributor

zaikunzhang commented Mar 25, 2025

A question, probably can be answered by @nbelakovski : does the interface of COBYLA in SciPy use rhoend or tol as the name for the final trust-region radius? The 1.16.0 release note mentions that it is tol, but I guess it is a typo so I changed it in my PR.

I did notice tol in

https://github.com/zaikunzhang/scipy_prima/blob/prima/scipy/optimize/_cobyla_py.py#L173

It confuses me a bit. It seems that we receive rhoend, change its name to tol, and then pass it to rhoend. Why?

Thank you.

Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this @andyfaff.

Can I suggest also adding scipy/_lib/pyprima to https://scipy.github.io/devdocs/dev/core-dev/index.html#vendored-code?

@lucascolley lucascolley added this to the 1.16.0 milestone Mar 25, 2025
@nickodell
Copy link
Member

A question, probably can be answered by @nbelakovski : does the interface of COBYLA in SciPy use rhoend or tol as the name for the final trust-region radius? The 1.16.0 release note mentions that it is tol, but I guess it is a typo so I changed it in my PR.

[...]

It confuses me a bit. It seems that we receive rhoend, change its name to tol, and then pass it to rhoend. Why?

My understanding of this is that we actually have two interfaces to COBYLA. We have scipy.optimize.fmin_cobyla(), and we have scipy.optimize.minimize(..., method='COBYLA'). The fmin_cobyla() interface existed first, and must be maintained for backward compatibility. The minimize() interface is the recommended way for new code to call COBYLA.

minimize() calls this argument tol, and fmin_cobyla() calls it rhoend. This is because minimize() is trying to provide a consistent interface for many different solvers. Both eventually call the same code, but they use different names for the parameters, which is why there is conversion back and forth.

Doing a spot check using GitHub code search, the two ways of calling COBYLA seem roughly equally popular.

@andyfaff
Copy link
Contributor Author

I note that there is already a separate pyPRIMA package on PyPI. We should keep this in mind.

@nbelakovski
Copy link
Contributor

I note that there is already a separate pyPRIMA package on PyPI. We should keep this in mind.

It lists Zaikun as the maintainer and points to PDFO so no conflict there. @zaikunzhang, @nickodell's answer above to the question about tol vs rhoend is correct.

andyfaff and others added 3 commits March 26, 2025 11:53
Co-authored-by: nbelakovski <nbelakovski@users.noreply.github.com>
@zaikunzhang
Copy link
Contributor

I note that there is already a separate pyPRIMA package on PyPI. We should keep this in mind.

It lists Zaikun as the maintainer and points to PDFO so no conflict there.

It is a placeholder by me, which will be used for PRIMA.

@andyfaff
Copy link
Contributor Author

What we have looks appropriate to me now. Authorship of PRIMA is referenced and the license is pointed to.

@andyfaff andyfaff merged commit b93e727 into scipy:main Mar 26, 2025
39 of 40 checks passed
@@ -20,10 +20,12 @@ Currently, this includes the following parts of the codebase:
- QHull_, at ``scipy/spatial/qhull_src``
- trlib_, at ``scipy/optimize/_trlib``
- UNU.RAN_, at ``scipy/stats/_unuran``
- PRIMA_, at ``scipy/_lib/pyprima``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, this is unnecessary as we are actually vendoring this as a git submodule. Not a big deal though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I didn't realize we had changed plans; I thought we wouldn't add a submodule (no bandwidth to follow along unfortunately).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my understanding was that we converged on:

  • not adding a submodule to Nikolai's repo, instead 'mirroring' under the SciPy org (for security reasons)
  • not adding a 'full' submodule, but rather using a script to trim off the parts we don't need to use (like the Fortran PRIMA implementation) while vendoring a specific commit hash

That script is https://github.com/scipy/pyprima/blob/main/vendor_pyprima.sh. I suppose we could just maintain the script and the vendored source in the main scipy repo, but I think the separation is nice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we could just maintain the script and the vendored source in the main scipy repo, but I think the separation is nice.

That's what I had thought we settled on indeed. The separation now just gives us the overhead of a git submodule without the ability to pull in or work on upstream commits without much of an upside, right?

Anyway, I'm not suggesting to change it. We have enough submodules, and this probably won't be updated too often.

Copy link
Member

@lucascolley lucascolley Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I think the only upside of the obvious separation is making it clear that contributors shouldn't (/can't) modify the source in this repo.

But that could equally be achieved (at some point in the future) by a refactor of _lib which cleanly separates internal from external code (scikit-learn separates sklearn.utils and sklearn.externals for example).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org scipy.optimize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants