I have a function wrapper, which is as defined below: Here I pass in a set of coefficients (inputArr), and a Tuple containing 2 double arrays.
The expected output is how many times the "WminObjectivefunction" shall be called and also to return the "FuncValue" which is basically "WminObjectivefunction" evaluated at "inputArr". Every time I call "WrapFunction" the array "inputArr" passed shall be different.
public void WrapFunction(out int ncalls, out double FuncValue, double[] inputArr, Tuple<List<double>, List<double>> arguments)
{
int calls = 0;//Number_of_FunctionEvaluations
// MASTER class instance
Master prismpy = new Master();
calls += 1;//Number_of_FunctionEvaluations_Increment
ncalls = calls;//Return_Number_of_FunctionEvaluations
FuncValue = prismpy.WminObjectivefunction(inputArr, arguments.Item1, arguments.Item2);//Return_FunctionValuation
}
Question1: I want to store the FuncValue as elements in an Array fsim, How can I command the WrapFunction to store the value as an array element denoted by an index. The following is what I tried, and the error is : Cannot implicitly convert 'void' to 'double'
// FSIM: put array in array of arrays
double[] fsim = new double[5];
int fcall;
fsim[0] = WrapFunction(out fcall, out fsim[0], _x0, args);
Question2: Is it necessary to call WrapFunction with all out arguments every time ? Is there a way if I just want to get either one of those two outputs?
ncallsalways going to be 1? In which case the only useful information is theFuncValueand you could just return it instead of using anoutparameter.