| Author |
Comment/Response |
toen
|
02/22/12 09:22am
g'day Dave,
I'd do the following:
fn[t_] := Product[(1 - t[[i]]), {i, 1, Length@t}];
maxFn[vectorLength_] :=
Module[{x, vars = Array[x, vectorLength], constraints},
constraints = ((0 <= # <= 1) & /@ vars)~Join~{Plus @@ vars == 1};
Maximize[{fn[vars], constraints}, vars]]
This will take quite a while to run for all but the smallest vector lengths, see for example:
Table[Timing[maxFn[j]], {j, 1, 5}]
cheers,
toen
URL: , |
|