source: branches/HeuristicLab.Problems.BioBoost/HeuristicLab.Problems.BioBoost/3.3/SolutionCreation/ConstantValueRealVectorCreator.cs @ 13069

Last change on this file since 13069 was 13069, checked in by gkronber, 7 years ago

#2499: imported source code for HeuristicLab.BioBoost from private repository with some changes

File size: 1.6 KB
Line 
1using HeuristicLab.Common;
2using HeuristicLab.Core;
3using HeuristicLab.Data;
4using HeuristicLab.Encodings.RealVectorEncoding;
5using HeuristicLab.Parameters;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7using System.Linq;
8
9namespace HeuristicLab.BioBoost.SolutionCreation {
10
11  [StorableClass]
12  public class ConstantValueRealVectorCreator : RealVectorCreator {
13
14    public IValueLookupParameter<DoubleValue> ValueParameter {
15      get { return (IValueLookupParameter<DoubleValue>) Parameters["Value"]; }
16    }
17
18    public double Value {
19      get { return ValueParameter.ActualValue.Value; }
20      set { ValueParameter.Value = new DoubleValue(value); }
21    }
22
23      #region Construction & Cloning
24    [StorableConstructor]
25    protected ConstantValueRealVectorCreator(bool isDeserializing) : base(isDeserializing) {}
26    protected ConstantValueRealVectorCreator(ConstantValueRealVectorCreator orig, Cloner cloner) : base(orig, cloner) {}
27    public ConstantValueRealVectorCreator() {
28      Parameters.Add(new ValueLookupParameter<DoubleValue>("Value", "The constant value to be replicated.", new DoubleValue(1)));
29      BoundsParameter.Value = new DoubleMatrix(new double[,] {{1, 1}});
30    }
31    public override IDeepCloneable Clone(Cloner cloner) {
32      return new ConstantValueRealVectorCreator(this, cloner);
33    }
34    #endregion
35
36    protected override RealVector Create(IRandom random, IntValue length, DoubleMatrix bounds) {
37      return new RealVector(Enumerable.Repeat(Value, length.Value).ToArray());
38    }
39
40  }
41}
Note: See TracBrowser for help on using the repository browser.