I want to plot the minimum of a function returned by Minimize over a range of constraint values.

Plot[Minimize[{2*Exp[-x] + 0.5*Exp[-y], x >= 0, y >= 0, x + y == z}, {x, y}], {z, 4, 20}]

This is the command I used: for a range of $z$, I wan to plot the minimum of this optimisation program. However I get no graph, though I get values for the Minimize command in isolation. How do I use plot appropriately here?


Here are the $x$ and $y$ values that minimize your function:

mydata = Table[
  {x, y} /. 
   Minimize[{2*Exp[-x] + 0.5*Exp[-y], x >= 0, y >= 0, x + y == z}, {x,
       y}][[2]], {z, 0, 3, .1}];

Here are the actual minima values of your function for the minimizing values of $x$ and $y$:

myminima = 2*Exp[-#[[1]]] + 0.5*Exp[-#[[2]]] & /@ mydata;

Here are the simple $z$ values in a range:

myzvalues = Table[z, {z, 0, 3, .1}]

Here is a plot of the minimum of your function for various values of $z$:

 ListPlot[Transpose[{myzvalues, myminima}]]

enter image description here

  • $\begingroup$ Thanks. No I want to plot the min value of the program as a function of $z$. It is $F(z)$ v $z$, where $F(z)$ is the value of the objective function at the $(x,y)$ that your table provides. $\endgroup$ – Bravo Apr 30 '15 at 15:14
  • $\begingroup$ What [2] means in mydata? $\endgroup$ – Dinesh Shankar Sep 21 '19 at 18:14
  • $\begingroup$ The second (realistic) of the two solutions. $\endgroup$ – David G. Stork Sep 21 '19 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.