Group Abstract Group Abstract

Message Boards Message Boards

Optimization without generating a huge analytical expression?

Posted 12 years ago
POSTED BY: anon ymous
2 Replies
Posted 12 years ago

Is there any chance you might be able to adapt something like this?

In[1]:= Clear[x, y, z];
a = Table[
   x^RandomInteger[{0, 3}] y^RandomInteger[{0, 3}] z^RandomInteger[{0, 3}] + 
   x^RandomInteger[{0, 3}] y^RandomInteger[{0, 3}] z^RandomInteger[{0, 3}] + 
   x^RandomInteger[{0, 3}] y^RandomInteger[{0, 3}] z^RandomInteger[{0, 3}] - 
   x^RandomInteger[{0, 3}] y^RandomInteger[{0, 3}] z^RandomInteger[{0, 3}] + RandomReal[{-5, 5}], {10}, {10}];
b = Table[
   x^RandomInteger[{0, 3}] y^RandomInteger[{0, 3}] z^RandomInteger[{0, 3}] + 
    x^RandomInteger[{0, 3}] y^RandomInteger[{0, 3}] z^RandomInteger[{0, 3}] + 
    x^RandomInteger[{0, 3}] y^RandomInteger[{0, 3}] z^RandomInteger[{0, 3}] - 
    x^RandomInteger[{0, 3}] y^RandomInteger[{0, 3}] z^RandomInteger[{0, 3}] + RandomReal[{-5, 5}], {10}, {10}];
c = Table[
   x^RandomInteger[{0, 3}] y^RandomInt{0, 3}] z^RandomInteger[{0, 3}] + 
    x^RandomInteger[{0, 3}] y^RandomInteger[{0, 3}] z^RandomInteger[{0, 3}] + 
    x^RandomInteger[{0, 3}] y^RandomInteger[{0, 3}] z^RandomInteger[{0, 3}] - 
    x^RandomInteger[{0, 3}] y^RandomInteger[{0, 3}] z^RandomInteger[{0, 3}] + RandomReal[{-5, 5}], {10}, {10}];
n[vx_?NumericQ, vy_?NumericQ, vz_?NumericQ] := Module[{na, nb, nc},
   na = a /. {x -> vx, y -> vy, z -> vz};
   nb = b /. {x -> vx, y -> vy, z -> vz};
   nc = c /. {x -> vx, y -> vy, z -> vz};
   Norm[na.nb.nc]];
Timing[NMinimize[n[x, y, z], {x, y, z}, Method -> "RandomSearch"]]

Out[5]= {58.765577, {1395.32, {x -> 0.30773, y -> 0.808193, z -> -1.31719}}}

That forces numeric substitution for each of your matricies individually and then minimizes the norm of the dot in 30-60 seconds. Yours may be somewhat slower because your matricies are apparently far more complicated. We can't tell if this will work for you until you try it. Let yours run for an hour or so and see if it finishes or not.

POSTED BY: Bill Simpson
Posted 12 years ago

Works like a charm, thank you! Didn't see anything about the ?NumericQ in my previous searching.

POSTED BY: Updating Name
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard