ADMMQPOption.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. /** Container for {@link ADMMQPOptimizer} settings.
  20.  * @since 3.1
  21.  */
  22. public class ADMMQPOption implements OptimizationData {

  23.     /** Default Absolute and Relative Tolerance for convergence. */
  24.     public static final double DEFAULT_EPS = 1.0e-5;

  25.     /** Default Absolute and Relative Tolerance for Infeasible Criteria. */
  26.     public static final double DEFAULT_EPS_INFEASIBLE = 1.0e-7;

  27.     /** Default Value of regularization term sigma for Karush–Kuhn–Tucker solver. */
  28.     public static final double DEFAULT_SIGMA = 1.0e-12;

  29.     /** Default Value of Alpha filter for ADMM iteration. */
  30.     public static final double DEFAULT_ALPHA = 1.6;

  31.     /** Default Value for Enabling Problem Scaling. */
  32.     public static final boolean DEFAULT_SCALING = true;

  33.     /** Default Value for the Max Iteration for the scaling. */
  34.     public static final int DEFAULT_SCALING_MAX_ITERATION = 10;

  35.     /** Default Value for adapting the weight during iterations. */
  36.     public static final boolean DEFAULT_RHO_UPDATE = true;

  37.     /** Default Max Value for the Weight for ADMM iteration. */
  38.     public static final double DEFAULT_RHO_MAX = 1.0e6;

  39.     /** Default Min Value for the Weight for ADMM iteration. */
  40.     public static final double DEFAULT_RHO_MIN = 1.0e-6;

  41.     /** Default Max number of weight changes. */
  42.     public static final int DEFAULT_MAX_RHO_ITERATION = 10;

  43.     /** Default Value for enabling polishing the solution. */
  44.     public static final boolean DEFAULT_POLISHING = false;

  45.     /** Default Value for Iteration of polishing Algorithm. */
  46.     public static final int DEFAULT_POLISHING_ITERATION = 5;

  47.     /** Absolute and Relative Tolerance for convergence. */
  48.     private double eps;

  49.     /** Absolute and Relative Tolerance for Infeasible Criteria. */
  50.     private double epsInfeasible;

  51.     /** Value of regularization term sigma for Karush–Kuhn–Tucker solver. */
  52.     private double sigma;

  53.     /** Value of alpha filter for ADMM iteration. */
  54.     private double alpha;

  55.     /** Scaling enabling flag. */
  56.     private boolean scaling;

  57.     /** Value for the Max Iteration for the scaling. */
  58.     private int scaleMaxIteration;

  59.     /** Value for adapt the weight during iterations. */
  60.     private boolean updateRho;

  61.     /** Max Value for thr Weight for ADMM iteration. */
  62.     private double rhoMax;

  63.     /** Min Value for the Weight for ADMM iteration. */
  64.     private double rhoMin;

  65.     /** Max Value of changing the weight during iterations. */
  66.     private int maxRhoIteration;

  67.     /** Enabling flag for polishing the solution. */
  68.     private boolean polishing;

  69.     /** Value for Iteration of polishing Algorithm. */
  70.     private int polishingIteration;

  71.     /** Simple constructor.
  72.      */
  73.     public ADMMQPOption() {
  74.         eps                = DEFAULT_EPS;
  75.         epsInfeasible      = DEFAULT_EPS_INFEASIBLE;
  76.         sigma              = DEFAULT_SIGMA;
  77.         alpha              = DEFAULT_ALPHA;
  78.         scaling            = DEFAULT_SCALING;
  79.         scaleMaxIteration  = DEFAULT_SCALING_MAX_ITERATION;
  80.         updateRho          = DEFAULT_RHO_UPDATE;
  81.         rhoMax             = DEFAULT_RHO_MAX;
  82.         rhoMin             = DEFAULT_RHO_MIN;
  83.         maxRhoIteration    = DEFAULT_MAX_RHO_ITERATION;
  84.         polishing          = DEFAULT_POLISHING;
  85.         polishingIteration = DEFAULT_POLISHING_ITERATION;
  86.     }

  87.     /** Set absolute and Relative Tolerance for convergence.
  88.      * @param eps absolute and Relative Tolerance for convergence
  89.      */
  90.     public void setEps(final double eps) {
  91.         this.eps = eps;
  92.     }

  93.     /** Get absolute and Relative Tolerance for convergence.
  94.      * @return absolute and Relative Tolerance for convergence
  95.      */
  96.     public double getEps() {
  97.         return eps;
  98.     }

  99.     /** Set absolute and Relative Tolerance for infeasible criteria.
  100.      * @param epsInfeasible absolute and Relative Tolerance for infeasible criteria
  101.      */
  102.     public void setEpsInfeasible(final double epsInfeasible) {
  103.         this.epsInfeasible = epsInfeasible;
  104.     }

  105.     /** Get absolute and Relative Tolerance for infeasible criteria.
  106.      * @return absolute and Relative Tolerance for infeasible criteria
  107.      */
  108.     public double getEpsInfeasible() {
  109.         return epsInfeasible;
  110.     }

  111.     /** Set value of regularization term sigma for Karush–Kuhn–Tucker solver.
  112.      * @param sigma value of regularization term sigma for Karush–Kuhn–Tucker solver
  113.      */
  114.     public void setSigma(final double sigma) {
  115.         this.sigma = sigma;
  116.     }

  117.     /** Get value of regularization term sigma for Karush–Kuhn–Tucker solver.
  118.      * @return value of regularization term sigma for Karush–Kuhn–Tucker solver
  119.      */
  120.     public double getSigma() {
  121.         return sigma;
  122.     }

  123.     /** Set value of alpha filter for ADMM iteration.
  124.      * @param alpha value of alpha filter for ADMM iteration
  125.      */
  126.     public void setAlpha(final double alpha) {
  127.         this.alpha = alpha;
  128.     }

  129.     /** Get value of alpha filter for ADMM iteration.
  130.      * @return value of alpha filter for ADMM iteration
  131.      */
  132.     public double getAlpha() {
  133.         return alpha;
  134.     }

  135.     /** Set scaling enabling flag.
  136.      * @param scaling if true, scaling is enabled
  137.      */
  138.     public void setScaling(final boolean scaling) {
  139.         this.scaling = scaling;
  140.     }

  141.     /** Check if scaling is enabled.
  142.      * @return true if scaling is enabled
  143.      */
  144.     public boolean isScaling() {
  145.         return scaling;
  146.     }

  147.     /** Set max iteration for the scaling.
  148.      * @param scaleMaxIteration max iteration for the scaling
  149.      */
  150.     public void setScaleMaxIteration(final int scaleMaxIteration) {
  151.         this.scaleMaxIteration = scaleMaxIteration;
  152.     }

  153.     /** Get max iteration for the scaling.
  154.      * @return max iteration for the scaling
  155.      */
  156.     public int getScaleMaxIteration() {
  157.         return scaleMaxIteration;
  158.     }

  159.     /** Set weight updating flag.
  160.      * @param updateRho if true, weight is updated during iterations
  161.      */
  162.     public void setUpdateRho(final boolean updateRho) {
  163.         this.updateRho = updateRho;
  164.     }

  165.     /** Check if weight updating is enabled.
  166.      * @return true if weight is updated during iterations
  167.      */
  168.     public boolean updateRho() {
  169.         return updateRho;
  170.     }

  171.     /** Set min Value for the Weight for ADMM iteration.
  172.      * @param rhoMin min Value for the Weight for ADMM iteration
  173.      */
  174.     public void setRhoMin(final double rhoMin) {
  175.         this.rhoMin = rhoMin;
  176.     }

  177.     /** Get min Value for the Weight for ADMM iteration.
  178.      * @return min Value for the Weight for ADMM iteration
  179.      */
  180.     public double getRhoMin() {
  181.         return rhoMin;
  182.     }

  183.     /** Set max Value for the Weight for ADMM iteration.
  184.      * @param rhoMax max Value for the Weight for ADMM iteration
  185.      */
  186.     public void setRhoMax(final double rhoMax) {
  187.         this.rhoMax = rhoMax;
  188.     }

  189.     /** Get max Value for the Weight for ADMM iteration.
  190.      * @return max Value for the Weight for ADMM iteration
  191.      */
  192.     public double getRhoMax() {
  193.         return rhoMax;
  194.     }

  195.     /** Set max number of weight changes.
  196.      * @param maxRhoIteration max number of weight changes
  197.      */
  198.     public void setMaxRhoIteration(final int maxRhoIteration) {
  199.         this.maxRhoIteration = maxRhoIteration;
  200.     }

  201.     /** Get max number of weight changes.
  202.      * @return max number of weight changes
  203.      */
  204.     public int getMaxRhoIteration() {
  205.         return maxRhoIteration;
  206.     }

  207.     /** Set polishing enabling flag.
  208.      * @param polishing if true, polishing is enabled
  209.      */
  210.     public void setPolishing(final boolean polishing) {
  211.         this.polishing = polishing;
  212.     }

  213.     /** Check if polishing is enabled.
  214.      * @return true if polishing is enabled
  215.      */
  216.     public boolean isPolishing() {
  217.         return polishing;
  218.     }

  219.     /** Set number of iterations of polishing algorithm.
  220.      * @param polishingIteration number of iterations of polishing algorithm
  221.      */
  222.     public void setPolishingIteration(final int polishingIteration) {
  223.         this.polishingIteration = polishingIteration;
  224.     }

  225.     /** Get number of iterations of polishing algorithm.
  226.      * @return number of iterations of polishing algorithm
  227.      */
  228.     public int getPolishIteration() {
  229.         return polishingIteration;
  230.     }

  231. }