All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.engineblock.extensions.optimizers.MVLogger Maven / Gradle / Ivy

There is a newer version: 2.12.65
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy