Minimum Resistor Algorithm

I am trying to create a simple algorithm that takes a vector of standard resistor values ​​along with the input of the desired resistance value, and then goes through series and parallel combinations to figure out what is the minimum number of standard resistors the equivalent resistance requires to achieve this, with any combination of series and parallel resistors, whichever is the least.

Does anyone have any idea? If I only wanted parallel or serial, it would be much easier, but not sure how to combine the two for minimum total resistors.

FYI, if you don't know the common series R = S1 + S2 + ... + SN and Total parallel R = (1 / S1 + 1 / S2 + ... + 1 / SN) ^ - 1

+3


source to share


2 answers


Create an object to hold the resistance value plus the two resistances it came from, plus the operation used to get the value from the previous two values ​​(series or parallel).

Use some collection data structure like Set or ArrayList to store resistance objects. Your S1 kit initially only contains the resistors you have (1 resistor networks). Now create a set S2, which is all combinations (rows or parallel) of S1 with S1. S3 is a combination of S1 and S2. S4 is a combination of S1 and S3, and combinations of S2 and S2. Continue until you have a Sk member that is within the tolerance (1%, 5%, or 10%, say) of your target value. The resulting resistance object can be unwrapped one step at a time to find a way to create it.



Another thing you need to consider is how the tolerances are combined. Errors will spread, so you may need 1% resistors to start to reach the resistance you want, at the end up to 5% rejection, say.

+1


source


Perhaps a genetic algorithm would be best? I don't know the calculation for the big-O notation for this but it looks exponential: O (cⁿ).

I found this comment on another post site , this is the number of options that can be achieved with resistors of different values ​​(i.e. brute force):
Networks with 1 resistors: 1
Networks with 2 resistors: 2
Networks with 3 resistors: 10
Networks with 4 resistors: 68
Networks with 5 resistors: 558
Networks with 6 resistors: 5186
Networks with 7 resistors: 53805



A genetic algorithm would avoid brute force, perhaps allowing you to arrive at an answer much earlier. Unfortunately, it cannot guarantee responses with the minimum number of resistors. It will likely find close equivalent resistor values ​​at a much lower cost, and it can be weighed to support the fewest resistors.

I will keep researching this and post whatever I find.

+1


source







All Articles