Skip to content

Commit

Permalink
Merge branch 'master' into ku/fourier_bounce_neo
Browse files Browse the repository at this point in the history
  • Loading branch information
unalmis authored Dec 24, 2024
2 parents 2cb0f3e + e357a9b commit 08b31b2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
12 changes: 6 additions & 6 deletions desc/optimize/aug_lagrangian.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from scipy.optimize import BFGS, NonlinearConstraint, OptimizeResult

from desc.backend import jnp
from desc.utils import errorif, setdefault
from desc.utils import errorif, safediv, setdefault

from .bound_utils import (
cl_scaling_vector,
Expand Down Expand Up @@ -350,12 +350,12 @@ def laghess(z, y, mu, *args):
# conngould : norm of the cauchy point, as recommended in ch17 of Conn & Gould
# scipy : norm of the scaled x, as used in scipy
# mix : geometric mean of conngould and scipy
tr_scipy = jnp.linalg.norm(z * scale_inv / v**0.5)
conngould = safediv(g_h @ g_h, abs(g_h @ H_h @ g_h))
init_tr = {
"scipy": jnp.linalg.norm(z * scale_inv / v**0.5),
"conngould": (g_h @ g_h) / abs(g_h @ H_h @ g_h),
"mix": jnp.sqrt(
(g_h @ g_h) / abs(g_h @ H_h @ g_h) * jnp.linalg.norm(z * scale_inv / v**0.5)
),
"scipy": tr_scipy,
"conngould": conngould,
"mix": jnp.sqrt(conngould * tr_scipy),
}
trust_radius = options.pop("initial_trust_radius", "conngould")
tr_ratio = options.pop("initial_trust_ratio", 1.0)
Expand Down
14 changes: 6 additions & 8 deletions desc/optimize/aug_lagrangian_ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from scipy.optimize import NonlinearConstraint, OptimizeResult

from desc.backend import jnp, qr
from desc.utils import errorif, setdefault
from desc.utils import errorif, safediv, setdefault

from .bound_utils import (
cl_scaling_vector,
Expand Down Expand Up @@ -289,14 +289,12 @@ def lagjac(z, y, mu, *args):
# conngould : norm of the cauchy point, as recommended in ch17 of Conn & Gould
# scipy : norm of the scaled x, as used in scipy
# mix : geometric mean of conngould and scipy
tr_scipy = jnp.linalg.norm(z * scale_inv / v**0.5)
conngould = safediv(jnp.sum(g_h**2), jnp.sum((J_h @ g_h) ** 2))
init_tr = {
"scipy": jnp.linalg.norm(z * scale_inv / v**0.5),
"conngould": jnp.sum(g_h**2) / jnp.sum((J_h @ g_h) ** 2),
"mix": jnp.sqrt(
jnp.sum(g_h**2)
/ jnp.sum((J_h @ g_h) ** 2)
* jnp.linalg.norm(z * scale_inv / v**0.5)
),
"scipy": tr_scipy,
"conngould": conngould,
"mix": jnp.sqrt(conngould * tr_scipy),
}
trust_radius = options.pop("initial_trust_radius", "conngould")
tr_ratio = options.pop("initial_trust_ratio", 1.0)
Expand Down
12 changes: 6 additions & 6 deletions desc/optimize/fmin_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from scipy.optimize import BFGS, OptimizeResult

from desc.backend import jnp
from desc.utils import errorif, setdefault
from desc.utils import errorif, safediv, setdefault

from .bound_utils import (
cl_scaling_vector,
Expand Down Expand Up @@ -247,12 +247,12 @@ def fmintr( # noqa: C901
# conngould : norm of the cauchy point, as recommended in ch17 of Conn & Gould
# scipy : norm of the scaled x, as used in scipy
# mix : geometric mean of conngould and scipy
tr_scipy = jnp.linalg.norm(x * scale_inv / v**0.5)
conngould = safediv(g_h @ g_h, abs(g_h @ H_h @ g_h))
init_tr = {
"scipy": jnp.linalg.norm(x * scale_inv / v**0.5),
"conngould": (g_h @ g_h) / abs(g_h @ H_h @ g_h),
"mix": jnp.sqrt(
(g_h @ g_h) / abs(g_h @ H_h @ g_h) * jnp.linalg.norm(x * scale_inv / v**0.5)
),
"scipy": tr_scipy,
"conngould": conngould,
"mix": jnp.sqrt(conngould * tr_scipy),
}
trust_radius = options.pop("initial_trust_radius", "scipy")
tr_ratio = options.pop("initial_trust_ratio", 1.0)
Expand Down
6 changes: 3 additions & 3 deletions desc/optimize/least_squares.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ def lsqtr( # noqa: C901
# conngould : norm of the cauchy point, as recommended in ch17 of Conn & Gould
# scipy : norm of the scaled x, as used in scipy
# mix : geometric mean of conngould and scipy
scipy = jnp.linalg.norm(x * scale_inv / v**0.5)
tr_scipy = jnp.linalg.norm(x * scale_inv / v**0.5)
conngould = safediv(jnp.sum(g_h**2), jnp.sum((J_h @ g_h) ** 2))
init_tr = {
"scipy": scipy,
"scipy": tr_scipy,
"conngould": conngould,
"mix": jnp.sqrt(conngould * scipy),
"mix": jnp.sqrt(conngould * tr_scipy),
}
trust_radius = options.pop("initial_trust_radius", "scipy")
tr_ratio = options.pop("initial_trust_ratio", 1.0)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ numpy >= 1.20.0, <= 2.2.0
nvgpu <= 0.10.0
orthax <= 0.2.1
plotly >= 5.16, <= 5.24.1
psutil <= 6.1.0
psutil <= 6.1.1
pylatexenc >= 2.0, <= 2.10
quadax >= 0.2.2, <= 0.2.4
scikit-image <= 0.25.0
Expand Down

0 comments on commit 08b31b2

Please sign in to comment.