Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/22/10 16:06:48 (14 years ago)
Author:
gkronber
Message:

Added weights for open parameters. #833 (Genetic Programming based search for equations (modeling with multiple target variables))

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification.Networks/3.2/Symbols/OpenParameterFunctionTree.cs

    r2616 r2674  
    3030    public string VariableName { get; set; }
    3131    public int SampleOffset { get; set; }
     32    public double Weight { get; set; }
    3233
    3334    public OpenParameterFunctionTree(OpenParameter openParameter)
    3435      : base(openParameter) {
     36      this.Weight = 1.0;
    3537    }
    3638
     
    3941      VariableName = original.VariableName;
    4042      SampleOffset = original.SampleOffset;
     43      Weight = original.Weight;
    4144    }
    4245
     
    5154      scope.AddSubScope(myVariableScope);
    5255      myVariableScope.AddVariable(CreateSampleOffsetVariable());
     56      myVariableScope.AddVariable(CreateWeightVariable());
    5357      return new AtomicOperation(Function.Manipulator, myVariableScope);
    5458    }
     
    5862      scope.AddSubScope(myVariableScope);
    5963      myVariableScope.AddVariable(CreateSampleOffsetVariable());
     64      myVariableScope.AddVariable(CreateWeightVariable());
    6065      return new AtomicOperation(Function.Initializer, myVariableScope);
    6166    }
     
    7277    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<System.Guid, IStorable> persistedObjects) {
    7378      XmlNode node = document.CreateElement(name);
     79      XmlAttribute weightAttr = document.CreateAttribute("Weight");
     80      weightAttr.Value = XmlConvert.ToString(Weight);
    7481      XmlAttribute variableAttr = document.CreateAttribute("Variable");
    7582      variableAttr.Value = VariableName;
    7683      XmlAttribute sampleOffsetAttr = document.CreateAttribute("SampleOffset");
    7784      sampleOffsetAttr.Value = XmlConvert.ToString(SampleOffset);
     85      node.Attributes.Append(weightAttr);
    7886      node.Attributes.Append(sampleOffsetAttr);
    7987      node.Attributes.Append(variableAttr);
     
    8391    public override void Populate(XmlNode node, IDictionary<System.Guid, IStorable> restoredObjects) {
    8492      base.Populate(node, restoredObjects);
     93      Weight = XmlConvert.ToDouble(node.Attributes["Weight"].Value);
    8594      SampleOffset = XmlConvert.ToInt32(node.Attributes["SampleOffset"].Value);
    8695      VariableName = node.Attributes["Variable"].Value;
     
    103112      return variable;
    104113    }
     114
     115    private IVariable CreateWeightVariable() {
     116      DoubleData data = new DoubleData(Weight);
     117      data.Changed += (sender, args) => Weight = data.Data;
     118      var variable = new HeuristicLab.Core.Variable(Variable.WEIGHT, data);
     119      variable.ValueChanged += (sender, args) => Weight = ((DoubleData)variable.Value).Data;
     120      return variable;
     121    }
    105122  }
    106123}
Note: See TracChangeset for help on using the changeset viewer.