# How can I solve the cvx problem wuth two variable

Q: One of the variables solved is almost zero,No matter how other variables are adjusted

``````q_UAV = 10;
q_car = 2;
Csingle_UAV = 1;
Csingle_car = 0.05;
C_req = 60;

cvx_begin
variable K_UAV
variable K_car
minimize (K_UAV*q_UAV + K_car*q_car)
subject to
K_UAV*Csingle_UAV + K_car*Csingle_car >= C_req;
K_UAV >= 0;
K_car >= 0;
cvx_end``````

This is a very simple Linear Programing problem, which CVX and the solver it calls easily solves.

So you object to `K_car` coming out to be 0? That is a result of the model and input data. if `Csingle_car` is set to 0.25, then optimal `K_car` is 240, with optimal objective value 480; and if `K_car` is then also constrained to be equal to 0, the optimal objective value is 600, which is worse, thereby proving that `K_car = 0` is not an optimal solution when `Csingle_car` is set to 0.25. Indeed, in this problem, `K_car = 0` only becomes non-optimal (all other inputs being held constant) when `Csingle_car` is sufficiently large so as to make `K_car = 0` not the best way of satisfying the first constraint, because it then makes non-zero `K_car` worth the non-zero contribution to the 2nd term of the objective, because of a more than offsetting saving to the first term of the objective, as made possible via the first constraint.

1 Like