A bit late but seasons greetings...the blurb under the line Selection.for hopefully explains what I've been trying to do! This problem has no doubt been looked at by better folk than I and with much faster code! The code seems to run ok and gives the right answers but as the the no. of objects increases the time taken becomes crazy, mainly due to the numbers involved. If anyone has the time or inclination, could you make some suggestions how to speed this up please? The objects placed on a trolley are 1-D (length) at present, so my next escapade will be to do this in 2-D (length and width). I thought this might be tricky but it is turning out to be very tricky indeed!!
I'm using FTN95 (64-bit option) Vers. 8.8 Many thanks Notquitenewton
C C Program: Selection.FOR C C Program to make selection of a number of objects from a total C pile of objects and see if they will fit on a trolley! C To avoid taking too long, restrict the total number (n) to C ⇐ 30. At a first attempt try n = 10 to check it's ok. As n C increases, the number of calculations begins to escalate C rapidly. The idea is to generate objects of different lengths and C see which combinations will fit on a trolley of known length. C Not quite as simple as it first appeared! C The length of each object is stored in array length() and it's C reference is used as a pointer in array itempointer(). C The lengths of the items are generated randomly (or the same) C and will be between ilow and ihigh. The min. amount of trolley C is stored in imin. C The other two routines calculate the no. of permutations and C the combinations using factorials. C The routines are compiled using FTN95 with /WIN/64 and linked C using SLINK64 to make the 'selection.exe' file. C After a run, the results are stored in file Results001.txt which C should be in the same directory as the program. C
Link for full code is
https://www.pcmodfit.co.uk/Selection.for
Notquitenewton