Hi Alberto,
If you simply call the ISEQOptimizationWizard2, then OpticStudio will automatically update the DMFS the same way it would if you called the wizard from the GUI:
- If there is already a DMFS operand in the MFE, then all operands below the DMFS are deleted and the DMF is rebuilt
- If there is not a DMFS operand in the MFE, then all operands are deleted and only the DMF will exist
If you want to keep this manual, then yes, you will need to scan all the rows of the MFE in order to find the first DMFS (if there is a second DMFS, OpticStudio will automatically re-write if you rebuild a DMFS); none of the methods attached to the IMertiFunctionEditor will allow you to get data values for more than 1 row at a time.
The DMFS should be close to the top so even with dozens or hundreds of calls to GetOperandAt()
method should be extremely quick. However, if you either have thousands of operands before your DMFS or you need to extract extra data from all the operands under the DMFS, this can be a very time consuming loop, especially if you’re using interpreted code such as Python/Matlab. I would suggest calling the SaveMeritFunction()
method and then manually parse the text .MF file. If memory serves, with Python I can parse 100,000 rows in under 2 seconds by reading directly from the text file.