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

pypesto.profile.parameter_profile incorrectly assumes symmetric bounds #1165

Closed
dweindl opened this issue Oct 30, 2023 · 1 comment · Fixed by #1166
Closed

pypesto.profile.parameter_profile incorrectly assumes symmetric bounds #1165

dweindl opened this issue Oct 30, 2023 · 1 comment · Fixed by #1166
Assignees
Labels
bug Something isn't working fixed but not released profiling Related to profiling

Comments

@dweindl
Copy link
Member

dweindl commented Oct 30, 2023

pypesto.profile.parameter_profile incorrectly assumes symmetric bounds (-lb = ub) here:

# check if the next profile point needs to be computed
if options.whole_path:
stop_profile = (
x_now[i_par] * par_direction >= problem.ub_full[[i_par]]
)
else:
stop_profile = (
x_now[i_par] * par_direction >= problem.ub_full[[i_par]]
) or (current_profile.ratio_path[-1] < options.ratio_min)
if stop_profile:
break

This causes major problems in case this is not fulfilled:

  • ub < -lb: premature stopping, cropped profiles
  • ub > -lb: infinite loop

Not sure how this could go unnoticed...

To reproduce:

def test_broken_profiles():
    import pypesto
    from pypesto import profile
    from ..util import rosen_for_sensi

    obj = rosen_for_sensi(max_sensi_order=1)['obj']

    # for infinite loop
    lb = 6 * np.ones(5)
    ub = 10 * np.ones(5)

    # for cropped profile
    lb = -4 * np.ones(5)
    ub = 1 * np.ones(5)

    problem = pypesto.Problem(
        objective=obj,
        lb=lb,
        ub=ub,
    )

    optimizer = optimize.ScipyOptimizer(options={'maxiter': 10})
    result = optimize.minimize(
        problem=problem,
        optimizer=optimizer,
        n_starts=2,
        progress_bar=False,
    )
    profile.parameter_profile(
        problem=problem,
        result=result,
        optimizer=optimizer,
        next_guess_method='fixed_step',
        profile_index=[1],
        progress_bar=False,
        profile_options=profile.ProfileOptions(
            min_step_size=0.5,
            delta_ratio_max=0.05,
            default_step_size=0.5,
            ratio_min=0.01,
            whole_path=True,
        )
    )
    x_path = result.profile_result.list[0][1]['x_path'][1]

    print(x_path.min(), x_path.max())
    assert x_path.max() == ub[1]
    assert x_path.min() == lb[1]
@dweindl dweindl added bug Something isn't working profiling Related to profiling labels Oct 30, 2023
@dweindl dweindl self-assigned this Oct 30, 2023
@dweindl
Copy link
Member Author

dweindl commented Oct 30, 2023

Introduced in #1014. Shame on the reviewer.

dweindl added a commit that referenced this issue Oct 30, 2023
…bounds

Use the correct bounds for checking whether we are done computing the profile.

Add test.

Closes #1165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed but not released profiling Related to profiling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants