SQPOption.java

  1. /*
  2.  * Licensed to the Hipparchus project 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 Hipparchus project 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.  *      https://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.hipparchus.optim.nonlinear.vector.constrained;

  18. import org.hipparchus.optim.OptimizationData;

  19. /** Parameter for SQP Algorithm.
  20.  * @since 3.1
  21.  */
  22. public class SQPOption implements OptimizationData {

  23.     /** Default convergence criteria. */
  24.     public static final int DEFAULT_CONV_CRITERIA = 1;

  25.     /** Default tolerance for convergence and active constraint. */
  26.     public static final double DEFAULT_EPSILON = 1.0e-9;//>0

  27.     /** Default weight for augmented QP subproblem. */
  28.     public static final double DEFAULT_RHO = 100.0;//rho>1

  29.     /** Default max value admitted for additional variable in QP subproblem. */
  30.     public static final  double DEFAULT_SIGMA_MAX = 0.90;//0<sigma<1

  31.     /** Default max iteration admitted for QP subproblem. */
  32.     public static final  int DEFAULT_QP_MAX_LOOP = 4;

  33.     /** Default parameter for evaluation of Armijo condition for descend direction. */
  34.     public static final  double DEFAULT_MU = 0.1;//[0,0.5]

  35.     /** Default parameter for quadratic line search. */
  36.     public static final  double DEFAULT_B = 0.1;//[0;1]

  37.     /** Default flag for using BFGS update formula. */
  38.     public static final  boolean DEFAULT_USE_FUNCTION_HESSIAN = false;

  39.     /** Default max iteration before reset hessian. */
  40.     public static final  int DEFAULT_MAX_LINE_SEARCH_ITERATION = 20;

  41.     /** Convergence criteria*/
  42.     private int convCriteria;

  43.     /** Tolerance for convergence and active constraint evaluation. */
  44.     private double eps;

  45.     /** Weight for augmented QP subproblem. */
  46.     private double rhoCons;

  47.      /** Max value admitted for the solution of the additional variable in QP subproblem. */
  48.     private double sigmaMax;

  49.     /** Max iteration admitted for QP subproblem evaluation.
  50.      * (over this threshold the descend direction will be approximated using the merit function).
  51.      */
  52.     private int qpMaxLoop;

  53.     /** Parameter for evaluation of Armijo condition for descend direction.
  54.      * (fhi(alfa)-fhi(0)<=mu * alfa * fhi'(0)) */
  55.     private double mu;

  56.     /** Parameter for quadratic line search. */
  57.     private double b;

  58.     /** Max Iteration for the line search. */
  59.     private int maxLineSearchIteration;

  60.     /** Enable or Disable using direct the function Hessian. */
  61.     private boolean useFunHessian;

  62.     /** Simple constructor.
  63.      * <p>
  64.      * This constructor uses all defaults values.
  65.      * </p>
  66.      */
  67.     public SQPOption() {
  68.         this.convCriteria           = DEFAULT_CONV_CRITERIA;
  69.         this.eps                    = DEFAULT_EPSILON;
  70.         this.rhoCons                = DEFAULT_RHO;
  71.         this.sigmaMax               = DEFAULT_SIGMA_MAX;
  72.         this.qpMaxLoop              = DEFAULT_QP_MAX_LOOP;
  73.         this.mu                     = DEFAULT_MU;
  74.         this.b                      = DEFAULT_B;
  75.         this.maxLineSearchIteration = DEFAULT_MAX_LINE_SEARCH_ITERATION;
  76.         this.useFunHessian          = DEFAULT_USE_FUNCTION_HESSIAN;
  77.     }

  78.     /** Set convergence criteria.
  79.      * @param convCriteria convergence criteria
  80.      */
  81.     public void setConvCriteria(final int convCriteria) {
  82.         this.convCriteria = convCriteria;
  83.     }

  84.     /** Get convergence criteria.
  85.      * @return convergence criteria
  86.      */
  87.     public int getConvCriteria() {
  88.         return convCriteria;
  89.     }

  90.     /** Set tolerance for convergence and active constraint evaluation.
  91.      * @param eps tolerance for convergence and active constraint evaluation
  92.      */
  93.     public void setEps(final double eps) {
  94.         this.eps = eps;
  95.     }

  96.     /** Get tolerance for convergence and active constraint evaluation.
  97.      * @return tolerance for convergence and active constraint evaluation
  98.      */
  99.     public double getEps() {
  100.         return eps;
  101.     }

  102.     /** Set weight for augmented QP subproblem.
  103.      * @param rhoCons weight for augmented QP subproblem
  104.      */
  105.     public void setRhoCons(final double rhoCons) {
  106.         this.rhoCons = rhoCons;
  107.     }

  108.     /** Get weight for augmented QP subproblem.
  109.      * @return weight for augmented QP subproblem
  110.      */
  111.     public double getRhoCons() {
  112.         return rhoCons;
  113.     }

  114.     /** Set max value admitted for the solution of the additional variable in QP subproblem.
  115.      * @param sigmaMax max value admitted for the solution of the additional variable in QP subproblem
  116.      */
  117.     public void setSigmaMax(final double sigmaMax) {
  118.         this.sigmaMax = sigmaMax;
  119.     }

  120.     /** Get max value admitted for the solution of the additional variable in QP subproblem.
  121.      * @return max value admitted for the solution of the additional variable in QP subproblem
  122.      */
  123.     public double getSigmaMax() {
  124.         return sigmaMax;
  125.     }

  126.     /** Set max iteration admitted for QP subproblem evaluation.
  127.      * @param qpMaxLoop max iteration admitted for QP subproblem evaluation
  128.      */
  129.     public void setQpMaxLoop(final int qpMaxLoop) {
  130.         this.qpMaxLoop = qpMaxLoop;
  131.     }

  132.     /** Get max iteration admitted for QP subproblem evaluation.
  133.      * @return max iteration admitted for QP subproblem evaluation
  134.      */
  135.     public int getQpMaxLoop() {
  136.         return qpMaxLoop;
  137.     }

  138.     /** Set parameter for evaluation of Armijo condition for descend direction.
  139.      * @param mu parameter for evaluation of Armijo condition for descend direction
  140.      */
  141.     public void setMu(final double mu) {
  142.         this.mu  = mu;
  143.     }

  144.     /** Get parameter for evaluation of Armijo condition for descend direction.
  145.      * @return parameter for evaluation of Armijo condition for descend direction
  146.      */
  147.     public double getMu() {
  148.         return mu;
  149.     }

  150.     /** Set parameter for quadratic line search.
  151.      * @param b parameter for quadratic line search
  152.      */
  153.     public void setB(final double b) {
  154.         this.b = b;
  155.     }

  156.     /** Get parameter for quadratic line search.
  157.      * @return parameter for quadratic line search
  158.      */
  159.     public double getB() {
  160.         return b;
  161.     }

  162.     /** Set max Iteration for the line search
  163.      * @param maxLineSearchIteration max Iteration for the line search
  164.      */
  165.     public void setMaxLineSearchIteration(final int maxLineSearchIteration) {
  166.         this.maxLineSearchIteration = maxLineSearchIteration;
  167.     }

  168.     /** Get max Iteration for the line search
  169.      * @return max Iteration for the line search
  170.      */
  171.     public int getMaxLineSearchIteration() {
  172.         return maxLineSearchIteration;
  173.     }

  174.     /** Enable or Disable using direct the function Hessian.
  175.      * @param useFunHessian enable or Disable using direct the function Hessian
  176.      */
  177.     public void setUseFunHessian(final boolean useFunHessian) {
  178.         this.useFunHessian = useFunHessian;
  179.     }

  180.     /** Check if using direct the function Hessian is enabled or disabled.
  181.      * @return true if using direct the function Hessian is enabled
  182.      */
  183.     public boolean useFunHessian() {
  184.         return useFunHessian;
  185.     }

  186. }