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

Avoid two candidates with same value. #1001

Closed
wants to merge 17 commits into from
Closed

Avoid two candidates with same value. #1001

wants to merge 17 commits into from

Conversation

teytaud
Copy link
Contributor

@teytaud teytaud commented Jan 7, 2021

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Motivation and Context / Related issue

Current concerns that need to be tackled (for discussion/tracking):

  • what should happen if an optimizer has tried all possible values but has budget left?
  • what should we do to redraw in case of already evaluated item? return the past evaluation to the optimizer? (can lead to early optimizer exhaustion for sequence based optim like LHS) or call mutate on the parameter? (can lead to bad points because mutate may not be appropriately scale at this point of the optimization)
  • could an optimizer get "locked up" in an area surrounded by already evaluated points, preventing it to move to other areas?

How Has This Been Tested (if it applies)

Checklist

  • The documentation is up-to-date with the changes I made.
  • I have read the CONTRIBUTING document and completed the CLA (see CLA).
  • All tests passed, and additional code has been covered with new tests.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jan 7, 2021
@teytaud
Copy link
Contributor Author

teytaud commented Jan 7, 2021

Supposed to fix #976

num_determinism_failures = 0
while candidate.get_value_hash() in self._forbidden_value:
num_determinism_failures += 1
if num_determinism_failures >= 10:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

with this limit we get rid of the risk of infinite / super-long loop.

Still, it would be better to have the auxiliary optimizer (which ensures that we do not go too far) - but Roma was not built in a single day.

@@ -78,7 +78,7 @@ def square2(m: tp.Any) -> float:
model.constraint1 = pyomo.Constraint(rule=lambda m: m.x >= 2)

func = core.Pyomo(model)
optimizer = ng.optimizers.OnePlusOne(parametrization=func.parametrization, budget=100)
optimizer = ng.optimizers.OnePlusOne(parametrization=func.parametrization, budget=20)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This shows that we are faster than previously.

@@ -146,7 +146,7 @@ def axis(self) -> tp.Optional[tp.Tuple[int, ...]]:
def _apply_array(self, arrays: tp.Sequence[np.ndarray]) -> np.ndarray:
assert len(arrays) == 1
data = arrays[0]
axis = tuple(range(data.dim)) if self.axis is None else self.axis
axis = tuple(range(len(data))) if self.axis is None else self.axis
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand why this was not caught earlier...

Copy link
Contributor

@jrapin jrapin left a comment

Choose a reason for hiding this comment

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

there are too many side effects, I'll need time to analyze this:

  • it's a breaking change (people with noisy function, including using noisy optimizers will by default get deterministic behavior)
  • it can explode memory for both long runs and huge parametrization
  • it's using the value hash which probably needs a lot of revamp because it is hard to implement (leading to issues when adding new parametrizations), and probably too inefficient.

Using request changes to make sure we do not merge it yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. Status: Do not merge Status: On hold
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants