optimization toolbox with fmincon

3 views (last 30 days)
Asshaa on 30 Jun 2022
Edited: John D'Errico on 30 Jun 2022
i have a function
f= @(x,y,z) -5-2.*x+4.*x.^3+4.*(1-x.^2).*y+8.*(1-x.^2).*x.*y-12.*(1-x.^2).*x.*y.^2+12.*(1-x.^2).*(1-(abs(y).^2)).*z
with only constraint boundary
lb = [-1 -1 -1]
ub = [1 1 1]
i used fmincon to obtain the minimum f.
[bestxyz, fval] = fmincon(f,xyz0, A, b, Aeq, beq, lb, ub, nonlcon)
The optimization fmincon result in mininum f with the value of x,y,z in real number, but the function f has value of y in complex number through analytical solution. Is it the toolbox is limited to the real root or it can be modified to have the solution with imaginary root?
  1 Comment
John D'Errico
John D'Errico on 30 Jun 2022
Edited: John D'Errico on 30 Jun 2022
A search for a minimum is equivalent to a search for the roots of the derivatives of that function. So you can think of this as three nonlinear equations in three unknowns. And that is then equivalent to a higher order polynomial in one variable. So there certainly would be complex roots of the gradient equations.
The problem is, fmincon will not generate a complex valued solution. There are tricks you can do, but there is one glaring problem. What is it?
You place lower and upper bounds on the unknowns. bound constraints make no sense here, IF you wanted to allow complex solutions, since you have placed no constraints on the imaginary part.

Sign in to comment.

Answers (1)

Torsten on 30 Jun 2022
If you want to admit x,y and z to be complex-valued, you also have to change your objective function to be real-valued for complex inputs of the variables (e.g. abs(f) or f*f' or real(f) or imag(f)). What's your choice ?
Here is one example:
f = @(x1,x2,y1,y2,z1,z2) -5-2.*(x1+1i*x2)+4.*(x1+1i*x2).^3+4.*(1-(x1+1i*x2).^2).*(y1+1i*y2)+8.*(1-(x1+1i*x2).^2).*(x1+1i*x2).*(y1+1i*y2)-12.*(1-(x1+1i*x2).^2).*(x1+1i*x2).*(y1+1i*y2).^2+12.*(1-(x1+1i*x2).^2).*(1-(abs((y1+1i*y2)).^2)).*(z1+1i*z2);
g = @(x1,x2,y1,y2,z1,z2) f(x1,x2,y1,y2,z1,z2)*f(x1,x2,y1,y2,z1,z2)';
lb = [-1 -1 -1 -1 -1 -1];
ub = [1 1 1 1 1 1];
xyz0 = zeros(6,1);
[bestxyz, fval] = fmincon(@(x)g(x(1),x(2),x(3),x(4),x(5),x(6)),xyz0, [],[],[],[], lb, ub)
Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
bestxyz = 6×1
0.0177 -0.0579 0.1697 -0.0297 0.3719 0.0046
fval = 2.2575e-14

Community Treasure Hunt

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

Start Hunting!

Translated by