# Nested optimization problem 3

thanks to Ulrich Neumann I am getting close to the solution of my problem... However, Mathematica tells me that no points satisfy the constraints of the following problem:

 i = 117; A = 1*10^4; a = 10;
f[w_?NumericQ, p_?NumericQ] := (A - a p) (p - w)
pR[w_?NumericQ] := Block[{p}, NArgMax[{f[w, p], p >= 0, w >= i}, p]]
J[w_?NumericQ] := (A - a pR[w]) (w - i)
NMaximize[{J[w], {w > i, f[w, pR[w]] > 0}}, w, Method -> "NelderMead",
AccuracyGoal -> 3]


Yet, it is easy to show that $$pR[181]=590.5$$ and $$f[181, 590]>0$$, so that $$w>i$$, $$p>=0$$ and $$f[w, pR[w]] > 0$$ are fulfilled.

So where exactly is this code letting me down?

Remove the constraint w>i. NArgMax expects only constraints depending on p!
pR[w_?NumericQ] :=Block[{p}, NArgMax[{f[w, p], p >= 0(*,w\[GreaterEqual]i*)}, p]]

Now the NMaximize evaluates
J[w_?NumericQ] := (A - a pR[w]) (w - i)