本文整理汇总了Java中org.apache.commons.math3.optim.SimpleBounds类的典型用法代码示例。如果您正苦于以下问题:Java SimpleBounds类的具体用法?Java SimpleBounds怎么用?Java SimpleBounds使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleBounds类属于org.apache.commons.math3.optim包,在下文中一共展示了SimpleBounds类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: applyToNetwork
import org.apache.commons.math3.optim.SimpleBounds; //导入依赖的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: testBoundsUnsupported
import org.apache.commons.math3.optim.SimpleBounds; //导入依赖的package包/类
@Test(expected=MathUnsupportedOperationException.class)
public void testBoundsUnsupported() {
LinearProblem problem
= new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
NonLinearConjugateGradientOptimizer optimizer
= new NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE,
new SimpleValueChecker(1e-6, 1e-6),
1e-3, 1e-3, 1);
optimizer.optimize(new MaxEval(100),
problem.getObjectiveFunction(),
problem.getObjectiveFunctionGradient(),
GoalType.MINIMIZE,
new InitialGuess(new double[] { 0 }),
new SimpleBounds(new double[] { -1 },
new double[] { 1 }));
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:17,代码来源:NonLinearConjugateGradientOptimizerTest.java
示例3: findOptimum
import org.apache.commons.math3.optim.SimpleBounds; //导入依赖的package包/类
@Override
public TreeMap<Double, TariffSpecification> findOptimum(TariffUtilityEstimate tariffUtilityEstimate,
int NUM_RATES, int numEval) {
double[] startingVertex = new double[NUM_RATES]; // start from the fixed-rate tariff's offset
Arrays.fill(startingVertex, 0.0);
//Arrays.fill(startingVertex, 0.5 * INITIAL_TRUST_REGION_RADIUS);
//Arrays.fill(startingVertex, 1 * INITIAL_TRUST_REGION_RADIUS);
final int numIterpolationPoints = 2 * NUM_RATES + 1; // BOBYQA recommends 2n+1 points
BOBYQAOptimizer optimizer = new BOBYQAOptimizer(numIterpolationPoints , INITIAL_TRUST_REGION_RADIUS, STOPPING_TRUST_REGION_RADIUS);
// needed since one optimization found positive
// charges (paying customer to consume...)
double[][] boundaries = createBoundaries(NUM_RATES);
final PointValuePair optimum
= optimizer.optimize(
new MaxEval(numEval),
new ObjectiveFunction(new OptimizerWrapperApacheObjective(tariffUtilityEstimate)),
GoalType.MAXIMIZE,
new InitialGuess(startingVertex),
//new SimpleBounds(boundaries[0], boundaries[1]));
SimpleBounds.unbounded(NUM_RATES));
TreeMap<Double, TariffSpecification> eval2TOUTariff = new TreeMap<Double, TariffSpecification>();
eval2TOUTariff.put(optimum.getValue(), tariffUtilityEstimate.getCorrespondingSpec(optimum.getKey()));
return eval2TOUTariff;
}
开发者ID:LARG,项目名称:TacTex,代码行数:31,代码来源:OptimizerWrapperApacheBOBYQA.java
示例4: testIssue914
import org.apache.commons.math3.optim.SimpleBounds; //导入依赖的package包/类
@Test
public void testIssue914() {
LinearProblem problem = new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
JacobianMultivariateVectorOptimizer underlyingOptimizer =
new GaussNewtonOptimizer(true, new SimpleVectorValueChecker(1e-6, 1e-6)) {
@Override
public PointVectorValuePair optimize(OptimizationData... optData) {
// filter out simple bounds, as they are not supported
// by the underlying optimizer, and we don't really care for this test
OptimizationData[] filtered = optData.clone();
for (int i = 0; i < filtered.length; ++i) {
if (filtered[i] instanceof SimpleBounds) {
filtered[i] = null;
}
}
return super.optimize(filtered);
}
};
JDKRandomGenerator g = new JDKRandomGenerator();
g.setSeed(16069223052l);
RandomVectorGenerator generator =
new UncorrelatedRandomVectorGenerator(1, new GaussianRandomGenerator(g));
MultiStartMultivariateVectorOptimizer optimizer =
new MultiStartMultivariateVectorOptimizer(underlyingOptimizer, 10, generator);
optimizer.optimize(new MaxEval(100),
problem.getModelFunction(),
problem.getModelFunctionJacobian(),
problem.getTarget(),
new Weight(new double[] { 1 }),
new InitialGuess(new double[] { 0 }),
new SimpleBounds(new double[] { -1.0e-10 }, new double[] { 1.0e-10 }));
PointVectorValuePair[] optima = optimizer.getOptima();
// only the first start should have succeeded
Assert.assertEquals(1, optima.length);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:38,代码来源:MultiStartMultivariateVectorOptimizerTest.java
示例5: testConstraintsUnsupported
import org.apache.commons.math3.optim.SimpleBounds; //导入依赖的package包/类
@Test(expected=MathUnsupportedOperationException.class)
public void testConstraintsUnsupported() {
createOptimizer().optimize(new MaxEval(100),
new Target(new double[] { 2 }),
new Weight(new double[] { 1 }),
new InitialGuess(new double[] { 1, 2 }),
new SimpleBounds(new double[] { -10, 0 },
new double[] { 20, 30 }));
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:10,代码来源:GaussNewtonOptimizerTest.java
示例6: testBoundsUnsupported
import org.apache.commons.math3.optim.SimpleBounds; //导入依赖的package包/类
@Test(expected=MathUnsupportedOperationException.class)
public void testBoundsUnsupported() {
SimplexOptimizer optimizer = new SimplexOptimizer(1e-10, 1e-30);
final FourExtrema fourExtrema = new FourExtrema();
optimizer.optimize(new MaxEval(100),
new ObjectiveFunction(fourExtrema),
GoalType.MINIMIZE,
new InitialGuess(new double[] { -3, 0 }),
new NelderMeadSimplex(new double[] { 0.2, 0.2 }),
new SimpleBounds(new double[] { -5, -1 },
new double[] { 5, 1 }));
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:14,代码来源:SimplexOptimizerMultiDirectionalTest.java
示例7: testMath864
import org.apache.commons.math3.optim.SimpleBounds; //导入依赖的package包/类
@Test
public void testMath864() {
final CMAESOptimizer optimizer
= new CMAESOptimizer(30000, 0, true, 10,
0, new MersenneTwister(), false, null);
final MultivariateFunction fitnessFunction = new MultivariateFunction() {
public double value(double[] parameters) {
final double target = 1;
final double error = target - parameters[0];
return error * error;
}
};
final double[] start = { 0 };
final double[] lower = { -1e6 };
final double[] upper = { 1.5 };
final double[] sigma = { 1e-1 };
final double[] result = optimizer.optimize(new MaxEval(10000),
new ObjectiveFunction(fitnessFunction),
GoalType.MINIMIZE,
new CMAESOptimizer.PopulationSize(5),
new CMAESOptimizer.Sigma(sigma),
new InitialGuess(start),
new SimpleBounds(lower, upper)).getPoint();
Assert.assertTrue("Out of bounds (" + result[0] + " > " + upper[0] + ")",
result[0] <= upper[0]);
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:28,代码来源:CMAESOptimizerTest.java
示例8: testBoundsUnsupported
import org.apache.commons.math3.optim.SimpleBounds; //导入依赖的package包/类
@Test(expected=MathUnsupportedOperationException.class)
public void testBoundsUnsupported() {
final MultivariateFunction func = new SumSincFunction(-1);
final PowellOptimizer optim = new PowellOptimizer(1e-8, 1e-5,
1e-4, 1e-4);
optim.optimize(new MaxEval(100),
new ObjectiveFunction(func),
GoalType.MINIMIZE,
new InitialGuess(new double[] { -3, 0 }),
new SimpleBounds(new double[] { -5, -1 },
new double[] { 5, 1 }));
}
开发者ID:Quanticol,项目名称:CARMA,代码行数:14,代码来源:PowellOptimizerTest.java
示例9: testBoundsUnsupported
import org.apache.commons.math3.optim.SimpleBounds; //导入依赖的package包/类
@Test(expected=MathUnsupportedOperationException.class)
public void testBoundsUnsupported() {
LinearProblem problem
= new LinearProblem(new double[][] { { 2 } }, new double[] { 3 });
NonLinearConjugateGradientOptimizer optimizer
= new NonLinearConjugateGradientOptimizer(NonLinearConjugateGradientOptimizer.Formula.POLAK_RIBIERE,
new SimpleValueChecker(1e-6, 1e-6));
optimizer.optimize(new MaxEval(100),
problem.getObjectiveFunction(),
problem.getObjectiveFunctionGradient(),
GoalType.MINIMIZE,
new InitialGuess(new double[] { 0 }),
new SimpleBounds(new double[] { -1 },
new double[] { 1 }));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:16,代码来源:NonLinearConjugateGradientOptimizerTest.java
注:本文中的org.apache.commons.math3.optim.SimpleBounds类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论