Conversion to double from optim.problemdef.OptimizationExpression is not possible
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello
I have an optimization problem and I have a constraint function in it, but I get error ' Conversion to double from optim.problemdef.OptimizationExpression is not possible' in below code in line 16:
function constraints = constraintFcn_2(v)
global Q
t=0.1;
x1=[6 3 0]';
x2=[3 5 0]';
x3=[1 4 0]';
x4=[1 2 0]';
x5=[3 1 0]';
M=[x1';x2';x3';x4';x5'];
coeff1= pca(M);
direc1=coeff1(:,1);
K=[];
W = Q;
TT=W+v;
for i=1:length(TT)/3
K(i,1)=TT(3*i-2); %%%%%%%Error occurs in this line
K(i,2)=TT(3*i-1);
K(i,3)=TT(3*i);
end
coeffpca=pca(p_mds_pca);
direction=coeffpca(:,1);
%%%%%%%%%%%%%%%%%%55
constraints=norm(direction-direc1)<=t;
end
How can I fix it?
thank you.
댓글 수: 0
답변 (1개)
Walter Roberson
2023년 3월 25일
https://www.mathworks.com/help/optim/ug/fcn2optimexpr.html#mw_7959222a-434e-46eb-aec3-fe7942326891
I am not sure if you will need remove the inequality from the function; the example shows the comparison after the call
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!