Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceReintegration/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/Policies/PolicyBase.cs @ 14923

Last change on this file since 14923 was 13669, checked in by gkronber, 9 years ago

#2581: made policies storable and added iteration of best solution to results

File size: 1.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Diagnostics.Contracts;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7using HeuristicLab.Common;
8using HeuristicLab.Core;
9using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
10
11namespace HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression.Policies {
12  [StorableClass]
13  public abstract class PolicyBase : Item, IParameterizedItem, IPolicy {
14    [Storable]
15    public IKeyedItemCollection<string, IParameter> Parameters { get; private set; }
16
17    [StorableConstructor]
18    protected PolicyBase(bool deserializing) : base(deserializing) { }
19    protected PolicyBase(PolicyBase original, Cloner cloner)
20      : base(original, cloner) {
21      Parameters = cloner.Clone(original.Parameters);
22    }
23    protected PolicyBase()
24      : base() {
25      Parameters = new ParameterCollection();
26    }
27
28    public void CollectParameterValues(IDictionary<string, IItem> values) {
29      foreach (var p in Parameters) values.Add(this.ItemName + "." + p.Name, p.ActualValue);
30    }
31
32    public abstract int Select(IEnumerable<IActionStatistics> actions, IRandom random);
33    public abstract void Update(IActionStatistics action, double q);
34    public abstract IActionStatistics CreateActionStatistics();
35  }
36}
Note: See TracBrowser for help on using the repository browser.