Hi, I am a new user to CVX. I am trying to model the particular objective function 0.5 * (u(t)^2 + u(t + delta)^2 + ... + u(t + N * delta)^2. There are N variables.

I have written my code as

function acceleration = control(x0,v0,brake, acc, N, delta, minDist)
cvx_begin
variable x(N);
variable v(N);
variable u(N);
whos
minimize(1/2 * u' * u);
subject to
brake <= u;
u <= acc;
x >= minDist;
x(1) == x0;
v(1) == v0;
for i = 1:N-1
x(i+1) == x(i) + delta * v(i) + 0.5 * delta^2 * u(i);
v(i+1) == v(i) + delta * u(i);
end
cvx_end
end

Upon running the code, I get Error using norm First argument must be single or double. Error in computeControl>control (line 12) norm(brake <= u); But, whos is giving the value as double for brake.

I removed norm and I get this sqlp stop: dual problem is suspected of being infeasible

I couldnâ€™t give the give the objective function as minimize(0.5 * u.^2) since I got that the objective function is not scalar error. Any help would be greatly appreciated. Thanks.

Where in your code is norm(brake <= u) ? Perhaps that is a typo in your post and is supposed to be norm(brake) <= u . But your code has brake <= u .

u.^2 is an N by 1 vector. The objective function must evaluate to a real scalar. Perhaps you want sum(u.^2) ? And that can be written more simply as u'*u

Which solver were you using? You can try a different solver. if you have them available, Gurobi and Mosek are likely more numerically robust than SeDuMi or SDPT3. you haven;t shown your input data, it is possible that is scaled poorly, which could contribute to numerical difficulties for the solver. If you show solver output (from each iteration), that might assist readers in assessing your situation.

You havenâ€™t provided all the input data. Can you provide all the commands which need to be run starting from a new MATLAB session to execute your problem?

I have no idea what the control function is. You need to provide values for all variables in the CVX program, other than those declared as variables in the CVX program.

Your problem is infeasible. It would be feasible for any value of minDist <= 1, and infeasible for any value of minDist > 1. If any value of minDist <=1 is used, the optimal objective value = 125., and even SDPt3 can solve that problem.

You can easily see this is due to the constraint x(1) == x0, which in your case is x(1) == 1, which is â€śincompatibleâ€ť with, i.e., infeasible given the constraint x >= norm(minDist), which in your case is x >= 5. So alternatively, you could change the value of x0 to get a feasible problem.