Dear Professor,
I am a beginner of yalmip.
My problem is to minmize the objective with constraint that the neighboring variables are in correct order, so the 'sort' operator is used as following code. However, the solution information shows 'Infeasible problem'.
Could you please tell me the reason of error or give me some advices?
Thanks in advance.
Best regards
========================================
[MM,JJ]=size(Force);
Alpha=0.3;
lb=ones(MM,1)*min(Y(:,Cpts_idx));
ub=ones(MM,1)*max(Y(:,Cpts_idx));
P = sdpvar(MM,JJ);
F=[];
obj=0;
for i=1:MM
for j=1:JJ
Ec=0;
Eg=0;
Eall=0;
nbors=nbor_idx{i,j}'; % nbors is corresponded to the row index of neighboring points which are sorted in correct order
[~,loc]=sort(P(nbors,j));
F=[F,loc==nbors]; % the constraint is to ensure correct order of optimized values
F=[F,lb(i,j)<=P(i,j)<=ub(i,j)];
Ec==abs(P(i,j)-Y(i,Cpts_idx(j)));
Eg=-Force(i,j)*(P(i,j)-Y(i,Cpts_idx(j)));
Eall=Alpha*Ec+(1-Alpha)*Eg;
obj=obj+Eall;
end
end
sol = optimize(F,obj);