How to plot maximized values over a range under different initial conditions?

I tried to plot maximized value over a range a\in [0,1] for different initial conditions b=0.2,0.3,0.4,0.5, but it does not work. Could anyone please help to work it out?

pi:=2 b + (x + y -b)(3-x)/3- a(y -b)

opt:=Maximize[{pi, a <= x <= 1 && a - 1 < y}, {x, y}]

Plot[Evaluate[Table[opt, {b, 0.2, 0.5, 0.1}]], {a, 0, 1}]

You are nearly there. With a few changes:

pi[x_, y_  , a_, b_ ] = 2 b + (x + y - b) (3 - x)/3 - a (y - b);
opt[a_, b_] :=
Maximize[{pi[x, y, a, b], a <= x <= 1 && a - 1 < y}, {x, y}];

Plot[Evaluate[Table[opt[a, b], {b, 0.2, 0.5, 0.1}]], {a, 0, 1}]


It looks that p[a,b] is unbounded for a<0.75

• Hi Daniel, Thank you very much for your correction. But when I run the same code on my computer, it did not work. Could you please help to look at it? Is it related to the version of Mathematica? I attached a picture in the following. Thank you. Nov 4, 2021 at 18:09
• when I run the same code on my computer, it did not work. Could you please help to look at it? Is it related to the version of Mathematica? I attached a picture in the following. Thank you. i.stack.imgur.com/4JJD7.png Nov 4, 2021 at 18:13
• Hi Ling, I tried the code again and it works on my machine. I have MMA 12.3 on Windows 10 Nov 5, 2021 at 8:33