How can I optimize complex functions within the Genetic Algorithm and Direct Search Toolbox?

A function of a complex variable "z" is called a complex function "f(z)". I have a complex function in the form:
f(z) = z^2 - z + 1
and I would like to determine the optimal complex value of this complex function.

 Accepted Answer

This bug has been fixed for Release 14 (R14). For previous releases, read below for any possible workarounds:
In general, complex functions "f(z)" evaluate to a complex value. In this situation, you must define a measure of optimality of these complex results that evaluate to a real value (e.g., "|f(z)|").
The real and imaginary parts must be considered separate variables within the objective function. Therefore, the input argument to the objective function will be a 1-by-2 vector including the real and imaginary part. For this example, the objective function is in the form:
function f = objfun(X)
% Create complex value from real and imaginary parts:
z = X(:, 1) + i*X(:, 2);
f = z.^2 - z + 1; % Evaluate complex function
f = abs(f); %Generate optimality measure
Then, using the initial guess "z = 1 + 2i", the function can be optimized by the following command:
[z f] = ga(@objfun, 2)
which produces the results:
z =
0.5000 0.8661
f =
6.2523e-005
Therefore, the complex value that produces a local minimum of "abs(f(z))" is found to be:
z = 0.5 + i*0.8661
Note that this method is the same for the PATTERNSEARCH function, except a 1-by-2 initial guess must be specified in the second input argument.
For information on how to optimize complex functions using the Optimization Toolbox, see the Related Solution.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!