Group Abstract Group Abstract

Message Boards Message Boards

0
|
6.8K Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

NMinimize "Function value is not a number" problem

Posted 5 years ago

I am trying to calculate the root mean squared deviation (RMSD) and minimise it using NMinimize between experimental data and a model. My model function has 2 parameters and the value of the function is an output from an external program which Mathematica calls and provides the inputs. The 2 parameters to be optimised by NMinimize are these inputs.

NMinimize runs for a while and complains that the function value is not a number at {x,y} (x, and y are the parameters). Whereas if I evaluate the function at those {x,y}, I do get an output which is a number. Any idea what is going wrong ? Below I paste part of my code:

simu[{x_?NumberQ, y_?NumberQ}] := (Interpreter["Number"][
   StringSplit[
    RunProcess[{"/program" , 
      "path/to/script/", ToString[x], ToString[y]]}, 
     "StandardOutput"]]])

RMSD[A_, B_, N_] := Sqrt[(Plus @@ ((A - B)^2)/N)]

NMinimize[RMSD[data, simu[{x, y}], 10], , {x, y}, MaxIterations -> 100]

Looking forward,

POSTED BY: Riddhiman Sarkar
2 Replies
POSTED BY: Martijn Froeling

Thanks a lot. I believe that was the issue.

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