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

Exception "Not a mode, as quality is too high" #34

Open
paul019 opened this issue Dec 9, 2024 · 0 comments
Open

Exception "Not a mode, as quality is too high" #34

paul019 opened this issue Dec 9, 2024 · 0 comments

Comments

@paul019
Copy link
Contributor

paul019 commented Dec 9, 2024

In the luigi config, one specifies the parameter ModeSearchConfig.quality_threshold; usually in the range of 1e-6 to 1e-4. This parameters is used at two points in the overall code:

  1. Both FindPassiveModes and FindThresholdModes call the function refine_mode_brownian_ratchet, where quality_threshold is a parameter that tells the algorithm when to stop the search.
  2. Later on, in ComputeModeCompetitionMatrix, the function mode_on_nodes is called (see below). In there, some mode quality is calculated and compared against quality_threshold. If it exceeds the threshold, an exception is thrown.

For some runs, I get the exception mentioned in point 2. I initially tried those runs with ModeSearchConfig.quality_threshold = 1e-6 and got the exception that my quality was slightly above that – usually just by a factor not greater than 1.5 (which is quite small considering we are speaking about orders of magnitude here). Then I increased ModeSearchConfig.quality_threshold to 1e-5, but still get an exception:

Not a mode, as quality is too high: 1.0717457667280263e-05 > 1e-05, mode: (6.873399477319817-0.0033058189568381364j)

It seems that (for some reason) the actual quality always exceeds the target quality by a tiny bit. The easy solution would be to compare the actual quality in the function mode_on_nodes (see below) against 2 * quality_threshold . This way, all exceptions that I get would be removed.

However, to be honest, I don't understand the code deeply enough (yet) to judge whether this solution would be reasonable. This is why I would be glad about an opinion from the code authors here.

netSALT/netsalt/modes.py

Lines 265 to 282 in 7729c76

def mode_on_nodes(mode, graph):
"""Compute the mode solution on the nodes of the graph."""
laplacian = construct_laplacian(to_complex(mode), graph)
min_eigenvalue, node_solution = sc.sparse.linalg.eigs(
laplacian, k=1, sigma=0, v0=np.ones(len(graph)), which="LM"
)
quality_thresh = graph.graph["params"].get("quality_threshold", 1e-4)
if abs(min_eigenvalue[0]) > quality_thresh:
raise Exception(
"Not a mode, as quality is too high: "
+ str(abs(min_eigenvalue[0]))
+ " > "
+ str(quality_thresh)
+ ", mode: "
+ str(mode)
)
return node_solution[:, 0]

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

No branches or pull requests

1 participant