本文整理汇总了Java中org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer类的典型用法代码示例。如果您正苦于以下问题:Java MultivariateOptimizer类的具体用法?Java MultivariateOptimizer怎么用?Java MultivariateOptimizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultivariateOptimizer类属于org.apache.commons.math3.optim.nonlinear.scalar包,在下文中一共展示了MultivariateOptimizer类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: optimize
import org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer; //导入依赖的package包/类
private PointValuePair optimize(final MultivariateOptimizer optimizer, final double[] initialValues,
final OptimizationData... data) {
final OptimizationData[] d = new OptimizationData[5 + data.length];
d[0] = new MaxIter(convergence.maxIt + 1);
d[1] = new MaxEval(convergence.maxIt * 2);
d[2] = new ObjectiveFunction(this);
d[3] = GoalType.MAXIMIZE;
d[4] = new InitialGuess(fixBounds(initialValues));
for (int i = 0; i < data.length; ++i) {
d[5 + i] = data[i];
}
return optimizer.optimize(d);
}
开发者ID:ProfilingIO,项目名称:insight-ml,代码行数:14,代码来源:AbstractOptimizable.java
示例2: solve
import org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer; //导入依赖的package包/类
@Override
public synchronized void solve(Objenome o, List<SetNumericValue> variables) {
this.variables = variables;
this.objenome = o;
if (numStarts==-1)
numStarts = variables.size() * 2;
double[] lower = new double[variables.size()];
double[] upper = new double[variables.size()];
double[] mid = new double[variables.size()];
int j = 0;
for (SetNumericValue n : variables) {
lower[j] = n.getMin().doubleValue();
upper[j] = n.getMax().doubleValue();
mid[j] = (lower[j] + upper[j]) * 0.5f;
j++;
}
//TODO add MultiStart
MultivariateOptimizer optimize =
new BOBYQAOptimizer(variables.size()*2);
//new PowellOptimizer(0.01, 0.05);
RandomGenerator rng = getRandomGenerator();
MultiStartMultivariateOptimizer multiOptimize = new MultiStartMultivariateOptimizer(optimize, numStarts, new UncorrelatedRandomVectorGenerator(variables.size(), new UniformRandomGenerator(rng)));
PointValuePair result = multiOptimize.optimize(
new MaxEval(evaluations),
new SimpleBounds(lower, upper),
goal,
new InitialGuess(mid),
new ObjectiveFunction(this)
);
apply(result.getPointRef());
this.bestValue = result.getValue();
}
开发者ID:automenta,项目名称:objenome_prototype,代码行数:43,代码来源:OptimizeMultivariate.java
示例3: optimiseModel
import org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer; //导入依赖的package包/类
public Pair<Double, SubstitutionModel> optimiseModel(final Tree tree, final SubstitutionModel model) {
double[] startingValues = Mapper.getOptimisable(model.getParameters());
PointValuePair optima;
setRunnerTree(tree);
SubstitutionModelFunction function = new SubstitutionModelFunction(model, this);
ConvergenceChecker<PointValuePair> convergenceChecker = new SimpleValueChecker(-1, Constants.CONVERGENCE_TOL);
//int n = initialGuess.length;
//MultivariateOptimizer optimiser = new BOBYQAOptimizer(2 * n + 1);
MultivariateOptimizer optimiser = new NativeLBFGSBMultivariateOptimizer(convergenceChecker);
//MultivariateOptimizer optimiser = new SimplexOptimizer(convergenceChecker);
try {
optima = optimiser.optimize(new ObjectiveFunction(function),
GoalType.MAXIMIZE,
new InitialGuess(startingValues),//,
new NelderMeadSimplex(startingValues.length),
new MaxEval(Constants.MAX_EVALUATIONS)
);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
System.out.println(" " + optimiser.getEvaluations() + " evaluations");
if (optima == null)
throw new RuntimeException("ERROR: Runner.optimiseMutationParameters was unsuccessful (optima == null).");
double[] d = optima.getPoint();
Mapper.setOptimisable(model.getParameters(), d);
model.build();
//CoreUtils.msg("Runner.optimiseMutationParameters optima: %s -> %s\n", Doubles.join(",", optima.getPoint()), optima.getValue());
return Pair.of(optima.getValue(), model);
}
开发者ID:tamuri,项目名称:swmutsel,代码行数:43,代码来源:Runner.java
示例4: optimiseMutationParameters
import org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer; //导入依赖的package包/类
public Pair<Double, SwMut> optimiseMutationParameters(final Tree tree, final SwMut mutation, final FitnessStore fitnesses, final Penalty penalty) {
double[] startingValues = Mapper.getOptimisable(mutation.getParameters());
PointValuePair optima;
// To improve performance (esp. the distributed runner), we set the tree
// and fitnesses for the runner so they do not need to be sent over the
// wire each iteration
setRunnerTree(tree);
setRunnerFitnesses(fitnesses);
setRunnerPenalty(penalty);
CoreUtils.msg("Optimising mutation parameters: ");
SwMutFunction function = new SwMutFunction(mutation, this);
ConvergenceChecker<PointValuePair> convergenceChecker = new SimpleValueChecker(-1, Constants.CONVERGENCE_TOL);
//int n = initialGuess.length;
//MultivariateOptimizer optimiser = new BOBYQAOptimizer(2 * n + 1);
//MultivariateOptimizer optimiser = new NativeLBFGSBMultivariateOptimizer(convergenceChecker);
MultivariateOptimizer optimiser = new SimplexOptimizer(convergenceChecker);
try {
optima = optimiser.optimize(new ObjectiveFunction(function),
GoalType.MAXIMIZE,
new InitialGuess(startingValues),//,
new NelderMeadSimplex(startingValues.length),
new MaxEval(Constants.MAX_EVALUATIONS)
);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
System.out.println(" " + optimiser.getEvaluations() + " evaluations");
if (optima == null)
throw new RuntimeException("ERROR: Runner.optimiseMutationParameters was unsuccessful (optima == null).");
double[] d = optima.getPoint();
Mapper.setOptimisable(mutation.getParameters(), d);
mutation.build();
//CoreUtils.msg("Runner.optimiseMutationParameters optima: %s -> %s\n", Doubles.join(",", optima.getPoint()), optima.getValue());
return Pair.of(optima.getValue(), mutation);
}
开发者ID:tamuri,项目名称:swmutsel,代码行数:50,代码来源:Runner.java
注:本文中的org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论