Line | |
---|
1 | using HeuristicLab.Common;
|
---|
2 | using HeuristicLab.Core;
|
---|
3 | using HeuristicLab.Data;
|
---|
4 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
5 | using HeuristicLab.Parameters;
|
---|
6 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
7 | using System.Linq;
|
---|
8 |
|
---|
9 | namespace 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.