1 /*
2 * Copyright 2006 - 2012 Christina Bohk and Roland Ewald
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package p3j.pppm.parameters;
17
18 import java.io.Serializable;
19
20 import p3j.misc.MatrixDimension;
21
22 /**
23 * Represents a parameter in the PPPM. A parameter is basically a name,
24 * associated with an ID. It denotes a certain basic sort of parameter within
25 * the PPPM, e.g. the fertility of emigrants, the fertility of natives, etc.
26 * Each parameter has to come in certain (matrix) dimensions, which are defined
27 * here as {@link Parameter#valueWidth} and {@link Parameter#valueHeight}. These
28 * are given in {@link MatrixDimension}. A parameter might be
29 * generation-dependent, expressed by {@link Parameter#generationDependent},
30 * e.g., fertility of X-th generation of emigrants. Note that this class only
31 * stores the general aspects of the parameter. The definition of an actual
32 * input parameter kind, e.g. the fertility of the 5-th generation of emigrants,
33 * is done by {@link ParameterInstance} objects. All instances of this class are
34 * defined as constants in {@link Parameters}.
35 *
36 * Created on January 18, 2007
37 *
38 * @author Christina Bohk
39 * @author Roland Ewald
40 *
41 */
42 public class Parameter implements Serializable {
43
44 /** Serialization ID. */
45 private static final long serialVersionUID = 7301913452917113893L;
46
47 /** ID of the parameter. */
48 private int id;
49
50 /** Flag to mark generation-dependent parameters. */
51 private boolean generationDependent;
52
53 /** Name of the parameter. */
54 private String name;
55
56 /** Width of a valid value matrix. */
57 private MatrixDimension valueWidth = MatrixDimension.YEARS;
58
59 /** Height of a valid value matrix. */
60 private MatrixDimension valueHeight = MatrixDimension.AGES;
61
62 /** The population this parameter refers to. */
63 private Population population;
64
65 /**
66 * Default constructor.
67 *
68 * @param paramID
69 * the unique identifier of the parameter
70 * @param genDependent
71 * if true, this parameter is generation-dependent
72 * @param paramName
73 * name of the parameter
74 * @param height
75 * height of the parameter matrix
76 * @param width
77 * width of the parameter matrix
78 * @param pop
79 * the population this parameter belongs to
80 */
81 public Parameter(int paramID, boolean genDependent, String paramName,
82 MatrixDimension height, MatrixDimension width, Population pop) {
83 id = paramID;
84 generationDependent = genDependent;
85 name = paramName;
86 valueHeight = height;
87 valueWidth = width;
88 population = pop;
89 }
90
91 /**
92 * Constructor for bean compatibility.
93 */
94 public Parameter() {
95 this(-1, false, "", MatrixDimension.AGES, MatrixDimension.YEARS,
96 Population.NATIVES);
97 }
98
99 public MatrixDimension getValueWidth() {
100 return valueWidth;
101 }
102
103 public void setValueWidth(MatrixDimension valWidth) {
104 this.valueWidth = valWidth;
105 }
106
107 public MatrixDimension getValueHeight() {
108 return valueHeight;
109 }
110
111 public void setValueHeight(MatrixDimension valHeight) {
112 this.valueHeight = valHeight;
113 }
114
115 public boolean isGenerationDependent() {
116 return generationDependent;
117 }
118
119 public void setGenerationDependent(boolean generationDependent) {
120 this.generationDependent = generationDependent;
121 }
122
123 public int getID() {
124 return id;
125 }
126
127 public final void setID(int paramID) {
128 id = paramID;
129 }
130
131 public String getName() {
132 return name;
133 }
134
135 public void setName(String name) {
136 this.name = name;
137 }
138
139 public Population getPopulation() {
140 return population;
141 }
142
143 public void setPopulation(Population population) {
144 this.population = population;
145 }
146
147 @Override
148 public String toString() {
149 return name;
150 }
151 }