cvx_begin
variable f(n,m); % two dimensional matrix
variable L(n,m); % two dimensional matrix
dual variables A B C D E F
minimize (sum(f.^2)+sum(power(2,2.*L/200)));
subject to
A: sum(L)-L_tot==0;
B: -L<=0;
C: -R<=0;
D: f-1000<= 0;
E: L<=2*f ;
F: 2*L-R<=0;
cvx_end
but, Unfortunately, I am unable to solve the problem and this problem exist:
“Your objective function is not a scalar.”
but, the results seems scalar!!!
If possible, please help me how to resolve the problem.
To the extent possible, CVX tries to adhere to the same conventions MATLAB does with its functions. For example, when X is a matrix, SUM(X) is a vector, not a scalar.
So that’s your problem here: quantities like sum(f.^2) are not scalars.
This is how I would write your objective: sum_square(vec(f))+sum(pow(2,2.*vec(L)/200))
Note that pow(2,x) is just exp(log(2)*x), which is subject to the standard warning about the use of exponentials, logarithms, etc. in CVX models.
I checked: sum_square(vec(f))+sum(power(2,2.*vec(L)/200)), that is fine but, what is your opinion this solution for main aforementioned object to be: sum_square(f(:))+sum(power(2,2.*L(:)/200))?