Skip to content

Commit

Permalink
added option to profile the whole parameter bounds. (#1014)
Browse files Browse the repository at this point in the history
* added option to profile the whole parameter bounds.

* combined stop profile check into one
  • Loading branch information
PaulJonasJost authored Feb 13, 2023
1 parent c9c1796 commit 5effaba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 5 additions & 0 deletions pypesto/profile/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class ProfileOptions(dict):
magic_factor_obj_value:
There is this magic factor in the old profiling code which slows down
profiling at small ratios (must be >= 0 and < 1).
whole_path:
Whether to profile the whole bounds or only till we get below the
ratio.
"""

def __init__(
Expand All @@ -48,6 +51,7 @@ def __init__(
reg_points: int = 10,
reg_order: int = 4,
magic_factor_obj_value: float = 0.5,
whole_path: bool = False,
):
super().__init__()

Expand All @@ -60,6 +64,7 @@ def __init__(
self.reg_points = reg_points
self.reg_order = reg_order
self.magic_factor_obj_value = magic_factor_obj_value
self.whole_path = whole_path

def __getattr__(self, key):
"""Allow usage of keys like attributes."""
Expand Down
15 changes: 7 additions & 8 deletions pypesto/profile/walk_along_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ def walk_along_profile(
x_now = current_profile.x_path[:, -1]

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

if par_direction == 1:
stop_profile = (x_now[i_par] >= problem.ub_full[[i_par]]) or (
current_profile.ratio_path[-1] < options.ratio_min
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
Expand Down

0 comments on commit 5effaba

Please sign in to comment.