Last change
on this file since 4682 was
4525,
checked in by cneumuel, 14 years ago
|
implemented basic crossover operator for ParameterSets. MetaOptimization is now functional on a basic level (Configuration and Crossing only works for IntValue Parameters) (#1215)
|
File size:
1.4 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Core;
|
---|
6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.Problems.MetaOptimization {
|
---|
9 | [StorableClass]
|
---|
10 | public class ParameterSet : Item, IParameterSet {
|
---|
11 | [Storable]
|
---|
12 | private List<IParameterConfiguration> parameters;
|
---|
13 | public IEnumerable<IParameterConfiguration> Parameters {
|
---|
14 | get { return parameters; }
|
---|
15 | }
|
---|
16 |
|
---|
17 | public ParameterSet() {
|
---|
18 | this.parameters = new List<IParameterConfiguration>();
|
---|
19 | }
|
---|
20 |
|
---|
21 | [StorableConstructor]
|
---|
22 | protected ParameterSet(bool deserializing) : base(deserializing) { }
|
---|
23 |
|
---|
24 | public ParameterSet(ParameterConfigurationList parametersToOptimize, IRandom random)
|
---|
25 | : this() {
|
---|
26 | foreach (IParameterConfiguration config in parametersToOptimize.CheckedItems) {
|
---|
27 | IParameterConfiguration clone = (IParameterConfiguration)config.Clone();
|
---|
28 | clone.SetParameterWithRandomValue(random);
|
---|
29 | parameters.Add(clone);
|
---|
30 | }
|
---|
31 | }
|
---|
32 |
|
---|
33 | #region Cloning
|
---|
34 | public override Common.IDeepCloneable Clone(Common.Cloner cloner) {
|
---|
35 | ParameterSet clone = (ParameterSet)base.Clone(cloner);
|
---|
36 | clone.parameters = new List<IParameterConfiguration>();
|
---|
37 | foreach (var param in this.parameters) {
|
---|
38 | clone.parameters.Add((IParameterConfiguration)param.Clone(cloner));
|
---|
39 | }
|
---|
40 | return clone;
|
---|
41 | }
|
---|
42 | #endregion
|
---|
43 | }
|
---|
44 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.