0
|
3367 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Why Doesn't EvaluateSymbolically work inside FindMinimum?

Posted 9 years ago
 A compiled function generated with EvaluateSymbolically -> True still gives a CompiledFunction symbolic argument error when used as the objective function in FindMinimum In[1]:= expr = E^Sin[50 x] + Sin[60 E^y] + Sin[70 Sin[x]] + Sin[Sin[80 y]] - Sin[10 (x + y)] + 1/4 (x^2 + y^2); In[2]:= cexpr = Compile[{x, y}, Evaluate[expr]]; In[4]:= FindMinimum[cexpr[x, y], {{x, 1}, {y, 1}}] During evaluation of In[4]:= CompiledFunction::cfsa: Argument x at position 1 should be a machine-size real number. >> Out[4]= {-0.342853, {x -> 0.953282, y -> 0.291998}} In[5]:= cexpr1 = Compile[{x, y}, Evaluate[expr], RuntimeOptions -> {"EvaluateSymbolically" -> True}]; In[6]:= FindMinimum[cexpr1[x, y], {{x, 1}, {y, 1}}] During evaluation of In[6]:= CompiledFunction::cfsa: Argument x at position 1 should be a machine-size real number. >> Out[6]= {-0.342853, {x -> 0.953282, y -> 0.291998}} 
4 Replies
Sort By:
Posted 9 years ago
 I think you are actually looking for RuntimeOptions -> {"EvaluateSymbolically" -> False} 
Posted 9 years ago
 I would have thought it would be the other way around. Unless FindMinimum checks to see what the setting of EvaluateSymbolically is.
Posted 9 years ago
 As documented, FindMinimum evaluates cexpr1[x, y] with symbolic x and y first. In this example, cexpr1 happens to be a compiled function, which means there will be a CompiledFunction::cfsa message -- unless cexpr1[x, y] was explicitly forced to stay unevaluated, which is what EvaluateSymbolically -> False does.
Posted 9 years ago
 Ok, that all makes sense. Now I'd like to know why FindMinimum runs faster with a compiled objective function with the option EvaluateSymbolically -> False as compared to True.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.