001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    package org.apache.commons.math3.optimization.linear;
019    
020    import java.util.Collection;
021    
022    import org.apache.commons.math3.exception.MathIllegalStateException;
023    import org.apache.commons.math3.optimization.GoalType;
024    import org.apache.commons.math3.optimization.PointValuePair;
025    
026    /**
027     * This interface represents an optimization algorithm for linear problems.
028     * <p>Optimization algorithms find the input point set that either {@link GoalType
029     * maximize or minimize} an objective function. In the linear case the form of
030     * the function is restricted to
031     * <pre>
032     * c<sub>1</sub>x<sub>1</sub> + ... c<sub>n</sub>x<sub>n</sub> = v
033     * </pre>
034     * and there may be linear constraints too, of one of the forms:
035     * <ul>
036     *   <li>c<sub>1</sub>x<sub>1</sub> + ... c<sub>n</sub>x<sub>n</sub> = v</li>
037     *   <li>c<sub>1</sub>x<sub>1</sub> + ... c<sub>n</sub>x<sub>n</sub> &lt;= v</li>
038     *   <li>c<sub>1</sub>x<sub>1</sub> + ... c<sub>n</sub>x<sub>n</sub> >= v</li>
039     *   <li>l<sub>1</sub>x<sub>1</sub> + ... l<sub>n</sub>x<sub>n</sub> + l<sub>cst</sub> =
040     *       r<sub>1</sub>x<sub>1</sub> + ... r<sub>n</sub>x<sub>n</sub> + r<sub>cst</sub></li>
041     *   <li>l<sub>1</sub>x<sub>1</sub> + ... l<sub>n</sub>x<sub>n</sub> + l<sub>cst</sub> &lt;=
042     *       r<sub>1</sub>x<sub>1</sub> + ... r<sub>n</sub>x<sub>n</sub> + r<sub>cst</sub></li>
043     *   <li>l<sub>1</sub>x<sub>1</sub> + ... l<sub>n</sub>x<sub>n</sub> + l<sub>cst</sub> >=
044     *       r<sub>1</sub>x<sub>1</sub> + ... r<sub>n</sub>x<sub>n</sub> + r<sub>cst</sub></li>
045     * </ul>
046     * where the c<sub>i</sub>, l<sub>i</sub> or r<sub>i</sub> are the coefficients of
047     * the constraints, the x<sub>i</sub> are the coordinates of the current point and
048     * v is the value of the constraint.
049     * </p>
050     * @version $Id: LinearOptimizer.java 1422230 2012-12-15 12:11:13Z erans $
051     * @deprecated As of 3.1 (to be removed in 4.0).
052     * @since 2.0
053     */
054    @Deprecated
055    public interface LinearOptimizer {
056    
057        /**
058         * Set the maximal number of iterations of the algorithm.
059         * @param maxIterations maximal number of function calls
060         */
061        void setMaxIterations(int maxIterations);
062    
063        /**
064         * Get the maximal number of iterations of the algorithm.
065         * @return maximal number of iterations
066         */
067        int getMaxIterations();
068    
069        /**
070         * Get the number of iterations realized by the algorithm.
071         * <p>
072         * The number of evaluations corresponds to the last call to the
073         * {@link #optimize(LinearObjectiveFunction, Collection, GoalType, boolean) optimize}
074         * method. It is 0 if the method has not been called yet.
075         * </p>
076         * @return number of iterations
077         */
078        int getIterations();
079    
080        /**
081         * Optimizes an objective function.
082         * @param f linear objective function
083         * @param constraints linear constraints
084         * @param goalType type of optimization goal: either {@link GoalType#MAXIMIZE} or {@link GoalType#MINIMIZE}
085         * @param restrictToNonNegative whether to restrict the variables to non-negative values
086         * @return point/value pair giving the optimal value for objective function
087         * @exception MathIllegalStateException if no solution fulfilling the constraints
088         *   can be found in the allowed number of iterations
089         */
090       PointValuePair optimize(LinearObjectiveFunction f, Collection<LinearConstraint> constraints,
091                                   GoalType goalType, boolean restrictToNonNegative) throws MathIllegalStateException;
092    
093    }