#region License Information /* HeuristicLab * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Random; namespace HeuristicLab.Problems.DataAnalysis.Symbolic { [StorableClass] public sealed class VariableConditionTreeNode : SymbolicExpressionTreeNode { #region properties public new VariableCondition Symbol { get { return (VariableCondition)base.Symbol; } } [Storable] private double threshold; public double Threshold { get { return threshold; } set { threshold = value; } } [Storable] private string variableName; public string VariableName { get { return variableName; } set { variableName = value; } } [Storable] private double slope; public double Slope { get { return slope; } set { slope = value; } } #endregion [StorableConstructor] private VariableConditionTreeNode(bool deserializing) : base(deserializing) { } private VariableConditionTreeNode(VariableConditionTreeNode original, Cloner cloner) : base(original, cloner) { threshold = original.threshold; variableName = original.variableName; slope = original.slope; } public override IDeepCloneable Clone(Cloner cloner) { return new VariableConditionTreeNode(this, cloner); } public VariableConditionTreeNode(VariableCondition variableConditionSymbol) : base(variableConditionSymbol) { } public override bool HasLocalParameters { get { return true; } } public override void ResetLocalParameters(IRandom random) { base.ResetLocalParameters(random); threshold = NormalDistributedRandom.NextDouble(random, Symbol.ThresholdInitializerMu, Symbol.ThresholdInitializerSigma); variableName = Symbol.VariableNames.SelectRandom(random); slope = NormalDistributedRandom.NextDouble(random, Symbol.SlopeInitializerMu, Symbol.SlopeInitializerSigma); } public override void ShakeLocalParameters(IRandom random, double shakingFactor) { base.ShakeLocalParameters(random, shakingFactor); double x = NormalDistributedRandom.NextDouble(random, Symbol.ThresholdManipulatorMu, Symbol.ThresholdManipulatorSigma); threshold = threshold + x * shakingFactor; variableName = Symbol.VariableNames.SelectRandom(random); x = NormalDistributedRandom.NextDouble(random, Symbol.SlopeManipulatorMu, Symbol.SlopeManipulatorSigma); slope = slope + x * shakingFactor; } public override string ToString() { return variableName + " > " + threshold.ToString("E4") + Environment.NewLine + "slope: " + slope.ToString("E4"); } } }