View Javadoc

1   /***
2    * 
3    */
4   package yawn.optim.genetic;
5   
6   import yawn.config.NeuralNetworkConfig;
7   import yawn.config.ValidationException;
8   import yawn.envs.Environment;
9   import yawn.nn.fuzzyartmap.FuzzyArtMapConfig;
10  
11  /***
12   * This is yawn.optim.genetic.GeneticParameterFitterConfig, part of the yawn
13   * project.
14   * 
15   * <p>$Id: GeneticParameterFitterConfig.java,v 1.4 2005/05/09 11:04:55 supermarti Exp $</p>
16   * 
17   * @author Luis Mart&iacute; (luis dot marti at uc3m dot es)
18   * @version $Revision: 1.4 $
19   */
20  public class GeneticParameterFitterConfig extends NeuralNetworkConfig {
21  
22  	/***
23  	 * 
24  	 * @uml.property name="maxGenerations" 
25  	 */
26  	protected int maxGenerations;
27  
28  	/***
29  	 * 
30  	 * @uml.property name="modeltoBeFittedConfig"
31  	 * @uml.associationEnd multiplicity="(0 1)"
32  	 */
33  	protected NeuralNetworkConfig modeltoBeFittedConfig;
34  
35  	/***
36  	 * 
37  	 * @uml.property name="populationSize" 
38  	 */
39  	protected int populationSize;
40  
41  	/***
42  	 * 
43  	 * @uml.property name="preserveFittestIndividual" 
44  	 */
45  	protected boolean preserveFittestIndividual;
46  
47  
48      /***
49       * 
50       */
51      public GeneticParameterFitterConfig() {
52          super();
53      }
54  
55      /***
56       * @see yawn.config.NeuralNetworkConfig#getBindedNetworkClass()
57       */
58      public Class getBindedNetworkClass() {
59          return GeneticParameterFitter.class;
60      }
61  
62  	/***
63  	 * @return Returns the maxGenerations.
64  	 * 
65  	 * @uml.property name="maxGenerations"
66  	 */
67  	public int getMaxGenerations() {
68  		return maxGenerations;
69  	}
70  
71  	/***
72  	 * @return Returns the modeltoBeFittedConfig.
73  	 * 
74  	 * @uml.property name="modeltoBeFittedConfig"
75  	 */
76  	public NeuralNetworkConfig getModeltoBeFittedConfig() {
77  		return modeltoBeFittedConfig;
78  	}
79  
80  	/***
81  	 * @return Returns the populationSize.
82  	 * 
83  	 * @uml.property name="populationSize"
84  	 */
85  	public int getPopulationSize() {
86  		return populationSize;
87  	}
88  
89  	/***
90  	 * @return Returns the preserveFittestIndividual.
91  	 * 
92  	 * @uml.property name="preserveFittestIndividual"
93  	 */
94  	public boolean getPreserveFittestIndividual() {
95  		return preserveFittestIndividual;
96  	}
97  
98  
99      /***
100      * @see yawn.config.NeuralNetworkConfig#internalValidate()
101      * @todo
102      */
103     protected void internalValidate() throws ValidationException {
104         // TODO Auto-generated method stub
105     }
106 
107     /***
108      * @return Returns the preserveFittestIndividual.
109      */
110     public boolean isPreserveFittestIndividual() {
111         return preserveFittestIndividual;
112     }
113 
114 	/***
115 	 * @param maxGenerations
116 	 *            The maxGenerations to set.
117 	 * 
118 	 * @uml.property name="maxGenerations"
119 	 */
120 	public void setMaxGenerations(int maxGenerations) {
121 		this.maxGenerations = maxGenerations;
122 	}
123 
124 	/***
125 	 * @param fittedModelConfig
126 	 *            The fittedModelConfig to set.
127 	 * 
128 	 * @uml.property name="modeltoBeFittedConfig"
129 	 */
130 	public void setModeltoBeFittedConfig(NeuralNetworkConfig fittedModelConfig) {
131 		this.modeltoBeFittedConfig = fittedModelConfig;
132 	}
133 
134 	/***
135 	 * @param populationSize
136 	 *            The populationSize to set.
137 	 * 
138 	 * @uml.property name="populationSize"
139 	 */
140 	public void setPopulationSize(int populationSize) {
141 		this.populationSize = populationSize;
142 	}
143 
144 	/***
145 	 * @param preserveFittestIndividual
146 	 *            The preserveFittestIndividual to set.
147 	 * 
148 	 * @uml.property name="preserveFittestIndividual"
149 	 */
150 	public void setPreserveFittestIndividual(boolean preserveFittestIndividual) {
151 		this.preserveFittestIndividual = preserveFittestIndividual;
152 	}
153 
154     /*
155      * (non-Javadoc)
156      * 
157      * @see yawn.config.NeuralNetworkConfig#setEnvironment(yawn.envs.Environment)
158      */
159     public void setEnvironment(Environment environment) {
160         if (modeltoBeFittedConfig != null) {
161             modeltoBeFittedConfig.setEnvironment(environment);
162         }
163         super.setEnvironment(environment);
164     }
165 
166 	/***
167 	 * @see yawn.config.NeuralNetworkConfig#createSampleInstance()
168 	 */
169 	public NeuralNetworkConfig createSampleInstance() {
170         GeneticParameterFitterConfig config = new GeneticParameterFitterConfig();
171         config.setMaxGenerations(20);
172         config.setPopulationSize(10);
173         config.setPreserveFittestIndividual(false);
174         
175 
176         FuzzyArtMapConfig conf = new FuzzyArtMapConfig();
177 
178         conf.setMaxEpochs(10);
179 
180         conf.setAlphaArtA(0.00000001);
181         conf.setBetaArtA(0.8);
182         conf.setVigilanceArtA(0.95);
183 
184         conf.setAlphaArtB(0.00000001);
185         conf.setBetaArtB(0.8);
186         conf.setVigilanceArtB(1);
187 
188         conf.setUseComplementCoding(true);
189         conf.setEpsilon(0.001);
190         conf.setMatchError(0.0005);
191 
192         config.setModeltoBeFittedConfig(conf);
193 
194         return config;
195 	}
196 
197 }