Using Multistart with constrainted fmincon
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Meikel Vollmers
el 25 de Mayo de 2021
Comentada: Meikel Vollmers
el 31 de Mayo de 2021
Hey,
i want to optimize a constrainted function using fmincon. To find the global optimum, i found out that the use of MultiStart is helpful. My function looks like this
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/629620/image.jpeg)
Here is my code for the use of fmincon
k = [5,7];
p = [1:4];
a = [pi/11, pi/7, pi/6, pi/3]; %Initial guesses
weights=(1./k.^4);
weights=weights/sum(weights);
fun = @(a) sqrt(sum( weights(:).*( 1 + 2*sum( (-1).^p.*cos(k(:).*a(p)) ,2) ).^2) );
A = [1, -1,0,0;0, 1, -1, 0; 0,0,1,-1]; % a1 < a2 < a3 ..
B = [0,0,0];
Aeq = [];
Beq = [];
lb = [0,0,0,0];
ub = [pi/4,pi/4,pi/4,pi/4];
function [c,ceq] = modindex(a,p) % saved as a seperate script
c = [];
ceq = 4/pi.*( 1 + 2*sum( (-1).^p.*cos(a(p)) ,2 ))-0.6;
end
nlcon = @(a) modindex(a,p); % this is a constraint, implemented as a function
x = fmincon(fun, a, A, B, Aeq, Beq, lb, ub,nlcon)
For the use of fmincon this code works, but now i want to run it with MultiStart. My question is how to respect all of my constraints?
My first try was this
problem = createOptimProblem('fmincon', 'objective', fun, 'x0', [pi/11, pi/7, pi/6, pi/3],'A', [1, -1,0,0;0, 1, -1, 0; 0,0,1,-1],...
'b',[0,0,0], 'Aeq', [], 'beq', [], 'lb', [0,0,0,0], 'ub', [pi/4,pi/4,pi/4,pi/4], 'nonlcon', @(a) modindex(a,p));
ms = MultiStart( 'UseParallel', 'allways', 'StartPointstoRun', 'bounds');
[x,f] = run(ms, problem, 10)
This doesnt work, "No field A exists for PROBLEM structure."
What does my code must look like, that all of the constraints are respected?
Kind regards
0 comentarios
Respuesta aceptada
Matt J
el 25 de Mayo de 2021
problem = createOptimProblem('fmincon', 'objective', fun, 'x0', [pi/11, pi/7, pi/6, pi/3],'Aineq', [1, -1,0,0;0, 1, -1, 0; 0,0,1,-1],...
'bineq',[0,0,0], 'Aeq', [], 'beq', [], 'lb', [0,0,0,0], 'ub', [pi/4,pi/4,pi/4,pi/4], 'nonlcon', @(a) modindex(a,p));
21 comentarios
Matt J
el 29 de Mayo de 2021
Editada: Matt J
el 29 de Mayo de 2021
We can prove mathematically that the smallest value m can have is about 0.527393087579050.
First, because the sequence of
are monotonic in [0,
],
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/635020/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/635025/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/635035/image.png)
Therefore,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/635040/image.png)
So, you cannot consider any m lower than this value.
Also, this is a tight lower bound, achieved for example by choosing
and all other
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/635045/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/635050/image.png)
Más respuestas (0)
Ver también
Categorías
Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!