Skip to content

Commit

Permalink
GA Max Run Count Note & Bugfixes
Browse files Browse the repository at this point in the history
Added a note to summarize when using the GA so the user is aware the max run count can be exceeded in certain circumstances
Small changes to testing to fix GA test bug and improve coverage
  • Loading branch information
m-bone committed Jul 31, 2024
1 parent 1660d85 commit d9a3e7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/test_plugins/test_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
monte_carlo=tdd.MethodMonteCarlo(num_points=5, rng_seed=1),
bay_opt=tdd.MethodBayOpt(initial_iter=5, n_iter=2, rng_seed=1),
gen_alg=tdd.MethodGenAlg(
solutions_per_pop=4,
solutions_per_pop=6,
n_generations=2,
n_parents_mating=4,
rng_seed=1,
Expand Down Expand Up @@ -354,6 +354,7 @@ def test_sweep(sweep_method, monkeypatch):

# Test multiple return statements for pre and post
# Currently not supporting this and intercepting attempts within _extract_output
# Note this requires a "tag1" tag to be in the prediction space
with pytest.raises(ValueError):
non_td_multi_return = design_space.run(non_td_pre_multi_return, non_td_post_multi_return)

Expand All @@ -366,7 +367,9 @@ def test_sweep(sweep_method, monkeypatch):

# Try with batch output from pre
td_batch = design_space.run(scs_pre_batch, scs_post_batch)
td_batch_run_batch = design_space.run_batch(scs_pre_batch, scs_post_batch, path_dir="")
td_batch_run_batch = design_space.run_batch(
scs_pre_batch, scs_post_batch, path_dir="", batch_kwargs={"fake_kwarg": None}
)

# # Test user specified batching works with combined function
td_batch_combined = design_space.run(scs_combined_batch)
Expand Down
7 changes: 7 additions & 0 deletions tidy3d/plugins/design/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,13 @@ def summarize(self, fn_pre: Callable = None) -> dict[str, Any]:
# Include additional notes/warnings
notes = []

if isinstance(self.method, MethodGenAlg):
notes.append(
"The maximum run count for MethodGenAlg is difficult to predict."
"Repeated solutions are not executed, reducing the total number of simulations."
"High crossover and mutation probabilities may result in an increased number of simulations, potentially exceeding the predicted maximum run count."
)

if isinstance(self.method, (MethodBayOpt, MethodGenAlg, MethodParticleSwarm)):
if any(isinstance(param, ParameterInt) for param in self.parameters):
if any(isinstance(param, ParameterAny) for param in self.parameters):
Expand Down

0 comments on commit d9a3e7c

Please sign in to comment.