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

net.sourceforge.cilib.tuning.parameterchange.reactions.MinMaxParameterChangeReaction Maven / Gradle / Ivy

Go to download

A library of composable components enabling simpler Computational Intelligence

There is a newer version: 0.8
Show newest version
/**           __  __
 *    _____ _/ /_/ /_    Computational Intelligence Library (CIlib)
 *   / ___/ / / / __ \   (c) CIRG @ UP
 *  / /__/ / / / /_/ /   http://cilib.net
 *  \___/_/_/_/_.___/
 */
package net.sourceforge.cilib.tuning.parameterchange.reactions;

import fj.*;
import fj.data.List;
import static fj.data.List.replicate;
import net.sourceforge.cilib.tuning.TuningAlgorithm;
import net.sourceforge.cilib.tuning.parameterlist.SobolParameterListProvider;
import net.sourceforge.cilib.tuning.parameters.TuningBounds;
import net.sourceforge.cilib.type.types.Numeric;
import net.sourceforge.cilib.type.types.container.Vector;
import static net.sourceforge.cilib.util.functions.Numerics.doubleValue;
import net.sourceforge.cilib.util.functions.Utils;
import static net.sourceforge.cilib.util.functions.Utils.pairwise;

public class MinMaxParameterChangeReaction extends ParameterChangeReaction {

    @Override
    public List f(TuningAlgorithm a) {
        final SobolParameterListProvider sobol = new SobolParameterListProvider();
        sobol.setCount((int) count.getParameter());

        List> pars = a.getParameterList().map(Utils.iterableList()
            .andThen(List.map_().f(doubleValue())));
        int size = pars.head().length();
        List min = pars.foldLeft(pairwise(Ord.doubleOrd.min), replicate(size, Double.MAX_VALUE));
        List max = pars.foldLeft(pairwise(Ord.doubleOrd.max), replicate(size, Double.MIN_VALUE));

        min.zip(max).map(new F, TuningBounds>() {
            @Override
            public TuningBounds f(P2 a) {
                return new TuningBounds(a._1(), a._2());
            }            
        }).foreach(new F() {
            @Override
            public Unit f(TuningBounds a) {
                sobol.addParameterBounds(a);
                return Unit.unit();
            }
        });

        return sobol._1();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy