MATLAB: Linear programming solution found unbounded but is bounded

linprogmixed inequalitiesOptimization Toolboxunbounded

%% linear programing problem
% minimize Z = 2*x1 + 3*x2 subject to
% 0.5*x1 + 0.25*x2 <= 4 and
% x1 + 3*x2 >= 20. Negate both sides of 2nd constraint as
% -x1 + -3*x2 <= -20
% define xv = [x1;x2], b = [4;-20], A = [0.5 0.25;-1 -3], and f = [2;3] so
% Z = f'*xv and A*x <= b. I try solving this at the end of this file.
% First, let's graphically solve it.
%% create line vectors for graphic solution
x1v = linspace(0,20,100); % span viable domain of x1
x2v = linspace(0,16,101); % span viable domain of x2
x2c1 = (4 -(1/2)*x1v)/(1/4);% constraint 1 equality
x2c2 = (20 - x1v)/3; % constraint 2 equality
%% apriori known solution at 2nd constraint at x1 = 0
x1s = 0;
x2s = 20/3;
%% cost function over domain of x1v and x2v
[X1,X2] = meshgrid(x1v,x2v); % create matrix x1 and x2 values
% I made x2v longer than x1v to ease knowing orientation of X1, X2, & Z
Z = 2*X1 + 3*X2; % compute Z at each set of points
cv = 0:5:(2*max(x1v)+3*max(x2v)); % contour levels for later plotting
%% plot space
figure(1)
hp = patch([x1s 0 5.6 x1s],... % (5.6,4.8) intersection of constraints
[x2s 16 4.8 x2s],'y'); % patch feasible domain
set(hp,'LineStyle','none')
hold on
[Cc,hc] = contour(X1,X2,Z,cv); % plot and label Z contours
clabel(Cc,hc)
hg = plot(x1v,x2c1,'b--',... % plot constraint equality lines
x1v,x2c2,'r-',... %
x1s,x2s,'kp'); % plot solution point
hold off
grid on
legend('feasible region','cost function','<= constraint',...
'>= constraint','optimal solution')
axis([0 max(x1v) 0 max(x2v)])
axis('equal')
xlabel('x_1')
ylabel('x_2')
title('minimization problem with >= and <= constraints')
%% try to use Matlab's optimization toolbox
A = [(1/2) (1/4)
-1 -3];
b = [4;-20];
f = [2 3];
[xs,fval] = linprog(f,A,b);
gives the error "Problem is unbounded."
Note, Wolfram's alpha has a tool that solves it at

Best Answer

Note, Wolfram's alpha has a tool that solves it
No, the Wolfram tool finds it to be unbounded as well. Are there supposed to be positivity constraints? If so, you've omitted them.
Related Question