@@ -8,20 +8,35 @@ namespace Microsoft.ML.Auto.Test
8
8
public class SweeperTests
9
9
{
10
10
[ TestMethod ]
11
- public void Smac3ParamsTest ( )
11
+ public void SmacQuickRunTest ( )
12
12
{
13
13
var numInitialPopulation = 10 ;
14
14
15
+ var floatValueGenerator = new FloatValueGenerator ( new FloatParamArguments ( ) { Name = "float" , Min = 1 , Max = 1000 } ) ;
16
+ var floatLogValueGenerator = new FloatValueGenerator ( new FloatParamArguments ( ) { Name = "floatLog" , Min = 1 , Max = 1000 , LogBase = true } ) ;
17
+ var longValueGenerator = new LongValueGenerator ( new LongParamArguments ( ) { Name = "long" , Min = 1 , Max = 1000 } ) ;
18
+ var longLogValueGenerator = new LongValueGenerator ( new LongParamArguments ( ) { Name = "longLog" , Min = 1 , Max = 1000 , LogBase = true } ) ;
19
+ var discreteValueGeneator = new DiscreteValueGenerator ( new DiscreteParamArguments ( ) { Name = "discrete" , Values = new [ ] { "200" , "400" , "600" , "800" } } ) ;
20
+
15
21
var sweeper = new SmacSweeper ( new SmacSweeper . Arguments ( )
16
22
{
17
23
SweptParameters = new IValueGenerator [ ] {
18
- new FloatValueGenerator ( new FloatParamArguments ( ) { Name = "x1" , Min = 1 , Max = 1000 } ) ,
19
- new LongValueGenerator ( new LongParamArguments ( ) { Name = "x2" , Min = 1 , Max = 1000 } ) ,
20
- new DiscreteValueGenerator ( new DiscreteParamArguments ( ) { Name = "x3" , Values = new [ ] { "200" , "400" , "600" , "800" } } ) ,
24
+ floatValueGenerator ,
25
+ floatLogValueGenerator ,
26
+ longValueGenerator ,
27
+ longLogValueGenerator ,
28
+ discreteValueGeneator
21
29
} ,
22
30
NumberInitialPopulation = numInitialPopulation
23
31
} ) ;
24
32
33
+ // sanity check grid
34
+ Assert . IsNotNull ( floatValueGenerator [ 0 ] . ValueText ) ;
35
+ Assert . IsNotNull ( floatLogValueGenerator [ 0 ] . ValueText ) ;
36
+ Assert . IsNotNull ( longValueGenerator [ 0 ] . ValueText ) ;
37
+ Assert . IsNotNull ( longLogValueGenerator [ 0 ] . ValueText ) ;
38
+ Assert . IsNotNull ( discreteValueGeneator [ 0 ] . ValueText ) ;
39
+
25
40
List < RunResult > results = new List < RunResult > ( ) ;
26
41
27
42
RunResult bestResult = null ;
@@ -31,12 +46,13 @@ public void Smac3ParamsTest()
31
46
32
47
foreach ( ParameterSet p in pars )
33
48
{
34
- float x1 = ( p [ "x1" ] as FloatParameterValue ) . Value ;
35
- float x2 = ( p [ "x2" ] as LongParameterValue ) . Value ;
36
- float x3 = float . Parse ( p [ "x3" ] . ValueText ) ;
49
+ float x1 = float . Parse ( p [ "float" ] . ValueText ) ;
50
+ float x2 = float . Parse ( p [ "floatLog" ] . ValueText ) ;
51
+ long x3 = long . Parse ( p [ "long" ] . ValueText ) ;
52
+ long x4 = long . Parse ( p [ "longLog" ] . ValueText ) ;
53
+ int x5 = int . Parse ( p [ "discrete" ] . ValueText ) ;
37
54
38
- double metric = - 200 * ( Math . Abs ( 100 - x1 ) +
39
- Math . Abs ( 300 - x2 ) + Math . Abs ( 500 - x3 ) ) ;
55
+ double metric = x1 + x2 + x3 + x4 + x5 ;
40
56
41
57
RunResult result = new RunResult ( p , metric , true ) ;
42
58
if ( bestResult == null || bestResult . MetricValue < metric )
@@ -53,7 +69,7 @@ public void Smac3ParamsTest()
53
69
Console . WriteLine ( $ "Best: { bestResult . MetricValue } ") ;
54
70
55
71
Assert . IsNotNull ( bestResult ) ;
56
- Assert . IsTrue ( bestResult . MetricValue != 0 ) ;
72
+ Assert . IsTrue ( bestResult . MetricValue > 0 ) ;
57
73
}
58
74
59
75
0 commit comments