Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6012 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Question for those who paid more attention in math class than I did.

I have a list of cities (80), and need to determine mileages between each possible pair.

My "Combination" function gives me the number I'll be dealing with, but no list of the combination coefficients. Any help would be much appreciated.

Thanks in advance.

Randy

Posted

What is a "list of the combination coefficients"? AFAIK, the Combination() function *is* the (binomial) coefficient.

Do you mean you want to enumerate the individual combinations?

Posted

The Combination() function returns how many combinations there are, not what those combinations are. (I think you've stated that already, but I'm making it explicit.)

The question you've asked (how to get a list of combinations) might not really solve your problem. Getting a list of city pairs won't work out how far apart they are, though it may be a step in the process.

If all you need is a way to work out the distances, why not use the web viewer to plug into a distance calculating web site, and let them do the heavy lifting. Check whether the distances returned are "by road" or "by air" because they can be very, very different.

If all you want are by-air distances, then a table of cities and their lat/long coordinates can be used (you may need to generate the table of coordinates yourself from data scraped from the net). However for short distances, like between suburbs in a city, these by-air distances can be misleading (eg, two places on opposite sides of a very long lake are close by air or boat, but quite far by road).

Anyway, one way to generate lists of combinations is through brute force creation of records in a table, looping through the options. The scripting is pretty straight forward, if tedious and time consuming. Then remove the equivalent pairs (AB = BA ) if you want combinations and not permutations.

In pseudo code, the script to generate the permutations for 2 pairs would be:

$cityList =

$countCity1 = 1

$countCity2 = 1

Loop

$city1 = GetValue( $cityList ; $countCity1 )

$city2 = GetValue( $cityList ; $countCity2 )

New Record

Set Field City1 = $city1

Set Field City2 = $city1

Commit Record Request

Exit Loop If [ $countCity2 = ValueCount( $cityList ) ]

$countCity2 = $countCity2 + 1

End Loop

Exit Loop If [ $countCity1 = ValueCount( $cityList ) ]

$countCity1 = $countCity1 + 1

End Loop

From this list of city pairs you''ll then have to look up the distances and type them in. All 80x80 of them (though some like AA and BB will be equal to zero, and about half will be equivalent pairs like AB and BA). AFAIK there is no way to do this automatically.

Posted

Hmmm...

Thanks very much. I'll give it a whirl. We're going to feed the city pairs from the Data generated in PC Miler. From here, I think your suggestion will do the trick.

Thanks again.

R

Posted

It's not that difficult to generate only the required records:


Set Variable [ $list;  ] 

# 

# OUTER LOOP 

Loop 

Set Variable [ $i; $i + 1 ] 

Set Variable [ $j; $i ] 

Exit Loop If [ $j > ValueCount ( $list ) ] 

# 

# INNER LOOP 

Loop 

Set Variable [ $j; $j + 1 ] 

Exit Loop If [ $j > ValueCount ( $list ) ] 

New Record

Set Field [ Origin; GetValue ( $list ; $i ) ]

Set Field [ Destination; GetValue ( $list ; $j ) ]

Commit Records []

End Loop 

# 

End Loop 

This topic is 6012 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.