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 | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Diagnostics;
|
---|
4 | using System.Linq;
|
---|
5 | using System.Text;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 | using HeuristicLab.Common;
|
---|
8 |
|
---|
9 | namespace 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.