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?

댓글을 달려면 로그인하십시오.

채택된 답변

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 CenterFile Exchange에서 Optimize Model Response에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by