source: src/main/java/agents/org/apache/commons/math/estimation/SimpleEstimationProblem.java

Last change on this file was 1, checked in by Wouter Pasman, 7 years ago

Initial import : Genius 9.0.0

File size: 3.8 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 */
17
18package agents.org.apache.commons.math.estimation;
19
20import java.util.ArrayList;
21import java.util.List;
22
23/**
24 * Simple implementation of the {@link EstimationProblem
25 * EstimationProblem} interface for boilerplate data handling.
26 * <p>This class <em>only</em> handles parameters and measurements
27 * storage and unbound parameters filtering. It does not compute
28 * anything by itself. It should either be used with measurements
29 * implementation that are smart enough to know about the
30 * various parameters in order to compute the partial derivatives
31 * appropriately. Since the problem-specific logic is mainly related to
32 * the various measurements models, the simplest way to use this class
33 * is by extending it and using one internal class extending
34 * {@link WeightedMeasurement WeightedMeasurement} for each measurement
35 * type. The instances of the internal classes would have access to the
36 * various parameters and their current estimate.</p>
37
38 * @version $Revision: 811827 $ $Date: 2009-09-06 17:32:50 +0200 (dim. 06 sept. 2009) $
39 * @since 1.2
40 * @deprecated as of 2.0, everything in package org.apache.commons.math.estimation has
41 * been deprecated and replaced by package org.apache.commons.math.optimization.general
42
43 */
44@Deprecated
45public class SimpleEstimationProblem implements EstimationProblem {
46
47 /** Estimated parameters. */
48 private final List<EstimatedParameter> parameters;
49
50 /** Measurements. */
51 private final List<WeightedMeasurement> measurements;
52
53 /**
54 * Build an empty instance without parameters nor measurements.
55 */
56 public SimpleEstimationProblem() {
57 parameters = new ArrayList<EstimatedParameter>();
58 measurements = new ArrayList<WeightedMeasurement>();
59 }
60
61 /**
62 * Get all the parameters of the problem.
63 * @return parameters
64 */
65 public EstimatedParameter[] getAllParameters() {
66 return parameters.toArray(new EstimatedParameter[parameters.size()]);
67 }
68
69 /**
70 * Get the unbound parameters of the problem.
71 * @return unbound parameters
72 */
73 public EstimatedParameter[] getUnboundParameters() {
74
75 // filter the unbound parameters
76 List<EstimatedParameter> unbound = new ArrayList<EstimatedParameter>(parameters.size());
77 for (EstimatedParameter p : parameters) {
78 if (! p.isBound()) {
79 unbound.add(p);
80 }
81 }
82
83 // convert to an array
84 return unbound.toArray(new EstimatedParameter[unbound.size()]);
85
86 }
87
88 /**
89 * Get the measurements of an estimation problem.
90 * @return measurements
91 */
92 public WeightedMeasurement[] getMeasurements() {
93 return measurements.toArray(new WeightedMeasurement[measurements.size()]);
94 }
95
96 /** Add a parameter to the problem.
97 * @param p parameter to add
98 */
99 protected void addParameter(EstimatedParameter p) {
100 parameters.add(p);
101 }
102
103 /**
104 * Add a new measurement to the set.
105 * @param m measurement to add
106 */
107 protected void addMeasurement(WeightedMeasurement m) {
108 measurements.add(m);
109 }
110
111}
Note: See TracBrowser for help on using the repository browser.