Optimize the Max Min over two sets for the given function
이전 댓글 표시
Hello Guys,
I have two matricis
and
whose rows represents the extreme points and all the rows of
are also the rows of
i.e.,
, and
. I want to compute the square root of
.
I want to solve the following problem.
Since
is convex, and convexity is also preserved under minimization, so the function
which is attained at
. Thus, we can compute the square root of
I hope the question is clear.
Thanks!
댓글 수: 5
Rik
2018년 12월 19일
Wasn't this question previously closed for being unclear? Because it is still unclear to me what your question is. Editing the question in a non-meaningfull way just to trigger the reopen is useless, because you will still not get an answer.
I think you want a and b to be convex combinations of the rows of A and B, don't you ?
Otherwise simply use this code:
min_B = Inf*ones(m,1)
for i = 1:m
a = A(i,:);
for j = 1:k
b = B(k,:);
min_b(i) = min(min_B(i),norm(a-b)^2);
end
end
max_A = max(min_B);
max_A = sqrt(max_A)
Just use the code from above ; it will throw sqrt(max min ||a-b||^2):
m=3;
k=2;
A=[2, 3; 1, 4; 3,1];
B=[1,2; 2,4];
min_B = Inf*ones(m,1)
for i = 1:m
a = A(i,:);
for j = 1:k
b = B(k,:);
min_B(i) = min(min_B(i),norm(a-b)^2);
end
end
max_A = max(min_B);
max_A = sqrt(max_A)
Torsten
2019년 1월 2일
Code edited.
답변 (4개)
max: eps
s.c.
[norm(a_j - sum_{i=1}^{i=k} lambda_i*b_i,2)]^2 >= eps (j=1,...,m)
sum_{i=1}^{i=k} lambda_i = 1
lambda_i >=0
where the a_j are the row vectors of the matrix A and the b_j are the row vectors of the matrix B.
Use "fmincon" to solve for the lambda_i and eps.
Or use "fminimax".
Best wishes
Torsten.
Bruno Luong
2018년 12월 21일
편집: Bruno Luong
2018년 12월 21일
Not sure why this bla-bla about convex that makes your statement confusing. There is no continuous variable in the quantity f2 = max min | a-b |^2. It is straightforward calculation:
A=[2, 3; 1, 4; 3,1];
B=[1,2; 2,4];
n = size(A,2);
AA = reshape(A,[],1,n);
BB = reshape(B,1,[],n);
d2 = sum((AA-BB).^2,3);
f2 = max(min(d2,[],2),[],1)
댓글 수: 8
Torsten
2018년 12월 21일
From the problem formualtion I think that a and b are meant to be convex combinations of the row vectors, not the row vectors themselves. But maybe the result will come out the same - did not think about it in depth.
Bruno Luong
2018년 12월 21일
But maybe the result will come out the same - did not think about it in depth.
I'm sure both problems are different.
Sultan
2018년 12월 21일
Bruno Luong
2018년 12월 21일
This code is correct when using with lastest version of MATLAB. If you ask nicely than you did, then I might give you a work around for older MATLAB version (previous to R2016b).
Sultan
2018년 12월 21일
Bruno Luong
2018년 12월 21일
편집: Bruno Luong
2018년 12월 21일
A=[2, 3; 1, 4; 3,1];
B=[1,2; 2,4];
n = size(A,2);
AA = reshape(A,[],1,n);
BB = reshape(B,1,[],n);
d2 = sum(bsxfun(@minus,AA,BB).^2,3);
f2 = max(min(d2,[],2),[],1)
Bruno Luong
2018년 12월 23일
편집: Bruno Luong
2018년 12월 23일
This answer is not longer valid since Sutan has editted and modified his question.
Bruno Luong
2018년 12월 23일
편집: Bruno Luong
2019년 1월 15일
For ant row a_j, the inner equation
argmin_lambda || sum (lambda_i * b_i - a_j) ||^2
lambda >= 0
sum(lambda_i) = 1
can be solved using QUADPROG.
Then loop on j to find the max.
Example:
A = [1 2 4; 2 3 4; 1 2 3];
B = [1 2 4; 1 2 3];
[m,n] = size(A);
k = size(B,1);
H = B*B';
lb = zeros(1,k);
ub = inf(1,k);
f = nan(1,m);
lambda = nan(k,m);
Aeq = ones(1,k);
beq = 1;
C = -A*B';
for j=1:m
[x,fx] = quadprog(H, C(j,:), [], [], Aeq, beq, lb, ub);
lambda(:,j) = x;
f(j) = norm(B'*x - A(j,:)')^2; % == 2*fx + norm(A(j,:))^2
end
fmax = max(f)
댓글 수: 4
Image Analyst
2018년 12월 26일
Well he may be reluctant to since you edited your prior question which invalidated his answer (according to him). Would you promise not to do that again?
댓글 수: 6
Bruno Luong
2019년 1월 15일
See my edited post
Sultan
2019년 1월 16일
Bruno Luong
2019년 1월 16일
편집: Bruno Luong
2019년 1월 16일
" while the optimal value fmax by your code is 1.3339e-08"
Nope. My code give
fmax = 2
obained for j=2 and
>> lambda(:,2)
ans =
0.999926050006163
0.000073949993837
for inputs:
A = [1 2 4; 2 3 4; 1 2 3];
B = [1 2 4; 1 2 3];
I can't check your code since you only posted a pseudo-code.
Torsten
2019년 1월 16일
Not pseudocode, but CVX:
http://cvxr.com/cvx/
Bruno Luong
2019년 1월 16일
@Sultan: "I have optimal value 1.414213580747754"
I suspect that is the 2-norm value at the solution and not the square of the norm as defined in your question.
@Torten: Not pseudocode, but CVX:
Thanks
Sultan
2019년 1월 18일
카테고리
도움말 센터 및 File Exchange에서 Choose a Solver에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!