Last change
on this file since 11728 was
11727,
checked in by gkronber, 9 years ago
|
#2283: worked on grammatical optimization problem solvers (simple MCTS done)
|
File size:
474 bytes
|
Rev | Line | |
---|
[11659] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Threading.Tasks;
|
---|
| 6 |
|
---|
[11727] | 7 | namespace HeuristicLab.Common {
|
---|
[11659] | 8 | public static class Extensions {
|
---|
| 9 | public static bool IsAlmost(this double x, double y) {
|
---|
| 10 | return Math.Abs(x - y) < 1.0e-6;
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | public static T SelectRandom<T>(this IEnumerable<T> xs, Random rand) {
|
---|
| 14 | var xsArr = xs.ToArray();
|
---|
| 15 | return xsArr[rand.Next(xsArr.Length)];
|
---|
| 16 | }
|
---|
| 17 | }
|
---|
| 18 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.