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 19 import org.hipparchus.optim.OptimizationData; 20 21 /** Parameter for SQP Algorithm. 22 * @since 3.1 23 */ 24 public class SQPOption implements OptimizationData { 25 26 /** Default convergence criteria. */ 27 public static final int DEFAULT_CONV_CRITERIA = 1; 28 29 /** Default tolerance for convergence and active constraint. */ 30 public static final double DEFAULT_EPSILON = 1.0e-9;//>0 31 32 /** Default weight for augmented QP subproblem. */ 33 public static final double DEFAULT_RHO = 100.0;//rho>1 34 35 /** Default max value admitted for additional variable in QP subproblem. */ 36 public static final double DEFAULT_SIGMA_MAX = 0.90;//0<sigma<1 37 38 /** Default max iteration admitted for QP subproblem. */ 39 public static final int DEFAULT_QP_MAX_LOOP = 4; 40 41 /** Default parameter for evaluation of Armijo condition for descend direction. */ 42 public static final double DEFAULT_MU = 0.1;//[0,0.5] 43 44 /** Default parameter for quadratic line search. */ 45 public static final double DEFAULT_B = 0.1;//[0;1] 46 47 /** Default flag for using BFGS update formula. */ 48 public static final boolean DEFAULT_USE_FUNCTION_HESSIAN = false; 49 50 /** Default max iteration before reset hessian. */ 51 public static final int DEFAULT_MAX_LINE_SEARCH_ITERATION = 20; 52 53 /** Convergence criteria*/ 54 private int convCriteria; 55 56 /** Tolerance for convergence and active constraint evaluation. */ 57 private double eps; 58 59 /** Weight for augmented QP subproblem. */ 60 private double rhoCons; 61 62 /** Max value admitted for the solution of the additional variable in QP subproblem. */ 63 private double sigmaMax; 64 65 /** Max iteration admitted for QP subproblem evaluation. 66 * (over this threshold the descend direction will be approximated using the merit function). 67 */ 68 private int qpMaxLoop; 69 70 /** Parameter for evaluation of Armijo condition for descend direction. 71 * (fhi(alfa)-fhi(0)<=mu * alfa * fhi'(0)) */ 72 private double mu; 73 74 /** Parameter for quadratic line search. */ 75 private double b; 76 77 /** Max Iteration for the line search. */ 78 private int maxLineSearchIteration; 79 80 /** Enable or Disable using direct the function Hessian. */ 81 private boolean useFunHessian; 82 83 /** Simple constructor. 84 * <p> 85 * This constructor uses all defaults values. 86 * </p> 87 */ 88 public SQPOption() { 89 this.convCriteria = DEFAULT_CONV_CRITERIA; 90 this.eps = DEFAULT_EPSILON; 91 this.rhoCons = DEFAULT_RHO; 92 this.sigmaMax = DEFAULT_SIGMA_MAX; 93 this.qpMaxLoop = DEFAULT_QP_MAX_LOOP; 94 this.mu = DEFAULT_MU; 95 this.b = DEFAULT_B; 96 this.maxLineSearchIteration = DEFAULT_MAX_LINE_SEARCH_ITERATION; 97 this.useFunHessian = DEFAULT_USE_FUNCTION_HESSIAN; 98 } 99 100 /** Set convergence criteria. 101 * @param convCriteria convergence criteria 102 */ 103 public void setConvCriteria(final int convCriteria) { 104 this.convCriteria = convCriteria; 105 } 106 107 /** Get convergence criteria. 108 * @return convergence criteria 109 */ 110 public int getConvCriteria() { 111 return convCriteria; 112 } 113 114 /** Set tolerance for convergence and active constraint evaluation. 115 * @param eps tolerance for convergence and active constraint evaluation 116 */ 117 public void setEps(final double eps) { 118 this.eps = eps; 119 } 120 121 /** Get tolerance for convergence and active constraint evaluation. 122 * @return tolerance for convergence and active constraint evaluation 123 */ 124 public double getEps() { 125 return eps; 126 } 127 128 /** Set weight for augmented QP subproblem. 129 * @param rhoCons weight for augmented QP subproblem 130 */ 131 public void setRhoCons(final double rhoCons) { 132 this.rhoCons = rhoCons; 133 } 134 135 /** Get weight for augmented QP subproblem. 136 * @return weight for augmented QP subproblem 137 */ 138 public double getRhoCons() { 139 return rhoCons; 140 } 141 142 /** Set max value admitted for the solution of the additional variable in QP subproblem. 143 * @param sigmaMax max value admitted for the solution of the additional variable in QP subproblem 144 */ 145 public void setSigmaMax(final double sigmaMax) { 146 this.sigmaMax = sigmaMax; 147 } 148 149 /** Get max value admitted for the solution of the additional variable in QP subproblem. 150 * @return max value admitted for the solution of the additional variable in QP subproblem 151 */ 152 public double getSigmaMax() { 153 return sigmaMax; 154 } 155 156 /** Set max iteration admitted for QP subproblem evaluation. 157 * @param qpMaxLoop max iteration admitted for QP subproblem evaluation 158 */ 159 public void setQpMaxLoop(final int qpMaxLoop) { 160 this.qpMaxLoop = qpMaxLoop; 161 } 162 163 /** Get max iteration admitted for QP subproblem evaluation. 164 * @return max iteration admitted for QP subproblem evaluation 165 */ 166 public int getQpMaxLoop() { 167 return qpMaxLoop; 168 } 169 170 /** Set parameter for evaluation of Armijo condition for descend direction. 171 * @param mu parameter for evaluation of Armijo condition for descend direction 172 */ 173 public void setMu(final double mu) { 174 this.mu = mu; 175 } 176 177 /** Get parameter for evaluation of Armijo condition for descend direction. 178 * @return parameter for evaluation of Armijo condition for descend direction 179 */ 180 public double getMu() { 181 return mu; 182 } 183 184 /** Set parameter for quadratic line search. 185 * @param b parameter for quadratic line search 186 */ 187 public void setB(final double b) { 188 this.b = b; 189 } 190 191 /** Get parameter for quadratic line search. 192 * @return parameter for quadratic line search 193 */ 194 public double getB() { 195 return b; 196 } 197 198 /** Set max Iteration for the line search 199 * @param maxLineSearchIteration max Iteration for the line search 200 */ 201 public void setMaxLineSearchIteration(final int maxLineSearchIteration) { 202 this.maxLineSearchIteration = maxLineSearchIteration; 203 } 204 205 /** Get max Iteration for the line search 206 * @return max Iteration for the line search 207 */ 208 public int getMaxLineSearchIteration() { 209 return maxLineSearchIteration; 210 } 211 212 /** Enable or Disable using direct the function Hessian. 213 * @param useFunHessian enable or Disable using direct the function Hessian 214 */ 215 public void setUseFunHessian(final boolean useFunHessian) { 216 this.useFunHessian = useFunHessian; 217 } 218 219 /** Check if using direct the function Hessian is enabled or disabled. 220 * @return true if using direct the function Hessian is enabled 221 */ 222 public boolean useFunHessian() { 223 return useFunHessian; 224 } 225 226 }