AllowedSolution.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. package org.apache.commons.math4.legacy.analysis.solvers;


  18. /** The kinds of solutions that a {@link BracketedUnivariateSolver
  19.  * (bracketed univariate real) root-finding algorithm} may accept as solutions.
  20.  * This basically controls whether or not under-approximations and
  21.  * over-approximations are allowed.
  22.  *
  23.  * <p>If all solutions are accepted ({@link #ANY_SIDE}), then the solution
  24.  * that the root-finding algorithm returns for a given root may be equal to the
  25.  * actual root, but it may also be an approximation that is slightly smaller
  26.  * or slightly larger than the actual root. Root-finding algorithms generally
  27.  * only guarantee that the returned solution is within the requested
  28.  * tolerances. In certain cases however, in particular for
  29.  * {@link org.apache.commons.math4.legacy.ode.events.EventHandler state events} of
  30.  * {@link org.apache.commons.math4.legacy.ode.ODEIntegrator ODE solvers}, it
  31.  * may be necessary to guarantee that a solution is returned that lies on a
  32.  * specific side the solution.</p>
  33.  *
  34.  * @see BracketedUnivariateSolver
  35.  * @since 3.0
  36.  */
  37. public enum AllowedSolution {
  38.     /** There are no additional side restriction on the solutions for
  39.      * root-finding. That is, both under-approximations and over-approximations
  40.      * are allowed. So, if a function f(x) has a root at x = x0, then the
  41.      * root-finding result s may be smaller than x0, equal to x0, or greater
  42.      * than x0.
  43.      */
  44.     ANY_SIDE,

  45.     /** Only solutions that are less than or equal to the actual root are
  46.      * acceptable as solutions for root-finding. In other words,
  47.      * over-approximations are not allowed. So, if a function f(x) has a root
  48.      * at x = x0, then the root-finding result s must satisfy s &lt;= x0.
  49.      */
  50.     LEFT_SIDE,

  51.     /** Only solutions that are greater than or equal to the actual root are
  52.      * acceptable as solutions for root-finding. In other words,
  53.      * under-approximations are not allowed. So, if a function f(x) has a root
  54.      * at x = x0, then the root-finding result s must satisfy s &gt;= x0.
  55.      */
  56.     RIGHT_SIDE,

  57.     /** Only solutions for which values are less than or equal to zero are
  58.      * acceptable as solutions for root-finding. So, if a function f(x) has
  59.      * a root at x = x0, then the root-finding result s must satisfy f(s) &lt;= 0.
  60.      */
  61.     BELOW_SIDE,

  62.     /** Only solutions for which values are greater than or equal to zero are
  63.      * acceptable as solutions for root-finding. So, if a function f(x) has
  64.      * a root at x = x0, then the root-finding result s must satisfy f(s) &gt;= 0.
  65.      */
  66.     ABOVE_SIDE;
  67. }