# # Written by: # -- # John L. Weatherwax 2009-04-21 # # email: wax@alum.mit.edu # # Please send comments and especially bug reports to the # above email address. # #----- save_plots = F # Chapter 7: Section 7: Exercise 8 # # Plot the feasible region for the primal problem: # x = seq( from=-1, to=50, length.out=100 ) y = 20 - x if( save_plots ){ postscript("../../WriteUp/Graphics/Chapter7/section_7_prob_8_primal_region.eps", onefile=FALSE, horizontal=FALSE) } plot( x, y, type='l', xlim=c(-1,+60), ylim=c(-1,30), xlab='x_1', ylab='x_2' ) y = ( -50 + x )/ (-2) lines( x, y, type='l', col='blue' ) abline( h=0 ) abline( v=0 ) polygon( c(0,20,0), c(0,0,20), col='gray' ) polygon( c(50,70,70,0,0), c(0,0,40,40,25), col='gray' ) grid() if( save_plots ){ dev.off() } # Plot the feasible region for the dual problem: # x = seq( from=-1, to=10, length.out=100 ) y = x - 2 if( save_plots ){ postscript("../../WriteUp/Graphics/Chapter7/section_7_prob_8_dual_region.eps", onefile=FALSE, horizontal=FALSE) } plot( x, y, type='l', xlim=c(-1,+10), ylim=c(-1,10), xlab='v_1', ylab='v_2' ) y = (x - 1)/2 lines( x, y, type='l', col='blue' ) abline( h=0 ) abline( v=0 ) x_inf = 15 y_inf = ( x_inf - 1 ) / 2 polygon( c(2,x_inf,x_inf,3,2), c(0,0,y_inf,1,0), col='gray' ) grid() if( save_plots ){ dev.off() }