source: src/main/java/agents/anac/y2019/harddealer/math3/optim/univariate/SearchInterval.java

Last change on this file was 204, checked in by Katsuhide Fujita, 5 years ago

Fixed errors of ANAC2019 agents

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) 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 ASF 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 * http://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 */
17package agents.anac.y2019.harddealer.math3.optim.univariate;
18
19import agents.anac.y2019.harddealer.math3.optim.OptimizationData;
20import agents.anac.y2019.harddealer.math3.exception.NumberIsTooLargeException;
21import agents.anac.y2019.harddealer.math3.exception.OutOfRangeException;
22
23/**
24 * Search interval and (optional) start value.
25 * <br/>
26 * Immutable class.
27 *
28 * @since 3.1
29 */
30public class SearchInterval implements OptimizationData {
31 /** Lower bound. */
32 private final double lower;
33 /** Upper bound. */
34 private final double upper;
35 /** Start value. */
36 private final double start;
37
38 /**
39 * @param lo Lower bound.
40 * @param hi Upper bound.
41 * @param init Start value.
42 * @throws NumberIsTooLargeException if {@code lo >= hi}.
43 * @throws OutOfRangeException if {@code init < lo} or {@code init > hi}.
44 */
45 public SearchInterval(double lo,
46 double hi,
47 double init) {
48 if (lo >= hi) {
49 throw new NumberIsTooLargeException(lo, hi, false);
50 }
51 if (init < lo ||
52 init > hi) {
53 throw new OutOfRangeException(init, lo, hi);
54 }
55
56 lower = lo;
57 upper = hi;
58 start = init;
59 }
60
61 /**
62 * @param lo Lower bound.
63 * @param hi Upper bound.
64 * @throws NumberIsTooLargeException if {@code lo >= hi}.
65 */
66 public SearchInterval(double lo,
67 double hi) {
68 this(lo, hi, 0.5 * (lo + hi));
69 }
70
71 /**
72 * Gets the lower bound.
73 *
74 * @return the lower bound.
75 */
76 public double getMin() {
77 return lower;
78 }
79 /**
80 * Gets the upper bound.
81 *
82 * @return the upper bound.
83 */
84 public double getMax() {
85 return upper;
86 }
87 /**
88 * Gets the start value.
89 *
90 * @return the start value.
91 */
92 public double getStartValue() {
93 return start;
94 }
95}
Note: See TracBrowser for help on using the repository browser.