Resources

Petroleum Distributor's Decision Problem

 /**************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y               */
 /*                                                            */
 /*    NAME: DTREEE06                                          */
 /*   TITLE: Petroleum Distributor's Decision Problem          */
 /*          (dtreee06)                                        */
 /* PRODUCT: OR                                                */
 /*  SYSTEM: ALL                                               */
 /*    KEYS: OR GRAPHICS PATTERN SYMBOL                        */
 /*   PROCS: DTREE PRINT GPLOT                                 */
 /*    DATA:                                                   */
 /*                                                            */
 /* SUPPORT:                             UPDATE:               */
 /*     REF: Example 6 from the DTREE chapter                  */
 /*    MISC:                                                   */
 /*                                                            */
 /**************************************************************/

goptions hpos=80 vpos=32;
goptions cback=ligr ctext=black;


/* -- create the STAGEIN= data set                     -- */
data Stage7;
   format _OUTCOM1 $14. _OUTCOM2 $14. ;
   input _STNAME_ $ _STTYPE_ $ _OUTCOM1 $
       _SUCC1 $ _OUTCOM2 $ _SUCC2 $ ;
   datalines;
Action    D   Invoking        Response  Not_Invoking    .
Response  C   Accept          .         Refuse          Lawsuit
Lawsuit   C   Press_Issue     .         Settle          .
.         .   Sue             Last      .               .
Last      C   3_Years         Result    4_Years         Result
.         .   5_Years         Result    .               .
Result    C   No_Damages      .         Normal_Damages  .
.         .   Double_Damages  .         .               .
;


/* -- create the PROBIN= data set                      -- */
data Prob7;
   format _EVENT1_ _EVENT2_ $14.;
   input _EVENT1_ $ _PROB1_ _EVENT2_ $ _PROB2_ ;
   datalines;
Accept          0.1     Refuse          0.9
Press_Issue     0.1     Settle          0.45
Sue             0.45    .               .
3_Years         0.3     4_Years         0.4
5_Years         0.3     .               .
No_Damages      0.15    Normal_Damages  0.65
Double_Damages  0.20    .               .
;


   /* -- create the PAYOFFS= data set            -- */
data Payoff7(drop=i j k D PCOST);
   length _ACTION_ _STATE1-_STATE4 $16;

      /* possible outcomes for the case last        */
   array YEARS{3}   $16. _TEMPORARY_ ('3_Years',
                                      '4_Years',
                                      '5_Years' );

      /* numerical values for the case last  */
   array Y{3}            _TEMPORARY_ (3, 4, 5);

      /* possible outcomes for the size of judgment */
   array DAMAGES{3} $16. _TEMPORARY_ ('No_Damages',
                                      'Normal_Damages',
                                      'Double_Damages' );

      /* numerical values for the size of judgment  */
   array C{3}            _TEMPORARY_ (0, 1500, 3000);

   D=0.1;                          /* discount rate */

      /* payoff for the scenario which the          */
      /* 10 percent clause is not invoked           */
   _ACTION_='Not_Invoking';   _VALUE_=-450;   output;

      /* the clause is invoked */
   _ACTION_='Invoking';

      /* payoffs for scenarios which the clause is  */
      /* invoked and the customer accepts the       */
      /* invocation                                 */
   _STATE1='Accept';           _VALUE_=600;   output;

      /* the customer refuses the invocation        */
   _STATE1='Refuse';

      /* payoffs for scenarios which the clause is  */
      /* invoked and the customer refuses the       */
      /* invocation but decline to press the issue  */
   _STATE2='Press_Issue';   _VALUE_=500;      output;

      /* payoffs for scenarios which the clause is  */
      /* invoked and the customer refuses the       */
      /* invocation but willing to settle out of    */
      /* court for 900K                             */
   _STATE2='Settle';        _VALUE_=500-900;   output;

      /* the customer will sue for damages          */
   _STATE2='Sue';
   do i=1 to 3;
      _STATE3=YEARS{i};

         /* determine the cost of proceedings       */
      PCOST=30;  /* initial cost of the proceedings */

         /* additional cost for every years in      */
         /* in present value                        */
      do k=1 to Y{i};
         PCOST=PCOST+(20/((1+D)**k));
      end;

         /* loop for all poss. of the lawsuit result */
      do j=1 to 3;
         _STATE4=DAMAGES{j}; /* the damage have to paid */

            /* compute the net return in present value  */
         _VALUE_=500-PCOST-(C{j}/((1+D)**Y{i}));

            /* output an observation for the payoffs */
            /* of this scenario                      */
         output;
      end;
   end;

run;

   /* -- print the payoff table                      -- */
title "Petroleum Distributor's Decision";
title3 "Payoff Table";

proc print;
run;


   /* -- define graphics options                         -- */
goptions colors=(green red blue);
goptions hsize=8 in vsize=8.4 in;

   /* -- define title                                    -- */
title h=2.5 "Petroleum Distributor's Decision";

   /* -- PROC DTREE statements                           -- */
proc dtree stagein=Stage7 probin=Prob7 payoffs=Payoff7;
   evaluate / summary;
   treeplot / graphics compress nolg name="dt6p1" ftext='Cumberland AMT'
           ybetween=1 cell lwidth=2 lwidthb=3 hsymbol=3;
quit;


   /* -- create data set for decision diagram        -- */
data Data7(drop=i);
   P=0.0;                  /* initialize P */

      /* loop for all possible values of P */
   do i=1 to 21;

         /* determine the corresponding Q  */
      Q=(86-(1136*P))/(1036*(1.0-P));
      if Q < 0.0 then Q=0.0;

         /* output this data point */
      output;

         /* set next possible value of P   */
      P=P+0.005;
   end;

run;

   /* create the ANNOTATE= data set for labels of  */
   /* decision diagram                             */
data label;
   length FUNCTION STYLE COLOR $8;
   length XSYS YSYS            $1;
   length WHEN POSITION        $1;
   length X Y                   8;
   length SIZE ROTATE           8;

   WHEN = 'A';
   POSITION='0';
   XSYS='2';
   YSYS='2';
   input FUNCTION $ X Y STYLE $ SIZE COLOR $
         ROTATE TEXT $ & 16.;
   datalines;
label   0.01    0.04    centx   2       black   .    Do Not
label   0.01    0.03    centx   2       black   .    Invoke
label   0.01    0.02    centx   2       black   .    The Clause
label   0.06    0.06    centx   2       black   .    Invoke The
label   0.06    0.05    centx   2       black   .    Clause
;

   /* -- define symbol characteristics for boundary  -- */
symbol1 i=joint v=NONE l=1 ci=black;

   /* -- define pattern for area fill                -- */
pattern1 value=msolid color=cyan;
pattern2 value=msolid color=green;

   /* -- define axis characteristics                 -- */
axis1 label=('Pr(Accept the Invocation)')
      order=(0 to 0.1 by 0.01) minor=none;
axis2 label=(angle=90 'Pr(Press the Issue)')
      order=(0 to 0.1 by 0.01) minor=none;

   /* -- plot decision diagram                       -- */
title h=2.5 "Petroleum Distributor's Decision";
proc gplot data=Data7 ;
   plot Q*P=1 / haxis=axis1
                vaxis=axis2
                annotate=label
                name="dt6p2"
                frame
                areas=2;
run;
quit;