I want to make a gear train out of lego gears that needs a specific gear ratio. So let’s say I want a gear train with a ratio of 45/28 or whatever, and I have gears with [8, 12, 16, 20, 24, 36, 40]
teeth. What combination will give me the specified ratio?
It seems like some sort of factorization or knapsack problem, but I’m not sure if there is any algo out there for this particular case.
I’ve defined all the gear ratios as follows
gears = [8, 12, 16, 20, 24, 36, 40]
gearratios = Set()
for g1 = gears
for g2 = gears
if g1 > g2
push!(gearratios, g1/g2)
end
end
end
And then I make an array of integers and have a cost function like
cost(x) = abs(prod(gearratios.^x)/ratio-1)
I was thinking, maybe just run some optimizer on it, but I’m not sure which kind would deal well with this type of problem. JuMP wasn’t happy wiith the exponent, and messing around with simulated annealing didn’t give any useful results so far. For that I was using a neighbor function that just increments/decrements a random number in x
.
Uh, ideas and suggestions welcome.