Nonlinear optimization not working
이전 댓글 표시
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?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Write Constraints에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!