-
Notifications
You must be signed in to change notification settings - Fork 47
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
ood startpoints #732
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
No objections. |
pypesto/startpoint/__init__.py
Outdated
|
||
Methods for selecting points that can be used as startpoints | ||
for multi-start optimization. | ||
Startpoint methods can be implemented as derived from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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__
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
pypesto/startpoint/base.py
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maximizing some distance). If n_guesses >= n_starts, only the first | |
maximizing some distance). |
pypesto/startpoint/base.py
Outdated
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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 ^^
There was a problem hiding this 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). | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise NotImplementedError() | |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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...
pypesto/startpoint/assign.py
Outdated
|
||
def assign_startpoints( | ||
n_starts: int, | ||
startpoint_method: StartpointMethod, |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, added
fixes #709