I tried solving the following problem using the SuanShu optimization library, with no success.
The optimization problem is:
Find the largest integral h such that the following constraint holds:
(h-2) * ArithmeticUtils.binomialCoefficient(b+h-2, h-1) -
ArithmeticUtils.binomialCoefficient(b+h-3, h-3) +
ArithmeticUtils.binomialCoefficientDouble(b+h-3,h-2)
- 2*epsilon*N
where b,epsilon, N are given and they are int, double, int respectively.
Can you please tell me which optimizer I should use and what optimization function ?
The code up to now looks like this:
public void optimize(){
//create the univariate function to be optimized
UnivariateRealFunction functionToOptimize = new UnivariateRealFunction() {
@Override
public double evaluate(double h) {
return -h;
}
};
UnivariateRealFunction hConstraint = new UnivariateRealFunction() {
public double evaluate(double h) {
(h-2) * ArithmeticUtils.binomialCoefficient(b+h-2, h-1) -
ArithmeticUtils.binomialCoefficient(b+h-3, h-3) +
ArithmeticUtils.binomialCoefficientDouble(b+h-3,h-2)
- 2*epsilon*N
}
};
List<RealScalarFunction> constraints = new ArrayList<RealScalarFunction>();
constraints.add(hConstraint);
ConstrainedOptimProblem problem = new ConstrainedOptimProblem(
functionToOptimize,
null,
new GeneralLessThanConstraints(constraints));
BFGS bfgs = new BFGS();
PenaltyMethodMinimizer optim = new PenaltyMethodMinimizer(
PenaltyMethodMinimizer.DEFAULT_PENALTY_FUNCTION_FACTORY,
1e30,
bfgs);
optim.solve(problem,1e-3,200);
Vector xmin = optim.search(new DenseVector(new int[]{8}));
double fxmin = functionToOptimize.evaluate(xmin.get(1));
System.out.println("fxmin: "+fxmin);
System.out.println(String.format("f(%s) = %f",
DoubleUtils.doubleArray2StringArray(xmin.toArray()), fxmin));
}
I took a look at the Apache commons math library and I don’t have a clue on how to use it for this problem.
If you use SuanShu, you can try the brute force minimizer or DeOptim. For DeOptim, you need to code up your integral constraint cell factory, such as this: IntegralCellFactory.java