Formulate second-order cone programm

(J) #1

Hi everybody:

I have to express the following optimization program with cvx.

What I have done is:

cvx_begin
variable s(N);
for nodo = 1:N,
nieghbors = find(A(:,nodo)); % Neighbors of node ‘nodo’
minimize (y);
subject to
y >= norm([error_v; error_d]).^2;
error_v >= (1/sigma_e)*norm((s(nodo)-red(nodo,3:4)) - v_med(nodo));
error_d >= (1/sigma_l)*abs(d_neighbors - d_med(nodo));
d_neighbors >= norm(s(nodo) - s(neighbors));
end
cvx_end

But I obtain the error ‘y is not defined’.

I know that this error is because the variable ‘s’ is not in the function to minimize, but I don’t know exactly how to include it in this function.

Could you help me, please?

Thanks in advance…

(Mark L. Stone) #2

I think there are a lot of things wrong with your program. Here are some of them, to get you started. I donl’t understand the notation and conventions, so I will leave you to fix the rest of the things - I don’t even know what is input data vs. optimization (decision) variables, because there is a long list of apparently (?) optimization variables under the min' - I’ll let you sort out all of that, proper indexing, dimensions, etc.

You need to declare y as a (CVX) variable. Actually, all symbols which are not input data must be declared variables (or defined as CVX expressions).

Only place in for loops the statements (minimize or constraints) which need to be made for each index value inside the for loop. The minimize statement and some of your constraints should not be inside the for loop.

(J) #3

Thank you very much for your response.

Basically, what this optimization problem do is to minimize errors in a node localization. s_i is the position of node i. b_ij is the distance between node i and j.v_i is the measured velocity and d_ij is the measured distance between node i and j. So, z_i is the set of all errors both the velocity and distance errors.

Therefore, the input data are measured velocity and distance, and the optimization variable is the localization error.

Based on that, I put the minimize statement inside the for loop because I need to minimize the localization error for each node based on measured velocity and distance to its neighbor nodes.

In this case, the minimize expression should be inside the for, no?

Regards,

(Mark L. Stone) #4

A CVX program, i.e., whatever appears between cvx_begin and cvx_end, can have only one minimize statement, which must evaluate to a real scalar.

If there are several separate optimization problems you wish to solve, you can place cvx_begin ... cvx_end inside a for loop In such case, CVX will be invoked separately each time though the loop.

If you have multiple objectives for a single optimization problem, then you must find a way to combine them into one.

As I wrote earlier, i don’t understand what the problem is supposed to be. The problem statement shows various symbols subscripted by i So does a separate optimization problem need to be solved for each value of i? If so, you might need an outer for loop, inside of which is cvx_begin to cvx_end, and another for loop inside a portion of the cvx_begin to cvx_end to handle indexed constraints if they can’t be vectorized.

(J) #5

I really appreciate your time and your effort. Thank you very much.

I thought to put the CVX program inside a for loop. However, what stops me was the fact that in the restrictions the program needs a variable, s_j, which should be estimated by the same CVX program simultaneosly. That is, in this CVX program, in order to find the optimal value of variable s I need to use the same variable (with other conditions) as a restriction; as it is observed in expression (14).

I really lost in how to express this fact in a CVX program.

Regards,

(Mark L. Stone) #6

You have to clearly and unambiguously define one or more pptimization problems you wish to solve. I don’t think either of us has a clear understanding of what the problem or problems are from the graphic you inserted - i certainly don’t.

Once you have clearly defined what problem(s) you wish to solve, this looks to be rather straightforward to implement, I don’t think with any reformulation “tricks” required but it might require attention to detail in declaring everything with the correct dimensions and indexing - but that’s more of a MATLAB than CVX-specific matter.

I suggest you study more carefully whatever paper or book you extracted this from.

(J) #7

Thank you for your support and your suggestions, sir.

Best regards,

J.