1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Threading.Tasks;
|
---|
6 | using HeuristicLab.BioBoost.Evaluators;
|
---|
7 | using HeuristicLab.Common;
|
---|
8 | using HeuristicLab.Core;
|
---|
9 | using HeuristicLab.Data;
|
---|
10 | using HeuristicLab.Operators;
|
---|
11 | using HeuristicLab.Optimization;
|
---|
12 | using HeuristicLab.Parameters;
|
---|
13 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
14 | using HeuristicLab.PluginInfrastructure;
|
---|
15 |
|
---|
16 | namespace HeuristicLab.BioBoost.Operators.Moves {
|
---|
17 |
|
---|
18 | [StorableClass]
|
---|
19 | public class MoveEvaluatorAdapter : SingleSuccessorOperator, ISingleObjectiveMoveEvaluator {
|
---|
20 |
|
---|
21 | public IConstrainedValueParameter<ISingleObjectiveEvaluator> EvaluatorParameter {
|
---|
22 | get { return (IConstrainedValueParameter<ISingleObjectiveEvaluator>) Parameters["Evaluator"]; }
|
---|
23 | }
|
---|
24 |
|
---|
25 | public ISingleObjectiveEvaluator Evaluator { get { return EvaluatorParameter.Value; } }
|
---|
26 |
|
---|
27 | #region construction & cloning
|
---|
28 |
|
---|
29 | [StorableConstructor]
|
---|
30 | public MoveEvaluatorAdapter(bool isDeserializing) : base(isDeserializing) {}
|
---|
31 |
|
---|
32 | public MoveEvaluatorAdapter(MoveEvaluatorAdapter orig, Cloner cloner) : base(orig, cloner) { }
|
---|
33 |
|
---|
34 | public MoveEvaluatorAdapter() {
|
---|
35 | Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "the move quality"));
|
---|
36 | var evaluators = new ItemSet<ISingleObjectiveEvaluator>();
|
---|
37 | evaluators.Add(new AggregateEvaluator());
|
---|
38 | evaluators.Add(new MonolithicEvaluator());
|
---|
39 | Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveEvaluator>("Evaluator", "The actual evaluator.", evaluators));
|
---|
40 | EvaluatorParameter.Value = EvaluatorParameter.ValidValues.FirstOrDefault(e => e.GetType() == typeof(MonolithicEvaluator));
|
---|
41 | }
|
---|
42 |
|
---|
43 | public override IDeepCloneable Clone(Cloner cloner) { return new MoveEvaluatorAdapter(this, cloner); }
|
---|
44 |
|
---|
45 | #endregion
|
---|
46 |
|
---|
47 | public ILookupParameter<DoubleValue> QualityParameter { get { return Evaluator.QualityParameter; } }
|
---|
48 |
|
---|
49 | public ILookupParameter<DoubleValue> MoveQualityParameter { get { return (ILookupParameter<DoubleValue>) Parameters["MoveQuality"]; } }
|
---|
50 |
|
---|
51 | public override IOperation Apply() {
|
---|
52 | var evaluator = (ISingleObjectiveEvaluator)Evaluator.Clone();
|
---|
53 | evaluator.QualityParameter.ActualName = MoveQualityParameter.ActualName;
|
---|
54 | return new OperationCollection {
|
---|
55 | ExecutionContext.CreateChildOperation(evaluator),
|
---|
56 | base.Apply(),
|
---|
57 | };
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|