Changeset 16901 for branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/MultiObjectiveGoalSeekingProblem.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/MultiObjectiveGoalSeekingProblem.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 (multi-objective)", "Represents a single objective optimization problem which uses configurable regression models to evaluate targets from a given dataset.")] 37 37 [Creatable("Problems")] 38 [Storable Class]38 [StorableType("76EA4627-FD52-41D0-A594-20C99F700F46")] 39 39 public sealed class MultiObjectiveGoalSeekingProblem : MultiObjectiveBasicProblem<RealVectorEncoding>, IGoalSeekingProblem { 40 40 #region parameter names … … 91 91 public IEnumerable<double> GetEstimatedGoalValues(IEnumerable<double> parameterValues, bool round = false) { 92 92 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 })) { 94 94 ds.SetVariableValue(parameter.Value, parameter.Name, 0); 95 95 } 96 96 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())); 101 99 } 102 100 … … 131 129 #region constructors 132 130 [StorableConstructor] 133 private MultiObjectiveGoalSeekingProblem( bool deserializing) : base(deserializing) { }131 private MultiObjectiveGoalSeekingProblem(StorableConstructorFlag _) : base(_) { } 134 132 135 133 private MultiObjectiveGoalSeekingProblem(MultiObjectiveGoalSeekingProblem original, Cloner cloner) : base(original, cloner) { … … 219 217 for (int j = 0; j < activeGoals.Count * 2; j += 2) { 220 218 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 223 220 rowValues[k + 1] = estimatedValues[j / 2]; // estimated value 224 221 }
Note: See TracChangeset
for help on using the changeset viewer.