How to formalize an optimization problem in Matlab?
1 次查看(过去 30 天)
显示 更早的评论
reincornator
2022-5-3
Hello.
How to issue a task in Matlab?
Given:
Vectors a1 and a2.
Find a vector of coefficients x such that:
abs((a2.')*x) -> min
abs ((a1.')*x) >= condition
under the conditions:
- Dimensions of vectors a1, a2 and x from 1 to p
- elements a1, a2 and x are complex numbers
- abs(a1_i)>0, abs(a2_i)>0, abs(x_i) = 1, where i =1..p
15 个评论
Torsten
2022-5-3
So you want to maximize abs(a1.'*x). And you want to minimize abs(a2.'*x).
How do you want to combine these two objectives in one ?
reincornator
2022-5-4
It is necessary to find a vector x such that:
abs ((a1.')*x) -> max - goal
abs((a2.')*x) < tol, wheh tol->0 - limitations
Matt J
2022-5-4
编辑:Matt J
2022-5-4
abs(x_i) = 1, where i =1..p
Are you sure it's not abs(x_i) <= 1 or sum(abs(xi).^2)=1? It would be hard to satisfy the constraint as posted.
For example, if a2=[1;0;0;0] it would be impossible to satisfy abs(a2.'*x)-->0, because abs(a2.'*x)=abs(x1) and abs(x1) is constrained to 1.
reincornator
2022-5-4
Torsten, thanks. The "fmincon" function only works with real numbers. I use complex numbers.
reincornator
2022-5-4
编辑:reincornator
2022-5-5
Matt J, thanks. You are right, there is another constraint: abs(a1_i)>0, abs(a2_i)>0, i=1..p.
Torsten
2022-5-4
With each optimization software you use, you will have to split in real and imaginary part and thus handle two real-valued numbers simultaneously.
Matt J
2022-5-4
编辑:Matt J
2022-5-4
You are right, there is another constraint: abs(a1_i)>0, abs(a1_i)>0, i=1..p.
I assume you meant abs(a1_i)>0, abs(a2_i)>0.
That's still not enough. Consider a2=[2,1].'. Then if abs(x1)=abs(x2)=1,
abs(a2.'*x)=abs(2*x1+x2)
>=abs( 2*abs(x1) -abs(x2))
=1
So, the constraint abs(a2.'*x)=0 can never be satisfied.
Matt J
2022-5-5
My counter-example still applies. There is little guarantee that a solution will exist under those constraints.
Matt J
2022-5-5
If you had abs(a2_i)=1 for all i=1...p. You might be able to guarantee existence of a solution for p>1.
reincornator
2022-5-5
@Torsten, in real numbers, the condition abs(x_i)=1, can be written as Re(x_i)=sqrt(1-Im(x_i)^2). How to write such a condition for vector x in constraints?
Matt J
2022-5-5
编辑:Matt J
2022-5-5
How to write such a condition for vector x in constraints?
Your problem wouldn't be written in terms of x_i in what Torsten is recommending. Your objective and constraints would be written in terms of independent variables (u_i, v_i) where u_i stands in for the real component of x_i and v_i stands in for the imaginary component. The constraint, written differentiably, would be,
u_i^2 + v_i^2 = 1
reincornator
2022-5-5
回答(1 个)
Matt J
2022-5-4
编辑:Matt J
2022-5-4
N=null(a2.');
a3=a1.'*N;
[~,idx]=max(abs(a3));
x=N(:,idx);
6 个评论
Matt J
2022-5-4
编辑:Matt J
2022-5-4
randcomplex = @(x,y) rand(x,y).*exp(2i*pi*rand(x,y));
a1 = randcomplex(10,1);
a2 = randcomplex(10,1);
N=null(a2.');
a3=a1.'*N;
[maxval,idx]=max(abs(a3));
x=N(:,idx)*conj(a3(idx))/abs(a3(idx))
x =
0.1546 - 0.3938i
0.0998 + 0.0391i
0.0617 - 0.0385i
0.0246 + 0.1474i
0.1035 + 0.0910i
0.0625 + 0.0216i
-0.5747 - 0.6314i
0.0177 + 0.0661i
0.0371 - 0.0283i
0.0319 + 0.1476i
a2.'*x
ans = -8.3267e-17 + 5.5511e-17i
maxval,
maxval = 0.7671
abs(a1.'*x)
ans = 0.7671
reincornator
2022-5-5
编辑:reincornator
2022-5-5
@Matt J, thank you. The graph shows that such a solution does not satisfy the condition abs(x_i)=1
randcomplex = @(x,y) rand(x,y).*exp(2i*pi*rand(x,y));
a1 = randcomplex(40,1);
a2 = randcomplex(40,1);
N=null(a2.');
a3=a1.'*N;
[maxval,idx]=max(abs(a3));
x=N(:,idx)*conj(a3(idx))/abs(a3(idx));
a2.'*x;
[a1.';a2.']*x
ans =
0.9866 + 0.0000i
0.0000 - 0.0000i
plot(abs(x))
Matt J
2022-5-5
The graph shows that such a solution does not satisfy the condition abs(x_i)=1
Yes, because as I've said above, I don't think you will be able to find such a solution.
reincornator
2022-5-5
@Matt J, I found one solution. It is implemented using a special algorithm and shows a good result. But I'm looking for a better way.
另请参阅
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)