Repository navigation
Conversation
- ORIG_DIRECT: a forced stop at the first evaluation returned from direct_dirinit_ before minpos was set, and direct_direct_ then read the point at an uninitialized index. Check the stop after minpos is set. - StoGO: InTime() and the checks in local() tested only maxeval and maxtime, so a forced stop was ignored. Test nlopt_stop_forced too and return NLOPT_FORCED_STOP. - CRS2: crs_init evaluated the whole initial population after a forced stop. Return NLOPT_FORCED_STOP from crs_init and keep the best point. New test t_force_stop_evals: no evaluations after force_stop() at evaluation 1, 2, 5, 15 and 40.
Contributor
Author
|
@stevengj, a reminder in case this one was missed: it is ready for review, and the checks pass. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After
nlopt_force_stop(oropt.force_stop(), or an exception in a C++ objective), three algorithms did not stop.GN_ORIG_DIRECTandGN_ORIG_DIRECT_Lcrashed with an access violation when the stop came at the first evaluation.direct_dirinit_returned before it setminpos, anddirect_direct_then read the point at that index afterL100. The check now comes after*minfand*minposare set, so the evaluated point is returned. (The SciPy version of this code in direct: diff from SciPy #615 avoids the crash by initializingminpos = 1indirect_direct_.)GD_STOGOandGD_STOGO_RANDignored the stop.Global::InTime()and the two checks inlocal()tested onlymaxevalandmaxtime, so the run went on tomaxevaland returnedNLOPT_SUCCESS. They now also testnlopt_stop_forced, andnlopt_optimize_returnsNLOPT_FORCED_STOP.GN_CRS2_LMevaluated the rest of its initial population, becausecrs_initdid not testnlopt_stop_forced. In 2-D, a stop at evaluation 1 gave 30 more evaluations.crs_initnow returnsNLOPT_FORCED_STOP, andcrs_minimizestill reports the best point found.New test
test/t_force_stop_evals.cxx: the objective callsforce_stop()at evaluation 1, 2, 5, 15 and 40. The test checks that the run ends withnlopt::forced_stop, that there are no further evaluations, and that a finite reported optimum equals the objective at the returned x. It runs for the five algorithms above and for MMA, COBYLA, BOBYQA, ISRES and ESCH, which already pass.On master: ORIG_DIRECT and ORIG_DIRECT_L crash; StoGO and StoGO-rand run all 1000 evaluations and do not report the stop; CRS2 runs 31 evaluations for a stop at evaluation 1 to 15. With the change, all pass. ctest: 98 of 98 pass (MSVC 2022).
I also ran every algorithm through the C API (2-D, stop at evaluation 1, 2, 5, 15, 40 and 100). Apart from these five, every algorithm returns
NLOPT_FORCED_STOP. A few evaluate one or two more points after the stop: the DIRECT variants and PRAXIS for a stop at evaluation 1, the Luksan algorithms (LBFGS, VAR1, VAR2, TNEWTON) at evaluation 2 or 5, and AGS at evaluation 1 or 2. I left those alone. Runs without a forced stop gave the same number of evaluations and the same result codes before and after the change.