The OPTMODEL Procedure

CROSS Expression

set-expression CROSS set-expression

The CROSS expression returns the crossproduct of its set operands. The result is the set of tuples formed by concatenating the tuple value of each member of the left operand with the tuple value of each member of the right operand. Scalar set members are treated as tuples of length 1. The following code demonstrates the CROSS operator:

    proc optmodel;
       set s1 = 1..2;
       set<string> s2 = {'a', 'b'};
       set<number, string> s3=s1 cross s2;
       put 's3 is ' s3;
       set<number, string, number> s4 = s3 cross 4..5;
       put 's4 is ' s4;
 

This code produces the output in Output 6.29.

                                                                                
                                                                                 
                                                                                 
 s3 is {<1,'a'>,<1,'b'>,<2,'a'>,<2,'b'>}                                         
 s4 is {<1,'a',4>,<1,'a',5>,<1,'b',4>,<1,'b',5>,<2,'a',4>,<2,'a',5>,<2,'b',4>,<2,
 'b',5>}                                                                         
 


Figure 6.29: CROSS Expression Output

Previous Page | Next Page | Top of Page