Find Minimum of all Possible Combinations for a Sequence of Length N
Nov 27, 2019 6:26 AM(480 views)
I am creating a script to optimize sequences of nominal chemistries by minimizing croppage (measured in feet). The "chemistries" are referred to by codes(ex: 1234AB, 5665SG) that contain four numbers and two letters.
What I want to do is look at all possible combinations of N codes for the length of the given sequence, choosing each code once, and minimizing the resulting croppage inbetween codes. Essentially, if i have N codes in a given sequence, there will be N-1 croppages (croppage in between each pair of codes, but not at the front or the back of the sequence). My example data set is for an 8 code sequence. I want to know the ordering (out of all 8! combinations of codes) that will give me the minimum amount of total croppage.
My current script pulls the applicable codes for the current sequence from a lookup table that contains all possible combinations (pairs) of codes in existence, and their respective croppage amounts. The resulting data table is attached for an example sequence with 8 codes.
Basically I want to minimize the sum of all the "(Sum_Crops)" that would exist in between each code for each permutation of the 8 codes.