The Traveler
Minimize your travel mileage and costs
by Ron Schaefer, M. D.
So you're finally getting a chance to take that big trip to Europe! Ride a gondola through the canals of Venice, spend an afternoon strolling through the Louvre. But before you start packing, start planning.Get out your maps, switch on your ST and let the START Traveler help you make sure everything goes smoothly.
Start planning your vacation right! File TRAVELER.ARC on your START disk.
In the November 1987 issue of Antic, Dr. Jeffrey Summers published "Your Best Route," an award-winning program for the 8-bit Atari. This program was so popular that START asked me to write a version for the ST. The Traveler is on your START disk, and the ST's superior graphics make it much more colorful than the original 8-bit version. Best of all, if you own Maps & Legends you can create overlay files of your trips and see how feasible your route really looks--no matter where in the world you are traveling!
The main function of the Traveler is to analyze the distances between a list of places, and to figure out the fastest way to travel between them. For example, suppose your family is planning a tour of Europe. Say, you land in any major city, and want to rent a car to visit Paris, Rome, Munich, Madrid and Amsterdam. The Traveler will show you the shortest route, so you can spend your vacation time wisely--and get the most out of your trip.
The key function of the Traveler is to economize, no matter how far apart the locations or whether the distances between them are measured in mileage, city blocks or air fare. In fact, you can use the Traveler to solve problems you wouldn't even think of. The owner of a fresh fish delivery business could find out how to get the fish to ten markets around town before they spoil--using the minimum of mileage, cost and time. A student planning an interview trip for medical school could find the cheapest combination of flights to visit seven cities in ten days. The flexibility of this program will amaze you.
The Traveler, a new ST version of an old 8- bit favorite, will show you the shortest route for your summer--or anytime--travels. |
TRIP THE LIGHT FANTASTIC
The Traveler is on your START Disk in the archive file TRAVELER.ARC. Copy this file and the program ARCX.TTP to a fresh disk. Double-click on ARCX.TTP, and in the box that comes on the screen, type the filename TRAVELER.ARC and press the Return key. The disk will spin for a minute or so, and when it's finished you'll find the Traveler program and data files on the disk. The Traveler will run in medium or high resolution and was written and compiled with GFA BASIC. The Traveler uses some DEGAS format pictures that were generated by Maps & Legends. The pictures must be in the same directory as TRAVELER.PRG. In addition, two sample data files--TRAVEL.LAT and TRAVEL.MAP are included on your START disk.
To run the program, simply double-click on the TRAVELER.PRG icon. To get an idea of how the program works, load the file TRAVEL.MAP by clicking on Load Data under the DATA menu. Next, click on Plan Trip under the Options menu.
Type in the number corresponding to the place you would like to start your trip; enter 0 if it does not matter where you start. Next, enter the number of the place where you would like to end your trip; again, enter 0 if it does not matter where you finish. Now enter the numbers of the places you wish to visit. You can enter up to twenty places, but be prepared to leave your ST on overnight if you do. Five or six places will take only a few minutes.
Once the program has checked every possible permutation on visiting the selected places, it will print out the minimum total mileage and the path that you should take If you are traveling between continental U.S. cities, a dialog box will ask you if you would like to see this data plotted out on a map of the continental United States. Finally, a dialog box will ask you if you want to generate an overlay file that can be read by the program Maps & Legends. If you do, click on Yes and then type in a filename using the extender .TXT. Refer to the Maps & Legends documentation on how to compile this text file into an overlay file.
CREATING DATA FILES
There are two ways you can generate mileage charts. The first is to enter the mileages between cities manually; the second is to have the computer figure out the mileages from the latitude and longitude of the locations. You can create data files by editing them with a word processor or text editor and saving them in ASCII format. If you do this, the first line in the file must contain the number of locations; there can be a maximum of 40 places in each file. Subsequent lines contain the information for the locations. First in each line is the name of the place, which must be eight characters in length or less. Following each place name is the latitude in degrees and minutes and the longitude in degrees and minutes. (Note: Indicate Iongitude values east of the Prime Meridian and latitude values south of the equator by using negative numbers.) Each number is separated by a comma.
If you wish to have the computer figure out the mileage, save the file with the extender.LAT and load it into Traveler by clicking on Load Lat/Lon under the DATA menu. When a Lat/Lon file is read into memory the program calculates the distance between all of the different places using a great circle route which follows the curve of the earth. Keep in mind that the distances the computer gives will be less than the actual mileage it will take you to drive since roads tend to zig and zag a bit.
If you wish to enter the mileage, separate the number of miles from the longitude with a comma. These numbers can be obtained from driving road atlases; alternately, they can be air fare or bus fare. If a dollar amount is used rather than a mileage then the trip will be optimized in terms of money instead of miles. (If you are entering the mileage manually, it is not very important that you enter the correct latitude and longitude; if you don't know these numbers, enter zeros instead. In fact, the only reason you would need these coordinates is if you wish to see your route on a map of the United States or create an overlay file for Maps & Legends.) Save the data file with the extender .MAP and load it into Traveler by clicking on Load Data under the DATA menu.
Summer trip from San Francisco to New York via Reno, Salt Lake, Denver and Chic- ago. The Traveler planned the route; Maps and Legends makes it easy to put it on a col- orful map of the U.S. |
CREATING A DATA TABLE
If you prefer, you can create a data table from inside the program. Click on Create Data under the DATA menu. Click on the second-from-the-top slot on the left hand column. At the bottom of the screen you will be prompted for the place name; remember that this should be eight characters or less. Now you will be prompted for the latitude and longitude in degrees and minutes. As places are entered the matrix will be filled with zeros. To have the computer figure out the mileage, exit the editor by clicking the right mouse button and save this file using the Save Data option. Use the extender .LAT. Now reload the file using the Load Lat/Lon option and the program will fill the matrix with the distances between the places.
To manually edit the number of miles between two places, click on the point intersected by those places and, at the prompt, enter the mileage. At the bottom right of the screen is a series of boxes with arrows and a size box. If you click on one of the arrows the data matrix is shifted one field in that direction. If you click on the middle box the matrix will shift back and forth from the beginning to the end of the data matrix. To speed data entry there is an inverse option at the bottom right of the screen. When Inverse is ON the program will automatically enter the inverse or reciprocal of the mileage you enter. For instance, the distance from Miami to New York is usually the same as the distance from New York to Miami. This option can be turned off by clicking on the light text OFF and turned on again by clicking on the text ON. Save the mileage file with the Save Data option under the DATA menu using the extender .MAP.
AROUND THE WORLD
You can use the Traveler to directly calculate the distance between two points. Simply click on Calculate under the OPTIONS menu and enter the latitudes and longitudes of the two points in degrees and minutes. This routine uses a series of trigonometric equations to calculate the great circle route, the shortest possible distance between any two places on earth.
HOW IT WORKS
The Traveler uses a brute force method to find the shortest route; all possible combinations are checked and the minimum number is found. For instance if you entered the three places A, B and C there are six possibilities: ABC, ACB, BAC, BCA, CAB and CBA. The number of possibilities is equal to the factorial of the number of places. For three places it is 3 factorial (or 3 x 2 x 1 = 6). Factorials grow pretty fast, so when you select lots of places to visit it can take the computer quite some time to figure it out. For instance for 20 different places more than 2,400,000,000,000,000,000 different routes are computed. If you wish to study the source code, you can read it into GFA BASIC by clicking on Merge and then the filename TRAVELER.LST.
Alternately, double-click on TRAVELER.LST from the desktop to either show the file on the screen or print it out.
WORLD TRAVELER
With the Traveler, you'll soon be finding the best ways to use your vacation money and time. You might even find you can squeeze one more city into your itinerary. After all, when you've got a computer, who needs AAA?
Dr. Ron Schaefer's work has appeared in the ST Resource section of Antic. He is also the author of the ST programs Code-Blue and Diet.
PRODUCTS MENTIONED
Maps & Legends--The Cartographer, $34.95, The Catalog, 544 Second St., San Francisco, CA 94107, (800) 234-701.