%Create a grid from -1 to 25 with an increment of 0.5 for the variables x1 and x2
clear all

[x1,x2]=meshgrid(-1:0.01:25.0, -1:0.01:25.0);


	%Enter functions for the profit maximization problem

f=400*x1+600*x2;

g1=x1+x2-16;

g2=x1/28+x2/14-1;

g3=x1/14+x2/24-1;

g4=-x1;

g5=-x2;


%Initialization statements; these need not end with a semicolon

cla reset

axis auto   	%Minimum and maximum values for axes are determined automatically
           
		%Limits for x- and y-axes may be specified with the command
            	
		%axis ([xmin xmax ymin ymax])

xlabel('x1'),ylabel('x2')   %Specifies labels for x- and y-axes

title('Profit Maximization Problem')

hold on     	%retains the current plot and axes properties for all subsequent plots
		

%Use the "contour" command to plot constraint and cost functions

cv1=[0 0]; %Specifies two contour values

const1=contour(x1,x2,g1,cv1,'k','LineWidth',3);   
		%Plots two specified contours of g1; k=black color

%clabel(const1)      %Automatically puts the contour value on the graph

text(2,16,'g1')     %Writes g1 at the location (1, 16)

cv11=[0.15:0.05:0.9];

const1=contour(x1,x2,g1,cv11,'r');

cv2=[0 0];

const2=contour(x1,x2,g2,cv2,'k','LineWidth',3);

%clabel(const2)

text(23,1.5,'g2')

cv22=[0.01:0.005:0.05];

const2=contour(x1,x2,g2,cv22,'r');

const3=contour(x1,x2,g3,cv2,'k','Linewidth',3);

const3=contour(x1,x2,g3,cv22,'r');

%clabel(const3)

text(2,23,'g3')

cv45=[0.1:0.05:.6];

cv3=[0 0];

const4=contour(x1,x2,g4,cv3,'k','Linewidth',3);

const4=contour(x1,x2,g4,cv45,'r');

%clabel(const4)

text(.25,20,'g4')


const5=contour(x1,x2,g5,cv3,'k','Linewidth',3);

%clabel(const5)

const5=contour(x1,x2,g5,cv45,'r');

text(19,1,'g5')


text(1.5,7,'Feasible Region')


fv=[2400, 4800, 7200, 8800];    %Defines 4 contours for the profit function

fs=contour(x1,x2,f,fv,'k--');   %'k--' specifies black dashed lines for profit function contours
clabel(fs)

hold off    %Indicates end of this plotting sequence
            
%Subsequent plots will appear in separate windows
