Optimization of a matrix with integers with nonlinear objective functions and nonlinear constraints
5 views (last 30 days)
Show older comments
Hello all,
I have the following problem:
I want to optimize a matrix, which contains integer entries (e.g. A = [ 1 2 3 ; 2 1 1]), that the integers are arranged in the matrix. Each integer represents one area. I have linear and non-linear objective functions and boundary conditions.
My question now would be which algorithm would be useful. Intlinprog does not work in my opinion, because there are no non-linear objective functions or boundary conditions possible and fmincon does not work because you can not calculate any integer as x0. Do you have an idea which algorithm I can use in Matlab?
Thank you very much.
2 Comments
Dyuman Joshi
on 9 Sep 2023
"fmincon does not work because you can not calculate any integer as x0."
I am not sure what you mean by this. Could you elaborate more?
Answers (1)
John D'Errico
on 9 Sep 2023
Edited: John D'Errico
on 9 Sep 2023
You are correct, in that fmincon does not provide integer constraints as an option, and that a tool like intlinprog does not allow nonlinear constraints.
This class of problem will typically fall into the domain of tools from the Global Optimization toolbox, mainly GA. (I cannot recall if any other of those tools allow integer constraints. I checked once, and there were no other options at that time, except for GA.) GA can accept integer constraints on the variables, but also nonlinear constraints on them.
5 Comments
John D'Errico
on 9 Sep 2023
Edited: John D'Errico
on 9 Sep 2023
Yes, by GA, I meant the function named GA, which is a genetic algorithm.
You did not say which kind of nonlinear constraints. What you should understand is that nonlinear EQUALITY constraints where integers are concerned, are rather difficult to deal with.
For example, suppose your problem was to solve for some variables x and y (for a fixed value of n), such that
x^2 - n*y^2 == 1
This is a variation of Pell equation.
And depending on the value of n, just finding any feasible points can be not at all trivial to identify. It makes the problem MUCH more difficult. And so, if you have integer variables, then you cannot also have nonlinear EQUALITY constraints. You will find that to be a common issue.
And, yes, you might wonder why that is a problem at all. But my point is, for such a solver to work, it first needs to find valid points to evaluate the function at. And, if the problem was as I described, where the only valid feasible points are the solutions of a Pell equation, that makes it a very difficult problem. Sorry.
Can a matrix be used as input? Well, GA does not take starting values, as it is not that class of solver that needs them. But even if you could only get a solution in the form of a vector, then you could still trivially just reshape the vector into a matrix of your desired size and shape.
help ga
So the fitness function is presumed to be a VECTOR, of length 1xnvars. But nothing stops you from reshaping that vector inside your objective function, and after it is returned from GA.
And, yes, surrogateopt does also allow integer constraints. However, it is designed a little differently, in that it has a target of problems with time-consuming functions. So if your function is not costly to evaluate, you may fund that GA does a little better at truly finding the global optimizer. I don't have any experience with surrogateopt, so I cannot know for sure. You might be well off to test your problem on both optimizers. I'd start with GA, unless your function is a costly one to evaluate.
help surrogateopt
Walter Roberson
on 9 Sep 2023
ga accepts an options structure that supports an 'InitialPopulationMatrix' -- so it can take starting values (just not conveniently)
The nonlinear equality A == B can be coded as the pair of nonlinear inequalities [A - B, B - A] which corresponds to A <= B & B <= A which is only true for A == B . You can do this -- but it will probably still have a lot of trouble finding matching points.
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!