Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Distributions/UniformModel.cs @ 13834

Last change on this file since 13834 was 12893, checked in by gkronber, 9 years ago

#2283: experiments on grammatical optimization algorithms (maxreward instead of avg reward, ...)

File size: 955 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Diagnostics;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7using HeuristicLab.Common;
8
9namespace HeuristicLab.Algorithms.Bandits.Models {
10  // uniform distribution [a..b[
11  public class UniformModel : IModel {
12
13    private readonly double a;
14    private readonly double b;
15
16    public UniformModel(double lower = 0.0, double upper = 1.0) {
17      this.a = lower;
18      this.b = upper;
19    }
20
21    public double Sample(Random random) {
22      return random.NextDouble() * (b - a) + a;
23    }
24
25    public void Update(double reward) {
26      throw new NotSupportedException();
27    }
28
29    public void Reset() {
30      throw new NotSupportedException();
31    }
32
33    public object Clone() {
34      return new UniformModel(a, b);
35    }
36
37    public override string ToString() {
38      return string.Format("U({0:F2},{1:F2})", a, b);
39    }
40  }
41}
Note: See TracBrowser for help on using the repository browser.