Today I’m going to follow up on Part I, but I’ll give you the implementation details of the classes. I provided you with a generic interface:
IDomainVariableSampler<T>
Now as I pointed out previously, we can choose to implement this interface for any domain type, so let’s try implementing it for a double domain:
public class DomainDoubleSampler : IDomainVariableSampler<double>
{
public double Maximum { get { return 100.0; } }
public double Minimum { get { return -100.0; } }
public double BoundaryNegative(double boundary)
{
return boundary - double.Epsilon;
}
public double BoundaryPositive(double boundary)
{
return boundary + double.Epsilon;
}
public double Sample(double lowerBound, double upperBound)
{
Random rand = new Random(1);
return lowerBound + rand.NextDouble() * (upperBound - lowerBound);
}
}
This implementation defines an input range of [-100.0, 100.0] and is sampling at random inside partitions of this interval.
