Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/06/19 15:36:43 (5 years ago)
Author:
bburlacu
Message:

#2679: Update branch: framework version 4.6.1, use heal.attic for persistence, some minor refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/SingleObjectiveGoalSeekingProblem.cs

    r14526 r16901  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
     22using HEAL.Attic;
    2523using HeuristicLab.Collections;
    2624using HeuristicLab.Common;
     
    3028using HeuristicLab.Optimization;
    3129using HeuristicLab.Parameters;
    32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3330using HeuristicLab.Problems.DataAnalysis;
     31using System;
     32using System.Collections.Generic;
     33using System.Linq;
    3434
    3535namespace HeuristicLab.GoalSeeking {
    3636  [Item("Goal seeking problem (single-objective)", "Represents a single objective optimization problem which uses configurable regression solutions to evaluate targets from a given dataset.")]
    3737  [Creatable("Problems")]
    38   [StorableClass]
     38  [StorableType("DD67A460-1A32-414A-AB18-E0C773B46689")]
    3939  public sealed class SingleObjectiveGoalSeekingProblem : SingleObjectiveBasicProblem<RealVectorEncoding>, IGoalSeekingProblem {
    4040    #region parameter names
     
    9191      }
    9292      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()));
    9795    }
    9896
     
    118116    #region constructors
    119117    [StorableConstructor]
    120     private SingleObjectiveGoalSeekingProblem(bool deserializing) : base(deserializing) { }
     118    private SingleObjectiveGoalSeekingProblem(StorableConstructorFlag _) : base(_) { }
    121119
    122120    private SingleObjectiveGoalSeekingProblem(SingleObjectiveGoalSeekingProblem original, Cloner cloner) : base(original, cloner) {
     
    156154      }
    157155      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);
    161158    }
    162159
Note: See TracChangeset for help on using the changeset viewer.