Question: NLPSolve is not reentrant?

f := proc(x, rec := true)
  if rec then Optimization:-NLPSolve(2, y -> (y -~ 1/4).(y -~ 1/4), [], [<-1, -1>, <1, 1>],
    maximize = false) end if;
  (x -~ 1/4).(x -~ 1/4)
end proc:

fgrad := proc(x, g) g[1 .. 2] := 2*~(x -~ 1/4) end proc:

Optimization:-NLPSolve(2, f, [], [<-1, -1>, <1, 1>],
  maximize = false, objectivegradient = fgrad);
Warning, no iterations performed as initial point satisfies first-order conditions
        [0.125000000000000000, Vector[column](2, [0., 0.])]


Optimization:-NLPSolve(2, x -> f(x, false), [],  [<-1, -1>, <1, 1>],
  maximize = false, objectivegradient = fgrad);
        [0., Vector[column](2, [.250000000000000, .250000000000000])]

The inner NLPSolve doesn't do anything, except it breaks the outer NLPSolve.

Please Wait...