Skip to content

access the objective function during optimisation #2931

Answered by mochen4
poutine-dejeuner asked this question in Q&A
Discussion options

You must be logged in to vote

If you already have defined an OptimizationProblem, opt, you can simply call opt() and it will return the objective function value and the gradient with respect to the design variables; you can additionally pass the argument need_gradient=False so that it will only compute the objective function value without the gradient.
Alternatively, with the simulation object sim alone, you can first add the mode monitors with "sim.add_mode_monitor(...)", run the simulation, and then call "sim.get_eigenmode_coefficients(...)" to compute the corresponding values. See the tutorial example https://meep.readthedocs.io/en/master/Python_Tutorials/Mode_Decomposition/

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by stevengj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2910 on November 14, 2024 13:25.