I'm working on an optimization algorithm and need to store some of the data (generated by the algorithm) in a 2-dimensional array called matrix
, where row(i) contains the fitness score and parameter values of optimization vector(i).
Dim matrix(vectorCount() - 1, parameterCount()) As Double
Dim params(parameterCount() - 1) As Double
For i As Integer = 0 To vectorCount() - 1
matrix(i, 0) = vectorScore(i)
params = vectorValues(i)
For j As Integer = 0 To params.Length - 1
matrix(i, j+1) = params(j)
Next
Next
int vectorCount()
returns the number of vectors.
int parameterCount()
returns the number of parameters in each vector.
double vectorScore(
int vectorIndex)
returns the fitness score of a specified vector.
double[] vectorValues(
int vectorIndex)
returns the parameter values of a specified vector.
My question:
Is there a faster (i.e. more efficient) way to insert params
into matrix
?