View Javadoc
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  
20  import org.junit.Assert;
21  import org.junit.Test;
22  
23  public class ADMMQPOptionTest {
24  
25      @Test
26      public void testSettersDouble() {
27          // GIVEN
28          final ADMMQPOption option = new ADMMQPOption();
29          // WHEN
30          final double expectedValue = 1.;
31          option.setAlpha(expectedValue);
32          option.setEps(expectedValue);
33          option.setEpsInfeasible(expectedValue);
34          option.setRhoMax(expectedValue);
35          option.setRhoMin(expectedValue);
36          option.setRhoMax(expectedValue);
37          option.setSigma(expectedValue);
38          // THEN
39          final double tolerance = 0.;
40          Assert.assertEquals(expectedValue, option.getAlpha(), tolerance);
41          Assert.assertEquals(expectedValue, option.getEps(), tolerance);
42          Assert.assertEquals(expectedValue, option.getEpsInfeasible(), tolerance);
43          Assert.assertEquals(expectedValue, option.getRhoMax(), tolerance);
44          Assert.assertEquals(expectedValue, option.getRhoMin(), tolerance);
45          Assert.assertEquals(expectedValue, option.getSigma(), tolerance);
46      }
47  
48      @Test
49      public void testSettersBoolean() {
50          // GIVEN
51          final ADMMQPOption option = new ADMMQPOption();
52          // WHEN
53          final boolean expectedValue = true;
54          option.setPolishing(expectedValue);
55          option.setUpdateRho(expectedValue);
56          option.setScaling(expectedValue);
57          // THEN
58          Assert.assertEquals(expectedValue, option.isPolishing());
59          Assert.assertEquals(expectedValue, option.updateRho());
60          Assert.assertEquals(expectedValue, option.isScaling());
61      }
62  
63      @Test
64      public void testSettersIntegers() {
65          // GIVEN
66          final ADMMQPOption option = new ADMMQPOption();
67          // WHEN
68          final int expectedValue = 10;
69          option.setMaxRhoIteration(expectedValue);
70          option.setPolishingIteration(expectedValue);
71          option.setScaleMaxIteration(expectedValue);
72          // THEN
73          Assert.assertEquals(expectedValue, option.getMaxRhoIteration());
74          Assert.assertEquals(expectedValue, option.getPolishIteration());
75          Assert.assertEquals(expectedValue, option.getScaleMaxIteration());
76      }
77  
78  }