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

invdes plugin GUI support #1973

Merged
merged 4 commits into from
Sep 24, 2024
Merged

invdes plugin GUI support #1973

merged 4 commits into from
Sep 24, 2024

Conversation

yaugenst-flex
Copy link
Contributor

This is a rebased & cleaned-up version of #1848, with changes properly grouped. Got a bit messy with rebasing those commits (lots of overlapping changes introduced at different points of development), so figured this was cleaner.

Didn't want to force-push there in case we want to keep a reference to the original commits around.

@yaugenst-flex yaugenst-flex added the 2.7 will go into version 2.7.* label Sep 23, 2024
@yaugenst-flex yaugenst-flex self-assigned this Sep 23, 2024
Copy link
Collaborator

@tylerflex tylerflex left a comment

Choose a reason for hiding this comment

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

Looks great!

@tylerflex tylerflex added the .4 label Sep 24, 2024
Copy link
Collaborator

@momchil-flex momchil-flex left a comment

Choose a reason for hiding this comment

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

Just a couple small notes.

- **Named Variables**: For each named variable, you must provide a corresponding keyword argument.
If a named variable is missing during evaluation, a `ValueError` will be raised.

- **Multiple Unnamed Variables**: If your expression contains multiple unnamed variables, you cannot provide multiple positional arguments.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This detailed readme is great, thanks for putting it together. One comment here is just that this is making me wonder why bother support unnamed variables at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not strictly necessary, but I thought it would be a nice convenience to not always have to provide keyword arguments, i.e. you might just want to do:

a = Variable()
f = 2 * a**2
f(2)  # = 8

if there were no unnamed variables, you'd have to do

a = Variable("a")
f = 2 * a**2
f(a=2)  # = 8

which is ever so slightly more cumbersome...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Right, only now you have to remember the extra rule that you can only have one of those and stumble upon errors if you end up used to mixing them.. So in some sense just teaching people to always use the slightly more cumbersome version seems like less potential annoyances down the road.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah fair enough, we can make the name required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@momchil-flex this is actually a bit more involved than I thought initially, because we'd also require the metrics to be named (since they are also variables). and then there needs to be logic in the InverseDesign while constructing the objective function that extracts the names from potentially nested expression objects to pass the simulation data. like, I can add it, but it'll be a relatively big change to introduce now. I'm leaning towards leaving it as-is for now and implement that change if it turns out that the current approach is causing confusion?
it's a relatively small change w.r.t. what's user-facing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, ok, if it's that involved it's fine by me (even to potentially keep as is forever, it's a nit-y thing).

tidy3d/plugins/invdes/optimizer.py Outdated Show resolved Hide resolved
tidy3d/plugins/invdes/optimizer.py Outdated Show resolved Hide resolved
@yaugenst-flex
Copy link
Contributor Author

ok, well I guess we're probably ready to go here then? 😬

@tylerflex
Copy link
Collaborator

yea I think so! can be in a separate PR, but check out on slack the error I got using invdes today. might be related to an edge case in 2D sims that we should probably handle before we officially release this

@momchil-flex momchil-flex merged commit 7367d26 into develop Sep 24, 2024
15 checks passed
@momchil-flex momchil-flex deleted the yaugenst-flex/invdes-gui branch September 24, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.7 will go into version 2.7.* .4
Projects
None yet
3 participants