0
|
4307 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
GROUPS:

# Optimization without generating a huge analytical expression?

Posted 10 years ago
 Firstly, forgive me for my lack of knowledge of programming and Mathematica. I have an optimization problem involving very large matrices when they are in analytical form. If I tried to generate analytical expressions for what I want to optimize it would be computationally intractable (the matrices are only on the order of 10x10 but each element is many pages worth of analytical expression). But, if for each iteration of the optimization I could plug in the guessed values, compute the numerical value of each cell of the matrix, the problem would become very tractable. Is there a way I can do this with the existing Minimize, NMinimize or FindMinimum functions? To be even more specific, when I try to evaluate Minimize[A(x,y,z) . B(x,y,z) . C(x,y,z), {x,y,z}], where A, B and C are matrices and their dot product would become a huge analytical mess, Mathematica hangs trying to compute the expression before plugging in test values for optimization. How can I fix this or get around it by just plugging in values, evaluating each matrix to just a ~10x10 array of numbers, without building an analytical expression?
2 Replies
Sort By:
Posted 10 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^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}]; 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 10 years ago
 Works like a charm, thank you! Didn't see anything about the ?NumericQ in my previous searching.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.