当前位置: 首页>>代码示例>>Java>>正文


Java MultivariateFunction.value方法代码示例

本文整理汇总了Java中org.apache.commons.math3.analysis.MultivariateFunction.value方法的典型用法代码示例。如果您正苦于以下问题:Java MultivariateFunction.value方法的具体用法?Java MultivariateFunction.value怎么用?Java MultivariateFunction.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.analysis.MultivariateFunction的用法示例。


在下文中一共展示了MultivariateFunction.value方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doLineSearch

import org.apache.commons.math3.analysis.MultivariateFunction; //导入方法依赖的package包/类
static public LineSearchResult doLineSearch(
   final MultivariateFunction function,
   final double[] startingPoint,
   final double[] vectorDirection,
   final double[] domainMaxima,
   final double[] domainMinima
   ) {
   final double
      maximumDistanceToTravel = computeMaximumSearchDistanceFromDomainBounds(
         startingPoint, vectorDirection, domainMaxima, domainMinima);
   if(maximumDistanceToTravel == 0.)
      return new LineSearchResult(
         Arrays.copyOf(startingPoint, startingPoint.length), function.value(startingPoint));
   return doLineSearch(
      function, startingPoint, vectorDirection, maximumDistanceToTravel,
      DEFAULT_MAXIMUM_EVALUATIONS,
      DEFAULT_ERROR_TARGET_RELATIVE,
      DEFAULT_ERROR_TARGET_ABSOLUTE
      );
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:21,代码来源:BrentLineSearch.java

示例2: gradient

import org.apache.commons.math3.analysis.MultivariateFunction; //导入方法依赖的package包/类
public static double[] gradient(MultivariateFunction f, double[] x) {
    double[] grad = new double[x.length];
    for (int i = 0; i < x.length; i++) {
        double h = MachineAccuracy.SQRT_EPSILON * (Math.abs(x[i]) + 1.0);

        /* codeml step size: double h = 1e-6 * 2 * Math.abs(x[i] + 1.); */

        double oldx = x[i];
        x[i] = oldx + h;
        double fxplus = -f.value(x); // notice this is -ve! For L-BFGS-S [minimising] optimiser
        x[i] = oldx - h;
        double fxminus = -f.value(x); // notice this is -ve!
        x[i] = oldx;

        // Centered first derivative
        grad[i] = (fxplus - fxminus) / (2.0 * h);
    }
    return grad;
}
 
开发者ID:tamuri,项目名称:swmutsel,代码行数:20,代码来源:MathUtils.java

示例3: max

import org.apache.commons.math3.analysis.MultivariateFunction; //导入方法依赖的package包/类
@Override
public final Triple<double[], Double, Double> max(final MultivariateFunction test, final double[] initial) {
	Check.size(initial, 1, 999);
	final double initialTrain = value(initial);
	final double initialTest = test == null ? Double.NEGATIVE_INFINITY : test.value(initial);
	PointValuePair result = new PointValuePair(initial, initialTrain);
	Triple<double[], Double, Double> bestTrain = Triple.create(initial, initialTrain, initialTest);
	Triple<double[], Double, Double> bestTest = Triple.create(initial, initialTrain, initialTest);

	while (true) {
		result = iteration(result);
		if (result.getSecond() < bestTrain.getSecond() + convergence.getAbsoluteThreshold()) {
			log("RESULT", result);
			break;
		}
		final double testScore = test == null ? 0 : test.value(result.getFirst());
		bestTrain = Triple.create(result.getFirst(), result.getSecond(), testScore);
		if (test != null && testScore > bestTest.getThird()) {
			bestTest = bestTrain;
		}
		// todo: prevent doing NM twice
		if (bounds == null) {
			break;
		}
	}

	if (test == null) {
		return bestTrain;
	}
	final double improveTrain = bestTrain.getSecond() - bestTest.getSecond();
	final double improveTest = bestTest.getThird() - bestTrain.getThird();
	if (improveTest > improveTrain) {
		logger.info(bestTrain + " vs. " + bestTest);
	}
	return improveTest > improveTrain ? bestTest : bestTrain;
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:37,代码来源:AbstractOptimizable.java

示例4: evaluate

import org.apache.commons.math3.analysis.MultivariateFunction; //导入方法依赖的package包/类
/**
 * Evaluate all the non-evaluated points of the simplex.
 *
 * @param evaluationFunction Evaluation function.
 * @param comparator Comparator to use to sort simplex vertices from best to worst.
 * @throws org.apache.commons.math3.exception.TooManyEvaluationsException
 * if the maximal number of evaluations is exceeded.
 */
public void evaluate(final MultivariateFunction evaluationFunction,
                     final Comparator<PointValuePair> comparator) {
    // Evaluate the objective function at all non-evaluated simplex points.
    for (int i = 0; i < simplex.length; i++) {
        final PointValuePair vertex = simplex[i];
        final double[] point = vertex.getPointRef();
        if (Double.isNaN(vertex.getValue())) {
            simplex[i] = new PointValuePair(point, evaluationFunction.value(point), false);
        }
    }

    // Sort the simplex from best to worst.
    Arrays.sort(simplex, comparator);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:23,代码来源:AbstractSimplex.java


注:本文中的org.apache.commons.math3.analysis.MultivariateFunction.value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。