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

Fix relax_and_split kwargs dict passing #466

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ryanwu4
Copy link

@ryanwu4 ryanwu4 commented Dec 18, 2024

I noticed that the relax_and_split() method in the permanent magnet optimization tools was .pop()'-ing keys such as nuand the regularization terms out ofkwargs`, even though these should actually be passed to the convex MwPGP algorithm in the code block:

algorithm_history, _, _, m = convex_step(
    A_obj=pm_opt.A_obj,
    b_obj=pm_opt.b_obj,
    ATb=ATb,
    m_proxy=np.ascontiguousarray(m_proxy.reshape(pm_opt.ndipoles, 3)),
    m0=np.ascontiguousarray(m.reshape(pm_opt.ndipoles, 3)),  # note updated m is new guess
    m_maxima=mmax,
    **kwargs
)

This causes a bug where if you optimize with relax_and_split(), the default value of nu = 1e100 is used since this key has been removed from the kwargs dict when it is passed on to the convex MwPGP method. This pull request changes it to a get() method for the relevant keys instead.

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.

1 participant