NMinimized is creating a seemingly malformed Experimental`NumericalFunction expression internally, not catching it, and returning it as the minimum value. It certainly seems like a bug.
The apparent misbehavior
Below is a good Experimental`NumericalFunction that represents the objective function. (Caveat: Because we're blocking it, it messes up NMinimize, but the function is well-formed.)
Block[{Experimental`NumericalFunction},
f = Last@Cases[
Trace[
Hold[
NMinimize[{Abs[x1] + Abs[x2] + Abs[x3] + Abs[x4] + Abs[x5],
Abs[0.055*(x1 + 11) + 0.065*(x2 - 13) + 0.068*(x3 - 47) +
0.071*(x4 - 50) + 0.07*(x5 - 43) + 0.852] <= Gcur &&
Abs[-8.567*(x1 + 11) - 9.057*(x2 - 13) -
9.154*(x3 - 47) - 8.937*(x4 - 50) - 8.608*(x5 - 43) -
1359.469] <= Tcur &&
Abs[55.818*(x1 + 11) + 62.22*(x2 - 13) +
64.286*(x3 - 47) + 64.945*(x4 - 50) +
63.306*(x5 - 43) + 4747.69] <= Vcur}, {x1, x2, x3, x4,
x5}(*,Method\[Rule]"DifferentialEvolution"*)]] /.
Thread[{Gcur, Tcur, Vcur} -> {0.1`, 9, 900}] // ReleaseHold,
TraceInternal -> True],
_Experimental`NumericalFunction, Infinity] // Quiet
]
List @@ f
(*
Experimental`NumericalFunction[{x1, x2, x3, x4, x5},
Abs[x1] + Abs[x2] + Abs[x3] + Abs[x4] + Abs[x5], "-NumericalFunctionData-"]
{{Hold[Abs[x1] + Abs[x2] + Abs[x3] + Abs[x4] + Abs[x5]], Block},
{0,
{{{}, 1, 0, Hold[x1], 0, 0}, {{}, 1, 1, Hold[x2], 0, 0}, (* N.B. )
{{}, 1, 2, Hold[x3], 0, 0}, {{}, 1, 3, Hold[x4], 0, 0},
{{}, 1, 4, Hold[x5], 0, 0}}},
{{{1, 5, 817}, {{Automatic, Automatic, None, 1, Automatic}, {Automatic,
Automatic, None, 1, Automatic}}}},
{0, 3, {}, 0}, ( N.B. )
{924, MachinePrecision,
{{Automatic},
{Hold[Abs[x1] + Abs[x2] + Abs[x3] + Abs[x4] + Abs[x5]], Block}},
True,
{{Automatic, "CleanUpRegisters" -> False,
"WarningMessages" -> False, "EvaluateSymbolically" -> False,
"RuntimeErrorHandler" -> ($Failed &)},
{}, ( N.B. )
Automatic, "MVM"},
Experimental`NumericalFunction, Automatic, None},
{None, None, None}
}
)
When compare it with the solutions in the OP's output, we see there are three places where the expression does not conform to the above structure.
{foo, pt} =
Hold[NMinimize[{Abs[x1] + Abs[x2] + Abs[x3] + Abs[x4] + Abs[x5],
Abs[0.055*(x1 + 11) + 0.065*(x2 - 13) + 0.068*(x3 - 47) +
0.071*(x4 - 50) + 0.07*(x5 - 43) + 0.852] <= Gcur &&
Abs[-8.567*(x1 + 11) - 9.057*(x2 - 13) - 9.154*(x3 - 47) -
8.937*(x4 - 50) - 8.608*(x5 - 43) - 1359.469] <= Tcur &&
Abs[55.818*(x1 + 11) + 62.22*(x2 - 13) + 64.286*(x3 - 47) +
64.945*(x4 - 50) + 63.306*(x5 - 43) + 4747.69] <=
Vcur}, {x1, x2, x3, x4, x5}]] /.
Thread[{Gcur, Tcur, Vcur} -> {0.3`, 9, 900}] // ReleaseHold //
Quiet;
foo
(*
ExperimentalNumericalFunction[ {Hold[Abs[-599.2446539346419] + Abs[-142.17435987634218`] +
Abs[1.7430469375731925`] + Abs[307.5351957153216`] +
Abs[415.5751895785901`]], Block},
{0,
{{1, 0, Hold[-599.2446539346419`], 0, 0}, (* malformed variables )
{1, 1, Hold[-142.17435987634218`], 0, 0},
{1, 2, Hold[1.7430469375731925`], 0, 0}, {1, 3, Hold[307.5351957153216`], 0, 0},
{1, 4, Hold[415.5751895785901`], 0, 0}}},
{{{1, 5, 817}, {{Automatic, Automatic, None, 1, Automatic}, {Automatic,
Automatic, None, 1, Automatic}}}},
{0, 3, 0}, ( missing output spec {} )
{908, ( different code )
MachinePrecision,
{{Automatic}, {Hold[Abs[-599.2446539346419`] + Abs[-142.17435987634218`] +
Abs[1.7430469375731925`] + Abs[307.5351957153216`] +
Abs[415.5751895785901`]], Block}},
True,
{{Automatic, "CleanUpRegisters" -> False,
"WarningMessages" -> False, "EvaluateSymbolically" -> False,
"RuntimeErrorHandler" -> ($Failed &)},
( missing Compile RuntimeAttributes )
Automatic, "MVM"},
Experimental`NumericalFunction, Automatic, None},
{None, None, None}]
)
If we fix these, we get a well-formed Experimental`NumericalFunction:
fooFixed =
Experimental`NumericalFunction[{Hold[
Abs[-599.2446539346419`] + Abs[-142.17435987634218`] +
Abs[1.7430469375731925`] + Abs[307.5351957153216`] +
Abs[415.5751895785901`]], Block},
{0,
{{{}, 1, 0, Hold[x1], 0, 0}, (* malformed variables *)
{{}, 1, 1, Hold[x2], 0, 0}, {{}, 1, 2, Hold[x3], 0, 0},
{{}, 1, 3, Hold[x4], 0, 0}, {{}, 1, 4, Hold[x5], 0, 0}}},
{{{1, 5, 817}, {{Automatic, Automatic, None, 1, Automatic}, {Automatic,
Automatic, None, 1, Automatic}}}},
{0, 3, {}, 0}, (* missing output spec {} *)
{(*908*)924, (* unimportant here? *)
MachinePrecision,
{{Automatic}, {Hold[Abs[-599.2446539346419`] + Abs[-142.17435987634218`] +
Abs[1.7430469375731925`] + Abs[307.5351957153216`] +
Abs[415.5751895785901`]], Block}},
True, {{Automatic, "CleanUpRegisters" -> False,
"WarningMessages" -> False, "EvaluateSymbolically" -> False,
"RuntimeErrorHandler" -> ($Failed &)},
{}, (* missing Compile RuntimeAttributes *)
Automatic, "MVM"},
Experimental`NumericalFunction, Automatic, None},
{None, None, None}]
fooFixed[{0, 0, 0, 0, 0}]
(*
Experimental`NumericalFunction[{x1, x2, x3, x4, x5},
Abs[-599.245] + Abs[-142.174] + Abs[1.74305] + Abs[307.535] + Abs[415.575],
"-NumericalFunctionData-"]
1466.27
*)
Notes:
I am assuming the value of the Experimental`NumericalFunction is the minimum found by NMinimize.
The minimum value returned is different in the different versions! Perhaps specifying the initial points, as suggested in the suppressed warning NMinimize::incst, would help.
If I apply FindMinimum to either the good or the buggy case above (Gcur -> 0.1 or Gcur -> 0.3), it returns a smaller minimum.
The structure of Experimental`NumericalFunction changed between V8.0.4 and V9.0.1. The same sort of errors occur in both versions, and the same sort of fix can be performed. The code will be different, of course.
The code, 924 v. 908, does not make a difference in fooFixed[{0, 0, 0, 0, 0}]. How it affects other uses I do not know.
Simpler fix
Note that the first held expression is the formula for the function. One can evaluate the malformed Experimental`NumericalFunction as follows:
foo /. ef_Experimental`NumericalFunction :> ReleaseHold @ ef[[1, 1]] /. pt
or simply
ReleaseHold @ foo[[1,1]] /. pt
(* 1466.27 *)
In the OP's case the functions are constant, so that substituting (/. pt) the values of x1 etc is unnecessary. The OP's solution list can be fixed thus:
sol /. ef_Experimental`NumericalFunction :> ReleaseHold @ ef[[1, 1]]
Tableinstead ofParallelTable. So it is not related to parallel computing functionality. After a hour of waiting I have got two such objects: at{Gcur, Tcur, Vcur} = {0.3, 9, 900}and at{Gcur, Tcur, Vcur} = {0.3, 15, 150}. After restarting the kernel and evaluating{Gcur, Tcur, Vcur} = {0.3, 9, 900}and thenNminimize[...]I get a couple of error messages (first two areNMinimize::incst) and the object cited in the question. – Alexey Popkov Apr 25 '14 at 04:21