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


Java PointValuePair.getValue方法代码示例

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


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

示例1: applyToNetwork

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
@Override
public double applyToNetwork(final MixedClearingNetwork network) {
   Preconditions.checkNotNull(network);
   final int dimension = network.getNumberOfEdges();
   
   final ResidualCostFunction aggregateCostFunction =
      super.getResidualScalarCostFunction(network);
   final RealVector
      start = new ArrayRealVector(network.getNumberOfEdges());
   start.set(1.0);                                       // Initial rate guess.
   
   final BOBYQAOptimizer optimizer = new BOBYQAOptimizer(2*dimension + 1, 1.2, 1.e-8);
   final PointValuePair result = optimizer.optimize(
      new MaxEval(maximumEvaluations),
      new ObjectiveFunction(aggregateCostFunction),
      GoalType.MINIMIZE,
      new SimpleBounds(new double[dimension], ArrayUtil.ones(dimension)),
      new InitialGuess(start.toArray())
      );
   
   final double residualCost = result.getValue();
   System.out.println("Network cleared: residual cost: " + residualCost + ".");
   
   return residualCost;
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:26,代码来源:BoundedQuadraticEstimationClearingAlgorithm.java

示例2: retrieveResults

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
private void retrieveResults(PointValuePair result) {
    int rows=suppliers.getValue();
    int cols=recipients.getValue();
    if (excessCheckbox.isSelected())
        cols++;
    double[] data=result.getPoint();
    for (int i = 0; i < rows; i++) {
        setVectorElement(excess,i,0);
    }
    for (int i = 0; i < data.length; i++) {
        int x=i%cols;
        int y=i/cols;
        if(x<recipients.getValue())
            setMatrixElement(this.result,y,x,data[i]);
        else
            setVectorElement(this.excess,y,data[i]);
    }
    double value=result.getValue();
    cost.setText(String.valueOf(value));
}
 
开发者ID:superdurszlak,项目名称:Transport-Production-Issue,代码行数:21,代码来源:Controller.java

示例3: getPairComparator

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
/**
 * @return a comparator for sorting the optima.
 */
private Comparator<PointValuePair> getPairComparator() {
    return new Comparator<PointValuePair>() {
        /** {@inheritDoc} */
        public int compare(final PointValuePair o1,
                           final PointValuePair o2) {
            if (o1 == null) {
                return (o2 == null) ? 0 : 1;
            } else if (o2 == null) {
                return -1;
            }
            final double v1 = o1.getValue();
            final double v2 = o2.getValue();
            return (optimizer.getGoalType() == GoalType.MINIMIZE) ?
                Double.compare(v1, v2) : Double.compare(v2, v1);
        }
    };
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:21,代码来源:MultiStartMultivariateOptimizer.java

示例4: getPairComparator

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
/**
 * @return a comparator for sorting the optima.
 */
private Comparator<PointValuePair> getPairComparator() {
    return new Comparator<PointValuePair>() {
        public int compare(final PointValuePair o1,
                           final PointValuePair o2) {
            if (o1 == null) {
                return (o2 == null) ? 0 : 1;
            } else if (o2 == null) {
                return -1;
            }
            final double v1 = o1.getValue();
            final double v2 = o2.getValue();
            return (optimizer.getGoalType() == GoalType.MINIMIZE) ?
                Double.compare(v1, v2) : Double.compare(v2, v1);
        }
    };
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:20,代码来源:MultiStartMultivariateOptimizer.java

示例5: testMath283

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
@Test
public void testMath283() {
    // fails because MultiDirectional.iterateSimplex is looping forever
    // the while(true) should be replaced with a convergence check
    SimplexOptimizer optimizer = new SimplexOptimizer(1e-14, 1e-14);
    final Gaussian2D function = new Gaussian2D(0, 0, 1);
    PointValuePair estimate = optimizer.optimize(new MaxEval(1000),
                                                 new ObjectiveFunction(function),
                                                 GoalType.MAXIMIZE,
                                                 new InitialGuess(function.getMaximumPosition()),
                                                 new MultiDirectionalSimplex(2));
    final double EPSILON = 1e-5;
    final double expectedMaximum = function.getMaximum();
    final double actualMaximum = estimate.getValue();
    Assert.assertEquals(expectedMaximum, actualMaximum, EPSILON);

    final double[] expectedPosition = function.getMaximumPosition();
    final double[] actualPosition = estimate.getPoint();
    Assert.assertEquals(expectedPosition[0], actualPosition[0], EPSILON );
    Assert.assertEquals(expectedPosition[1], actualPosition[1], EPSILON );
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:22,代码来源:SimplexOptimizerMultiDirectionalTest.java

示例6: applyToNetwork

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
@Override
public double applyToNetwork(final MixedClearingNetwork network) {
   Preconditions.checkNotNull(network);
   final SimplexOptimizer optimizer = new SimplexOptimizer(relErrorTarget, absErrorTarget);
   
   final ResidualCostFunction aggregateCostFunction =
      super.getResidualScalarCostFunction(network);
   final RealVector
      start = new ArrayRealVector(network.getNumberOfEdges());
   for(int i = 0; i< network.getNumberOfEdges(); ++i)
      start.setEntry(i, network.getEdges().get(i).getMaximumRateAdmissibleByBothParties());
   start.set(1.);
   
   final PointValuePair result = optimizer.optimize(
      new MaxEval(maximumEvaluations),
      new ObjectiveFunction(aggregateCostFunction),
      GoalType.MINIMIZE,
      new InitialGuess(start.toArray()),
      new NelderMeadSimplex(network.getNumberOfEdges())
      );
   
   final double residualCost = result.getValue();
   System.out.println("Network cleared: residual cost: " + residualCost + ".");
   
   return residualCost;
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:27,代码来源:NelderMeadClearingAlgorithm.java

示例7: select

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
private PointValuePair select(final String method, final PointValuePair newResult, final PointValuePair oldResult) {
	if (newResult.getValue() < oldResult.getValue()
			|| convergence.trainMax != null && newResult.getValue() > convergence.trainMax) {
		log(method + " (rejc.)", newResult);
		return oldResult;
	}
	log(method, newResult);
	return newResult;
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:10,代码来源:AbstractOptimizable.java

示例8: converged

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
@Override
public boolean converged(final int iteration, final PointValuePair previous, final PointValuePair current) {
	if (++it >= maxIt) {
		return true;
	}
	if (trainMax != null && current.getValue() >= trainMax) {
		return true;
	}
	return super.converged(iteration, previous, current);
}
 
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:11,代码来源:Convergence.java

示例9: doOptimize

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    checkParameters();

    // Indirect call to "computeObjectiveValue" in order to update the
    // evaluations counter.
    final MultivariateFunction evalFunc
        = new MultivariateFunction() {
            /** {@inheritDoc} */
            public double value(double[] point) {
                return computeObjectiveValue(point);
            }
        };

    final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
    final Comparator<PointValuePair> comparator
        = new Comparator<PointValuePair>() {
        /** {@inheritDoc} */
        public int compare(final PointValuePair o1,
                           final PointValuePair o2) {
            final double v1 = o1.getValue();
            final double v2 = o2.getValue();
            return isMinim ? Double.compare(v1, v2) : Double.compare(v2, v1);
        }
    };

    // Initialize search.
    simplex.build(getStartPoint());
    simplex.evaluate(evalFunc, comparator);

    PointValuePair[] previous = null;
    int iteration = 0;
    final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();
    while (true) {
        if (getIterations() > 0) {
            boolean converged = true;
            for (int i = 0; i < simplex.getSize(); i++) {
                PointValuePair prev = previous[i];
                converged = converged &&
                    checker.converged(iteration, prev, simplex.getPoint(i));
            }
            if (converged) {
                // We have found an optimum.
                return simplex.getPoint(0);
            }
        }

        // We still need to search.
        previous = simplex.getPoints();
        simplex.iterate(evalFunc, comparator);

        incrementIterationCount();
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:56,代码来源:SimplexOptimizer.java

示例10: doOptimize

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected PointValuePair doOptimize() {
    checkParameters();

    // Indirect call to "computeObjectiveValue" in order to update the
    // evaluations counter.
    final MultivariateFunction evalFunc
        = new MultivariateFunction() {
            public double value(double[] point) {
                return computeObjectiveValue(point);
            }
        };

    final boolean isMinim = getGoalType() == GoalType.MINIMIZE;
    final Comparator<PointValuePair> comparator
        = new Comparator<PointValuePair>() {
        public int compare(final PointValuePair o1,
                           final PointValuePair o2) {
            final double v1 = o1.getValue();
            final double v2 = o2.getValue();
            return isMinim ? Double.compare(v1, v2) : Double.compare(v2, v1);
        }
    };

    // Initialize search.
    simplex.build(getStartPoint());
    simplex.evaluate(evalFunc, comparator);

    PointValuePair[] previous = null;
    int iteration = 0;
    final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();
    while (true) {
        if (getIterations() > 0) {
            boolean converged = true;
            for (int i = 0; i < simplex.getSize(); i++) {
                PointValuePair prev = previous[i];
                converged = converged &&
                    checker.converged(iteration, prev, simplex.getPoint(i));
            }
            if (converged) {
                // We have found an optimum.
                return simplex.getPoint(0);
            }
        }

        // We still need to search.
        previous = simplex.getPoints();
        simplex.iterate(evalFunc, comparator);

        incrementIterationCount();
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:54,代码来源:SimplexOptimizer.java

示例11: solve

import org.apache.commons.math3.optim.PointValuePair; //导入方法依赖的package包/类
public Optimisation.Result solve(final Result kickStarter) {

        //        final InitialGuess guess = new InitialGuess(kickStarter.toRawCopy1D());
        //
        //        myModelData.add(guess);

        Optimisation.State state = Optimisation.State.FAILED;
        double value = Double.NaN;
        Access1D<?> solution = kickStarter;

        try {

            final SimplexSolver solver = new SimplexSolver();

            DEFAULT.configure(solver, myOptions);
            final Optional<Configurator> optional = myOptions.getConfigurator(Configurator.class);
            if (optional.isPresent()) {
                optional.get().configure(solver, myOptions);
            }

            final PointValuePair solutionAndValue = solver.optimize(myModelData.toArray(new OptimizationData[myModelData.size()]));

            state = Optimisation.State.OPTIMAL;
            value = solutionAndValue.getValue();
            solution = Access1D.wrap(solutionAndValue.getPoint());

        } catch (final NoFeasibleSolutionException infeasible) {

            state = Optimisation.State.INFEASIBLE;

        } catch (final UnboundedSolutionException unbounded) {

            state = Optimisation.State.UNBOUNDED;
        }

        final Optimisation.Result result = new Optimisation.Result(state, value, solution);

        return result;
    }
 
开发者ID:optimatika,项目名称:ojAlgo-extensions,代码行数:40,代码来源:SolverCommonsMath.java


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