Skip to content

Instantly share code, notes, and snippets.

@jdherman
Created March 12, 2014 18:03
Show Gist options
  • Save jdherman/9512575 to your computer and use it in GitHub Desktop.
Save jdherman/9512575 to your computer and use it in GitHub Desktop.
clc; clear all;
% Plot the feasible space for the Masonry LP
% max Z = 140*x1 + 160*x2
% subject to:
% 2*x1 + 4*x2 <= 28
% 5*x1 + 5*x2 <= 50
% x1 <= 8
% x2 <= 6
% x1, x2 >= 0
% general range for x values
x = 0:1:10;
% contour
[X1,X2] = meshgrid(x,x);
Z = 140*X1 + 160*X2;
contour(X1,X2,Z,25);
% constraint lines
hold on;
plot(x, (28 - 2*x)/4, 'k', 'linewidth', 2);
plot(x, (50 - 5*x)/5, 'k', 'linewidth', 2);
plot(8*ones(length(x)), x, 'k', 'linewidth', 2);
plot(x, 6*ones(length(x)), 'k', 'linewidth', 2);
xlabel('Amount of HYDIT (tons/wk)');
ylabel('Amount of FILIT (tons/wk)');
title('Masonry LP problem');
hcb = colorbar;
set(get(hcb,'ylabel'),'String', 'Profit Z (millions $)');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment