/** * Creates a trifocal tensor estimation algorithm. * * @param type Which algorithm. * @param iterations If the algorithm is iterative, then this is the number of iterations. Try 200 * @return Trifocal tensor estimator */ public static Estimate1ofTrifocalTensor estimateTrifocal_1(EnumTrifocal type, int iterations) { switch( type ) { case LINEAR_7: return new WrapTrifocalLinearPoint7(); case ALGEBRAIC_7: UnconstrainedLeastSquares optimizer = FactoryOptimization.leastSquaresLM(1e-3, false); TrifocalAlgebraicPoint7 alg = new TrifocalAlgebraicPoint7(optimizer,iterations,1e-12,1e-12); return new WrapTrifocalAlgebraicPoint7(alg); } throw new IllegalArgumentException("Unknown type "+type); }
public void optimize() { new FactoryOptimization(); UnconstrainedLeastSquares optimizer = FactoryOptimization.leastSquaresLM(1e-3, true); optimizer.setFunction(residual, null); double[] prm = new double[residual.getNumOfInputsN()]; residual.getCurrentLinkCom().set(prm); optimizer.initialize(prm, 0, 0); boolean converged; int maxIter = 10; for (int i = 0; i < maxIter; i++) { converged = optimizer.iterate(); prm = optimizer.getParameters(); System.out.println("iter " + i + " obj: " + optimizer.getFunctionValue() + "converged " + converged); if (optimizer.isConverged()) break; } System.out.println("Optimiztion finished."); } }
optimizer = FactoryOptimization.leastSquaresLM(1e-3,true);