After I successfully run the fmincon Optimization tool on my objective function, I generate code. When I try to run the computer generated code it does not run. Gives error message.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
My objective Function is V=Pvariance(A,B,C,W)
After I successfully run the fmincon Optimization tool on my objective function, I generate code. When I try to run the computer generated code it does not run. Gives error message.
The computer generated code is:
function [x,fval,exitflag,output,lambda,grad,hessian] = minPvariance3(x0,Aeq,beq,lb)
%%This is an auto generated MATLAB file from Optimization Tool.
%%Start with the default options
options = optimoptions('fmincon');
%%Modify options setting
options = optimoptions(options,'Display', 'off');
options = optimoptions(options,'Algorithm', 'active-set');
[x,fval,exitflag,output,lambda,grad,hessian] = ...
fmincon(@(W)Pvariance(A,B,C,W),x0,[],[],Aeq,beq,lb,[],[],options);
Notice that the variables A,B,C are missing from the first line.
When I run this code I get the following error message even though the Variables A,B,C are in the workspace.
Undefined function or variable 'A'.
Error in minPvariance3/@(W)Pvariance(A,B,C,W)
Error in fmincon (line 635)
initVals.f = feval(funfcn{3},X,varargin{:});
Error in minPvariance3 (line 9)
[x,fval,exitflag,output,lambda,grad,hessian] = ...
Caused by:
Failure in initial user-supplied objective function evaluation. FMINCON cannot
continue.
Please help me solve this problem. Thanks
2 comentarios
Matt J
el 12 de Mayo de 2013
It sounds like you already know what the problem is. You said yourself that A,B,C are missing. Isn't the obvious solution to supply them?
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!