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

net.sourceforge.cilib.tuning.parameterlist.SobolParameterListProvider Maven / Gradle / Ivy

/**           __  __
 *    _____ _/ /_/ /_    Computational Intelligence Library (CIlib)
 *   / ___/ / / / __ \   (c) CIRG @ UP
 *  / /__/ / / / /_/ /   http://cilib.net
 *  \___/_/_/_/_.___/
 */
package net.sourceforge.cilib.tuning.parameterlist;

import fj.F;
import fj.P2;
import fj.data.List;
import fj.data.Stream;
import net.sourceforge.cilib.math.random.generator.Rand;
import net.sourceforge.cilib.math.random.generator.quasi.Sobol;
import net.sourceforge.cilib.tuning.parameters.TuningBounds;
import net.sourceforge.cilib.type.types.container.Vector;
import net.sourceforge.cilib.util.functions.Utils;

public class SobolParameterListProvider extends ParameterListProvider {
    
    private List parameters;
    private int count;
    private int precision;
    
    public SobolParameterListProvider() {
        this.parameters = List.nil();
        this.count = 1000;
        this.precision = 4;
    }

    @Override
    public List _1() {
        final Sobol sobol = new Sobol(Rand.nextLong());
        sobol.setDimensions(parameters.length());
        
        return Stream.range(0, count).map(new F() {
            @Override
            public Vector f(Integer a) {
                final double[] p = sobol.nextPoint();
                return Vector.copyOf(parameters.zipIndex()
                    .map(new F, Double>() {
                        @Override
                        public Double f(P2 a) {
                            return p[a._2()] * a._1().getRange() + a._1().getLowerBound();
                        }                    
                    }.andThen(Utils.precision(precision))));
            }            
        }).toList();
    }
    
    public void addParameterBounds(TuningBounds p) {
        parameters = parameters.snoc(p);
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getCount() {
        return count;
    }

    public void setPrecision(int precision) {
        this.precision = precision;
    }

    public int gtPrecision() {
        return precision;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy