2

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]}]
m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Jabber
  • 21
  • 1
  • Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey May 12 '15 at 21:15
  • In answer to your P.S., you cannot display Subscript variables in Mathematica format on StackExchange. This is, however, one of the lesser reasons for not using Subscript. – bbgodfrey May 12 '15 at 21:19
  • 2
    Subscript will not do what you want it to. See http://mathematica.stackexchange.com/questions/373 for more details and some workarounds. The very short version is Subscript[a,1]=3 assigns 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:36
  • 1
    Perhaps the conditions could be constructed, for example: n = 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

0 Answers0