Problems with GA function (global optimization toolbox)

1 view (last 30 days)
I am trying to execute the global optimization toolbox function ga, but my FITNESSFUNCTION has another non-parameterized values. Specifically I want to call another function with multiple parameters inside the calling of ga function :
FITNESSFUNCTION = @(x1,x2,x3) mod_sol(x1, x2, x3, DSSCircuit, DSSText, canb(1), cand(1), i, s1);
[x_sol, f_sol] = ga(FITNESSFUNCTION,3, [], [], [], [],lb, ub, [], [], opts);
the parameters to be optmized are x1, x2 and x3, but I need doing some other calculus with the variables DSSCircuit, DSSText, canb(1), cand(1), i et s1 in order to evaluate the fitness function
  6 Comments
Jose Vivas
Jose Vivas on 28 Jan 2016
Edited: Jose Vivas on 28 Jan 2016
I Finally found the error, on the handler definition, it must be
FITNESSFUNCTION = @(x) mod_sol(x1, x2, x3, DSSCircuit, DSSText, canb(1), cand(1), i, s1);
instead
FITNESSFUNCTION = @(x1,x2,x3) mod_sol(x1, x2, x3, DSSCircuit, DSSText, canb(1), cand(1), i, s1);
thanks a lot to jgg and Walter Roberson by your suggestions
Walter Roberson
Walter Roberson on 28 Jan 2016
More likely you would need
FITNESSFUNCTION = @(x) mod_sol(x(1), x(2), x(3), DSSCircuit, DSSText, canb(1), cand(1), i, s1);

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!