Changeset 16901 for branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/SingleObjectiveGoalSeekingProblem.cs
- Timestamp:
- 05/06/19 15:36:43 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/SingleObjectiveGoalSeekingProblem.cs
r14526 r16901 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 22 using HEAL.Attic; 25 23 using HeuristicLab.Collections; 26 24 using HeuristicLab.Common; … … 30 28 using HeuristicLab.Optimization; 31 29 using HeuristicLab.Parameters; 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;33 30 using HeuristicLab.Problems.DataAnalysis; 31 using System; 32 using System.Collections.Generic; 33 using System.Linq; 34 34 35 35 namespace HeuristicLab.GoalSeeking { 36 36 [Item("Goal seeking problem (single-objective)", "Represents a single objective optimization problem which uses configurable regression solutions to evaluate targets from a given dataset.")] 37 37 [Creatable("Problems")] 38 [Storable Class]38 [StorableType("DD67A460-1A32-414A-AB18-E0C773B46689")] 39 39 public sealed class SingleObjectiveGoalSeekingProblem : SingleObjectiveBasicProblem<RealVectorEncoding>, IGoalSeekingProblem { 40 40 #region parameter names … … 91 91 } 92 92 var rows = new[] { 0 }; // actually just one row 93 var estimatedValues = 94 round ? ActiveGoals.Select(t => RoundToNearestStepMultiple(GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()), t.Step)) 95 : ActiveGoals.Select(t => GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single())); 96 return estimatedValues; 93 return round ? ActiveGoals.Select(t => RoundToNearestStepMultiple(GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()), t.Step)) 94 : ActiveGoals.Select(t => GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single())); 97 95 } 98 96 … … 118 116 #region constructors 119 117 [StorableConstructor] 120 private SingleObjectiveGoalSeekingProblem( bool deserializing) : base(deserializing) { }118 private SingleObjectiveGoalSeekingProblem(StorableConstructorFlag _) : base(_) { } 121 119 122 120 private SingleObjectiveGoalSeekingProblem(SingleObjectiveGoalSeekingProblem original, Cloner cloner) : base(original, cloner) { … … 156 154 } 157 155 var estimatedValues = GetEstimatedGoalValues(vector, round: true); 158 var quality = ActiveGoals.Zip(estimatedValues, (t, v) => new { Target = t, EstimatedValue = v }) 159 .Average(x => x.Target.Weight * Math.Pow(x.EstimatedValue - x.Target.Goal, 2) / x.Target.Variance); 160 return quality; 156 return ActiveGoals.Zip(estimatedValues, (t, v) => new { Target = t, EstimatedValue = v }) 157 .Average(x => x.Target.Weight * Math.Pow(x.EstimatedValue - x.Target.Goal, 2) / x.Target.Variance); 161 158 } 162 159
Note: See TracChangeset
for help on using the changeset viewer.