Skip to content

Commit

Permalink
multistart updates + control parameter tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisChau committed Apr 17, 2024
1 parent 0442f0c commit 2265c20
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
9 changes: 5 additions & 4 deletions R/nls_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ nls_test_list <- function(fields = c("name", "class", "p", "n", "check")) {
2L, 2L, 5L, 7L, 3L, 5L, 6L, 6L, 8L, 2L, 2L, 4L, 9L, 4L, 7L, 2L,
3L, 3L, 3L, 4L, 3L, 4L, 9L, 4L, 4L, 3L, 4L,
5L, 5L, 5L, 2L, 3L, 4L, 2L, 3L, 4L, 3L, 6L,
3L, 2L, 4L, 5L, 10L, 5L, 11L, 2L, 3L, 2L, 3L, 5L, 4L, 5L, 2L),
3L, 2L, 4L, 9L, 10L, 5L, 11L, 2L, 3L, 2L, 3L, 5L, 4L, 5L, 2L),
n = c(14L, 54L, 214L, 24L, 250L, 250L, 6L, 14L,
151L, 236L, 128L, 33L, 24L, 24L, 250L, 14L, 14L, 25L, 168L,
11L, 37L, 6L, 9L, 16L, 35L, 15L, 154L,
24L, 53L, 12L, 15L, 54L, 9L,
10L, 10L, 10L, 2L,
3L, 4L, 2L, 15L, 11L, 16L, 31L, 10L, 10L, 20L, 10L, 10L,
3L, 4L, 2L, 15L, 11L, 16L, 31L, 10L, 10L, 20L, 9L, 10L,
33L, 65L, 16L, 16L, 3L, 4L, 10L, 24L, 16L, 3L),
check = c("p, n fixed",
"p, n fixed", "p, n fixed", "p, n fixed", "p, n fixed", "p, n fixed",
Expand Down Expand Up @@ -1026,8 +1026,9 @@ nls_test_problem <- function(name, p = NA, n = NA) {
.start_sol[["target"]] <- c(x1 = -11.594436774009, x2 = 13.2036289039192, x3 = -0.403439671815375,
x4 = 0.236778987189955)
} else if(identical(name, "Chebyquad")) {
.start_sol[["target"]] <- c(x1 = 0.0845197234842066, x2 = 0.915480280334846, x3 = 0.741423111649444,
x4 = 0.50000000, x5 = 0.258576892300304)
.start_sol[["target"]] <- c(x1 = 0.583953092107561, x2 = 0.416046907892861, x3 = 0.199490672310222,
x4 = 0.800509327690258, x5 = 0.764380891528748, x6 = 0.499999999999716,
x7 = 0.955794653864209, x8 = 0.0442053461358728, x9 = 0.235619108470807)
} else if(identical(name, "Osborne 1")) {
.start_sol[["target"]] <- c(x1 = 0.375410049869887, x2 = -1.46468686469542, x3 = 1.93584664236735,
x4 = 0.0221227007674338, x5 = 0.012867534096761)
Expand Down
18 changes: 9 additions & 9 deletions man/gsl_nls_control.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/nls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,15 +1069,17 @@ static void gsl_multistart_driver(pdata *pars,
{
if (pmin < 0.9 * l0 || (mpars->luchange)[k] > 4) // enlarge
{
(mpars->start)[2 * k] = l0 < 0 ? gsl_max(l0 / pow(-1e-5 * (l0 - 1.0), 0.1) - 1.0, -1.0E5) : -0.1;
(mpars->start)[2 * k] = l0 < 0 ? gsl_max(l0 / pow(-1e-5 * (l0 - 1.0), 0.1) - 1.0, -1.0E5) : -0.01;
if (pars->lu)
(mpars->start)[2 * k] = gsl_max((mpars->start)[2 * k], gsl_matrix_get(pars->lu, 0, k));
(mpars->maxlims)[2 * k] = gsl_min((mpars->start)[2 * k], (mpars->maxlims)[2 * k]);
luchange_add = -1;
}
else if (pmin > 0.2 * l0) // shrink
{
(mpars->start)[2 * k] = gsl_min(l0 / pow(-0.05 * (l0 - 1.0), 0.05), -0.1);
(mpars->start)[2 * k] = gsl_min(l0 / pow(-0.05 * (l0 - 1.0), 0.05), -0.01);
if (pars->lu)
(mpars->start)[2 * k] = gsl_max((mpars->start)[2 * k], gsl_matrix_get(pars->lu, 0, k));
luchange_add = ((mpars->mssropt)[0] < (double)GSL_POSINF) ? -1 : 1;
}
else
Expand All @@ -1097,6 +1099,8 @@ static void gsl_multistart_driver(pdata *pars,
else if (pmax < 0.2 * l1) // shrink
{
(mpars->start)[2 * k + 1] = gsl_max(l1 / pow(0.05 * (l1 + 1.0), 0.05), 0.1);
if (pars->lu)
(mpars->start)[2 * k + 1] = gsl_min((mpars->start)[2 * k + 1], gsl_matrix_get(pars->lu, 1, k));
luchange_add = ((mpars->mssropt)[0] < (double)GSL_POSINF) ? -1 : 1;
}
else
Expand Down

0 comments on commit 2265c20

Please sign in to comment.