12 Custom optimization with COM
The methods implemented in InventSim COM interface allow you not only to edit and/or simulate the structure, but also to define your own optimization schemes. The software can be accessed from external tools like Matlab/GNU
Octave where you can easily define a custom optimization goal. If you would like to apply gradient-based optimization routines, like fmincon() or fminimax(), InventSim can provide the responses
(S-parameters) for user-defined perturbations of design parameters (optimization variables). The perturbation can be defined using the following method:
App.ActiveProject.Simulation.SetPerturbationValues(x_pert)
where x_pert is a vector of \(N\) values of perturbed design parameters. If the simulation is run with non-empty vector x_pert, then the solver will also compute the set of \(N\)-responses,
subsequently for each perturbation of design parameters at a time. This set of responses can be accessed with the function:
Sp_ij = App.ActiveProject.Simulation.GetPerturbationResult(q, Port_i, Port_j, Mode1, Mode2)
where \(q=0..N-1\) is the design parameter index (zero-based index), and (Port,Mode) parameters define the row and column of scattering matrix to be extracted. Size of output \(S_p\) confines with number of frequency points defined in the project.
The output vector \(S_p\) can be used, for example, to compute the gradient of S-parameters in frequency domain using finite-difference approach. Please note: to compute the perturbed responses InventSim is only executed once, similar to meshing, which is also done once.