Time delay of estimation

(VINAYAK KARANDIKAR) #1

hello, i am trying to solve a time delay of arrival problem.

i encountered a problem:

Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {complex affine} .* {log-affine}

Error in * (line 36)
z = feval( oper, x, y );

Error in RIMAX_CostFcn (line 20)
x = -1j2pi*mf’f0Theta_SP;

Error in Maximum_Likelihood_detector (line 23)
[ val, Rnn_Theta_Dan ] = RIMAX_CostFcn(D,Theta, Mf,f0);

so how do i solve it?

(Mark L. Stone) #2

Obviously, you have violated CVX’s DCP rules. Please read Why isn’t CVX accepting my model? READ THIS FIRST! .

If you can not resolve your difficulty after reading the FAQ, then feel free to post your code, preferably with reproducible input. “Time delay of estimation” doesn’t tell forum readers anything useful.

(VINAYAK KARANDIKAR) #3

how do i attach my code?

(Mark L. Stone) #4

Copy and paste it into your reply, and use the Prefromatted text.

(VINAYAK KARANDIKAR) #5
1. function [ Tau_Los, CRLB_Theta_SP ] = Maximum_Likelihood_detector(D)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here

% Tau_Los =0; Tau_Dmc = 0; Beta = 0; Alpha1 = 0; Alpha0 = 0;

Mf = 4095; f0 = 1/Mf; n = 5;

% Theta_SP = [Tau_Los];
% Theta_Dmc = [Tau_Dmc Beta Alpha1]’;
% Theta_Noise = [Alpha0];

cvx_expert true
cvx_begin gp
cvx_solver sedumi
variable Theta(n);

% Theta = exponential;

``````[ val, Rnn_Theta_Dan ] = RIMAX_CostFcn(D,Theta, Mf,f0);

minimize(val);
``````

cvx_end

Tau_Los = Theta(1);

mf = (-ceil(Mf-1)/2):1:(ceil(Mf-1)/2);

D_Theta_SP = (-2jpif0mf’).exp( -2jpif0*mf’*Tau_Los);

CRLB_Theta_SP = 0.5*real(D_Theta_SP’*inv(Rnn_Theta_Dan)*D_Theta_SP);
end

1. function [ val, Rnn_Theta_Dan ] = RIMAX_CostFcn(D,Theta, Mf,f0)
%MINIMIZE Summary of this function goes here
% Detailed explanation goes here

``````display(Theta);
display(size(Theta));

Theta_SP = Theta(1);

Tau_Dmc = Theta(2);
Beta = Theta(3);
Alpha1 = Theta(4);
Theta_Dmc = [Tau_Dmc  Beta  Alpha1]';

Alpha0 = Theta(5);
mf = (-ceil(Mf-1)/2):1:(ceil(Mf-1)/2);
S_Theta_SP = exp(-1j*2*pi*mf'*f0*Theta_SP);
``````

% Theta_SP = double(Theta_SP);
% x = -2pimf’f0Theta_SP;

% p =[0.5 1 1];

% S_Theta_SP = 1 + x;

% S_Theta_SP = 1 + x; %+ ((x.^2)/2);

`````` R_Theta_Dmc = RTD(Theta_Dmc, Mf, f0);
``````

% [c, r] = RTD(Theta_Dmc, Mf, f0)
Rnn_Theta_Dan = R_Theta_Dmc + Alpha0eye(Mf);
% Rnn_Theta_Dan = toeplitz(c,r) + Alpha0
eye(Mf);
val = (D.’-S_Theta_SP)‘inv(Rnn_Theta_Dan)(D.’-S_Theta_SP);

``````validateattributes(val,{'numeric'},{'real','nonnegative','scalar','finite'});
``````

end

1. function [ R_Theta_Dmc] = RTD( Theta_Dmc, Mf, f0)
%RTD Summary of this function goes here
% Detailed explanation goes here

Tau_Dmc = Theta_Dmc(1,1);
Alpha1 = Theta_Dmc(3,1);

C = cvx(zeros(Mf,1)); R = cvx(zeros(1, Mf));
% d1=cvx(zeros(sz1,sz2));

for rcf = 1:Mf
x1 = -2jpi(+(rcf-1)0.5)f0Tau_Dmc;
% p =[0.5 1 1];
% e1 = 1 + x1;
pi*(+(rcf-1)/2)*f0))*exp(x1);
% cvx_begin
% C(rcf,1) = (Alpha1);

% cvx_end
x2 = -2pi(-(rcf-1)0.5)f0Tau_Dmc;
% p =[0.5 1 1];
% e2 = 1 + x2;
pi*(-(rcf-1)/2)*f0))*exp(x2);
% rcf_count = rcf

end
% szr = size®
R_Theta_Dmc = toeplitz(C,R);
%variable R_Theta_Dmc(5,5) toeplitz
end

1. So function 1 calls function 2 which calls function 3. D is a 36 by 4095 data matrix.

(Mark L. Stone) #6

Per your first post, the error occurs at
`x = -1j*2*pi*mf'*f0*Theta_SP;`

However, this line does not even occur in your posted function 2, although there is a similar, but different, line commented out there (missing `1j` )

Please post a version of code with error message corresponding to it.

(VINAYAK KARANDIKAR) #7

Yes i have modified the code. The following is what the actual code is. And i have attached the error message also.

1. function [ Tau_Los, CRLB_Theta_SP ] = Maximum_Likelihood_detector(D)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here

% Tau_Los =0; Tau_Dmc = 0; Beta = 0; Alpha1 = 0; Alpha0 = 0;

Mf = 4095; f0 = 1/Mf; n = 5;

% Theta_SP = [Tau_Los];
% Theta_Dmc = [Tau_Dmc Beta Alpha1]’;
% Theta_Noise = [Alpha0];

cvx_expert true
cvx_begin gp
cvx_solver sedumi
variable Theta(n) ;

% Theta = exponential;

``````[ val, Rnn_Theta_Dan ] = RIMAX_CostFcn(D,Theta, Mf,f0);

minimize(val);
``````

cvx_end

Tau_Los = Theta(1);

mf = (-ceil(Mf-1)/2):1:(ceil(Mf-1)/2);

D_Theta_SP = (-2jpif0mf’).exp( -2jpif0*mf’*Tau_Los);

CRLB_Theta_SP = 0.5*real(D_Theta_SP’*inv(Rnn_Theta_Dan)*D_Theta_SP);
end

1. function [ val, Rnn_Theta_Dan ] = RIMAX_CostFcn(D,Theta, Mf,f0)
%MINIMIZE Summary of this function goes here
% Detailed explanation goes here

% display(Theta);
display(size(Theta));

``````Theta_SP = Theta(1);

Tau_Dmc = Theta(2);
Beta = Theta(3);
Alpha1 = Theta(4);
Theta_Dmc = [Tau_Dmc  Beta  Alpha1]';

Alpha0 = Theta(5);
mf = (-ceil(Mf-1)/2):1:(ceil(Mf-1)/2);
``````

% S_Theta_SP = cos(2pimf’f0Theta_SP) - 1jsin(2pimf’f0Theta_SP);
S_Theta_SP = exp(-1j
2pimf’f0Theta_SP);

% Theta_SP = double(Theta_SP);
% x = -2pimf’f0Theta_SP;

% p =[0.5 1 1];

% S_Theta_SP = 1 + x;

% S_Theta_SP = 1 + x; %+ ((x.^2)/2);

`````` R_Theta_Dmc = RTD(Theta_Dmc, Mf, f0);
``````

% [c, r] = RTD(Theta_Dmc, Mf, f0)
Rnn_Theta_Dan = R_Theta_Dmc + Alpha0eye(Mf);
% Rnn_Theta_Dan = toeplitz(c,r) + Alpha0
eye(Mf);
val = (D.’-S_Theta_SP)‘inv(Rnn_Theta_Dan)(D.’-S_Theta_SP);

``````validateattributes(val,{'numeric'},{'real','nonnegative','scalar','finite'});
``````

end

1. function [ R_Theta_Dmc] = RTD( Theta_Dmc, Mf, f0)
%RTD Summary of this function goes here
% Detailed explanation goes here

Tau_Dmc = Theta_Dmc(1,1);
Alpha1 = Theta_Dmc(3,1);

C = cvx(zeros(Mf,1)); R = cvx(zeros(1, Mf));
% d1=cvx(zeros(sz1,sz2));

for rcf = 1:Mf
x1 = -2jpi(+(rcf-1)0.5)f0Tau_Dmc;
% p =[0.5 1 1];
% e1 = 1 + x1;
pi*(+(rcf-1)/2)*f0))*exp(x1);
% cvx_begin
% C(rcf,1) = (Alpha1);

% cvx_end
x2 = -2pi(-(rcf-1)0.5)f0Tau_Dmc;
% p =[0.5 1 1];
% e2 = 1 + x2;
pi*(-(rcf-1)/2)*f0))*exp(x2);
% rcf_count = rcf

end
% szr = size®
R_Theta_Dmc = toeplitz(C,R);
%variable R_Theta_Dmc(5,5) toeplitz
end

1. The error message when these 3 functions are run in cvx:

Error using .* (line 173)
Disciplined convex programming error:
Cannot perform the operation: {complex
affine} .* {log-affine}

Error in * (line 36)
z = feval( oper, x, y );

Error in RIMAX_CostFcn (line 20)
S_Theta_SP =
exp(-1j2pi*mf’f0Theta_SP);

Error in Maximum_Likelihood_detector (line 22)
[ val, Rnn_Theta_Dan ] =
RIMAX_CostFcn(D,Theta, Mf,f0);

1. this is the final code and the error message pasted corresponds to it on debugging mode.

Thank you

(Mark L. Stone) #8

The argument of exp is not real, contrary to CVX’s rules.

`````` help cvx/exp
Disciplined convex programming information:
exp(X) is convex and nondecreasing in X. When used in CVX
expressions, X must be real. Typically, X must also be affine
or convex; X can also be concave, but this produces a log-concave
result with very limited usefulness.``````

(VINAYAK KARANDIKAR) #9

Alright, so how can we solve this problem? The optimization problem i am trying to solve involves exponential functions and also complex functions. Is cvx not a tool for these situations? Can you then suggest a different method, MATLAB based , to solve the optimization problem?

I can also send you a snapshot of the mathematical formulation of the problem i am trying to solve? But then please tell me how do i send you a picture?

Thank you

(Mark L. Stone) #10

Please re-read the FAQ Why isn't CVX accepting my model? READ THIS FIRST! . The first thing for you to determine is whether your problem is convex. Is it? If so, how have you shown that?

Right now, your program is a big unreproducible “mess”, and I have no idea what you are even trying to do mathematically. There is an upload image icon you can use.

(VINAYAK KARANDIKAR) #11
``````Alright,
1) I will try finding if the problem is convex or not.
2) I am attaching a mathematical formulation of the problem:
3) Can we discuss this on skype?
``````

Thank you

(Mark L. Stone) #12

All communications should be via forum posts.

(VINAYAK KARANDIKAR) #13
``````Alright,
I will get back to you/this forum soon. I have to find a way to solve this optimization problem in matlab only.
``````

Thank you