Last change
on this file since 72 was
70,
checked in by swagner, 17 years ago
|
Worked on ticket #15
- added crossover and manipulation operators implemented by adoppelb
|
File size:
1.3 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Text;
|
---|
4 | using HeuristicLab.Core;
|
---|
5 | using HeuristicLab.Data;
|
---|
6 |
|
---|
7 | namespace HeuristicLab.RealVector {
|
---|
8 | class UniformAllPositionsManipulator : RealVectorManipulatorBase {
|
---|
9 | public override string Description {
|
---|
10 | get { return "Uniformly distributed change of all positions of a real vector."; }
|
---|
11 | }
|
---|
12 |
|
---|
13 | public UniformAllPositionsManipulator() {
|
---|
14 | AddVariableInfo(new VariableInfo("Minimum", "Minimum of the sampling range for the vector element (included)", typeof(DoubleData), VariableKind.In));
|
---|
15 | AddVariableInfo(new VariableInfo("Maximum", "Maximum of the sampling range for the vector element (excluded)", typeof(DoubleData), VariableKind.In));
|
---|
16 | }
|
---|
17 |
|
---|
18 | public static double[] Apply(IRandom random, double[] vector, double min, double max) {
|
---|
19 | double[] result = (double[])vector.Clone();
|
---|
20 |
|
---|
21 | for (int i = 0; i < result.Length; i++) {
|
---|
22 | result[i] = min + random.NextDouble() * (max - min);
|
---|
23 | }
|
---|
24 |
|
---|
25 | return result;
|
---|
26 | }
|
---|
27 |
|
---|
28 | protected override double[] Manipulate(IScope scope, IRandom random, double[] vector) {
|
---|
29 | double min = GetVariableValue<DoubleData>("Minimum", scope, true).Data;
|
---|
30 | double max = GetVariableValue<DoubleData>("Maximum", scope, true).Data;
|
---|
31 | return Apply(random, vector, min, max);
|
---|
32 | }
|
---|
33 | }
|
---|
34 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.