Classic Computer Magazine Archive ANTIC VOL. 6, NO. 7 / NOVEMBER 1987

FEATURES

Your Best Route

Trip Planner saves $$$

by JEFFREY SUMMERS, M.D.

screen shot

Your Best Route helps you cut down travel expenses by finding the shortest distance among a cluster of destinations. This BASIC program works on Atari 8-bit computers with minimum 48K memory and disk drive.

ABC Delivery Service has a regular route involving 10 stores and businesses around town. There is a morning pickup, then the parcels are sorted, and an afternoon delivery is planned for those customers that have packages. With gasoline prices increasing again, they want their drivers to use the shortest possible routes - which may change daily as different businesses receive packages from the service.

Map

John and Mary Smith of Honolulu are planning a trip to the mainland. They want to see the Grand Canyon, Yellowstone National Park, the Grand Tetons, the Air Force Academy, San Fran cisco and Disneyland. Flights could land them near any of these locations, and then they will rent a car that charges by mileage. Where should they land and what route should they take to minimize expenses?

J.Q. Publique, with his Official Airline Guide confidently in hand, figures he can get anywhere in the country in a day, but he has trouble figuring out the least expensive route when he has to go to five different cities in five days, the order of which doesn't matter.

Your Best Route effortlessly solves a wide range of route-planning problems. Type in Listing 1, TRAVEL.BAS, check it with TYPO II and SAVE a copy before you RUN it.

When you first RUN the program, use option [1] to create a new table/map. In the following example, we'll make up a small table using only four locations. Up to 20 locations are allowed. Antic Disk Owners will find a larger map file covering major cities in the Western U.S., WEST.MAP, on this months disk.

MAKE A TABLE

Each location name can have only eight characters, so type Buffilo, Cleve, Pitts and Columbus.

Now you'll see the first three columns of your table. The cursor is in the upper right-hand corner, almost like a spreadsheet. The locations appear along the side of the table and across the top. Move around the grid with the [ARROW] keys, filling in distances as you go. Once you start in a direction, you can either press [RETURN] to continue in that direction or another [ARROW] key to change direction. The table shows three columns at a time.

Now move to the first row (Buffalo), second column (Cleveland) and start entering distances until your table looks like this:

		Buffalo	Cleve	Pitts	Columbus
Buffilo		0	240	300	360
Cleve		240	0	240	120
Pitts		300	240	0	150
Columbus	360	120	150	0

The R ON in inverse video at the upper right-hand corner of the screen means that the “reciprocal” function is on. Entries for distances in one direction are entered automatically into the opposite direction. Naturally, the distance between Buffalo and Cleveland is the same as the distance between Cleveland and Buffalo. Press [R] to turn off the reciprocal function. You can toggle this as much as you like while entering or editing a table

After you're satisfied with the table, press [E] or [ESCAPE] to go back to the main menu. Now save the table with option [2]. Use the format D:FILENAME.EXT. Here, enter “D:EXAMPLE.MAP”. If you need a directory for drive 1 before saving the table, press [RETURN] at the filename prompt. If there’s an error, the screen turns red. The same procedure is used for loading a table with option [3].

ROUTE CALC

NOW, starting in Buffalo, what’s the shortest route for going to all the cities and returning to Buffalo? Option [5] plans the trip. The locations are listed and numbered. If the starting location could be any of the locations, as in the case of the Hawaiian travellers, press [0] at the prompt. In our example, we would type [1], then [RETURN].

You are then prompted for the final location. Again, if it doesn't matter where you end up, enter [0]; otherwise, enter the number of the final location. If you want the ending location to be the same as the starting point, type [RETURN] at the ending location prompt.

The program now asks for the numbers of the locations you want to visit, followed by [RETURN]. When you've entered all locations, press [0], then [RETURN], to tell the program you're done. The screen turns yellow (“I'm thinking. . .“) and the starting location is displayed.

The time needed to find the shortest path depends on the number of locations being examined. If you have six locations including a set start and finish, you'll see results fairly quickly. If you choose nine locations, go for coffee.

Built into the program, however, is another way to speed things up by 15% to 30%. Press the [SPACEBAR]. In a moment the screen will turn black and the computer can devote more power to running the program at top speed. You can turn the screen back on by repeating the process, but it's unnecessary. The program turns the screen back on after it has found the shortest path. If at any time you find an error in your table, you can edit the table with option [4], which puts you back into the “spreadsheet” mode used to enter the table.

So how does this help J.Q. Publique, who didn't care about distances, only about the fares (which seem to have little relationship to distance these days)? If you guessed that the program does not actually have to work with distances, but is just as good with dollar amounts (or any other numerical units you need to work with), give yourself a gold star.

Jeffrey Summers is a practicing internist in Rochester, NY. He teaches a BASIC class for the ACORN users group. Dr. Summers is the author of Decide (ANTIC, June 1986).

Listing 1 TRAVEL.BAS Download
On disk WEST.MAP Download