Contradiction in the solution of CVX


(Meysam) #1

Hello,

Here is my code:

clc;
clear;

%==================== Problem data (parameters) (Beginning) ===============

m = 10; %The number of decision variables
q = 3; %The number of constraints(Kanpsacks)

Q = [

271.3788 -52.9917 -17.4327 29.3242 -6.5822 10.8102 -33.5483 136.2279 -24.4510 61.7511
-52.9917 180.6587 -81.1929 -96.4848 -34.0679 28.4455 53.8037 -83.4439 -65.6968 -137.1036
-17.4327 -81.1929 468.9480 17.1663 52.1956 36.6299 27.9683 103.8484 190.7419 57.2107
29.3242 -96.4848 17.1663 169.6924 -9.8650 -134.4780 -149.6199 6.4986 86.7345 116.8412
-6.5822 -34.0679 52.1956 -9.8650 495.5128 246.1815 98.8579 159.7614 135.8221 -37.1874
10.8102 28.4455 36.6299 -134.4780 246.1815 315.7725 114.6974 50.7118 -23.4092 -30.8213
-33.5483 53.8037 27.9683 -149.6199 98.8579 114.6974 263.6750 87.8618 24.4719 -92.0776
136.2279 -83.4439 103.8484 6.4986 159.7614 50.7118 87.8618 287.4340 85.4487 -37.6911
-24.4510 -65.6968 190.7419 86.7345 135.8221 -23.4092 24.4719 85.4487 285.9480 90.4382
61.7511 -137.1036 57.2107 116.8412 -37.1874 -30.8213 -92.0776 -37.6911 90.4382 269.1263
];

A = [ 3 9 4 6 3 7 4 8 8 8
6 2 3 10 3 9 6 11 2 5
2 11 1 9 9 10 2 5 4 9
];

b = [30 ; 30 ; 30];

c = [ -300;-500;-700;-800;-400;-800;-400;-600;-900;-700];

Ap = [A eye(q)];

Qp = zeros(m + q,m + q);

for i = 1 : m
for j = 1 : m

    Qp(i,j) = Q(i,j);
    
end

end

cp = zeros(m + q,1);

for i = 1 : m

cp(i , 1) = c(i , 1);

end

E = zeros(m + q,m + q); % The matrix of unit vectors

for i = 1 : m + q

E(i,i) = 1;

end

N = 100; % The number of scenarios
u_holder{N} = 0; % To save all N randomly created ui vectors

for i = 1 : N

u_holder{i} = rand( m + q + 1 , 1);

end

P = 0.999; % The probability used in the objective function of CVAR method

%==================== Problem data (parameters) (The end) =================

%==================== The mathematical model (The beginning) ==============

cvx_begin

cvx_solver SEDUMI

variable y
variable alphaa(q , 1)
variable betaa(q , 1)
variable gamaa(m , 1)
variable Z(m + q + 1, m + q + 1) 

variable w(N)
variable BETTA   

summation = 0;

for i = 1 : N, summation = summation + w(i); end

obj = BETTA + (1/( 1 - P )) * ( summation / N );

minimize ( obj )

subject to

%===================== 1st Constraint set ==========================

    M1 = zeros (m + q + 1, m + q + 1);
    
    for i = 1 : q, M1 = M1 + alphaa(i , 1) * [2*b(i)  -1*Ap(i,:) ; -1*Ap(i,:)' zeros(m + q , m + q)]; end
    
    M2 = zeros (m + q + 1, m + q + 1);
   
    for i = 1 : q, M2 = M2 + betaa(i , 1) * [b(i)^2  zeros(1, m + q) ; zeros(m + q, 1) -1*Ap(i,:)'*Ap(i,:)]; end
    
    M = M1 + M2;
    
   %===================== 2nd Constraint set ==========================

   W = zeros (m + q + 1, m + q + 1);
   
   for i = 1 : m, W = W + gamaa(i , 1) * [0 -1*E(:,i)' ; -1*E(:,i) 2*E(:,i)*E(:,i)']; end
   
   %===================== 3rd Constraint set ==========================
    
   Z == [-1*y cp' ; cp Qp ] - M - W ;

% %=========== 4th constraint set ===================================
for i = 1 : N

           w ( i ) >= 0;
           
       end
       
   %===========  5th constraint set ===================================
       for i = 1 : N
           
           w ( i ) >= -1*(u_holder{i})' * Z * u_holder{i} - BETTA ;
           
       end

cvx_end

I have coded the following model (See the image). Surprisingly, the optimal solutions of decision variables do not result in an unbounded objective function value. Indeed, according to the solutions of decision variables, the objective function value must be a relatively small number. Could you please tell me what is going on? Thank you for your help and time.


(Mark L. Stone) #2

Per mcg in Discrepancy between cvx_optval and objective value?

When a problem is unbounded, the values returned in the variables represent an unbounded direction. They aren’t intended to be interpreted as a potential solution.