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 /** Container for {@link ADMMQPOptimizer} settings. 22 * @since 3.1 23 */ 24 public class ADMMQPOption implements OptimizationData { 25 26 /** Default Absolute and Relative Tolerance for convergence. */ 27 public static final double DEFAULT_EPS = 1.0e-5; 28 29 /** Default Absolute and Relative Tolerance for Infeasible Criteria. */ 30 public static final double DEFAULT_EPS_INFEASIBLE = 1.0e-7; 31 32 /** Default Value of regularization term sigma for Karush–Kuhn–Tucker solver. */ 33 public static final double DEFAULT_SIGMA = 1.0e-12; 34 35 /** Default Value of Alpha filter for ADMM iteration. */ 36 public static final double DEFAULT_ALPHA = 1.6; 37 38 /** Default Value for Enabling Problem Scaling. */ 39 public static final boolean DEFAULT_SCALING = true; 40 41 /** Default Value for the Max Iteration for the scaling. */ 42 public static final int DEFAULT_SCALING_MAX_ITERATION = 10; 43 44 /** Default Value for adapting the weight during iterations. */ 45 public static final boolean DEFAULT_RHO_UPDATE = true; 46 47 /** Default Max Value for the Weight for ADMM iteration. */ 48 public static final double DEFAULT_RHO_MAX = 1.0e6; 49 50 /** Default Min Value for the Weight for ADMM iteration. */ 51 public static final double DEFAULT_RHO_MIN = 1.0e-6; 52 53 /** Default Max number of weight changes. */ 54 public static final int DEFAULT_MAX_RHO_ITERATION = 10; 55 56 /** Default Value for enabling polishing the solution. */ 57 public static final boolean DEFAULT_POLISHING = false; 58 59 /** Default Value for Iteration of polishing Algorithm. */ 60 public static final int DEFAULT_POLISHING_ITERATION = 5; 61 62 /** Absolute and Relative Tolerance for convergence. */ 63 private double eps; 64 65 /** Absolute and Relative Tolerance for Infeasible Criteria. */ 66 private double epsInfeasible; 67 68 /** Value of regularization term sigma for Karush–Kuhn–Tucker solver. */ 69 private double sigma; 70 71 /** Value of alpha filter for ADMM iteration. */ 72 private double alpha; 73 74 /** Scaling enabling flag. */ 75 private boolean scaling; 76 77 /** Value for the Max Iteration for the scaling. */ 78 private int scaleMaxIteration; 79 80 /** Value for adapt the weight during iterations. */ 81 private boolean updateRho; 82 83 /** Max Value for thr Weight for ADMM iteration. */ 84 private double rhoMax; 85 86 /** Min Value for the Weight for ADMM iteration. */ 87 private double rhoMin; 88 89 /** Max Value of changing the weight during iterations. */ 90 private int maxRhoIteration; 91 92 /** Enabling flag for polishing the solution. */ 93 private boolean polishing; 94 95 /** Value for Iteration of polishing Algorithm. */ 96 private int polishingIteration; 97 98 /** Simple constructor. 99 */ 100 public ADMMQPOption() { 101 eps = ADMMQPOption.DEFAULT_EPS; 102 epsInfeasible = ADMMQPOption.DEFAULT_EPS_INFEASIBLE; 103 sigma = ADMMQPOption.DEFAULT_SIGMA; 104 alpha = ADMMQPOption.DEFAULT_ALPHA; 105 scaling = ADMMQPOption.DEFAULT_SCALING; 106 scaleMaxIteration = ADMMQPOption.DEFAULT_SCALING_MAX_ITERATION; 107 updateRho = ADMMQPOption.DEFAULT_RHO_UPDATE; 108 rhoMax = ADMMQPOption.DEFAULT_RHO_MAX; 109 rhoMin = ADMMQPOption.DEFAULT_RHO_MIN; 110 maxRhoIteration = ADMMQPOption.DEFAULT_MAX_RHO_ITERATION; 111 polishing = ADMMQPOption.DEFAULT_POLISHING; 112 polishingIteration = ADMMQPOption.DEFAULT_POLISHING_ITERATION; 113 } 114 115 /** Set absolute and Relative Tolerance for convergence. 116 * @param eps absolute and Relative Tolerance for convergence 117 */ 118 public void setEps(final double eps) { 119 this.eps = eps; 120 } 121 122 /** Get absolute and Relative Tolerance for convergence. 123 * @return absolute and Relative Tolerance for convergence 124 */ 125 public double getEps() { 126 return eps; 127 } 128 129 /** Set absolute and Relative Tolerance for infeasible criteria. 130 * @param epsInfeasible absolute and Relative Tolerance for infeasible criteria 131 */ 132 public void setEpsInfeasible(final double epsInfeasible) { 133 this.epsInfeasible = epsInfeasible; 134 } 135 136 /** Get absolute and Relative Tolerance for infeasible criteria. 137 * @return absolute and Relative Tolerance for infeasible criteria 138 */ 139 public double getEpsInfeasible() { 140 return epsInfeasible; 141 } 142 143 /** Set value of regularization term sigma for Karush–Kuhn–Tucker solver. 144 * @param sigma value of regularization term sigma for Karush–Kuhn–Tucker solver 145 */ 146 public void setSigma(final double sigma) { 147 this.sigma = sigma; 148 } 149 150 /** Get value of regularization term sigma for Karush–Kuhn–Tucker solver. 151 * @return value of regularization term sigma for Karush–Kuhn–Tucker solver 152 */ 153 public double getSigma() { 154 return sigma; 155 } 156 157 /** Set value of alpha filter for ADMM iteration. 158 * @param alpha value of alpha filter for ADMM iteration 159 */ 160 public void setAlpha(final double alpha) { 161 this.alpha = alpha; 162 } 163 164 /** Get value of alpha filter for ADMM iteration. 165 * @return value of alpha filter for ADMM iteration 166 */ 167 public double getAlpha() { 168 return alpha; 169 } 170 171 /** Set scaling enabling flag. 172 * @param scaling if true, scaling is enabled 173 */ 174 public void setScaling(final boolean scaling) { 175 this.scaling = scaling; 176 } 177 178 /** Check if scaling is enabled. 179 * @return true if scaling is enabled 180 */ 181 public boolean isScaling() { 182 return scaling; 183 } 184 185 /** Set max iteration for the scaling. 186 * @param scaleMaxIteration max iteration for the scaling 187 */ 188 public void setScaleMaxIteration(final int scaleMaxIteration) { 189 this.scaleMaxIteration = scaleMaxIteration; 190 } 191 192 /** Get max iteration for the scaling. 193 * @return max iteration for the scaling 194 */ 195 public int getScaleMaxIteration() { 196 return scaleMaxIteration; 197 } 198 199 /** Set weight updating flag. 200 * @param updateRho if true, weight is updated during iterations 201 */ 202 public void setUpdateRho(final boolean updateRho) { 203 this.updateRho = updateRho; 204 } 205 206 /** Check if weight updating is enabled. 207 * @return true if weight is updated during iterations 208 */ 209 public boolean updateRho() { 210 return updateRho; 211 } 212 213 /** Set min Value for the Weight for ADMM iteration. 214 * @param rhoMin min Value for the Weight for ADMM iteration 215 */ 216 public void setRhoMin(final double rhoMin) { 217 this.rhoMin = rhoMin; 218 } 219 220 /** Get min Value for the Weight for ADMM iteration. 221 * @return min Value for the Weight for ADMM iteration 222 */ 223 public double getRhoMin() { 224 return rhoMin; 225 } 226 227 /** Set max Value for the Weight for ADMM iteration. 228 * @param rhoMax max Value for the Weight for ADMM iteration 229 */ 230 public void setRhoMax(final double rhoMax) { 231 this.rhoMax = rhoMax; 232 } 233 234 /** Get max Value for the Weight for ADMM iteration. 235 * @return max Value for the Weight for ADMM iteration 236 */ 237 public double getRhoMax() { 238 return rhoMax; 239 } 240 241 /** Set max number of weight changes. 242 * @param maxRhoIteration max number of weight changes 243 */ 244 public void setMaxRhoIteration(final int maxRhoIteration) { 245 this.maxRhoIteration = maxRhoIteration; 246 } 247 248 /** Get max number of weight changes. 249 * @return max number of weight changes 250 */ 251 public int getMaxRhoIteration() { 252 return maxRhoIteration; 253 } 254 255 /** Set polishing enabling flag. 256 * @param polishing if true, polishing is enabled 257 */ 258 public void setPolishing(final boolean polishing) { 259 this.polishing = polishing; 260 } 261 262 /** Check if polishing is enabled. 263 * @return true if polishing is enabled 264 */ 265 public boolean isPolishing() { 266 return polishing; 267 } 268 269 /** Set number of iterations of polishing algorithm. 270 * @param polishingIteration number of iterations of polishing algorithm 271 */ 272 public void setPolishingIteration(final int polishingIteration) { 273 this.polishingIteration = polishingIteration; 274 } 275 276 /** Get number of iterations of polishing algorithm. 277 * @return number of iterations of polishing algorithm 278 */ 279 public int getPolishIteration() { 280 return polishingIteration; 281 } 282 283 }