I'm trying to do something very straight forward. The following maximization works:
Maximize[{
(Subscript[a, 1] + Subscript[a, 2]),
Sum[Subscript[a, x], {x, 1, 2}] == 1 ,
0 <= Subscript[a, 1] <= 1,
0 <= Subscript[a, 2] <= 1},
{Subscript[a, 1], Subscript[a, 2]}]
{1, {Subscript[a, 1] -> 1, Subscript[a, 2] -> 0}}
Now I'd like to do something identical, but using ForAll. I need to do this because the real optimization I'm trying to do will have 144 variables, most easily defined by subscripts.
Why doesn't the following work?
Maximize[{
Subscript[a, 1] - Subscript[a, 2],
Sum[Subscript[a, x], {x, 1, 2}] == 1 ,
Resolve[ForAll[x, x ∈ Integers && 1 <= x < 2, Subscript[a, x] >= 0]]},
{Subscript[a, 1], Subscript[a, 2]}]
Maximize[{ Subscript[a, 1] - Subscript[a, 2], Subscript[a, 1] + Subscript[a, 2] == 1, ForAll[{x}, x ∈ Integers && 1 <= x < 2, Subscript[a, x] >= 0]}, {Subscript[a, 1], Subscript[a, 2]}]
Subscriptvariables in Mathematica format on StackExchange. This is, however, one of the lesser reasons for not usingSubscript. – bbgodfrey May 12 '15 at 21:19Subscript[a,1]=3assigns a value to the function Subscript (when evaluated at (a,1)), it does not create a symbol $a_1$. – Eric Towers May 12 '15 at 23:36n = 144; vars = Array[a, n]; obj = Sum[a[k], {k, n}]; cons = Table[0 <= a[k] <= 1, {k, n}]; Maximize[Join[{obj}, cons], vars]– ilian May 13 '15 at 11:59