! Unordered LexicoMinMax procedure.           (uLexMinMax.lng)
 Minimize the unordered lexico-max of the X( j)
    subject to given constraints on the X( j).
I.e., find the X(j) so largest X( j) is minimized,
subject to that, minimize the sum of the 2 largest,
subject to that, minimize the sum of the 3 largest, etc.
Variables:
  X( i)) = penalty (less is better) incurred by party i,
  klrgst( k) = kth largest X(i) when minimizing the
              sum of the k largest X(i),
  delta(i,k) = amount by which X(i)
                 is greater than klrgst(k) when minimizing the
                 sum of j largest, = 0 if <= klrgst( k);
! References:
 Serafini, P. (1996), “Scheduling Jobs on Several Machines with the Job Splitting Property”,
  Operations Research, Vol. 44, No. 4, (July-August), pp. 617-628.
 Maschler, M., B. Peleg, and L. S. Shapley (1979), “Geometric Properties of the
  Kernel, Nucleolus, and Related Solution Concepts”, Mathematics of Operations Research,
  vol. 4, No. 4 (Nov), pp. 303-338. 

!Keywords: Fair allocation, Lexico-min, Minimax,
      Unordered lexico-min, Goal programming, Multi-criteria;

SETS:
  PARTY: klrgst, z, X;
  PXP( PARTY, PARTY): delta;
ENDSETS
DATA: PARTY = 1..6; ENDDATA SUBMODEL ULexMin: Min = OBJ; OBJ = z( ks); ! Here are the constraints related to finding the unordered Lexico MinMax; @FOR( PARTY( k): @FOR( PARTY( i): klrgst(k) + delta( i, k) >= X( i); ); z(k) >= k*klrgst(k) + @SUM( PARTY( i): delta( i, k)); ! Notice that for a given k, an optimal solution is to set klrgst(k) = kth largest X, and delta( i,k) = max( 0, X(i) - klrgst(k)) ; ); ! Here insert the regular constraints; X( 1) + 2 *X( 2) + 4 *X( 3) + 7 *X( 4) >= 16; 2.5 *X( 1) + 3.5 *X( 2) + 5.2 *X( 5) >= 17.5; 0.4 *X( 2) + 1.3 *X( 4) + 7.2 *X( 6) >= 12; 2.5 *X( 2) + 3.5 *X( 3) + 5.2 *X( 5) >= 13.1; 3.5 *X( 1) + 3.5 *X( 4) + 5.2 *X( 6) >= 18.2; ENDSUBMODEL
CALC: @SET( "TERSEO", 2);! Turn off default messages; old = 0; ! Remember sum of previous largest; @FOR( PARTY( j): ks = j; @SOLVE( ULexMin); ! Fix z( ks); z( ks) = OBJ; @WRITE(' Min possible Sum of ', ks,' largest = ', @FORMAT( OBJ,'8.5f'), ' so next added= ',@FORMAT( OBJ- old,'8.5f'),@NEWLINE(1)); old = OBJ; ! Remember old value; ); @WRITE(@NEWLINE(1),' And the solution is',@NEWLINE(1)); @FOR( PARTY( j): @WRITE(' X(',j,') =', @FORMAT(X( j),'8.5f'), @NEWLINE(1)); ); ENDCALC