1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Diagnostics;
|
---|
4 | using System.Linq;
|
---|
5 | using HeuristicLab.Common;
|
---|
6 | using HeuristicLab.Core;
|
---|
7 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
8 | using HeuristicLab.Parameters;
|
---|
9 | using HeuristicLab.PDPSimulation.DomainModel;
|
---|
10 | using HeuristicLab.PDPSimulation.Operators;
|
---|
11 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
12 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
13 | using HeuristicLab.Problems.DataAnalysis.Symbolic;
|
---|
14 | using HeuristicLab.Problems.DataAnalysis;
|
---|
15 |
|
---|
16 | namespace HeuristicLab.PDPSimulation {
|
---|
17 | [Item("TreePriorityDispatching", "")]
|
---|
18 | [StorableClass]
|
---|
19 | public class TreePriorityDispatching : PriorityDispatching {
|
---|
20 | public IValueLookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
|
---|
21 | get { return (IValueLookupParameter<ISymbolicExpressionTree>)Parameters["SymbolicExpressionTree"]; }
|
---|
22 | }
|
---|
23 |
|
---|
24 | public IValueLookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter {
|
---|
25 | get { return (IValueLookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters["SymbolicExpressionTreeInterpreter"]; }
|
---|
26 | }
|
---|
27 |
|
---|
28 | [StorableConstructor]
|
---|
29 | protected TreePriorityDispatching(bool deserializing) : base(deserializing) { }
|
---|
30 | protected TreePriorityDispatching(PriorityDispatching original, Cloner cloner) : base(original, cloner) { }
|
---|
31 | public TreePriorityDispatching() {
|
---|
32 | Parameters.Add(new ValueLookupParameter<ISymbolicExpressionTree>("SymbolicExpressionTree", "The symbolic data analysis solution encoded as a symbolic expression tree."));
|
---|
33 | Parameters.Add(new ValueLookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>("SymbolicExpressionTreeInterpreter", "The interpreter that should be used to calculate the output values of the symbolic data analysis tree."));
|
---|
34 | }
|
---|
35 |
|
---|
36 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
37 | return new TreePriorityDispatching(this, cloner);
|
---|
38 | }
|
---|
39 |
|
---|
40 | protected override double CalculatePriority(IDictionary<string, double> variables) {
|
---|
41 | var tree = SymbolicExpressionTreeParameter.Value;
|
---|
42 | var interpreter = SymbolicDataAnalysisTreeInterpreterParameter.Value;
|
---|
43 |
|
---|
44 | Dataset ds = new Dataset(variables.Keys, variables.Values.Select(v => new List<double>(new double[] { v })));
|
---|
45 |
|
---|
46 | List<int> rows = new List<int>();
|
---|
47 | rows.Add(0);
|
---|
48 |
|
---|
49 | double prio = interpreter.GetSymbolicExpressionTreeValues(tree, ds, rows).First();
|
---|
50 |
|
---|
51 | return prio;
|
---|
52 | }
|
---|
53 | }
|
---|
54 | }
|
---|