1dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond/*
2dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Licensed to the Apache Software Foundation (ASF) under one or more
3dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * contributor license agreements.  See the NOTICE file distributed with
4dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * this work for additional information regarding copyright ownership.
5dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * The ASF licenses this file to You under the Apache License, Version 2.0
6dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * (the "License"); you may not use this file except in compliance with
7dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * the License.  You may obtain a copy of the License at
8dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond *
9dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond *      http://www.apache.org/licenses/LICENSE-2.0
10dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond *
11dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Unless required by applicable law or agreed to in writing, software
12dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * distributed under the License is distributed on an "AS IS" BASIS,
13dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * See the License for the specific language governing permissions and
15dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * limitations under the License.
16dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */
17dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
18dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondpackage org.apache.commons.math.optimization.general;
19dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
20dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondimport org.apache.commons.math.FunctionEvaluationException;
21dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
22dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond/**
23dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * This interface represents a preconditioner for differentiable scalar
24dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * objective function optimizers.
25dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @version $Revision: 1073158 $ $Date: 2011-02-21 22:46:52 +0100 (lun. 21 févr. 2011) $
26dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @since 2.0
27dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */
28dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondpublic interface Preconditioner {
29dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
30dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    /**
31dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * Precondition a search direction.
32dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * <p>
33dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * The returned preconditioned search direction must be computed fast or
34dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * the algorithm performances will drop drastically. A classical approach
35dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * is to compute only the diagonal elements of the hessian and to divide
36dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * the raw search direction by these elements if they are all positive.
37dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * If at least one of them is negative, it is safer to return a clone of
38dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * the raw search direction as if the hessian was the identity matrix. The
39dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * rationale for this simplified choice is that a negative diagonal element
40dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * means the current point is far from the optimum and preconditioning will
41dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * not be efficient anyway in this case.
42dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * </p>
43dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param point current point at which the search direction was computed
44dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @param r raw search direction (i.e. opposite of the gradient)
45dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @return approximation of H<sup>-1</sup>r where H is the objective function hessian
46dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @exception FunctionEvaluationException if no cost can be computed for the parameters
47dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     * @exception IllegalArgumentException if point dimension is wrong
48dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond     */
49dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond    double[] precondition(double[] point, double[] r)
50dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond        throws FunctionEvaluationException, IllegalArgumentException;
51dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond
52dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond}
53