On 1/27/2016 10:24 AM, Devraj Dutt wrote:
> I use genetic algorithm based optimization to run a software in the loop
> simulation for an electromagnetic simulation of an electric motor with
> the following command
>
> [x,fval,exitflag,output] = ga(@vbrunner,5,[],[],[],[],lb,ub,[],options);
>
> I wanted to include some non linear constraints in the ga directly using
> [x,fval,exitflag,output] =
> ga(@vbrunner,5,[],[],[],[],lb,ub,nonlcon,options);
>
> with the nonlcon function header as
> function [c,ceq] = nonlcon(x)
>
> but when I run this and set a breakpoint within nonlcon, I find no
> variable called x implying that nothing was passed to the function by
> ga. Does anyone know what is going on?
Perhaps you should use
[x,fval,exitflag,output] =
ga(@vbrunner,5,[],[],[],[],lb,ub,@nonlcon,options);
Note the @ symbol before nonlcon.
Alan Weiss
MATLAB mathematical toolbox documentation
> I use genetic algorithm based optimization to run a software in the loop
> simulation for an electromagnetic simulation of an electric motor with
> the following command
>
> [x,fval,exitflag,output] = ga(@vbrunner,5,[],[],[],[],lb,ub,[],options);
>
> I wanted to include some non linear constraints in the ga directly using
> [x,fval,exitflag,output] =
> ga(@vbrunner,5,[],[],[],[],lb,ub,nonlcon,options);
>
> with the nonlcon function header as
> function [c,ceq] = nonlcon(x)
>
> but when I run this and set a breakpoint within nonlcon, I find no
> variable called x implying that nothing was passed to the function by
> ga. Does anyone know what is going on?
Perhaps you should use
[x,fval,exitflag,output] =
ga(@vbrunner,5,[],[],[],[],lb,ub,@nonlcon,options);
Note the @ symbol before nonlcon.
Alan Weiss
MATLAB mathematical toolbox documentation