discrete optimization for minimizing the distance between vectors

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, 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

Natalia
Natalia 2013년 11월 5일
편집: Natalia 2013년 11월 5일
Thank you Matt,
However I do not completely understand your code. What is the function '12norm'? And where do you actually compare the vectors? Do you suggest to calculate the distance for every vector from the reference vector, i.e. for each combination of parameters A and B? I would like to avoid the exaustive search...
What is the function '12norm'?
Sorry, you can replace that line with
Graph=sqrt(sum(bsxfun(@minus, A, B).^2,1));
And this is the line where the separation distances are computed.
Do you suggest to calculate the distance for every vector from the reference vector, i.e. for each combination of parameters A and B? I would like to avoid the exaustive search...
Because you only have discrete information, I don't think there's an alternative to exhaustive search. Do you really have so many vectors that it makes a big difference? How many vectors do you have? And of what dimension?
Is there a reason you think non-exhaustive search would be possible? For example, are the vectors pre-sorted in some way?
Fore the moment I have A*B vectors of the length 4096. But I am planning to inroduce more parameters. Than the amount of teir combinations, and therefore vectors, to compare (A*B*C*D*E*F*...) will grow extremely...
Matt J
Matt J 2013년 11월 5일
편집: Matt J 2013년 11월 5일
Assuming the simulation output vectors are differentiable functions of the parameters, you should use Optimization Toolbox solvers,e .g., lsqnonlin(), instead of sampling your parameter space discretely.
And how should I define the function to be optimized?
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
Thank you for your help!

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

추가 답변 (0개)

카테고리

질문:

2013년 11월 4일

댓글:

2013년 11월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by