Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.2K Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Summation indices inside of NMaximize

Posted 12 years ago

Hello!

Why don't the following commands produce equivalent results?

NMaximize[{10 *(-d[1] + d[2])^4* q[1, 2]^4 + (-d[1] + d[2])^2* 
    q[1, 2]^2* (4* q[1, 2]^2 + (q[1, 1] - q[2, 2])^2) - 
   6 *(d[1] - d[2])^3 *
    q[1, 2]^2 (q[1, 1] - q[2, 2]) (d[1] *q[1, 1] + d[2]* q[2, 2]) + 
   2 *(d[1] - d[2])^4* q[1, 2]^2 *(d[1]* q[1, 1] + d[2]* q[2, 2])^2, 
  d[1]^2 + d[2]^2 == 1, 
  q[1, 1]^2 + 2*q[1, 2]^2 + q[2, 2]^2 == 1}, {q[1, 1], q[1, 2], 
  q[2, 2], d[1], d[2]}]

and

NMaximize[{10 *(-x + y)^4 *b^4 + (-x + y)^2* 
    b^2 *(4* b^2 + (a - c)^2) - 
   6 (x - y)^3* b^2 (a - c)* (x* a + y *c) + 
   2 *(x - y)^4 *b^2*(x *a + y *c)^2, x^2 + y^2 == 1, 
  a^2 + 2*b^2 + c^2 == 1}, {a, b, c, x, y}]

For the first I get output :

NMaximize::nosat: Obtained solution does not satisfy the following constraints within Tolerance -> 0.001`: {1-d[1]^2-d[2]^2==0,1-q[1,1]^2-2 q[1,2]^2-q[2,2]^2==0}. >>

For the second I get (correct) output:

{12.0002, {a -> 1.01851*10^-6, b -> -0.707108, c -> -3.9843*10^-7, 
  x -> -0.707108, y -> 0.70711}}

The first comes from using a summation index inside a NMaximize routine and I get the wrong result. When I replace the indexed variables with a,b,c,x,y then I get the correct results. I want to be able to vary the limit of summation for such functions and optimize them but it is not computing correctly.

Thanks!

POSTED BY: PW Laslo
4 Replies

The issue seems to appear when Method->"NelderMead" is used. Using "DifferentialEvolution" or "SimulatedAnnealing" works fine for the first example.

It is a bit strange since Method->"NelderMead" works fine on the second example. The variable names do influence the algebraic form given to NMaximize, but I didn't see any obvious evidence that was the issue. It might still be the case.

Anyway, long story short, I'd try using Method->"DifferentialEvolution".

POSTED BY: Sean Clarke
Posted 12 years ago

Sean changing the method works, thanks!

POSTED BY: PW Laslo
POSTED BY: David Reiss
POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard