Asked by MathWorks Support Team
on 7 Apr 2017

I would like to run an optimization to determine the best resistors for my circuit. Currently I am setting upper and lower bounds of the possible resistor values, solving the optimization in a continuous manner using "fmincon", and then mapping the solution to the nearest resistor value I have in stock. For example, the possible values may be something like: {15.5, 20, 27.2, 31.1, 33}.

Is there a way in MATLAB to solve this optimization problem directly considering the possible values, instead of solving the continuous problem and then picking the closest value?

Answer by MathWorks Support Team
on 21 Aug 2019

Accepted Answer

One way to approach this problem is to treat it like an optimization with Integer Constraints, where you actually solve for an *index_ _*within the set possible solutions.

There are two primary optimization methods in MATLAB which support integer constraints: the Genetic Algorithm, and Linear Programming, although Linear Programming may not be a good fit for some problems. Even if you could implement an integer constraint on a function like "fmincon", the underlying algorithm would still search on a continuous space which does not make sense and is not efficient given the problem statement.

If the discrete solution space is small enough, you may even consider a direct search of all options, as opposed to some iterative optimization method. This approach may not be feasible if you have for example 40 possible resistor values and you are looking to solve for a vector of 8 resistor values. In such a situation, you end up with a search space of size 40^8 which is quite a few solutions to consider.

There is an example in the documentation which is quite similar to the described problem, and in this case the Genetic Algorithm is used with Discrete Non-Integer Constraints:

In this example, you can use the Genetic Algorithm to solve for an index, (i.e. 3) which then corresponds to some resistor value (i.e. 27.2). Given the inclusion of Integer Constraints, you will always find an exact index corresponding to one available resistor values, successfully implementing Discrete Non-Integer Variable Constraints on the optimization problem.

Answer by Jeff Rothermel
on 18 Oct 2019 at 0:26

Seems to be an example now matching this question:

"This example shows how to choose the resistors and thermistors in a circuit to best match a specified curve at one point in the circuit. You must choose all of the electronic components from a list of available components, which means this is a discrete optimization problem."

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.