%Problem 173. % %In this optimization problem, the student is asked to add slack %variables to a set of inequalities, and then to enter the %corresponding augmented matrix. This matrix is checked before %proceeding any further. Once this has been done, the student is %asked to find and record all basic solutions, and hence find the %maximum of a function f(X1,X2). % %One hint is provided in the latter part of the problem. clear variables global undo; global hintnumber global noprint; global err; hintnumber=173; err=0; noprint=0; N=0; M=0; r='nothing'; %this prevents Matlab error on first pass of while loop correcto=[2 -1 1 0 0;3 1 0 1 15]; A=[1]; clc sprintf('%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n%s\n%s\n\n%s\n%s ','Problem 173.','Consider the convex set C defined by the inequalities',' X2 >= 2 X1',' 3 X1 + X2 <= 15',' X1 >= 0, X2 >= 0','Add slack variables and then enter the augmented matrix as A.','Enter "discuss" to have the matrix checked by the computer and to see the rest','of the problem.','One hint is available','Enter "stop" to leave the problem') while(strcmp(r,'stop')==0) %outer loop r=input('problem 173>>','s'); if (strcmp(r,'stop')==1) return end if (findstr(r,'discuss')>=1) if (size(A)==size(correcto)) if (A==correcto) clc sprintf('%s\n%s\n%s\n%s\n%s','Your matrix A is correct. Now find and record all basic solutions.','Hence find the maximum of f(X1,X2) = 5 X1 + X2','When you are satisfied you have done the above, enter "stop"','to leave the problem. There is one hint available') while(strcmp(r,'stop')==0) %inner loop r=input('problem 173>>','s'); if (strcmp(r,'stop')==1) return end if (findstr(r,'hint')>=1) hint %calls hint m-file elseif (findstr(r,'discuss')>=1) sprintf('%s\n\n%s\n%s\n%s\n%s\n%s','There is no more discussion for this problem.','Find and record all basic solutions.','Hence find the maximum of f(X1,X2) = 5 X1 + X2','When you are satisfied you have done the above, enter "stop"','to leave the problem. There is one hint available') else eval(r,'errormessage') noprint=0; %resets error suppression err=0; end %inner if-else loop end end %inner while loop end else clc sprintf('%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n%s\n%s\n\n%s\n%s ','The matrix A you have entered is INCORRECT. Please try again.','Consider the convex set C defined by the inequalities',' X2 >= 2 X1',' 3 X1 + X2 <= 15',' X1 >= 0, X2 >= 0','Add slack variables and then enter the augmented matrix as A.','Enter "discuss" to have the matrix checked by the computer and to see the rest','of the problem.','One hint is available','Enter "stop" to leave the problem') end else %tied to sizecheck "if" clc sprintf('%s\n\n%s\n\n%s\n\n%s\n\n%s\n\n%s\n%s\n%s\n\n%s\n%s ','The matrix A you have entered has INCORRECT dimensions. Please try again.','Consider the convex set C defined by the inequalities',' X2 >= 2 X1',' 3 X1 + X2 <= 15',' X1 >= 0, X2 >= 0','Add slack variables and then enter the augmented matrix as A.','Enter "discuss" to have the matrix checked by the computer and to see the rest','of the problem.','One hint is available','Enter "stop" to leave the problem') end %tied to sizecheck "if" elseif (findstr(r,'hint')>=1) sprintf('%s\n%s','There is a hint available once you have entered the','matrix A correctly.') else eval(r,'errormessage') noprint=0; %resets error suppression err=0; end %if-else loop end end %while loop end