필터 지우기
필터 지우기

2 unknown variable constraint optimization with single unknown variable objective function

조회 수: 1 (최근 30일)
hello, I am writting a code where objective function is depend on single unknown variable but constraint function is depend on 2 unknown veriables. The code look like
fun=@(a) C1.*a.^2 +C2.*a+C3;
x0=[1,1];
lb = [];
ub = [];
Aeq = [];
beq =[];
A = [];
b = [];
nonlcon =@constraintfcn;
opts = optimoptions('fmincon','Display','iter','Algorithm','sqp');
[x_value,fval] = fmincon( fun,x0,A,b,Aeq,beq,lb,ub,nonlcon,opts);
Also the constraint function can be written as
function [c,ceq] = constraintfcn(z)
a=z(1);b=z(2);
c = a^2 + b^2 - 1;
ceq = [];
end
But it gives the error lke"Nonlinear constraint function is undefined at initial point. Fmincon cannot continue." How I can resolve this problem?

채택된 답변

Matt J
Matt J 2020년 12월 23일
fun=@(z) C1.*z(1).^2 +C2.*z(1)+C3;

추가 답변 (1개)

Matt J
Matt J 2020년 12월 23일
편집: Matt J 2020년 12월 23일
The problem, as you've posted it, has an analytical solution, which can be obtained using
z=trustregprob(diag([2*C1,0]) , [-C2;0], 1)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by