io.engineblock.extensions.optimizers.MVLogger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eb-extensions Show documentation
Show all versions of eb-extensions Show documentation
Scripting extensions for engineblock.
package io.engineblock.extensions.optimizers;
import org.apache.commons.math3.analysis.MultivariateFunction;
import java.util.ArrayList;
import java.util.List;
public class MVLogger implements MultivariateFunction {
private final MultivariateFunction function;
List> log = new ArrayList<>();
public MVLogger(MultivariateFunction function) {
this.function = function;
}
@Override
public double value(double[] doubles) {
ArrayList params = new ArrayList<>(doubles.length);
log.add(params);
return function.value(doubles);
}
public List> getLogList() {
return log;
}
public double[][] getLogArray() {
double[][] ary = new double[log.size()][];
for (int row = 0; row < log.size(); row++) {
List columns = log.get(row);
double[] rowary = new double[columns.size()];
ary[row]=rowary;
for (int col = 0; col < log.get(row).size(); col++) {
rowary[col]=columns.get(col);
}
}
return ary;
}
}