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/MultiObjectiveGoalSeekingProblem.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 (multi-objective)", "Represents a single objective optimization problem which uses configurable regression models to evaluate targets from a given dataset.")]
    3737  [Creatable("Problems")]
    38   [StorableClass]
     38  [StorableType("76EA4627-FD52-41D0-A594-20C99F700F46")]
    3939  public sealed class MultiObjectiveGoalSeekingProblem : MultiObjectiveBasicProblem<RealVectorEncoding>, IGoalSeekingProblem {
    4040    #region parameter names
     
    9191    public IEnumerable<double> GetEstimatedGoalValues(IEnumerable<double> parameterValues, bool round = false) {
    9292      var ds = (ModifiableDataset)dataset.Clone();
    93       foreach (var parameter in ActiveInputs.Zip(parameterValues, (p, v) => new { Name = p.Name, Value = v })) {
     93      foreach (var parameter in ActiveInputs.Zip(parameterValues, (p, v) => new { p.Name, Value = v })) {
    9494        ds.SetVariableValue(parameter.Value, parameter.Name, 0);
    9595      }
    9696      var rows = new[] { 0 }; // actually just one row
    97       var estimatedValues =
    98         round ? ActiveGoals.Select(t => RoundToNearestStepMultiple(GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()), t.Step))
    99               : ActiveGoals.Select(t => GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()));
    100       return estimatedValues;
     97      return round ? ActiveGoals.Select(t => RoundToNearestStepMultiple(GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()), t.Step))
     98                   : ActiveGoals.Select(t => GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()));
    10199    }
    102100
     
    131129    #region constructors
    132130    [StorableConstructor]
    133     private MultiObjectiveGoalSeekingProblem(bool deserializing) : base(deserializing) { }
     131    private MultiObjectiveGoalSeekingProblem(StorableConstructorFlag _) : base(_) { }
    134132
    135133    private MultiObjectiveGoalSeekingProblem(MultiObjectiveGoalSeekingProblem original, Cloner cloner) : base(original, cloner) {
     
    219217        for (int j = 0; j < activeGoals.Count * 2; j += 2) {
    220218          int k = j + offset;
    221           var goal = activeGoals[j / 2].Goal;
    222           rowValues[k] = goal; // original value
     219          rowValues[k] = activeGoals[j / 2].Goal; // original value
    223220          rowValues[k + 1] = estimatedValues[j / 2]; // estimated value
    224221        }
Note: See TracChangeset for help on using the changeset viewer.