• 23 January 2023
  • 2 replies


I would like to know how to use the OCOD and OPEV operands with multi configuration files: In case the same operand is present more than once (for example for different configurations) how to read the right one?

Also, I want to know if it is possible to use OCOD with mathematical operands, like MINN, or MAXX, and same question, what if there is more than one in the Merit Function?

Otherwise, is there a simpler way to read one value from any line in the MF?





Best answer by David.Nguyen 24 January 2023, 12:05

View original

2 replies

Userlevel 6
Badge +2

Hi Cristina,


Every Merit Function operand type is identified by an integer code. And I’m not talking about the operands you actually have in your Merit Function Editor, I’m talking about every single type of Merit Function operand. You can retrieve this integer code with OCOD. If you run the following macro with the name of your operand of interest (REAY in this example):


It will return the following codes for the different operands (change REAY in the line of code above for MINN, MAXX, or any other operand you like):

  • REAY is 126
  • MINN is 221
  • MAXX is 217

Now, OPEV serves to evaluate an operand that is not in your Merit Function Editor. The Help File reads:

Computes the same value as any optimization operand would, without the need to add the operand to the merit function

However, to be able to do that, OPEV needs to know what operand type it should compute. Therefore, it needs the integer code from OCOD. Because OPEV doesn’t have any knowledge of the Merit Function Editor, it cannot compute MAXX, and MINN. Again from the Help File:

OPEV will only work for operands that do not depend upon the presence of prior operands

If you wanted to evaluate MAXX, and MINN, you’d have to add this operand to your Merit Function Editor (either manually or using ZPL with the keywords INSERTMFO and SETOPERAND).

If you then want to read the value of an operand that is present in your Merit Function Editor, you need to use OPER. OPER has only two parameters, the operand number, and the data you want to retrieve (for an operand value it is number 10, check the Help File for other data such as Weight or % Contrib).

Imagine I have a Merit Function like so (CONS means constant, it is just a number whose Value equals the Target):

If I wanted to take the MAXX with ZPL, this is what I would write:

# Define new operand number
new_op = 4

# Insert new operand at the end of the Merit Function Editor

# Change the new operand type to MAXX
SETOPERAND new_op, 11, "MAXX"

# Adjust MAXX parameters
op_1 = 1
op_2 = 3
SETOPERAND new_op, 2, op_1
SETOPERAND new_op, 3, op_2

# Change Weight of MAXX to zero
SETOPERAND new_op, 9, 0

# Update Merit Function Editor

# Print the value of MAXX
PRINT OPER(new_op, 10)

You could also delete the operand after its use using DELETEMFO. The code above returns the value:


I hope this helps, and take care,



Hi David,

Thanks, it helped a lot!