コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void NestOption_mapping_order_test()
        {
            // each dimension in uniform space should be mapping to the options under nest option in a certain (key ascending) order.
            var nestOption = new NestOption();

            nestOption["a"] = new UniformIntOption(0, 1);
            nestOption["b"] = new UniformIntOption(1, 2);
            nestOption["c"] = new UniformIntOption(2, 3);

            // changing of the first dimension should be reflected in option "a"
            var parameter = nestOption.SampleFromFeatureSpace(new double[] { 0, 0.5, 0.5 });

            parameter["a"].AsType <int>().Should().Be(0);
            parameter = nestOption.SampleFromFeatureSpace(new double[] { 1, 0.5, 0.5 });
            parameter["a"].AsType <int>().Should().Be(1);

            nestOption.Remove("a");

            // the first dimension should be option "b"
            parameter = nestOption.SampleFromFeatureSpace(new double[] { 0, 0.5 });
            parameter["b"].AsType <int>().Should().Be(1);
            parameter = nestOption.SampleFromFeatureSpace(new double[] { 1, 0.5 });
            parameter["b"].AsType <int>().Should().Be(2);
        }
コード例 #4
0
ファイル: LineNestAttribute.cs プロジェクト: Nama3/madrace
 /// <summary>
 /// Activates the attributes of a Serializable class or struct and draws lines around the field.
 /// </summary>
 /// <param name="linePosition">The position options of the decoration.</param>
 /// <param name="options">Some drawing options for the field.</param>
 public LineNestAttribute(ArrayDecoratorPosition linePosition, NestOption options)
 {
     PositionCallback = linePosition.ToString();
     OptionsCallback  = options.ToString();
 }
コード例 #5
0
ファイル: LineNestAttribute.cs プロジェクト: Nama3/madrace
 /// <summary>
 /// Activates the attributes of a Serializable class or struct and draws lines around the field.
 /// </summary>
 /// <param name="linePositionCallback">Callback for the position of the lines.
 /// The callback type should be ArrayDecoratorPosition.</param>
 /// <param name="options">Some drawing options for the field.</param>
 public LineNestAttribute(string linePositionCallback, NestOption options)
 {
     PositionCallback = linePositionCallback;
     OptionsCallback  = options.ToString();
 }
コード例 #6
0
 public NestAttribute(NestOption option = NestOption.Nothing) : base((FieldOption)option) =>
コード例 #7
0
ファイル: MightyEnums.cs プロジェクト: Nama3/madrace
 public static bool ContainsExact(this NestOption option, NestOption flag) => (option & flag) == flag;
コード例 #8
0
ファイル: MightyEnums.cs プロジェクト: Nama3/madrace
 public static bool Contains(this NestOption option, NestOption flag) => (option & flag) != 0;
コード例 #9
0
 /// <summary>
 /// Activates the attributes of a Serializable class or struct, draws lines around the field and wraps the field inside a dark area.
 /// </summary>
 /// <param name="linePosition">The position options of the decoration.</param>
 /// <param name="options">Some drawing options for the field.</param>
 public DarkNestAttribute(ArrayDecoratorPosition linePosition, NestOption options) : base(linePosition, options)
 {
 }
コード例 #10
0
 /// <summary>
 /// Activates the attributes of a Serializable class or struct, draws lines around the field and wraps the field inside a dark area.
 /// </summary>
 /// <param name="linePositionCallback">Callback for the position of the lines.
 /// The callback type should be ArrayDecoratorPosition.</param>
 /// <param name="options">Some drawing options for the field.</param>
 public DarkNestAttribute(string linePositionCallback, NestOption options) : base(linePositionCallback, options)
 {
 }
コード例 #11
0
 public DarkNestAttribute(string linePosition = null, string boxName = null,
                          NestOption option   = NestOption.Nothing) : base(linePosition, option) => BoxName = boxName;
コード例 #12
0
 public LineNestAttribute(string linePosition = null, NestOption option = NestOption.Nothing)
 {
     Position   = linePosition;
     NestOption = option;
 }