Search code examples
matlabmathematical-optimizationlinear-programming

Why does linprog only give one value of x1 or x2 and not a combination of both?


Hi I have the following code using linprog

for K = 1:3;
   for M = 1:3; 

      PV_output(:,:,K) = real(PV_power_output(:,:,K));
      PV =reshape(PV_output(:,:,1),8760,1); 
      WT_output(:,:,M) =  WT_power_output(:,:,M);
      WT = reshape(WT_output(:,:,1),8760,1);
    PVenergy = sum(sum(PV_output(:,:,1)));
   WTenergy = sum(sum(WT_power_output(:,:,1)));
   % Linprog
   f = [((CRF*CC_PV)/PVenergy)+OM_PV; ((CRF*CC_WT)/WTenergy)+OM_WT];
   A(:,:) = [-PV  -WT];
   b(:,:)  = -0.25.*Demand(:);
   lb = zeros(2,1);
 ub = [max_PV_area/PV_area; max_WT_area/WT_area]';
   [x(:,K,M), fval, exitflag] = linprog(f,A,b,[],[],lb,ub)
    end
end

Where PV = 8760x2 , WT = 8760 x 2 and x = 2x1. When I run this program the optimisation converges with an exit flag of 1 but I either get a value of x1 =0 and a value of x2 equal to a certain integer.

Why doesn't the output give a mixture of the results (i.e a non-zero value of both x1 and x2?


Solution

  • Because a linear programming solver will return a solution at a vertex of the polytope defined by the constraints. An optimal solution will always lie at such a vertex.