For example, the average transmission of an Optical Network Analyzer…

# Can I define an arbitrary figure-of-merit (FOM) for optimization?

**xwang**#1

User Defined FOM in Optimization

What’s the meaning of the “Mean” operation in INTERCONNECT sweep?

Proper format for Figure of Merit script

**gwang**#2

Hi @xwang, yes you definitely can define your own figure-of-merit for optimizations, and there are two ways of doing so. The first method is to define the figure-of-merit in the “Advanced” tab under the “Figure of merit script” window. Please make sure you check the “Use figure of merit script” box when using this method.

The other method, which is also the one I recommend in you case, is to pre-define this figure-of-merit inside the Root Element Edit window and then optimize this figure-of-merit. To pre-define the figure-of-merit, you need to add a new result in the “Edit Root Element” window under the “Results” tab. Then under the “Scripts” tab, in the “Analysis script” window, write the script to define the figure-of-merit and add it to the new result you have just defined. Then in the “Optimization” window, you can add this result as the figure-of-merit.

I made a simple example, fom_optimization.icp (111.9 KB) showing the second method, please check it out.

I hope this could help

**feng.liu**#3

Nice example.

I tried to use optical powermeter.

I was able to add the script to “Root Element”.

But the script did not always compute – ie obtai the optical power , instead it sometimes resulted to “power (dBm)”.

Is there some mistake in my script below? Thanks in advance.

T1=getresult(“OPWM_1”, “sum/power”);

T2=getresult(“OPWM_2”, “sum/power”);

Ratio=abs(T1-T2);

setresult(“Ratio”, Ratio);

**gwang**#4

Hi @feng.liu,

As I tested, the `getresult("OPWM_1", "sum/power");`

generally works since the power meter has a single number result. Could you please upload your file when it doesn’t work? I agree that the results datasets are complicated; some results come with units while some don’t, and the dataset structures are different for different analyzers.

One trick is to use the `getresultdata`

command instead of `getresult`

. This command returns the result as a matrix instead of a dataset so there is no unit associated.

I hope this could help looking forward to seeing your file.

**feng.liu**#5

Hi, Dr. Wang,

Thanks for your help.

Attached is the simulation file I used to test the optimization procedure

for your review.

I tried the commend you suggested. It sometimes still does not work.

see below screen capture.

Best Regards,

Feng

Feng Liu

Development Engineer

Foxconn Interconnect Technology Ltd http://www.fit-foxconn.com/ (FIT)9999

Hamilton Blvd.

Breinigsville, PA 18031

Office: 484-795-5071

E-mail: feng.liu@foit-foxconn.com feng.liu@avagotech.com

laser_pdk_test.icp (611 KB)

**gwang**#6

Hi @feng.liu,

Indeed I see the same problem as you saw, and the optimization sometimes works while sometimes complains about “result Ratio cannot be found”. This indicates that there is something wrong in the optimization process for automatically running “runanalysis”. I found that to change the “run setup script” to “always” for the Root Element would solve this problem. Please try this and let me know whether it works for you or not.

We will keep digging into this problem and I will keep you updated on this.

I hope this could help