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,