home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
SIMTEL
/
CPMUG
/
CPMUG033.ARK
/
CASPPLUS.BAS
< prev
next >
Wrap
BASIC Source File
|
1984-04-29
|
14KB
|
246 lines
REM THIS IS THE PROGRAM 'CASPPLUS.BAS' (COMPUTER-AIDED SEARCH PLANNING)
REM
REM BASED UPON THE FORTRAN PROGRAM 'RJCASP'
REM WRITTEN BY LT.COL. BOB MATTSON USAF, DIR OF SAR, CIVIL AIR PATROL
REM TRANSLATED FROM FORTRAN TO BASIC BY CAPT GARY WILSON CAP
REM POD ENHANCEMENTS AND REWRITE IN BASIC-E BY MAJOR BOB GREGORY CAP
REM LT.COL.MATTSON WORK PH(205)293-5310 ;MAJOR GREGORY HOME PH(717)243-3979
REM
REM
REM D( )=INTERNAL CELL NUMBER USED FOR SORTING
REM CELLP$( )=CELL/GRID PRIMARY NAME
REM COVF( )=CUMULATIVE COVERAGE FACTOR FOR EACH CELL
REM CELLS$( )=CELL/GRID SECONDARY NAME
REM CID$( ),CPOD( )=TWO VARIABLES USED TO STORE INPUTTED POD DATA
REM POTI( )=INITIAL CELL PROBABILITY OF TARGET
REM POT( )=CURRENT CALCULATED CELL/GRID PROBABILITY OF TARGET
REM SPOTI=SUM OF ALL CELL POTI( )'S, USED FOR SCALING DOWN POTI'S
REM POF( )=PROBABILITY THAT TARGET WAS IN CELL BUT IT WAS NOT DETECTED
REM TPOF=TOTAL PROBABILITY OF FAILURE=SUM OF POF( )'S
REM POS( )=PROBABILITY OF SUCCESS FOR A CELL=POD( )*POT( )
REM POD( )=PROBABILITY OF DETECTION FOR A CELL=1-EXP(-SUM(COVF( )))
REM NPOD=NUMBER OF POD'S LOGGED INTO THE PROGRAM
REM MX=MAXIMUM NUMBER OF CELLS/GRIDS (IE 50)
REM MAX=MAXIMUM NUMBER OF POD'S/SORTIES (IE 200)
REM IPOD=USER INPUTTED PROBABILITY OF DETECTION (POD) FOR A CELL (0%-99%)
REM IPOT=USER INPUTTED PROBABILITY OF TARGET (POT) BEING IN THIS CELL/GRID
REM NUM=NUMBER OF CELLS LOGGED INTO THE PROGRAM
REM CAT=TERRAIN CATEGORY IE. 1,2,3, OR 4
REM V=SEARCH TERRAIN VISIBILITY
REM S,TRACK.SPACING=SEARCH A/C TRACK SPACING
REM HRS,MIN=HRS,MIN
REM EST.TIME=ESTIMATED TIME TO SEARCH 'AREA' AT 'SPEED'
REM GRID.AREA=SIZE OF GRID/CELL IN SQ. NM
REM PERCENT=PERCENT OF GRID/CELL SEARCHED (0-100%)
REM AREA=ACTUAL AREA SEARCHED IN SQ. NM
REM A,A1,A2,A3,A4,A5=SEARCH ALTITUDE AND EQUATION CONSTANTS
REM K$,K1$,I,J,K,L=TEMPORY VARIABLES
REM****************************************************************************
SPOTI=99:MX=50:MAX=200 REM SET INITIAL EVALUATION OF POT SCALE FOR CELLS
GRID.AREA=172 REM SET INITIAL GRID SIZE
DIM D(MX),CELLP$(MX),COVF(MX),CELLS$(MX),POTI(MX),POT(MX),CID$(MAX),CPOD(MAX)
REM****************************************************************************
REM THE COMMAND MENUE ROUTINE**************************************************
REM
PRINT "THIS IS 'CASPPLUS' A SAR RESOURCE ALLOCATION PROGRAM":PRINT:PRINT
PRINT "BEFORE ENTERING DATA INTO THIS PROGRAM THE USER MUST FIRST ANALYZE"
PRINT "THE CURRENT SAR SITUATION AND THEN SUBDIVIDE THE SEARCH MAP INTO"
PRINT "SEARCH CELLS (AS MANY AS 50 CELLS)"
PRINT "THEN THE USER MUST ASSIGN TO EACH CELL AN INITIAL PROBABILITY THAT"
PRINT "THE TARGET IS WITHIN THAT CELL. THESE ESTIMATES MAY BE CHANGED"
PRINT "LATER AND NEW CELLS MAY BE ADDED AT ANY TIME"
PRINT:PRINT "YOU WILL NOW BE ASKED TO ENTER THESE ESTIMATES"
GOSUB 45 REM GET INITIAL CELL/GRID NAMES AND POT'S
15 PRINT:PRINT "THE FOLLOWING COMMANDS ARE AVAILABLE:":PRINT
PRINT TAB(10);"1.ADD A NEW CELL/GRID OR CHANGE 'POT' FOR EXISTING CELL"
PRINT TAB(10);"2.ADD A NEW POD FOR AN EXISTING CELL"
PRINT TAB(10);"3.LIST THE CURRENT TABULAR SUMMARY OF CELLS"
PRINT TAB(10);"4.LIST ALL CELLS/POD'S THAT HAVE BEEN ENTERED"
PRINT TAB(10);"5.DELETE AN INCORRECTLY ENTERED POD"
PRINT TAB(10);"6.QUIT THE PROGRAM AND DISCARD ALL DATA"
25 PRINT:INPUT "WHAT IS THE COMMAND NUMBER (1 TO 6) PLEASE";K:PRINT
IF K<1 OR K>6 OR K<>INT(K) THEN GOTO 25
IF K=6 THEN STOP REM END OF PROGRAM
ON K GOSUB 44,240,470,600,300
GOTO 15
REM****************************************************************************
REM CELL ADDITION AND PROBABILITY OF TARGET (POT) ROUTINE**********************
44 FOR I=1 TO NUM:POTI(I)=SPOTI*POTI(I):NEXT I REM SCALE UP POTI'S
45 IF NUM>=MX THEN PRINT "NO MORE CELLS ALLOWED":GOTO 185 REM CHG MX
PRINT "ENTER PRIMARY CELL NAME,COMMA,SECONDARY CELL NAME,COMMA,AND THEN"
PRINT "THE PROBABILITY OF THE TARGET IN THE CELL USING THE RANGE 0-";SPOTI
PRINT "FOR THE LAST ENTRY USE 'END,0,0'"
60 INPUT K$,K1$,IPOT REM ENTER P-NAME,S-NAME,CELL POT
FOR I=1 TO NUM
IF K$="END" THEN SPOTI=0:GOTO 180 REM EXIT TO DELPHI ROUTINE
IF K$=CELLP$(I) THEN POTI(I)=POTI(I)+IPOT:PRINT"CELL FOUND":GOTO 60
NEXT I
PRINT "THE NEW CELL IS '";K$;"' AND THE POT=";IPOT;"%" REM ADD NEW CELL
NUM=NUM+1:CELLP$(NUM)=K$:CELLS$(NUM)=K1$:POTI(NUM)=IPOT:D(NUM)=NUM
IF NUM<=MX THEN GOTO 60 ELSE PRINT "NO MORE CELLS ALLOWED" REM DELPHI NEXT
REM****************************************************************************
REM DELPHI EVALUTATION AND SCALING ROUTINE*************************************
REM
180 FOR I=1 TO NUM:SPOTI=SPOTI+POTI(I):NEXT I REM ADD UP POTI FOR CELLS
185 FOR I=1 TO NUM:POTI(I)=POTI(I)/SPOTI:NEXT I REM SCALE DOWN POTI FOR CELLS
GOTO 280 REM GENERATE POT( ) AND SORT
REM***************************************************************************
REM PROBABILITY OF DETECTION INPUT ROUTINE*************************************
REM
240 IF NPOD>=MAX THEN PRINT "NO MORE POD'S ALLOWED":RETURN
PRINT "THESE ARE THE CURRENT VALID PRIMARY CELL NAMES: ";
FOR I=1 TO NUM:PRINT CELLP$(I);", ";:NEXT I:PRINT
INPUT "TYPE THE PRIMARY CELL NAME OR ELSE 'END' FOR THE LAST ENTRY";K$
IF K$="END" THEN GOTO 280 REM CALC NEW POT( )'S
FOR K=1 TO NUM REM FOR ALL CELLS
IF K$=CELLP$(K) THEN PRINT "CELL FOUND":GOTO 250
NEXT K
PRINT "'";K$;"' IS NOT A LEGITIMATE CELL NAME":GOTO 240
250 INPUT "DO YOU NEED HELP IN CALCULATING THE POD (Y/N)";K1$
IF LEFT$(K1$,1)="Y" THEN GOSUB 800:GOTO 270
260 PRINT "WHAT IS THE POD FOR THE CELL ";K$;:INPUT IPOD REM GET POD
IF IPOD<0 OR IPOD>=100 THEN PRINT "INVALID POD":GOTO 260 REM AGAIN
270 COVF(K)=COVF(K)+LOG(1-IPOD/100):NPOD=NPOD+1:CPOD(NPOD)=IPOD:CID$(NPOD)=K$
GOTO 240 REM GET MORE DATA
REM****************************************************************************
REM ROUTINE TO CALCULATE POT( ) AND THEN SORT ON POT **************************
REM
280 TPOF=0 REM ENTRANCE POINT FROM BOTH DELPHI AND POD ROUTINES
FOR I=1 TO NUM:TPOF=TPOF+POTI(I)*EXP(COVF(I)):NEXT I REM ADD POF'S
FOR I=1 TO NUM:POT(I)=POTI(I)*EXP(COVF(I))/TPOF:NEXT I REM CALC POT'S
FOR J=1 TO NUM-1 REM SORT ALL CELL DATA ON POT
FOR I=J+1 TO NUM
IF POT(D(J))<POT(D(I)) THEN K=D(J):D(J)=D(I):D(I)=K REM BUBBLE SORT
NEXT I
NEXT J
RETURN
REM****************************************************************************
REM POD CORRECTION ROUTINE*****************************************************
REM
300 GOSUB 600 REM GET LIST OF PREVIOUS POD ENTRIES
310 INPUT "WHICH CELL HAS THE INCORRECT POD";K$
FOR K=1 TO NUM REM GET INDEX # OF CELL NAME
IF K$=CELLP$(K) THEN PRINT "CELL FOUND":GOTO 320
NEXT K REM NORMAL EXIT THEREFORE NOT FOUND
PRINT "CELL '";K$;"' IS NOT A LEGITIMATE NAME":GOTO 310
320 PRINT "THE AREA '";K$;"' HAS HAD THE FOLLOWING POD'S ENTERED: ";
FOR J=1 TO NPOD REM FOR ALL ENTRIES
IF K$=CID$(J) THEN PRINT CPOD(J);"%, ";
NEXT J:PRINT
340 INPUT "ENTER THE INCORRECT POD (OR '0' IF NONE ARE INCORRECT)";IPOD
IPOD=ABS(IPOD) REM IPOD MUST BE +
IF IPOD>=100 THEN PRINT "QUIT PLAYING AROUND":GOTO 340
COVF(K)=COVF(K)-LOG(1-IPOD/100):NPOD=NPOD+1:CPOD(NPOD)=-IPOD:CID$(NPOD)=K$
IF COVF(K)>0 THEN COVF(K)=0 REM DATA TRAP
GOTO 280 REM RECALCULATE POD'S
REM****************************************************************************
REM P-NAME,S-NAME,POT,POD,POT OUTPUT ROUTINE***********************************
REM
470 PRINT NUM;"CELLS/GRIDS ARE ACTIVE ";
INPUT "HOW MANY CELLS YOU WISH TO SEE TABULATED";J
IF J<0 OR J>NUM OR J<>INT(J) THEN PRINT "INVALID NUMBER":GOTO 470
PRINT "CELL","CELL","INIT PROB", "CUMULATIVE","CURRENT PROB"
PRINT "NUMBER", "NAME","TGT IN CELL","POD","TARGET IN CELL"
FOR I=1 TO J REM OUTPUT TABLE OF J CELLS SORTED ON POT
PRINT CELLP$(D(I)),CELLS$(D(I)),INT(100*POTI(D(I))+.5);"%",
PRINT INT(100*(1-EXP(COVF(D(I))))+.5);"%",INT(1000*POT(D(I))+.5)/10;"%"
NEXT I
PRINT "SEARCH EFFECTIVENESS PROBABILITY =";INT(1000*(1-TPOF)+.5)/10;"%"
INPUT "ENTER LETTER 'C' TO RETURN TO COMMAND MENUE";K$
RETURN
REM****************************************************************************
REM ROUTINE FOR LISTING ALL CELL/POD ENTRIES **********************************
REM
600 FOR I=1 TO NPOD:PRINT I;". ";
PRINT"CELL/GRID '";CID$(I);"' WAS SEARCHED WITH A REPORTED POD OF ";CPOD(I);"%"
NEXT I
RETURN
REM****************************************************************************
REM POD ANALYSIS ROUTINE FOR AIRCRAFT VISUAL SEARCHES *************************
REM
800 PRINT "DESCRIBE THE TERRAIN TO BE SEARCHED USING THE FOLLOWING CATEGORIES:"
PRINT TAB(10);"1.OPEN AND FLAT";TAB(40);"2.MODERATE TREE+BUSH COVER"
PRINT TAB(10);"3.HEAVY TIMBER";TAB(40);"4.ROCKY,MOUNTAINOUS OR NEW SNOW"
810 INPUT "WHAT IS THE TERRAIN CATEGORY NUMBER";CAT
IF CAT=1 THEN T=1 :GOTO 815 REM TERRAIN FACTORS
IF CAT=2 THEN T=.5 :GOTO 815
IF CAT=3 THEN T=.25:GOTO 815
IF CAT=4 THEN T=.15:GOTO 815
GOTO 810 REM NO MATCH
815 PRINT:INPUT "WHAT WAS THE SEARCH AREA VISIBILITY (1-5NM)";V
IF V<1 OR V>5 THEN PRINT "VISIBILITY MUST BE BETWEEN 1 AND 5 NM":GOTO 815
820 INPUT "WHAT WAS THE SEARCH ALTITUDE (200,300,500,700,1000 FT)";SA
RESTORE:FOR I=1 TO 5:READ A,A1,A2,A3,A4,A5 REM EQUATION CONSTANTS
IF A=SA THEN GOTO 830
NEXT I
PRINT "PLEASE SELECT ONE OF THE LISTED ALTITUDES":GOTO 820 REM DOPE
830 INPUT "DO YOU NEED HELP IN CALCULATING THE TRACK SPACING (Y/N)";K1$
IF LEFT$(K1$,1)="Y" THEN GOSUB 900:GOTO 840 REM SUBROUTINE
835 INPUT "WHAT WAS THE TRACK SPACING (NM)";S
840 IF S<=0 OR S>5 THEN PRINT "LETS BE REASONABLE":GOTO 835 REM DATA TRAP
IPOD=100*(1-EXP(-T/S*(A1+V*(A2+V*(A3+V*(A4+V*A5)))))) REM CALC POD
PRINT "THE POD FOR AREA '";K$;"' IS ";INT(10*IPOD+.5)/10;"%" REM OUTPUT
RETURN REM RETURN TO POD INPUT ROUTINE
REM****************************************************************************
REM TRACK SPACING ANALYSIS ROUTINE FOR AIRCRAFT VISUAL SEARCHES ***************
REM
900 PRINT "THE AREA OF THE LAST REPORTED CELL/GRID WAS ";GRID.AREA;"SQ NM"
INPUT "DID YOU SEARCH THE SAME SIZE CELL THIS TIME (Y/N)";K1$
IF LEFT$(K1$,1)="Y" THEN GOTO 920
INPUT "WHAT WAS THE AREA OF THIS CELL IN SQ NM";GRID.AREA
920 INPUT "WHAT PERCENTAGE OF THIS CELL WAS SEARCHED (0-100)";PERCENT
AREA=GRID.AREA*PERCENT/100
PRINT"SO ABOUT ";AREA;"SQ NM WAS SEARCHED.";:INPUT"IS THAT RIGHT (Y/N)";K1$
IF LEFT$(K1$,1)<>"Y" THEN GOTO 900
INPUT "WHAT WAS THE AIRCRAFT SEARCH SPEED";SPEED
PRINT "WHAT WAS THE TIME SPENT IN THE SEARCH AREA?";
INPUT "ENTER 'HOURS,COMMA,MINUTES'";HRS,MIN
SEARCH.TIME=HRS+MIN/60
950 TRACK.SPACING=(60*AREA+SPEED*SQR(AREA))/(SEARCH.TIME*SPEED*60)
PRINT "I ESTIMATE TRACK SPACING TO BE ";INT(10*TRACK.SPACING+.5)/10;"NM"
INPUT "IS THAT SPACING ABOUT RIGHT (Y/N)";K1$
IF LEFT$(K1$,1)="Y" THEN S=TRACK.SPACING:RETURN
INPUT "WHAT WAS THE TRACK SPACING THEN (NM)";TRACK.SPACING
EST.TIME=(60*AREA+SPEED*SQR(AREA))/(SPEED*TRACK.SPACING*60)
PRINT "TO SEARCH A CELL OF ";AREA;"SQ NM AT ";SPEED;"KNOTS WOULD TAKE ";\
INT(EST.TIME);"HRS AND ";INT(60*(EST.TIME-INT(EST.TIME)));"MINUTES"
INPUT "DO YOU STILL WANT TO USE YOUR ESTIMATE (Y/N)";K1$
IF LEFT$(K1$,1)<>"Y" THEN GOTO 950 ELSE S=TRACK.SPACING:RETURN
REM****************************************************************************
REM ***************************************************************************
REM DATA FOR POD EQUATIONS:
DATA 200,-3.438060E-2,.2050731,-1.006933E-2,-5.605945E-4,-6.269870E-5
DATA 300,.4948905,-.7147783,.535268,-.12496,9.579662E-3
DATA 500,.6070413,-.924985,.7044575,-.1699153,1.340136E-2
DATA 700,.7330137,-1.134626,.8355327,-.1996037,1.568362E-2
DATA 1000,.4649629,-.5862799,.4975626,-.1146642,8.416611E-3
REM
END REM THATS ALL FOLKS *****************************************************
DEFINITIONS:
PROBABILITY OF DETECTION(POD)=THE PROBABILITY THAT, IF A TARGET IS IN A
GIVEN CELL/GRID, IT WILL BE FOUND
PROBABILITY OF TARGET(POT)=THE PROBABILITY THAT THE TARGET WILL BE
PRESENT IN A GIVEN CELL/GRID
PROBABILITY OF SUCCESS(POS)=THE PROBABILITY THAT A TARGET WILL BE
PRESENT A CELL, AND IT WILL BE FOUND
PROBABILITY OF FAILURE(POF)=THE PROBABILITY THAT A TARGET WAS ACTUALLY
IN A GIVEN CELL, BUT IT WAS NOT FOUND DURING THE SEARCH
TOTAL CELL PROBABILITY OF FAILURE=NOT(POT( ))+POF( )=1-POS( )
COVERAGE FACTOR=THE RATIO OF SWEEP WIDTH TO TRACK SPACING. FOR A SINGLE
CELL, COVERAGE FACTORS ARE ADDATIVE BUT POD'S ARE NOT
TOTAL POD FOR CELL=100*(1-EXP(-(COVF(1)+COVF(2)+...+COVF(N))))%
CELL/GRID PRIMARY NAME=THE LOCAL (ON BASE) NAME FOR A CELL/GRID.
EG. A,B,C...OR 1,2,3... OR AA,BB,CC.... ETC
CELL/GRID SECONDARY NAME=THE OFFICIAL GRID NAME. USUALLY USED IN
REPORTING SEARCHED CELL/GRIDS TO ANOTHER SITE
NOT(POD)=THE PROBABILITY THAT A TARGET, WHICH IS PRESENT IN A GIVEN
GRID/CELL, WILL NOT BE FOUND
NOT(POT)=THE PROBABILITY THAT A TARGET WILL NOT BE PRESENT IN A GIVEN
GRID/CELL
FORMULAS USED: POS( )=POT( )*POD( ) :NOT(POD( ))=EXP(-COVF)
TPOS=1-TPOF :TPOF=SUM(POF( )) :POT( )=POF( )/TPOF
COVF=SUM(COVF( )) :POD( )=1-EXP(-COVF) :COVF( )=-LN(1-POD( ))
1=POD( )+NOT(POD( )) :1=POS( )+NOT(POS( )) :1=POT( )+NOT(POT( ))
"CELL POF"=NOT(POT( ))+POT( )*(NOT(POD( )))=NOT(POT( ))+POF( )