!   Given several different parameters in a model,  (AstroCosFuzzy)
  with lowest and highest possible values for each,
  enumerate all combinations of high and low values
  and tabulate the possible optimal solutions for each combination,
  and find the fuzziness range for the objective function value,
  given the fuzziness range for each parameter.;
!    More qualitatively, given fuzzy input for a model, how "fuzzy"
  can the output be?
     To customize of other situations:
    a) Replace the DATA section with your data,
    b) Replace the SUBMODEL PARAMODEL with your model,
    c) Click on the red bullseye;

! Keywords: Sensitivity analysis, Fuzzy logic, Fuzzy optimization,
            Parametric analysis, Enumeration, 
            Depth first enumeration, Lexico-graphic enumeration,
            Range analysis;

SETS:
   PSET: PAMV, PLO, PMED, PHI;
ENDSETS
DATA: ! Names of the parameters; PSET = APRFT CPRFT ALCAP CLCAP LABRAVL ALBRUSE CLBRUSE ; ! The median or base case values for the parameters (These are used in Tornado Diagram analysis, but not Fuzzy); PMED = 20 30 60 50 120 1 2 ; ! Plausible low values for the parameters; PLO = 17 25 55 45 110 0.8 1.7 ; ! Plausible high values for the parameters; PHI = 25 38 65 60 140 1.4 2.3 ; BigM = 999999; ! A big number; ENDDATA SUBMODEL PARA! Fuzzy version of Astro/Cosmo Problem. ! The objective is to maximize profit. The PAMV( ) represent the fuzzy parameters; MAX = OBJ; OBJ = PAMV(1)*ASTRO + PAMV(2)*COSMO; ASTRO <= PAMV(3); ! Astro line capacity; COSMO <= PAMV(4); ! Cosmo line capacity; ! Labor usage <= labor available; PAMV(6)*ASTRO + PAMV(7)*COSMO <= PAMV(5); ENDSUBMODEL
CALC: @SET('TERSEO',2); ! Turn off default output; NP = @SIZE( PSET); @WRITE(' Sensitivity Analysis for an Optimization Problem', @NEWLINE(1),' with Various Lo and Hi/Fuzzy Parameter Values:', @NEWLINE(1)); @WRITE(' Iter'); @FOR( PSET( i): @WRITE( ' ',@FORMAT( PSET(i), '7s')); ); @WRITE(' Profit', @NEWLINE(1)); PROFLO = BigM; ! Record lowest profit observed; PROFHI = -BigM; ! Record highest profit observed; ! Do depth-first lexicographic enumeration from LO to HI of all parameter value combinations; p = 0; ! Current parameter index; iter = 0; ! Current iteration/parameter combination; NOTDONE = 1; ! = 0 when enumeration is complete; @WHILE( NOTDONE: iter = iter + 1; ! Forward step to set all remaining PAMV's to LO; @WHILE( p #LT# NP: p = p + 1; PAMV(p) = PLO(p); ); @WRITE( @FORMAT( iter, "5.0f")); @FOR(PSET(i): @WRITE(' ',@FORMAT(PAMV(i),"7.2f"));); !Solve the problem for current combination; @SOLVE( PARAMODEL); @WRITE(' ', Obj,@NEWLINE(1)); @IFC( OBJ #LT# PROFLO: PROFLO = OBJ; ITERLO = iter; ); @IFC( OBJ #GT# PROFHI: PROFHI = OBJ; ITERHI = iter; ); ! Backward step. Get next parameter combination. Find highest PAMV(p) = PLO(p), and...; MORE = 1; @WHILE(MORE: @IFC(p #LE# 0: MORE = 0; @ELSE @IFC( PAMV(p) #EQ# PLO(p): MORE = 0; @ELSE p = p - 1; ); ); ); @IFC( p #GT# 0: PAMV(p) = PHI(p); ! ...Flip it to Hi and take forward step; @ELSE NOTDONE = 0; ! Enumeration complete; ); ); @WRITE(@NEWLINE(1),' The optimal value falls in the range:', @NEWLINE(1), ' [ProfitLo, ProfitHi] = [',@FORMAT(PROFLO,"12.4f"),', ' ,@FORMAT( PROFHI,"12.4f"),']',@NEWLINE(1), ' Iteration= ', @FORMAT( ITERLO, "12.0f"),' ', @FORMAT( ITERHI,"12.0f")); ENDCALC