discrete optimization for minimizing the distance between vectors

8 ビュー (過去 30 日間)
Natalia
Natalia 2013 年 11 月 4 日
コメント済み: Natalia 2013 年 11 月 5 日
Hello,
I have a row of values for the parameter A and a row of values for the parameter B. For each combination of the parameters A and B I perform a simulation resulting in a vector. All vectors have the same length. I want to compare each vector to the reference vector, obtained for the reference parameters A and B (that I don't know). Which optimizer can I use to find a vector with the least distance from the reference vector (and therefore determine the reference A and B)?
  2 件のコメント
Matt J
Matt J 2013 年 11 月 4 日
編集済み: Matt J 2013 年 11 月 4 日
I want to compare each vector to the reference vector, obtained for the reference parameters A and B (that I don't know).
You mean you know the reference vector, but not the reference parameters that induce it?
Natalia
Natalia 2013 年 11 月 4 日
Matt, right!

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

採用された回答

Matt J
Matt J 2013 年 11 月 4 日
編集済み: Matt J 2013 年 11 月 4 日
[minval,minIndex] = min( interdists(reference_vector, other_vectors));
other_vectors(:,minIndex),
where
function Graph=interdists(A,B)
%Finds the graph of distances between point coordinates
%
% (1) Graph=interdists(A,B)
%
% in:
%
% A: matrix whose columns are coordinates of points, for example
% [[x1;y1;z1], [x2;y2;z2] ,..., [xM;yM;zM]]
% but the columns may be points in a space of any dimension, not just 3D.
%
% B: A second matrix whose columns are coordinates of points in the same
% Euclidean space. Default B=A.
%
%
% out:
%
% Graph: The MxN matrix of separation distances in l2 norm between the coordinates.
% Namely, Graph(i,j) will be the distance between A(:,i) and B(:,j).
%
%
% (2) interdists(A,'noself') is the same as interdists(A), except the output
% diagonals will be NaN instead of zero. Hence, for example, operations
% like min(interdists(A,'noself')) will ignore self-distances.
%
% See also getgraph
noself=false;
if nargin<2
B=A;
elseif ischar(B)&&strcmpi(B,'noself')
noself=true;
B=A;
end
[N,M]=size(A);
B=reshape(B,N,1,[]);
Graph=l2norm(bsxfun(@minus, A, B),1);
Graph=reshape(Graph,M,[]);
if noself
n=length(Graph);
Graph(linspace(1,n^2,n))=nan;
  7 件のコメント
Matt J
Matt J 2013 年 11 月 5 日
Let S(x) be the differentiable function that converts your unknown parameter vector x to to the simulation output vector and let R be your reference vector. Then for lsqnonlin, the objective function to be passed as input would be
f(x) = S(x)-R
Natalia
Natalia 2013 年 11 月 5 日
Thank you for your help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOptimize Model Response についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by