I'm trying to minimize a non-linear function of four variables with some linear constraints. NMinimize on Mathematica 8 seems to go out of bounds on some constraints giving complex values of the function at some point in the iteration. The function to minimize is
ff[lxw_, lwz_, c_, d_] := - J1 (lxw + lwz) - 2 J2 c +
T (-Log[2] - 1/2 (1 - lxw) Log[(1 - lxw)/4] -
1/2 (1 + lxw) Log[(1 + lxw)/4] -
1/2 (1 - lwz) Log[(1 - lwz)/4] -
1/2 (1 + lwz) Log[(1 + lwz)/4] + 1/2 (1 - d) Log[(1 - d)/16] +
1/8 (1 + 2 c + d - 2 lwz - 2 lxw) Log[
1/16 (1 + 2 c + d - 2 lwz - 2 lxw)])
where
T = 10;
J1 = 1;
J2 = -0.2;
are constant parameters. The constraints are
var = {lxw, lwz, c, d};
cons = And @@ Cases[ff @@ var, Log[x_] -> x > 0, Infinity] // Simplify
which amounts to
d < 1 && lwz < 1 && 1 + lwz > 0 && 1 + 2 c + d > 2 (lwz + lxw) &&
lxw < 1 && 1 + lxw > 0
Then
NMinimize[{ff @@ var, cons}, var, Method -> "DifferentialEvolution"]
gives
NMinimize::nrnum: The function value 7.60939\[VeryThinSpace]-3.87314 I
is not a real number at {c,d,lwz,lxw} = {-0.267966,0.319033,0.899803,-0.0151082}. >>
{-12.5741, {c -> -0.236255, d -> -0.978425, lwz -> -0.681637,
lxw -> -0.939595}}
Thread[var->theBadSet]
. The message states that it is using a reordering ofvar
and for that the value is indeed complex. $\endgroup$