How can I perform optimization over a discrete set of possible values in MATLAB?

77 views (last 30 days)
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?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 4 Mar 2021
Edited: MathWorks Support Team on 4 Mar 2021
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.

More Answers (0)

Products


Release

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!