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 */
17
18 package org.apache.commons.math.estimation;
19
20 import java.io.Serializable;
21
22 /** This class represents the estimated parameters of an estimation problem.
23 *
24 * <p>The parameters of an estimation problem have a name, a value and
25 * a bound flag. The value of bound parameters is considered trusted
26 * and the solvers should not adjust them. On the other hand, the
27 * solvers should adjust the value of unbounds parameters until they
28 * satisfy convergence criterions specific to each solver.</p>
29 *
30 * @version $Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 2008) $
31 * @since 1.2
32 *
33 */
34
35 public class EstimatedParameter
36 implements Serializable {
37
38 /** Simple constructor.
39 * Build an instance from a first estimate of the parameter,
40 * initially considered unbound.
41 * @param name name of the parameter
42 * @param firstEstimate first estimate of the parameter
43 */
44 public EstimatedParameter(String name, double firstEstimate) {
45 this.name = name;
46 estimate = firstEstimate;
47 bound = false;
48 }
49
50 /** Simple constructor.
51 * Build an instance from a first estimate of the parameter and a
52 * bound flag
53 * @param name name of the parameter
54 * @param firstEstimate first estimate of the parameter
55 * @param bound flag, should be true if the parameter is bound
56 */
57 public EstimatedParameter(String name,
58 double firstEstimate,
59 boolean bound) {
60 this.name = name;
61 estimate = firstEstimate;
62 this.bound = bound;
63 }
64
65 /** Copy constructor.
66 * Build a copy of a parameter
67 * @param parameter instance to copy
68 */
69 public EstimatedParameter(EstimatedParameter parameter) {
70 name = parameter.name;
71 estimate = parameter.estimate;
72 bound = parameter.bound;
73 }
74
75 /** Set a new estimated value for the parameter.
76 * @param estimate new estimate for the parameter
77 */
78 public void setEstimate(double estimate) {
79 this.estimate = estimate;
80 }
81
82 /** Get the current estimate of the parameter
83 * @return current estimate
84 */
85 public double getEstimate() {
86 return estimate;
87 }
88
89 /** get the name of the parameter
90 * @return parameter name
91 */
92 public String getName() {
93 return name;
94 }
95
96 /** Set the bound flag of the parameter
97 * @param bound this flag should be set to true if the parameter is
98 * bound (i.e. if it should not be adjusted by the solver).
99 */
100 public void setBound(boolean bound) {
101 this.bound = bound;
102 }
103
104 /** Check if the parameter is bound
105 * @return true if the parameter is bound */
106 public boolean isBound() {
107 return bound;
108 }
109
110 /** Name of the parameter */
111 private String name;
112
113 /** Current value of the parameter */
114 protected double estimate;
115
116 /** Indicator for bound parameters
117 * (ie parameters that should not be estimated)
118 */
119 private boolean bound;
120
121 /** Serializable version identifier */
122 private static final long serialVersionUID = -555440800213416949L;
123
124 }