List of usage examples for org.apache.commons.math3.optim MaxEval unlimited
public static MaxEval unlimited()
From source file:edu.uchc.octane.GaussianFitAstigmatism.java
/** * calculate the Z coordinate based on astigmatism *///from ww w . ja v a2 s. c o m void calculateZ() { if (calibration_ == null) { z_ = 0; return; } UnivariateFunction func = new UnivariateFunction() { @Override public double value(double z) { double sigmax = FastMath.sqrt(pvp_.getPoint()[3] / 2); double sigmay = FastMath.sqrt(pvp_.getPoint()[4] / 2); double vx = calibration_[0] + (z - calibration_[1]) * (z - calibration_[1]) * calibration_[2] - sigmax; double vy = calibration_[3] + (z - calibration_[4]) * (z - calibration_[4]) * calibration_[5] - sigmay; return vx * vx + vy * vy; } }; BrentOptimizer optimizer = new BrentOptimizer(1e-4, 1e-4); UnivariatePointValuePair upvp = optimizer.optimize(new UnivariateObjectiveFunction(func), GoalType.MINIMIZE, MaxEval.unlimited(), new SearchInterval(2 * z0min_ - z0max_, 2 * z0max_ - z0min_)); if (upvp.getValue() > errTol_) { throw (new ConvergenceException()); } z_ = upvp.getPoint(); }
From source file:norbert.mynemo.core.selection.SvdRecommenderSelector.java
/** * Evaluates the given recommender type for several configurations. The number of iterations and * the number of features for each evaluation is chosen via an optimizer. The number of evaluation * performed depends of the number of steps necessary for the evaluation results to converge. The * number of evaluations performed is also bounded by an internal maximum. * * <p>/*from ww w . ja va 2 s .com*/ * The given recommender type must be part of the SVD based family. * * @return all evaluations done during the selection process */ public Collection<RecommenderEvaluation> select(RecommenderType type, double minimumCoverage) { checkArgument(type.getFamily() == RecommenderFamily.SVD_BASED); // initialize necessary optimization data ConvergenceChecker<PointValuePair> checker = new MaxIterationChecker<PointValuePair>(CMAES_MAX_ITERATIONS); SvdRecommenderEvalFunction function = new SvdRecommenderEvalFunction(configuration, type, minimumCoverage); ObjectiveFunction objectiveFunction = new ObjectiveFunction(function); CMAESOptimizer optimizer = new CMAESOptimizer(CMAES_MAX_ITERATIONS, 1.0, true, 2, 0, new JDKRandomGenerator(), false, checker); MaxEval maxEval = MaxEval.unlimited(); GoalType goalType = GoalType.MINIMIZE; SimpleBounds bounds = new SimpleBounds(new double[] { MIN_SVD_FEATURES, MIN_SVD_ITERATIONS }, new double[] { MAX_SVD_FEATURES, MAX_SVD_ITERATIONS }); InitialGuess initialGuess = new InitialGuess( new double[] { INITIAL_GUESS_FEATURES, INITIAL_GUESS_ITERATIONS }); CMAESOptimizer.PopulationSize populationSize = new CMAESOptimizer.PopulationSize(16); CMAESOptimizer.Sigma sigma = new CMAESOptimizer.Sigma( new double[] { CMAES_SIGMA_FEATURE, CMAES_SIGMA_ITERATION }); // run the optimizer optimizer.optimize(objectiveFunction, goalType, initialGuess, populationSize, sigma, bounds, maxEval); return function.getEvaluations(); }