• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: 922710 $ $Date: 2010-03-14 02:20:56 +0100 (dim. 14 mars 2010) $
31  * @since 1.2
32  * @deprecated as of 2.0, everything in package org.apache.commons.math.estimation has
33  * been deprecated and replaced by package org.apache.commons.math.optimization.general
34  *
35  */
36 @Deprecated
37 public class EstimatedParameter
38   implements Serializable {
39 
40     /** Serializable version identifier */
41     private static final long serialVersionUID = -555440800213416949L;
42 
43     /** Current value of the parameter */
44     protected double  estimate;
45 
46     /** Name of the parameter */
47     private final String  name;
48 
49     /** Indicator for bound parameters
50      * (ie parameters that should not be estimated)
51      */
52     private   boolean bound;
53 
54     /** Simple constructor.
55      * Build an instance from a first estimate of the parameter,
56      * initially considered unbound.
57      * @param name name of the parameter
58      * @param firstEstimate first estimate of the parameter
59      */
EstimatedParameter(String name, double firstEstimate)60     public EstimatedParameter(String name, double firstEstimate) {
61         this.name = name;
62         estimate  = firstEstimate;
63         bound     = false;
64     }
65 
66     /** Simple constructor.
67      * Build an instance from a first estimate of the parameter and a
68      * bound flag
69      * @param name name of the parameter
70      * @param firstEstimate first estimate of the parameter
71      * @param bound flag, should be true if the parameter is bound
72      */
EstimatedParameter(String name, double firstEstimate, boolean bound)73     public EstimatedParameter(String name,
74                               double firstEstimate,
75                               boolean bound) {
76         this.name  = name;
77         estimate   = firstEstimate;
78         this.bound = bound;
79     }
80 
81     /** Copy constructor.
82      * Build a copy of a parameter
83      * @param parameter instance to copy
84      */
EstimatedParameter(EstimatedParameter parameter)85     public EstimatedParameter(EstimatedParameter parameter) {
86         name     = parameter.name;
87         estimate = parameter.estimate;
88         bound    = parameter.bound;
89     }
90 
91     /** Set a new estimated value for the parameter.
92      * @param estimate new estimate for the parameter
93      */
setEstimate(double estimate)94     public void setEstimate(double estimate) {
95         this.estimate = estimate;
96     }
97 
98     /** Get the current estimate of the parameter
99      * @return current estimate
100      */
getEstimate()101     public double getEstimate() {
102         return estimate;
103     }
104 
105     /** get the name of the parameter
106      * @return parameter name
107      */
getName()108     public String getName() {
109         return name;
110     }
111 
112     /** Set the bound flag of the parameter
113      * @param bound this flag should be set to true if the parameter is
114      * bound (i.e. if it should not be adjusted by the solver).
115      */
setBound(boolean bound)116     public void setBound(boolean bound) {
117         this.bound = bound;
118     }
119 
120     /** Check if the parameter is bound
121      * @return true if the parameter is bound */
isBound()122     public boolean isBound() {
123         return bound;
124     }
125 
126 }
127