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

ood startpoints #732

Merged
merged 12 commits into from
Oct 12, 2021
Merged

ood startpoints #732

merged 12 commits into from
Oct 12, 2021

Conversation

yannikschaelte
Copy link
Member

  • Make startpoint methods object-oriented for clear API
  • Filling also resampling in there and getting rid of assign_startpoints and optimize options would be preferable, but didn't want to break API unless fine for all.

fixes #709

@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2021

Codecov Report

Merging #732 (56d37b5) into develop (160c2a8) will decrease coverage by 54.00%.
The diff coverage is 27.67%.

Impacted file tree graph

@@             Coverage Diff              @@
##           develop     #732       +/-   ##
============================================
- Coverage    88.16%   34.16%   -54.01%     
============================================
  Files           79       99       +20     
  Lines         5257     6659     +1402     
============================================
- Hits          4635     2275     -2360     
- Misses         622     4384     +3762     
Impacted Files Coverage Δ
pypesto/engine/mpi_pool.py 0.00% <0.00%> (ø)
pypesto/ensemble/covariance_analysis.py 18.36% <0.00%> (-0.39%) ⬇️
pypesto/objective/aesara.py 0.00% <0.00%> (ø)
pypesto/objective/amici_calculator.py 25.00% <0.00%> (-66.67%) ⬇️
pypesto/optimize/__init__.py 100.00% <ø> (ø)
pypesto/petab/__init__.py 0.00% <0.00%> (ø)
pypesto/petab/importer.py 0.00% <0.00%> (-85.90%) ⬇️
pypesto/petab/pysb_importer.py 0.00% <0.00%> (-100.00%) ⬇️
pypesto/profile/profile.py 32.43% <0.00%> (-59.46%) ⬇️
pypesto/profile/util.py 23.40% <ø> (-72.35%) ⬇️
... and 125 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f696e3...56d37b5. Read the comment docs.

@dweindl
Copy link
Member

dweindl commented Oct 4, 2021

Filling also resampling in there and getting rid of assign_startpoints and optimize options would be preferable, but didn't want to break API unless fine for all.

No objections.


Methods for selecting points that can be used as startpoints
for multi-start optimization.
Startpoint methods can be implemented as derived from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Startpoint methods can be implemented as derived from
Startpoint methods can be implemented by deriving from

lb=lb,
ub=ub,
objective=objective,
x_guesses=x_guesses
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will lead to issues when non-empty x_guesses is passed since n_starts is always set to one and the startpoint index is not provided. I think startpoint_method should really only use x_guesses as reference and any selection of startpoint vs guess should be carried out in this function and assign_startpoints. Along these lines this function should probably issue a warning when resampling a user-provided guess.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if I understand. the startpoint_method is simply a uniform or lhs function, so atm no startpoint_method actually uses x_guesses. They could use it to only suggest points away from those guesses, but that only makes a limited amount of sense, so atm if would be no problem to just remove x_guesses from the startpoint_method.__call__.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the docstring in StartpointMethod, the respective methods are supposed to account for x_guesses.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, that was a copy-pasta error. the StartpointMethod is not supposed to return any of these, but only conceptually use them to e.g. only sample remote points. xguesses was passed in the original formulation but never used. to avoid issues here I think I'll just remove the argument.

x_guesses:
Externally provided guesses, shape (n_guess, n_par).
Maybe used as reference points to generate remote points (e.g.
maximizing some distance). If n_guesses >= n_starts, only the first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
maximizing some distance). If n_guesses >= n_starts, only the first
maximizing some distance).

Externally provided guesses, shape (n_guess, n_par).
Maybe used as reference points to generate remote points (e.g.
maximizing some distance). If n_guesses >= n_starts, only the first
n_starts guesses are returned.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
n_starts guesses are returned.

"Problem.startpoint_method will be ignored. Startpoints will be "
"generated using the startpoint method given as an argument to "
"the minimize function.",
)
elif problem.startpoint_method is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a switch if isinstance(startpoint_method, Callable) that instantiates a FunctionStartpoints and issues a deprecation warning to mantain backwards compatibility?

optimizer: Optimizer = None,
n_starts: int = 100,
ids: Iterable[str] = None,
startpoint_method: Union[StartpointMethod, bool] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to say that I find it a bit counterintuitive to pass a class object to an argument that is called "..._method"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah ... was to keep it consistent with before. Effectively, it is a method with maybe some hyperparameters that are memorized via self reference ^^

Copy link
Member

@jvanhoefer jvanhoefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

startpoints:
Startpoints, shape (n_starts, n_par).
"""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise NotImplementedError()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessary as method is declared as abstract. further, I would argue that "NotImplementedError" is for when functionality is just still missing (e.g. due to developer's laziness), while abstractmethod is for stuff that is not actually meant to be implemented in this place.

"""


class FunctionStartpoints(StartpointMethod):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put that in a separate function_startpoint.py file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could, but as this is also very core functionality, I'd just keep it in here, to have not too many files

Startpoints, shape (n_starts, n_par).
"""
# check if startpoints needed
if startpoint_method is False:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is in contrast with the type annotations...


def assign_startpoints(
n_starts: int,
startpoint_method: StartpointMethod,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can apparently also be a bool.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, added

@yannikschaelte yannikschaelte merged commit 18960c0 into develop Oct 12, 2021
@yannikschaelte yannikschaelte deleted the fix_startpoints branch October 12, 2021 13:42
@yannikschaelte yannikschaelte mentioned this pull request Oct 28, 2021
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.

6 participants