# Maple, Graph of an optimization problem

I have solved the following maximisation problem analytically. I would like to graph the solution as well so I can see it, but I am not sure how to do this with Maple, i have just started using it.

Maximise x+y subject to: $$\begin {eqnarray*} x + 2y &\le& 4, \\ x + 2y &\le& 4, \\ x - y &\le& 1, \end {eqnarray*}$$where $x,y\ge0$.

-

You could try something like this,

with(plots):

sol := Optimization:-Maximize( x+y, {2*x+y<=4, x>=0, y>=0} );

optpt := [eval(x,sol[2]), eval(y,sol[2]), sol[1]];  # optimal [x,y,z]

common := style=patchnogrid, transparency=0.4:
xrng,yrng,zrng := x=0..10, y=0..10, z=-10..10:

display( pointplot3d( [optpt], symbol=solidsphere, symbolsize=30,
color=red ),
plot3d( x+y, xrng, yrng, style=patch ),
implicitplot3d( x=0, xrng, yrng, zrng, common ),
implicitplot3d( 2*x+y-4, xrng, yrng, zrng, common ),
axes=box, view=[0..4,0..5,0..10] );


Another way is to invoke the Optimization:-Interactive() command, which brings up a pop-up assistant. In that assistant, enter the constraints and objective, toggle it as maximize, hit the Solve button, then the Plot button, and then change the returned object to be the Plot, and then Quit it. That should produce a similar 3D plot.

This question probably belongs more on www.stackoverflow.com (with the Maple tag) than here, as it's more a Maple programming question than a math question. You can also ask questions on www.mapleprimes.com

-