Converged to an infeasible point. fmincon stopped because the size of the current step is less than the default value of the step size tolerance but constraints are not satisfied to within the default value of the constraint tolerance.

10 views (last 30 days)
N = 2; % Number of mass points
X0 = rand(1,N);
p0 = ones(1,N)/N;
x0 = [X0 p0];
n = 1;
lb = zeros(length(x0),1);
ub = ones(length(x0),1);
Aeq = [zeros(1,length(x0)); ones(1,length(x0))];
beq = [1 1];
% nonlcon = @unitdisk
[x_star,~,exitflg] = fmincon(@(x) myfunct12(x,n),x0,[],[],Aeq,beq,lb,ub);
while exitflg ~= 1
X0 = rand(1,N);
p0 = ones(1,N) / N;
x0 = [X0,p0];
[x_star,~,exitflg] = fmincon(@(x) myfunct12(x,n),x0,[],[],Aeq,beq,lb,ub);
end
% x = fmincon(@(x) myfunct12(x,n),x0,[],[],Aeq,beq,lb,ub)
% x
x_star;
myfunction is
function [z] = myfunct12(x,n)
y = 0:1:n;
p_y_x = zeros(n,n+1);
h_y_x = [];
for i=1:n
for k =1:length(y)
p_y_x(i,k) = nchoosek(n,y(k)).*(x(i).^y(k)).*(1-x(i).^(n-y(k)));
end
index = find(p_y_x(i,:));
p_y_x(i,index);
h_y_x = [h_y_x -p_y_x(i,index)*log(p_y_x(i,index))'];
end
sec_term = x(n+1:2*n)*h_y_x';
q_y = p_y_x(i,index).*x(n+1:2*n);
first_term = q_y*log(q_y)';
z = first_term + sec_term;
end

Accepted Answer

Matt J
Matt J on 5 Jul 2019
There are no feasible solutions to your problem because it is impossible to satisfy the first equality constraint,
zeros(1,length(x))*x(:)=1
The left hand side will always be zero for every x.
  7 Comments
Matt J
Matt J on 5 Jul 2019
No, I'm asking about your problem definition. You said, about the equations you posted a few comments ago, that your unknows were "x0", but I don't see any x0 in the equations.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!