Optimizing two vectors of different sizes

1 回表示 (過去 30 日間)
Adam Rish
Adam Rish 2021 年 5 月 20 日
編集済み: Matt J 2021 年 5 月 24 日
I am working to optimize the following problem:
r=optimvar('r',size(S,1),'LowerBound',0,'UpperBound',1);
B= optimvar ('B', size(dm,2));
p=prob2matrices({r, B},'Constraints', sum(r)<=1);
%Solving optimization problem
Roptimal=lsqlin([S', 1], dm(:), p.Aineq,p.bineq,[],[],p.lb,p.ub)
Where S is a n x m matrix, and dm is a m x 1 matrix. The result is that r (n x 1 natrix) and B (m x 1 matrix) are different sizes, and cannot be concatenated. The equation I am essential trying to solve is as follows:
%minimize "e2"
e= dm - (S'*r+B)
e2= e*e'
I recogonize I am probably not using an appropriate function. Any help would be greatly appreciated.
  2 件のコメント
Nagasai Bharat
Nagasai Bharat 2021 年 5 月 24 日
Hi,
From the equation (r' * S) would be a 1 x m matrix whereras B is a m x 1 matrix. Try to cross-check as a transpose of B would be needed to have an addition operation.
Adam Rish
Adam Rish 2021 年 5 月 24 日
編集済み: Adam Rish 2021 年 5 月 24 日
So I adjusted my inputs, but am still getting the same error. Here is what I've written
r=optimvar('r',size(S,1),'LowerBound',0,'UpperBound',1);
p=prob2matrices({r},'Constraints', sum(r)<=1);
%Solving optimization problem
Roptimal=lsqlin([S', I], dm(:), p.Aineq,p.bineq,[],[],p.lb,p.ub)
So the equation I am trying to solve/minimize using lsqlin is the following:
S'*r+B-dm
Where I am trying to solve for r (n x 1 matrix) and B. S is still a n x m matrix, and dm is a 1 x m matrix. S'*r is therefore a m x 1 matrix. The problem is that I need B to be an m x 1 matrix but the requirement of multiplier I seems to prevent me from doing that

サインインしてコメントする。

採用された回答

Matt J
Matt J 2021 年 5 月 24 日
編集済み: Matt J 2021 年 5 月 24 日
r=optimvar('r',n,'LowerBound',0,'UpperBound',1);
B= optimvar ('B', m);
[p,idx]=prob2matrices({r, B},'Constraints', sum(r)<=1);
C=nan(m,m+n);
C(:,idx.r)=S';
C(:,idx.B)=eye(m);
Roptimal=lsqlin(C, dm(:), p.Aineq,p.bineq,[],[],p.lb,p.ub);
sol=x2sol(Roptimal,idx), %solution

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultiobjective Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by