1 REM VALPRINF  
5 CLEAR  1000  
10 CLS:PRINT  TAB(5); "VALUE OF PERFECT INFORMATION":PRINT   
20 PRINT "IN THE SCENARIO TO THIS PROGRAM THERE ARE SEVERAL  
25 PRINT "POSSIBLE STATES OF NATURE, ONE OF WHICH IS THE TRUE STATE.  
30 PRINT "WE DO NOT KNOW WHAT THE TRUE STATE OF NATURE(S OF N) IS BUT  
35 PRINT "WE KNOW THE PROBABILITY OF OCCURRENCE OF EACH S OF N.  
40 PRINT "IN ADDITION THERE ARE SEVERAL ALTERNATIVE ACTIONS WE MAY TAKE  
45 PRINT "EACH OF WHICH HAS A CERTAIN EXPECTED VALUE(OR AVERAGE RETURN)."  
50 PRINT "EXPECTATION THEORY SAYS TO CHOOSE THE ACTION WITH THE HIGHEST  
55 PRINT "EXPECTED VALUE. IF WE KNEW WHAT THE TRUE STATE OF NATURE WAS  
60 PRINT "THEN WE WOULD KNOW WHAT ACTION TO TAKE. THE EXPECTED VALUE OF  
65 PRINT "PERFECT INFORMATION IS THE EXPECTED VALUE OF DECISIONS WITH  
70 PRINT "KNOWLEDGE OF THE S OF N MINUS THE MAXIMUM EXPECTED VALUE OF  
75 PRINT "ACTIONS WITHOUT THIS KNOWLEDGE."  
77 PRINT :GOSUB  10100  
80 CLS:PRINT "IN THIS PROGRAM THERE ARE UP TO 25 S OF N'S AND 8 POSSIBLE  
82 PRINT "ACTIONS. THE MAXIMUM EXPECTED VALUE OF THESE ACTIONS IS  
84 PRINT "COMPUTED. THEN THE EXPECTED VALUE WITH PERFECT INFORMATION  
86 PRINT "ABOUT THE S OF N IS COMPUTED. THEIR DIFFERENCE IS THE EVPI.  
95 PRINT :INPUT "PRESS ENTER TO BEGIN";Z9$  
100 DIM  A(25,8),P(25),M(25),E(8)  
105 P=0  
110 CLS  
120 INPUT "ENTER NUMBER OF POSSIBLE STATES OF NATURE";N  
125 IF  N<2  OR  N>25  OR  N<>INT(N)  THEN  GOSUB  10000:GOTO  120  
127 PRINT   
130 FOR  I=1  TO  N  
135 PRINT "ENTER PROBABILITY OF S OF N";I;:INPUT  P(I)  
140 P=P+P(I)  
150 NEXT  I  
160 IF  P=1  THEN  PRINT :GOTO  200  
170 PRINT :PRINT "PROBABILITIES DO NOT SUM TO 1."  
175 INPUT "ENTER 1 TO STANDARDIZE,0 TO BEGIN OVER";Z9  
180 IF  Z9<>0  AND  Z9<>1  THEN  GOSUB  10000:GOTO  170  
185 IF  Z9=0  THEN  GOTO  105  
190 FOR  I=1 TO N:P(I)=P(I)/P:NEXT :P=1  
200 PRINT :INPUT "ENTER NUMBER OF POSSIBLE DECISIONS(<=8)";M  
205 IF  M<2  OR  M>8  OR  M<>INT(M)  THEN  GOSUB  10000:GOTO  200  
220 FOR  J=1  TO  M  
225 PRINT   
230 PRINT "DECISION ";J  
240 FOR  I=1  TO  N  
250 PRINT  TAB(5);"PAYOFF WHEN S OF N IS";I;:INPUT  A(I,J)  
260 NEXT  I  
270 NEXT  J  
300 REM COMPUTATION  
310 CLS:PRINT  @  340,"COMPUTING"  
320 FOR  I=1  TO  N  
330 M(I)=A(I,1)  
340 FOR  J=2  TO  M  
350 IF  A(I,J)>M(I)  THEN  M(I)=A(I,J)  
360 NEXT  J  
370 NEXT  I  
400 FOR  J=1  TO  M  
405 EM=-10E6  
410 FOR I=1 TO N:E(J)=E(J)+A(I,J)*P(I):NEXT I:REM EXP. VAL.   
415 IF  E(J)>EM  THEN  EM=E(J)  
420 NEXT  J  
430 FOR I=1 TO N:E=E+M(I)*P(I):NEXT I:REM EVWPI  
495 REM PRINT  
500 CLS  
510 F$(1)="    DECISION          EXPECTED VALUE"  
520 F$(2)="      ##              #########.##  
525 PRINT  F$(1)  
530 FOR  J=1  TO  M:PRINT USING  F$(2);J,E(J):NEXT   
570 PRINT :PRINT "MAXIMUM EXPECTED VALUE = ";EM  
580 PRINT :PRINT "EVWPI                  = ";E  
590 PRINT "EXPECTED VALUE OF PERFECT INFORMATION = ";E - EM  
600 PRINT :END  
10000 PRINT "INPUT ERROR!TRY AGAIN!":FOR  JJ=1 TO 300:NEXT :RETURN   
10100 INPUT "PRESS ENTER TO CONTINUE";Z9$:RETURN   

