- Home
- Optimization
- How To Write Your Own Optimization Operand
- Home
- Programming ZEMAX
- ZPL
- How To Write Your Own Optimization Operand
How To Write Your Own Optimization Operand
- By Dan Hill
- Published 1 February 2006
- Optimization , ZPL
-
Rating:




Do User Defined Operands Slow Down Execution of the Merit Function?
You might find yourself asking how significant the computation times will be affected when you have user defined operands in the Merit Function Editor. This really depends upon the complexity of the computation performed within the macro, but in general the execution of a macro during optimization is extremely fast. To demonstrate, we can optimize the Cooke Triplet twice: once using the ZPLM operand and our constructed macro, and once using the pre-programmed operand, WFNO.
For the first case, Target the ZPLM operand to be 5, and give it a Weight of 1. You may leave the WFNO operand in place, but leave its Weight at zero. Construct a Default Merit Function using the following settings:

Run DLS optimization. The approximate execution time is 4 seconds:

Undo the changes made by the optimization (press F3 to do so). Change the Weight of the ZPLM operand to 0, set the Target of the WFNO operand to 5 and its Weight to 1. Re-optimize.

The execution time with the native operand is roughly 3.6 seconds. The difference between the two is roughly one-half-second! As you can see, ZEMAX can still optimize very efficiently, even in cases which call user-defined macros or an externally compiled program.
For the first case, Target the ZPLM operand to be 5, and give it a Weight of 1. You may leave the WFNO operand in place, but leave its Weight at zero. Construct a Default Merit Function using the following settings:

Run DLS optimization. The approximate execution time is 4 seconds:

Undo the changes made by the optimization (press F3 to do so). Change the Weight of the ZPLM operand to 0, set the Target of the WFNO operand to 5 and its Weight to 1. Re-optimize.

The execution time with the native operand is roughly 3.6 seconds. The difference between the two is roughly one-half-second! As you can see, ZEMAX can still optimize very efficiently, even in cases which call user-defined macros or an externally compiled program.