Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/18/08 16:00:00 (17 years ago)
Author:
swagner
Message:

Fixed ticket #67

  • adapted accessing of variables in operators due to changes of variable lookup and the new name aliasing mechanism (actual/formal name translations should not be done directly anymore; instead the new method Scope.TranslateName should be used)
Location:
trunk/sources/HeuristicLab.RealVector
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.RealVector/HeuristicCrossover.cs

    r73 r77  
    3535    protected sealed override void Cross(IScope scope, IRandom random, IScope parent1, IScope parent2, IScope child) {
    3636      bool maximization = GetVariableValue<BoolData>("Maximization", scope, true).Data;
    37       IVariableInfo realVectorInfo = GetVariableInfo("RealVector");
    38       IVariableInfo qualityInfo = GetVariableInfo("Quality");
    39       DoubleArrayData vector1 = parent1.GetVariableValue<DoubleArrayData>(realVectorInfo.ActualName, false);
    40       DoubleData quality1 = parent1.GetVariableValue<DoubleData>(qualityInfo.ActualName, false);
    41       DoubleArrayData vector2 = parent2.GetVariableValue<DoubleArrayData>(realVectorInfo.ActualName, false);
    42       DoubleData quality2 = parent2.GetVariableValue<DoubleData>(qualityInfo.ActualName, false);
     37      DoubleArrayData vector1 = parent1.GetVariableValue<DoubleArrayData>("RealVector", false);
     38      DoubleData quality1 = parent1.GetVariableValue<DoubleData>("Quality", false);
     39      DoubleArrayData vector2 = parent2.GetVariableValue<DoubleArrayData>("RealVector", false);
     40      DoubleData quality2 = parent2.GetVariableValue<DoubleData>("Quality", false);
    4341
    4442      if (vector1.Data.Length != vector2.Data.Length) throw new InvalidOperationException("Cannot apply crossover to real vectors of different length.");
    4543
    4644      double[] result = Apply(random, maximization, vector1.Data, quality1.Data, vector2.Data, quality2.Data);
    47       child.AddVariable(new Variable(realVectorInfo.ActualName, new DoubleArrayData(result)));
     45      child.AddVariable(new Variable(child.TranslateName("RealVector"), new DoubleArrayData(result)));
    4846    }
    4947  }
  • trunk/sources/HeuristicLab.RealVector/RealVectorCrossoverBase.cs

    r2 r77  
    3535
    3636    protected sealed override void Cross(IScope scope, IRandom random, IScope parent1, IScope parent2, IScope child) {
    37       IVariableInfo realVectorInfo = GetVariableInfo("RealVector");
    38       DoubleArrayData vector1 = parent1.GetVariableValue<DoubleArrayData>(realVectorInfo.ActualName, false);
    39       DoubleArrayData vector2 = parent2.GetVariableValue<DoubleArrayData>(realVectorInfo.ActualName, false);
     37      DoubleArrayData vector1 = parent1.GetVariableValue<DoubleArrayData>("RealVector", false);
     38      DoubleArrayData vector2 = parent2.GetVariableValue<DoubleArrayData>("RealVector", false);
    4039
    4140      if (vector1.Data.Length != vector2.Data.Length) throw new InvalidOperationException("Cannot apply crossover to real vectors of different length.");
    4241
    4342      double[] result = Cross(scope, random, vector1.Data, vector2.Data);
    44       child.AddVariable(new Variable(realVectorInfo.ActualName, new DoubleArrayData(result)));
     43      child.AddVariable(new Variable(child.TranslateName("RealVector"), new DoubleArrayData(result)));
    4544    }
    4645
  • trunk/sources/HeuristicLab.RealVector/UniformRandomRealVectorGenerator.cs

    r2 r77  
    5454
    5555      double[] vector = Apply(random, length, min, max);
    56       scope.AddVariable(new Variable(GetVariableInfo("RealVector").ActualName, new DoubleArrayData(vector)));
     56      scope.AddVariable(new Variable(scope.TranslateName("RealVector"), new DoubleArrayData(vector)));
    5757
    5858      return null;
Note: See TracChangeset for help on using the changeset viewer.