Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor prima_is_success to accept options.ctol #200

Merged
merged 3 commits into from
May 6, 2024

Conversation

nbelakovski
Copy link
Contributor

This is in reference to #195

I made it so that ctol is initialized to the default value that was being used. Another option is to check if options.ctol is NaN within prima_is_success, but I know we've discussed before that isnan can have issues with certain optimization levels.

I'll think about it some more, but I'm not sure what other options there are. With either option above we need to maintain a default value within prima.c which is not ideal since that implies two places where default values are stored (prima.c and consts.f90). Would it make sense to have a consts folder at the root of the repo, which then contains folders like fortran, c, python, each of which defines const values for each of the languages, so that there's one place where these values are maintained?

@zaikunzhang
Copy link
Member

zaikunzhang commented May 1, 2024

Hi @nbelakovski ,

I agree with what you said.

I think the solution you propose is fine given the current situation.

However, I am considering another possibility: let the Fortran backend return success (optional), so that other languages do not need to define success themselves.

This also motivates a single gateway prima.f90 to the Fortran backend, so that we do not need to define success for each solver. You proposed this before, and I disagreed, but I now think it is a good idea. Once prima.f90 is defined, we will provide prima_c.f90 to replace newuoa_c.f90 etc, disabling the access to individual solvers. It will make the Fortran API more consistent with the current C and Python ones. However, this is still some dispute about this perspective.

What do you think? We can merge the current solution first, but I hope to hear your opinions.

Thanks.

Zaikun

@zaikunzhang
Copy link
Member

Hi @nbelakovski ,

Do we really need to expose prima_is_success in the public API? Could we add a success field to result, expecting users to get success by reading this field?

A similar question was asked about prima_get_rc_string.

Thanks.

@nbelakovski
Copy link
Contributor Author

Do we really need to expose prima_is_success in the public API? Could we add a success field to result, expecting users to get success by reading this field?

A similar question was asked about prima_get_rc_string.

I don't think we need to expose either of these in the public API, and I've made the appropriate changes.

Once prima.f90 is defined, we will provide prima_c.f90 to replace newuoa_c.f90 etc, disabling the access to individual solvers.

Of course I think that defining prima_c.f90 would be much more straightforward than our current solution of almost identically copying the same file 5 times. I think the package overall is more useful if it automatically determines what algorithm to use given the constraints provided, but it would be nice to have an "advanced mode" where users could explicitly specify the solver.

@zaikunzhang zaikunzhang merged commit 9bbc828 into libprima:main May 6, 2024
38 of 57 checks passed
@nbelakovski nbelakovski deleted the ctol branch May 6, 2024 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants