HNHacker News
TopNewBestAskShowJobs

zaikunzhang

1,408 karma · joined April 21, 2023

A Chinese applied mathematician working on optimization and coding in Fortran/MATLAB on Linux. See

https://zhangzk.net

http://libprima.net

http://github.com/libprima/prima

submissionscomments
zaikunzhang··on SciPy: Interested in adopting PRIMA, but little appetite for more Fortran code
A list of books, tutorials, and online courses:

https://fortran-lang.org/en/learn/

BTW, the Fortran Lang website (https://fortran-lang.org/) is THE official website of modern Fortran, maintained by the modern Fortran community.

You may also take a look at the modern Fortran discourse at

https://fortran-lang.discourse.group/

where you can find all the gurus of modern Fortran. They are very willing to help if you post a question. I have asked all my Fortran questions over there during the development of PRIMA.

zaikunzhang··on SciPy: Interested in adopting PRIMA, but little appetite for more Fortran code
Each of LFortran, fpm, and stdlib deserve a HN front-page story :)
zaikunzhang··on SciPy: Interested in adopting PRIMA, but little appetite for more Fortran code
> The central issue is that their experience with the old Fortran doesn't translate to modern Fortran; they are two different beasts.

This is so true! I hope anyone could spend a few minutes checking what modern Fortran is before blaming it. A good reference is https://fortran-lang.org/en/

zaikunzhang··on SciPy: Interested in adopting PRIMA, but little appetite for more Fortran code
> Modern fortran is quite nice, much nicer than C from a Python programmer's perspective.

Totally agree. I hope everyone making comments on Fortran can spend a few minitues reading what modern Fortran is, e.g., by checking

https://fortran-lang.org/en/

zaikunzhang··on SciPy: Interested in adopting PRIMA, but little appetite for more Fortran code
Thank you so much for your very warm and encouraging comments!

PRIMA has been a black hole that absorbs all my time and energy in the past three years, which even puts my career (as a junor professor) in real danger. The positive feedback like yours is vital for me. Without it, I would not have the energe or courage to continue. Many thanks!

> A motivated developer could very quickly port this code to their preferred numerical programming language.

I am much glad to hear a person other than myself saying this. It is the very reason why I develop this reference implementation. PRIMA achieves its success if others can implement Powell's solvers to high quality using PRIMA as a referene, without the genius like Powell and without the long-term experience and strugling like me.

Many thanks! --- Zaikun

zaikunzhang··on SciPy: Interested in adopting PRIMA, but little appetite for more Fortran code
Thank you so much for your encouragement! Such positive feedback means a lot to me.
zaikunzhang··on SciPy: Interested in adopting PRIMA, but little appetite for more Fortran code
Thank you very much for quoting this! --- Zaikun
zaikunzhang··on SciPy: Interested in adopting PRIMA, but little appetite for more Fortran code
I guess one of the major issues is the compilation and packaging of the Fortran code. It is also my experience when developing PDFO ( https://www.pdfo.net/ ), the predecessor of PRIMA.

This is also reflected by the following comment at https://github.com/scipy/scipy/issues/18118#issuecomment-155...

> The real maintenance burden is the compilation and the packaging not the code itself that we are carrying around.

zaikunzhang··on SciPy: Interested in adopting PRIMA, but little appetite for more Fortran code
A native port is indeed planned. However, since we are talking about a project of about 10K lines of code (though many of the lines are comments), such a port will not be delivered very soon.

In fact, native implementations of PRIMA in Python, MATLAB, C++, Julia, and R will all be done in the future. See https://github.com/libprima/prima#other-languages . But they will take time. PRIMA has been a one-man project since it started three years ago. Community help is greatly needed.

Thanks.

zaikunzhang··on Optimization Without Derivatives: Prima Fortran Version and Inclusion in SciPy
See also

SciPy: Interested in adopting PRIMA, but little appetite for more Fortran code, https://news.ycombinator.com/item?id=35986906

zaikunzhang··on SciPy: Interested in adopting PRIMA, but little appetite for more Fortran code
see also

Optimization Without Derivatives: PRIMA Fortran Version and Inclusion in SciPy, https://news.ycombinator.com/item?id=35959991

SciPy enhancement: The Fortran 77 implementation of COBYLA is buggy and challenging to maintain. Switch to the PRIMA implementation? #18118, https://github.com/scipy/scipy/issues/18118#issuecomment-155...

zaikunzhang··on Optimization Without Derivatives: Prima Fortran Version and Inclusion in SciPy
1. The following recent book is a good reference:

Milan Curcic, Modern Fortran: Building efficient parallel applications, Manning, 2020, https://www.manning.com/books/modern-fortran

2. More references, online courses, and tutorials can be found at

https://fortran-lang.org/en/learn/

3. If you have questions, Fortran Discourse is a good place to ask:

https://fortran-lang.discourse.group/

People there are gurus of modern Fortran and are very willing to help.

zaikunzhang··on Optimization Without Derivatives: Prima Fortran Version and Inclusion in SciPy
The extensive tests are vital in this project. The tests do not only verify the faithfulness of the implementation but also check that the solvers behave properly even if they are invoked with improper inputs or encounter failures of function evaluations.
zaikunzhang··on Optimization Without Derivatives: Prima Fortran Version and Inclusion in SciPy
I have some funding available if someone here would like to undertake the project of getting PRIMA into SciPy, although the person must come to work at my university in Hong Kong, as the funding cannot be used online/abroad. I can open a research assistant or postdoc position for the project. My contact can be found at https://github.com/libprima/prima . Thanks.
zaikunzhang··on Optimization Without Derivatives: Prima Fortran Version and Inclusion in SciPy
Who was Powell?

Michael James David Powell FRS was “a British numerical analyst who was among the pioneers of computational mathematics” [1]. He was the inventor/early contributor of Quasi-Newton method, Trust-Region method, Augmented Lagrangian method, and SQP method [1,2]. Each of them is a pillar of modern numerical optimization. He also made significant contributions to approximation theory and methods [1,2,3].

Among numerous honors, Powell was one of the first two recipients of the Dantzig Prize [4] from the Mathematical Programming Society/Society for Industrial and Applied Mathematics (SIAM). This is considered the highest award in optimization.

See also his Google Scholar profile [5] and the memorial page at [6].

[1] https://royalsocietypublishing.org/doi/full/10.1098/rsbm.201...

[2] https://en.wikipedia.org/wiki/Michael_J._D._Powell

[3] https://www.cambridge.org/highereducation/books/approximatio...

[4] https://en.wikipedia.org/wiki/Dantzig_Prize

[5] https://scholar.google.com/citations?user=p3kDmy0AAAAJ&hl

[6] https://www.zhangzk.net/powell.html

zaikunzhang··on Optimization Without Derivatives: Prima Fortran Version and Inclusion in SciPy
Thank you @certik for your encouragement!

I cherish the following comment from you:

> if SciPy accepts this modern Fortran codebase, then I think the tide for Fortran will change.

I believe that you and the LFortran project are truly turning the tide on Fortran. I wish to see the production release of LFortran as soon as possible.

If PRIMA can also contribute to “turning the tide on Fortran”, I will feel honored. All the pain, depression, and frustration that I have experienced in the past three years will then be partially compensated.

Let us the community work together to get PRIMA included in SciPy and see whether the tide on Fortran will improve.

Many thanks.

zaikunzhang··on Optimization Without Derivatives: Prima Fortran Version and Inclusion in SciPy
Extraction from https://github.com/libprima/prima

“There do exist "translations" of Powell's Fortran 77 code into other languages. For example, NLopt contains a C version of COBYLA, NEWUOA, and BOBYQA, but the C code in NLopt is translated from the Fortran 77 code straightforwardly, if not automatically by f2c, and hence inherits the style, structure, and probably bugs of the original Fortran 77 implementation.”

See also https://github.com/stevengj/nlopt/issues/501 , where the author of NLopt talks.

zaikunzhang··on Can Fortran survive another 15 years?
This is a review of https://permalink.lanl.gov/object/tr?what=info:lanl-repo/lar...
zaikunzhang··on Evaluation of risks associated with relying on Fortran for the next 15 years
Discussions about the report on the Fortran Discourse:

https://fortran-lang.discourse.group/t/an-evaluation-of-risk...

zaikunzhang··on Evaluation of risks associated with relying on Fortran for the next 15 years
A copy-paste of the Executive Summary:

This document examines risks associated with relying on Fortran for codes critical to nuclear security into the late 2030s. The study was requested by the LANL ASC program office to support its decisions. To date, much of the discussion about the prospects for Fortran has tended to be informal and centered on questions (such as, “will the language be around in 20 years”) that are impossible to answer with any certainty. By focusing on estimates of the likelihood associated with different outcomes, rather than on specific predictions, we hope to clarify points of disagreement within the community and strengthen the analytic basis for reasoning about the future. Our assessment for seven distinct risks associated with continued use of Fortran are that in the next fifteen years:

1. It is very likely that we will be unable to staff Fortran projects with top-rate computer scientists and computer engineers.

2. There is an even chance that we will be unable to staff Fortran projects with top-rate computational scientists and physicists.

3. There is an even chance continued maintenance of Fortran codes will lead to expensive human or financial maintenance costs.

4. It is very unlikely that codes that rely on Fortran will have poor performance on future CPU technologies.

5. It is likely that codes that rely on Fortran will have poor performance for GPU technologies.

6. It is very likely that Fortran will preclude effective use of important advances in computing technology.

7. There is an even chance that Fortran will inhibit introduction of new features or physics that can be introduced with other languages.

zaikunzhang··on Optimization Without Using Derivatives
Reading the discussions under a previous thread titled "More Descent, Less Gradient"( https://news.ycombinator.com/item?id=23004026 ), I guess people might be interested in PRIMA ( www.libprima.net ), which provides the reference implementation for Powell's renowned gradient/derivative-free (zeroth-order) optimization methods, namely COBYLA, UOBYQA, NEWUOA, BOBYQA, and LINCOA.

PRIMA solves general nonlinear optimizaton problems without using derivatives. It implements Powell's solvers in modern Fortran, compling with the Fortran 2008 standard. The implementation is faithful, in the sense of being mathmatically equivalent to Powell's Fortran 77 implementation, but with a better numerical performance. In contrast to the 7939 lines of Fortran 77 code with 244 GOTOs, the new implementation is structured and modularized.

There is a discussion to include the PRIMA solvers into SciPy ( https://github.com/scipy/scipy/issues/18118 ), replacing the buggy and unmaintained Fortran 77 version of COBYLA, and making the other four solvers available to all SciPy users.

← PreviousPage 3 of 3