Global minimisation of multivariable constrained function with mixed integers
Show older comments
Hello, I was minimising a function with 2 variables and non-linear constraints with fmincon because it does exactly what I need, and it worked perfectly. Then, I introduced 2 additional variables and changed the constraints accordingly and still worked. The issue I am facing is that, while the first 2 variables could be any number (integer or decimal), the last 2 can only have a certain value: x(3) can only be [4,6,8,10] while x(4) [6:1:30] (for a total of 100 combinations), and fmincon obviusly returns decimal numbers.
I cannot round the results because I need the right combination of all 4 variables. I also know that ga() can work with integers limitations, however ga() doesn't minimise the function, but the variables. How could I model the problem?
Many thanks
5 Comments
Lorenzo Manni
on 1 Sep 2021
Walter Roberson
on 1 Sep 2021
You are mistaken. ga() and patternsearch() minimize the function value, not the variables. But as usual, global minimizers typically cannot guarantee that the global minima will be found (there are some kinds of functions for which it is possible to prove that ga() will find the global minima given enough time. Quadratic functions, or something similar to that.)
Lorenzo Manni
on 1 Sep 2021
Walter Roberson
on 1 Sep 2021
There are some classes of functions for which it is possible to guaranteed that a minima can be found, but if you have non-linear constraints, then chances are that your function is not one of those varieties.
Answers (1)
Matt J
on 1 Sep 2021
0 votes
Since there are only 100 combinations, I would just run fmincon 100 times.
4 Comments
Lorenzo Manni
on 1 Sep 2021
Matt J
on 1 Sep 2021
Yes.
Lorenzo Manni
on 1 Sep 2021
No, with a loop around the call to fmincon,
for i=1:100
fun=@(x)objectiveFunction( [x,p1(i),p2(i)] );
[X(i,:),fval(i)]=fmincon(fun,x0,________)
end
imin=min(fval);
x=[X(imin,:),p1(imin),p2(imin)];
Categories
Find more on Write Constraints 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!