Example usage for org.apache.commons.math3.optim MaxIter MaxIter

List of usage examples for org.apache.commons.math3.optim MaxIter MaxIter

Introduction

In this page you can find the example usage for org.apache.commons.math3.optim MaxIter MaxIter.

Prototype

public MaxIter(int max) 

Source Link

Usage

From source file:org.lightjason.agentspeak.action.buildin.math.linearprogram.CSolve.java

@Override
public final IFuzzyValue<Boolean> execute(final IContext p_context, final boolean p_parallel,
        final List<ITerm> p_argument, final List<ITerm> p_return, final List<ITerm> p_annotation) {
    // first argument is the LP pair object, second argument is the goal-type (maximize / minimize),
    // third & fourth argument can be the number of iterations or string with "non-negative" variables
    final List<OptimizationData> l_settings = new LinkedList<>();

    final Pair<LinearObjectiveFunction, Collection<LinearConstraint>> l_default = p_argument.get(0).raw();
    l_settings.add(l_default.getLeft());
    l_settings.add(new LinearConstraintSet(l_default.getRight()));

    p_argument.subList(1, p_argument.size()).stream().map(i -> {
        if (CCommon.rawvalueAssignableTo(i, Number.class))
            return new MaxIter(i.raw());

        if (CCommon.rawvalueAssignableTo(i, String.class))
            switch (i.<String>raw().trim().toLowerCase()) {
            case "non-negative":
                return new NonNegativeConstraint(true);
            case "maximize":
                return GoalType.MAXIMIZE;
            case "minimize":
                return GoalType.MINIMIZE;

            default:
                return null;
            }/*from w  w w  . ja  va 2  s .  com*/

        return null;
    }).filter(Objects::nonNull).forEach(l_settings::add);

    // optimze and return
    final SimplexSolver l_lp = new SimplexSolver();
    final PointValuePair l_result = l_lp.optimize(l_settings.toArray(new OptimizationData[l_settings.size()]));

    p_return.add(CRawTerm.from(l_result.getValue()));
    p_return.add(CRawTerm.from(l_result.getPoint().length));
    Arrays.stream(l_result.getPoint()).boxed().map(CRawTerm::from).forEach(p_return::add);

    return CFuzzyValue.from(true);
}

From source file:org.lightjason.agentspeak.action.builtin.math.linearprogram.CSolve.java

@Nonnull
@Override//from  w  w  w .j  av  a 2 s  .  c  o  m
public final IFuzzyValue<Boolean> execute(final boolean p_parallel, @Nonnull final IContext p_context,
        @Nonnull final List<ITerm> p_argument, @Nonnull final List<ITerm> p_return) {
    // first argument is the LP pair object, second argument is the goal-type (maximize / minimize),
    // third & fourth argument can be the number of iterations or string with "non-negative" variables
    final List<OptimizationData> l_settings = new LinkedList<>();

    final Pair<LinearObjectiveFunction, Collection<LinearConstraint>> l_default = p_argument.get(0).raw();
    l_settings.add(l_default.getLeft());
    l_settings.add(new LinearConstraintSet(l_default.getRight()));

    p_argument.subList(1, p_argument.size()).stream().map(i -> {
        if (CCommon.rawvalueAssignableTo(i, Number.class))
            return new MaxIter(i.raw());

        if (CCommon.rawvalueAssignableTo(i, String.class))
            switch (i.<String>raw().trim().toLowerCase()) {
            case "non-negative":
                return new NonNegativeConstraint(true);
            case "maximize":
                return GoalType.MAXIMIZE;
            case "minimize":
                return GoalType.MINIMIZE;

            default:
                return null;
            }

        return null;
    }).filter(Objects::nonNull).forEach(l_settings::add);

    // optimze and return
    final SimplexSolver l_lp = new SimplexSolver();
    final PointValuePair l_result = l_lp.optimize(l_settings.toArray(new OptimizationData[l_settings.size()]));

    p_return.add(CRawTerm.from(l_result.getValue()));
    p_return.add(CRawTerm.from(l_result.getPoint().length));
    Arrays.stream(l_result.getPoint()).boxed().map(CRawTerm::from).forEach(p_return::add);

    return CFuzzyValue.from(true);
}

From source file:put.ci.cevo.framework.algorithms.ApacheCMAES.java

public void optimize(EvolutionTarget target, int populationSize, double sigma, double[] guess,
        PopulationEvaluator<double[]> populationEvaluator) {
    this.maxIterations = ((GenerationsTarget) target).getGenerations();
    this.populationEvaluator = populationEvaluator;
    optimize(new MaxIter(maxIterations), new PopulationSize(populationSize),
            new Sigma(DoubleArrays.vector(sigma, guess.length)), new InitialGuess(guess), GoalType.MAXIMIZE,
            new SimpleBounds(DoubleArrays.vector(Double.NEGATIVE_INFINITY, guess.length),
                    DoubleArrays.vector(Double.POSITIVE_INFINITY, guess.length)));
}