public void NestOption_sampling_from_uniform_space_test() { var nestOption = new NestOption(); nestOption.Add("choice", new ChoiceOption("a", "b", "c")); nestOption.Add("int", new UniformIntOption(0, 1)); var anotherNestOption = new NestOption(); anotherNestOption["choice"] = new ChoiceOption("d", "e"); anotherNestOption["int"] = new UniformIntOption(2, 3); nestOption["nestOption"] = anotherNestOption; nestOption.FeatureSpaceDim.Should().Be(4); var parameter = nestOption.SampleFromFeatureSpace(new double[] { 0, 0, 0, 0 }); parameter["nestOption"]["choice"].AsType <string>().Should().Be("d"); parameter["nestOption"]["int"].AsType <int>().Should().Be(2); parameter["choice"].AsType <string>().Should().Be("a"); parameter["int"].AsType <int>().Should().Be(0); parameter = nestOption.SampleFromFeatureSpace(new double[] { 1, 1, 1, 1 }); parameter["nestOption"]["choice"].AsType <string>().Should().Be("e"); parameter["nestOption"]["int"].AsType <int>().Should().Be(3); parameter["choice"].AsType <string>().Should().Be("c"); parameter["int"].AsType <int>().Should().Be(1); }
public void NestOption_mapping_to_uniform_space_test() { var nestOption = new NestOption(); nestOption.Add("choice", new ChoiceOption("a", "b", "c")); nestOption.Add("int", new UniformIntOption(0, 1)); var parameter = Parameter.CreateNestedParameter(); parameter["choice"] = Parameter.FromString("a"); parameter["int"] = Parameter.FromInt(0); nestOption.MappingToFeatureSpace(parameter).Should().Equal(0, 0); }