/** * Scans the list of (required and optional) optimization data that * characterize the problem. * * @param optData Optimization data. * The following data will be looked for: * <ul> * <li>{@link ModelFunctionJacobian}</li> * </ul> */ @Override protected void parseOptimizationData(OptimizationData... optData) { // Allow base class to register its own data. super.parseOptimizationData(optData); // The existing values (as set by the previous call) are reused if // not provided in the argument list. for (OptimizationData data : optData) { if (data instanceof ModelFunctionJacobian) { jacobian = ((ModelFunctionJacobian) data).getModelFunctionJacobian(); // If more data must be parsed, this statement _must_ be // changed to "continue". break; } } } }
/** * {@inheritDoc} * * @param optData Optimization data. In addition to those documented in * {@link MultivariateVectorOptimizer#optimize(OptimizationData...)} * MultivariateOptimizer}, this method will register the following data: * <ul> * <li>{@link ModelFunctionJacobian}</li> * </ul> * @return {@inheritDoc} * @throws TooManyEvaluationsException if the maximal number of * evaluations is exceeded. * @throws DimensionMismatchException if the initial guess, target, and weight * arguments have inconsistent dimensions. */ @Override public PointVectorValuePair optimize(OptimizationData... optData) throws TooManyEvaluationsException, DimensionMismatchException { // Set up base class and perform computation. return super.optimize(optData); }
/** * {@inheritDoc} * * @param optData Optimization data. In addition to those documented in * {@link JacobianMultivariateVectorOptimizer#parseOptimizationData(OptimizationData[]) * JacobianMultivariateVectorOptimizer}, this method will register the following data: * <ul> * <li>{@link org.apache.commons.math3.optim.nonlinear.vector.Weight}</li> * </ul> * @return {@inheritDoc} * @throws TooManyEvaluationsException if the maximal number of * evaluations is exceeded. * @throws DimensionMismatchException if the initial guess, target, and weight * arguments have inconsistent dimensions. */ @Override public PointVectorValuePair optimize(OptimizationData... optData) throws TooManyEvaluationsException { // Set up base class and perform computation. return super.optimize(optData); }
model = ((ModelFunction) data).getModelFunction(); continue; target = ((Target) data).getTarget(); continue; weightMatrix = ((Weight) data).getWeight(); continue; checkParameters();
/** * Scans the list of (required and optional) optimization data that * characterize the problem. * If the weight matrix is specified, the {@link #weightMatrixSqrt} * field is recomputed. * * @param optData Optimization data. The following data will be looked for: * <ul> * <li>{@link Weight}</li> * </ul> */ @Override protected void parseOptimizationData(OptimizationData... optData) { // Allow base class to register its own data. super.parseOptimizationData(optData); // The existing values (as set by the previous call) are reused if // not provided in the argument list. for (OptimizationData data : optData) { if (data instanceof Weight) { weightMatrixSqrt = squareRoot(((Weight) data).getWeight()); // If more data must be parsed, this statement _must_ be // changed to "continue". break; } } }
/** * @return a comparator for sorting the optima. */ private Comparator<PointVectorValuePair> getPairComparator() { return new Comparator<PointVectorValuePair>() { /** Observed value to be matched. */ private final RealVector target = new ArrayRealVector(optimizer.getTarget(), false); /** Observations weights. */ private final RealMatrix weight = optimizer.getWeight(); /** {@inheritDoc} */ public int compare(final PointVectorValuePair o1, final PointVectorValuePair o2) { if (o1 == null) { return (o2 == null) ? 0 : 1; } else if (o2 == null) { return -1; } return Double.compare(weightedResidual(o1), weightedResidual(o2)); } private double weightedResidual(final PointVectorValuePair pv) { final RealVector v = new ArrayRealVector(pv.getValueRef(), false); final RealVector r = target.subtract(v); return r.dotProduct(weight.operate(r)); } }; } }
/** {@inheritDoc} */ public int compare(final PointVectorValuePair o1, final PointVectorValuePair o2) { if (o1 == null) { return (o2 == null) ? 0 : 1; } else if (o2 == null) { return -1; } return Double.compare(weightedResidual(o1), weightedResidual(o2)); }
/** * {@inheritDoc} */ @Override public PointVectorValuePair[] getOptima() { Collections.sort(optima, getPairComparator()); return optima.toArray(new PointVectorValuePair[0]); }
model = ((ModelFunction) data).getModelFunction(); continue; target = ((Target) data).getTarget(); continue; weightMatrix = ((Weight) data).getWeight(); continue; checkParameters();
/** * Scans the list of (required and optional) optimization data that * characterize the problem. * * @param optData Optimization data. * The following data will be looked for: * <ul> * <li>{@link ModelFunctionJacobian}</li> * </ul> */ @Override protected void parseOptimizationData(OptimizationData... optData) { // Allow base class to register its own data. super.parseOptimizationData(optData); // The existing values (as set by the previous call) are reused if // not provided in the argument list. for (OptimizationData data : optData) { if (data instanceof ModelFunctionJacobian) { jacobian = ((ModelFunctionJacobian) data).getModelFunctionJacobian(); // If more data must be parsed, this statement _must_ be // changed to "continue". break; } } } }
/** {@inheritDoc} */ public int compare(final PointVectorValuePair o1, final PointVectorValuePair o2) { if (o1 == null) { return (o2 == null) ? 0 : 1; } else if (o2 == null) { return -1; } return Double.compare(weightedResidual(o1), weightedResidual(o2)); }
/** * {@inheritDoc} * * @param optData Optimization data. In addition to those documented in * {@link MultivariateVectorOptimizer#optimize(OptimizationData...)} * MultivariateOptimizer}, this method will register the following data: * <ul> * <li>{@link ModelFunctionJacobian}</li> * </ul> * @return {@inheritDoc} * @throws TooManyEvaluationsException if the maximal number of * evaluations is exceeded. * @throws DimensionMismatchException if the initial guess, target, and weight * arguments have inconsistent dimensions. */ @Override public PointVectorValuePair optimize(OptimizationData... optData) throws TooManyEvaluationsException, DimensionMismatchException { // Set up base class and perform computation. return super.optimize(optData); }
/** * {@inheritDoc} * * @param optData Optimization data. In addition to those documented in * {@link JacobianMultivariateVectorOptimizer#parseOptimizationData(OptimizationData[]) * JacobianMultivariateVectorOptimizer}, this method will register the following data: * <ul> * <li>{@link org.apache.commons.math3.optim.nonlinear.vector.Weight}</li> * </ul> * @return {@inheritDoc} * @throws TooManyEvaluationsException if the maximal number of * evaluations is exceeded. * @throws DimensionMismatchException if the initial guess, target, and weight * arguments have inconsistent dimensions. */ @Override public PointVectorValuePair optimize(OptimizationData... optData) throws TooManyEvaluationsException { // Set up base class and perform computation. return super.optimize(optData); }
/** * {@inheritDoc} */ @Override public PointVectorValuePair[] getOptima() { Collections.sort(optima, getPairComparator()); return optima.toArray(new PointVectorValuePair[0]); }
model = ((ModelFunction) data).getModelFunction(); continue; target = ((Target) data).getTarget(); continue; weightMatrix = ((Weight) data).getWeight(); continue; checkParameters();
/** * Scans the list of (required and optional) optimization data that * characterize the problem. * * @param optData Optimization data. * The following data will be looked for: * <ul> * <li>{@link ModelFunctionJacobian}</li> * </ul> */ @Override protected void parseOptimizationData(OptimizationData... optData) { // Allow base class to register its own data. super.parseOptimizationData(optData); // The existing values (as set by the previous call) are reused if // not provided in the argument list. for (OptimizationData data : optData) { if (data instanceof ModelFunctionJacobian) { jacobian = ((ModelFunctionJacobian) data).getModelFunctionJacobian(); // If more data must be parsed, this statement _must_ be // changed to "continue". break; } } } }
/** {@inheritDoc} */ public int compare(final PointVectorValuePair o1, final PointVectorValuePair o2) { if (o1 == null) { return (o2 == null) ? 0 : 1; } else if (o2 == null) { return -1; } return Double.compare(weightedResidual(o1), weightedResidual(o2)); }
/** * {@inheritDoc} * * @param optData Optimization data. In addition to those documented in * {@link MultivariateVectorOptimizer#optimize(OptimizationData...)} * MultivariateOptimizer}, this method will register the following data: * <ul> * <li>{@link ModelFunctionJacobian}</li> * </ul> * @return {@inheritDoc} * @throws TooManyEvaluationsException if the maximal number of * evaluations is exceeded. * @throws DimensionMismatchException if the initial guess, target, and weight * arguments have inconsistent dimensions. */ @Override public PointVectorValuePair optimize(OptimizationData... optData) throws TooManyEvaluationsException, DimensionMismatchException { // Set up base class and perform computation. return super.optimize(optData); }
/** * {@inheritDoc} * * @param optData Optimization data. In addition to those documented in * {@link JacobianMultivariateVectorOptimizer#parseOptimizationData(OptimizationData[]) * JacobianMultivariateVectorOptimizer}, this method will register the following data: * <ul> * <li>{@link org.apache.commons.math3.optim.nonlinear.vector.Weight}</li> * </ul> * @return {@inheritDoc} * @throws TooManyEvaluationsException if the maximal number of * evaluations is exceeded. * @throws DimensionMismatchException if the initial guess, target, and weight * arguments have inconsistent dimensions. */ @Override public PointVectorValuePair optimize(OptimizationData... optData) throws TooManyEvaluationsException { // Set up base class and perform computation. return super.optimize(optData); }