using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Encodings.RealVectorEncoding; using HeuristicLab.Parameters; using HeuristicLab.PDPSimulation.DomainModel; using HeuristicLab.PDPSimulation.Operators; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; using HeuristicLab.Problems.DataAnalysis.Symbolic; using HeuristicLab.Problems.DataAnalysis; namespace HeuristicLab.PDPSimulation { [Item("TreePriorityDispatching", "")] [StorableClass] public class TreePriorityDispatching : PriorityDispatching { public IValueLookupParameter SymbolicExpressionTreeParameter { get { return (IValueLookupParameter)Parameters["SymbolicExpressionTree"]; } } public IValueLookupParameter SymbolicDataAnalysisTreeInterpreterParameter { get { return (IValueLookupParameter)Parameters["SymbolicExpressionTreeInterpreter"]; } } [StorableConstructor] protected TreePriorityDispatching(bool deserializing) : base(deserializing) { } protected TreePriorityDispatching(PriorityDispatching original, Cloner cloner) : base(original, cloner) { } public TreePriorityDispatching() { Parameters.Add(new ValueLookupParameter("SymbolicExpressionTree", "The symbolic data analysis solution encoded as a symbolic expression tree.")); Parameters.Add(new ValueLookupParameter("SymbolicExpressionTreeInterpreter", "The interpreter that should be used to calculate the output values of the symbolic data analysis tree.")); } public override IDeepCloneable Clone(Cloner cloner) { return new TreePriorityDispatching(this, cloner); } protected override double CalculatePriority(IDictionary variables) { var tree = SymbolicExpressionTreeParameter.Value; var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.Value; Dataset ds = new Dataset(variables.Keys, variables.Values.Select(v => new List(new double[] { v }))); List rows = new List(); rows.Add(0); double prio = interpreter.GetSymbolicExpressionTreeValues(tree, ds, rows).First(); return prio; } } }