필터 지우기
필터 지우기

Code verification for multiple nonlinear constraints

조회 수: 2 (최근 30일)
Oladunjoye
Oladunjoye 2014년 3월 27일
편집: Oladunjoye 2014년 3월 27일
Hi everyone,
I am using fmincon and I have a couple of nonlinear equality constraints. I wish to know which of the codes below is correct for the constraint.
function [c,ceq] = const(x)
c = [];
ceq(1) = x(1)'*x(1) + x(2)'*x(2) + x(3)'*x(3)+ x(4)'*x(4) + x(5)'*x(5) ...
+x(6)'*x(6) - 1;
ceq(2) = x(7)'*x(7) + x(8)'*x(8) + x(9)'*x(9)+ x(8)'*x(10) + ...
x(11)'*x(11) +x(12)'*x(12) - 1;
end
OR
function [c,ceq] = const(x)
c = [];
f1 = x(1)'*x(1) + x(2)'*x(2) + x(3)'*x(3)+ x(4)'*x(4) + x(5)'*x(5) ...
+x(6)'*x(6) - 1;
f2 = x(7)'*x(7) + x(8)'*x(8) + x(9)'*x(9)+ x(10)*x(10) + x('11)*x(11) ...
+x(12)'*x(12) - 1;
ceq = [f1,f2];
end
Which of the above codes is the correct way to write the constraints?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver-Based Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by