Nonlinear optimization not working
Afficher commentaires plus anciens
Hi, I'm trying to solve the below:
min 25x+37y+48z
s.t.
z−0.25x∧2+0.1y∧2+0.01xy>=10,000
x,y,z>=200
y>=2z
So far, I have a function file:
function [c,ceq] = myfunction(x)
c(1) = z - 0.25*(x)^2 + 0.1*(y^2) + 0.01*x*y - 10000;
c(2) = x^2 - 200;
c(3) = y^2 - 200;
c(4) = z^2 - 200;
c(5) = y - 2*z;
ceq = [];
end
In the main file I have:
clc
clear
x=0;
y=0;
z=0;
fun = 25*x + 37*y + 48*z;
nonlcon=@myfunction;
x0 = [0,0,0];
A = []; % No other constraints
b = [];
Aeq = [];
beq = [];
lb = [];
ub = [];
fvalue = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)
I'm getting the below errors:
Error using optimfcnchk
FUN must be a function, a valid character vector expression, or an inline
function object.
Error in fmincon (line 430)
funfcn = optimfcnchk(FUN,'fmincon',length(varargin),funValCheck,flags.grad,flags.hess,false,Algorithm);
Error in HW6_4 (line 15)
fvalue = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,nonlcon)
Can anyone advise on how to resolve this?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Write Constraints dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!