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

Added custom theta initialization & small refactor #107

Merged

Conversation

japanavi
Copy link
Contributor

Added custom theta initialization parameter custom_theta_init: dict[float]. To initialize custom angles, pass a dict of floats with the angle as key, e.g.

maxcut_benchmark.run(custom_theta_init={"beta": 0.5, "gamma": 0.5})

Slightly refactored code to initialize new thetas in main loop, this means we no longer need the method and rounds parameters in MaxCut since we always pass thetas_init.

Also, fixed title issue in optimality gap plot (was missing the f for the fstring).

Copy link
Collaborator

@rtvuser1 rtvuser1 left a comment

Choose a reason for hiding this comment

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

Method 1 can also use a different number of rounds even if the incoming theta is None. We could assume that the beta and gamma repeat if not explicitly provided for each round.
I think we should restore rounds as an argument to MaxCut and pass it from run(), so we don't lose that flexibility.
I agree that method could be removed, as we would always want to process the theta array., even for method 1.
So the circuit is always the same for either method 1 or method 2

@japanavi
Copy link
Contributor Author

Re: "Method 1 can also use a different number of rounds even if the incoming theta is None."

  • Was this available in the original implementation, or are you asking me to implement it?
    • We didn't pass in a theta for Method 1, so theta was always None

Re: "We could assume that the beta and gamma repeat if not explicitly provided for each round."

  • I can implement a feature that uses a different $\beta, \gamma$ for each round, let me know if you want me to.

@rtvuser1
Copy link
Collaborator

Re: "Method 1 can also use a different number of rounds even if the incoming theta is None."

  • Was this available in the original implementation, or are you asking me to implement it?

    • We didn't pass in a theta for Method 1, so theta was always None

Re: "We could assume that the beta and gamma repeat if not explicitly provided for each round."

  • I can implement a feature that uses a different β,γ for each round, let me know if you want me to.

Regarding method 1 ... previously it always created the default because we didn't pass theta in, so it defaulted. I think we want to create the theta default always, even for method 2 if theta = None. This way method 1 and method 2 are the same in that regard. Both accept rounds and an optional custom theta array, but they always create a similar circuit that could have more than one round.

You could implement the multiple betas and gammas, that might change the behavior when more than one round.
The optimizer will need to adjust multiple parameters in that case, which is different from now.
If it gets at all complicated, you might consider doing that in a diff PR.

@japanavi japanavi requested a review from rtvuser1 June 17, 2022 23:45
Copy link
Collaborator

@rtvuser1 rtvuser1 left a comment

Choose a reason for hiding this comment

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

OK, merging now

@rtvuser1 rtvuser1 merged commit 6f5a8c6 into SRI-International:add-maxcut-benchmark Jun 18, 2022
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.

None yet

2 participants