public void AddSearchSpace_EmptyName_Failure()
        {
            SearchSpace oSearchSpace;
            var         res = SearchSpace.AddSearchSpace(_mockServer, out oSearchSpace, "");

            Assert.IsFalse(res.Success, "Static method for add SearchSpace did not fail with empty name");
        }
        public void GetSearchSpaces_NullConnectionServer_Failure()
        {
            List <SearchSpace> oSpaces;
            var res = SearchSpace.GetSearchSpaces(null, out oSpaces, 1, 10, "params");

            Assert.IsFalse(res.Success, "Calling GetSearchSpaces member did not fail with null Connection server ");
        }
        public void AddSearchSpace_NullConnectionServer_Failure()
        {
            SearchSpace oSearchSpace;
            var         res = SearchSpace.AddSearchSpace(null, out oSearchSpace, "name");

            Assert.IsFalse(res.Success, "Static method for add SearchSpace did not fail with null ConnectionServer");
        }
        public void SearchSpace_Constructor_DisplayNameNotFound_Success()
        {
            Reset();
            SearchSpace oTest = new SearchSpace(_mockServer, "", "Name");

            Console.WriteLine(oTest);
        }
        public void CFO_should_find_maximum_value_when_function_is_convex()
        {
            var    searchSpace = new SearchSpace <LSE3DSearchSpace>();
            var    initValues  = searchSpace.SampleFromFeatureSpace(searchSpace.Default);
            var    cfo         = new CostFrugalTuner(searchSpace, Parameter.FromObject(initValues), false);
            double bestMetric  = 0;

            for (int i = 0; i != 100; ++i)
            {
                var trialSettings = new TrialSettings()
                {
                    TrialId = 0,
                };

                var param  = cfo.Propose(trialSettings).AsType <LSE3DSearchSpace>();
                var x      = param.X;
                var y      = param.Y;
                var z      = param.Z;
                var metric = LSE3D(x, y, z);
                bestMetric = Math.Max(bestMetric, metric);
                Output.WriteLine($"{i} x: {x} y: {y} z: {z}");
                if (x == 10 && y == 10 && z == 10)
                {
                    break;
                }
                cfo.Update(new TrialResult()
                {
                    DurationInMilliseconds = 1 * 1000,
                    Metric        = metric,
                    TrialSettings = trialSettings,
                });
            }

            bestMetric.Should().BeGreaterThan(LSE3D(10, 10, 10) - 2);
        }
        /// <summary>
        /// For each block, check whether all hidden dimensions in hiddenList are the same (except for 0).
        /// If all hidden dimensions in one block are 0, it will be set to the last hidden dimension
        /// (if exists) or the maximum hidden dimension (if not exist).
        /// </summary>
        /// <returns>The list of hidden dimensions in blocks.</returns>
        private List <int> CheckBlockHiddenSize(int blockPerLayer)
        {
            var hiddenSizePerBlock = new List <int>();

            for (var i = 0; i < DistillBlocks; ++i)
            {
                var hiddenSizesPerBlock = Enumerable.Range(i * blockPerLayer, blockPerLayer)
                                          .Select(j => SearchSpace.ArchHiddenSize[DiscreteArches[j]]).ToArray();
                var nextHiddenSize = SearchSpace.CheckHiddenDimensionsAndReturnMax(hiddenSizesPerBlock);
                if (nextHiddenSize == 0)
                {
                    if (hiddenSizePerBlock.Count == 0)
                    {
                        nextHiddenSize = SearchSpace.ArchHiddenSize[SearchSpace.ArchHiddenSize.Length - 1];
                    }
                    else
                    {
                        nextHiddenSize = hiddenSizePerBlock[hiddenSizePerBlock.Count - 1];
                    }
                }
                hiddenSizePerBlock.Add(nextHiddenSize);
            }

            return(hiddenSizePerBlock);
        }
        public void CFO_e2e_test()
        {
            var searchSpace = new SearchSpace <LbfgsOption>();
            var initValues  = searchSpace.SampleFromFeatureSpace(searchSpace.Default);
            var cfo         = new CostFrugalTuner(searchSpace, Parameter.FromObject(initValues));

            for (int i = 0; i != 1000; ++i)
            {
                var trialSettings = new TrialSettings()
                {
                    TrialId = i,
                };

                var param  = cfo.Propose(trialSettings);
                var option = param.AsType <CodeGen.LbfgsOption>();

                option.L1Regularization.Should().BeInRange(0.03125f, 32768.0f);
                option.L2Regularization.Should().BeInRange(0.03125f, 32768.0f);

                cfo.Update(new TrialResult()
                {
                    DurationInMilliseconds = i * 1000,
                    Metric        = i,
                    TrialSettings = trialSettings,
                });
            }
        }
        public void SearchSpace_Constructor_ObjectId_Success()
        {
            Reset();
            SearchSpace oTest = new SearchSpace(_mockServer, "ObjectId");

            Console.WriteLine(oTest);
        }
Beispiel #9
0
        /// <summary>
        ///  Initializes the solver so that the optimization can be run.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        /// If not all target nodes are connected to the start node.
        /// </exception>
        public void Initialize()
        {
            BuildSearchGraph();

            _searchSpace =
                _searchGraph.NodeDict.Values.Where(n => IncludeNode(n) && n != StartNodes && !TargetNodes.Contains(n))
                .ToList();

            var consideredNodes = SearchSpace.Concat(TargetNodes).ToList();

            consideredNodes.Add(StartNodes);
            Distances.CalculateFully(consideredNodes);

            if (_targetNodes.Any(node => !Distances.AreConnected(StartNodes, node)))
            {
                throw new InvalidOperationException("The graph is disconnected.");
            }

            // Saving the leastSolution as initial solution. Makes sure there is always a
            // solution even if the search space is empty or MaxGeneration is 0.
            BestSolution = SpannedMstToSkillnodes(CreateLeastSolution());

            var removedNodes   = new List <GraphNode>();
            var newSearchSpace = new List <GraphNode>();

            foreach (var node in SearchSpace)
            {
                if (IncludeNodeUsingDistances(node))
                {
                    newSearchSpace.Add(node);
                }
                else
                {
                    removedNodes.Add(node);
                }
            }
            _searchSpace = newSearchSpace;

            var remainingNodes = SearchSpace.Concat(TargetNodes).ToList();

            remainingNodes.Add(StartNodes);
            Distances.RemoveNodes(removedNodes, remainingNodes);

            if (_targetNodes.Count / (double)remainingNodes.Count >= PreFilledSpanThreshold)
            {
                var prioQueue = new LinkedListPriorityQueue <LinkedGraphEdge>(100);
                for (var i = 0; i < remainingNodes.Count; i++)
                {
                    for (var j = i + 1; j < remainingNodes.Count; j++)
                    {
                        prioQueue.Enqueue(new LinkedGraphEdge(i, j), Distances[i, j]);
                    }
                }
                _firstEdge = prioQueue.First;
            }

            InitializeGa();

            _isInitialized = true;
        }
Beispiel #10
0
        public Parameter Propose(SearchSpace searchSpace)
        {
            var d          = searchSpace.FeatureSpaceDim;
            var featureVec = Enumerable.Repeat(0, d).Select(i => _rnd.NextDouble()).ToArray();

            return(searchSpace.SampleFromFeatureSpace(featureVec));
        }
        public void DeleteSearchSpaceMember_EmptyClassData_Failure()
        {
            SearchSpace oSpace = new SearchSpace(_mockServer);
            var         res    = oSpace.DeleteSearchSpaceMember("PartitionObjectId");

            Assert.IsFalse(res.Success, "Calling DeleteSearchSpaceMember from empty class instance should fail");
        }
Beispiel #12
0
        public void GridSearchTuner_should_search_entire_naive_search_space()
        {
            // the behavior of a grid search tuner is it will exhaustively generate
            // candidates from a grid of parameter value. And once exhausted, it will start
            // over again.
            // So we use the following way to test a grid search tuner: we go through the grid search
            // twice, and check if all candidates are repeated twice. By doing so we know if grid search
            // tuner either search grid of parameter value exhaustively or or generate candidates exactly one
            // time in each search.

            // default step is used when an option is continous, like double option or single option.
            var defaultStep = 10;
            var searchSpace = new SearchSpace <NaiveSearchSpace>();
            var tuner       = new GridSearchTuner(searchSpace, defaultStep);
            var parameters  = new List <Parameter>();

            // calculate the total steps, which is the sum of all grid points.
            var steps = 1;

            foreach (var step in searchSpace.Step)
            {
                steps *= step ?? defaultStep;
            }

            foreach (var i in Enumerable.Range(0, steps * 2))
            {
                var settings = new TrialSettings();
                parameters.Add(tuner.Propose(settings));
            }

            steps.Should().Be(600);
            parameters.Distinct().Count().Should().Be(steps);
        }
        public void Update_EmptyClassData_Failure()
        {
            Reset();
            SearchSpace oSpace = new SearchSpace(_mockServer);
            var         res    = oSpace.Update("New Name", "New Description");

            Assert.IsFalse(res.Success, "Calling Update from empty class instance should fail");
        }
        public void Delete_EmptyClassData_Failure()
        {
            Reset();
            SearchSpace oSpace = new SearchSpace(_mockServer);
            var         res    = oSpace.Delete();

            Assert.IsFalse(res.Success, "Calling Delete from empty class instance should fail");
        }
Beispiel #15
0
        public void AddSearchSpace_InvalidLocationId_Failure()
        {
            SearchSpace oSearchSpace;

            //invalid locaiton
            var res = SearchSpace.AddSearchSpace(_connectionServer, out oSearchSpace, "name", "description", "boguslocation");

            Assert.IsFalse(res.Success, "Static method for add SearchSpace did not fail with invalid Location");
        }
Beispiel #16
0
        public void SearchSpace_Test()
        {
            _errorString = "";
            List <SearchSpace> oSearchSpaces;
            var res = SearchSpace.GetSearchSpaces(_connectionServer, out oSearchSpaces, 1, 2);

            Assert.IsTrue(res.Success & oSearchSpaces.Count > 0, "Failed to fetch SearchSpace:" + res);
            Assert.IsTrue(string.IsNullOrEmpty(_errorString), _errorString);
        }
        public void SearchSpace_Constructor_EmptyObjectIdAndName_Success()
        {
            Reset();
            SearchSpace oTest = new SearchSpace(_mockServer);

            Console.WriteLine(oTest.ToString());
            Console.WriteLine(oTest.DumpAllProps());
            Console.WriteLine(oTest.UniqueIdentifier);
            Console.WriteLine(oTest.SelectionDisplayString);
        }
 private void ResetSearch()
 {
     if (SearchResults != null)
     {
         SearchResults.Clear();
     }
     ImageGrid.Children.Clear();
     SearchSpace.ScrollToTop();
     ImageGrid.RowDefinitions.Clear();
 }
Beispiel #19
0
        /// <summary>
        /// Create a list of <see cref="SweepableEstimator"/> for multiclass classification.
        /// </summary>
        /// <param name="labelColumnName">label column name.</param>
        /// <param name="featureColumnName">feature column name.</param>
        /// <param name="exampleWeightColumnName">example weight column name.</param>
        /// <param name="useFastForest">true if use fast forest as available trainer.</param>
        /// <param name="useLgbm">true if use lgbm as available trainer.</param>
        /// <param name="useFastTree">true if use fast tree as available trainer.</param>
        /// <param name="useLbfgs">true if use lbfgs as available trainer.</param>
        /// <param name="useSdca">true if use sdca as available trainer.</param>
        /// <param name="fastTreeOption">if provided, use it as initial option for fast tree, otherwise the default option will be used.</param>
        /// <param name="lgbmOption">if provided, use it as initial option for lgbm, otherwise the default option will be used.</param>
        /// <param name="fastForestOption">if provided, use it as initial option for fast forest, otherwise the default option will be used.</param>
        /// <param name="lbfgsOption">if provided, use it as initial option for lbfgs, otherwise the default option will be used.</param>
        /// <param name="sdcaOption">if provided, use it as initial option for sdca, otherwise the default option will be used.</param>
        /// <param name="fastTreeSearchSpace">if provided, use it as search space for fast tree, otherwise the default search space will be used.</param>
        /// <param name="lgbmSearchSpace">if provided, use it as search space for lgbm, otherwise the default search space will be used.</param>
        /// <param name="fastForestSearchSpace">if provided, use it as search space for fast forest, otherwise the default search space will be used.</param>
        /// <param name="lbfgsSearchSpace">if provided, use it as search space for lbfgs, otherwise the default search space will be used.</param>
        /// <param name="sdcaSearchSpace">if provided, use it as search space for sdca, otherwise the default search space will be used.</param>
        /// <returns></returns>
        public SweepableEstimator[] MultiClassification(string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, bool useFastForest = true, bool useLgbm = true, bool useFastTree = true, bool useLbfgs = true, bool useSdca = true,
                                                        FastTreeOption fastTreeOption = null, LgbmOption lgbmOption = null, FastForestOption fastForestOption = null, LbfgsOption lbfgsOption = null, SdcaOption sdcaOption = null,
                                                        SearchSpace <FastTreeOption> fastTreeSearchSpace = null, SearchSpace <LgbmOption> lgbmSearchSpace = null, SearchSpace <FastForestOption> fastForestSearchSpace = null, SearchSpace <LbfgsOption> lbfgsSearchSpace = null, SearchSpace <SdcaOption> sdcaSearchSpace = null)
        {
            var res = new List <SweepableEstimator>();

            if (useFastTree)
            {
                fastTreeOption = fastTreeOption ?? new FastTreeOption();
                fastTreeOption.LabelColumnName         = labelColumnName;
                fastTreeOption.FeatureColumnName       = featureColumnName;
                fastTreeOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateFastTreeOva(fastTreeOption, fastTreeSearchSpace ?? new SearchSpace <FastTreeOption>(fastTreeOption)));
            }

            if (useFastForest)
            {
                fastForestOption = fastForestOption ?? new FastForestOption();
                fastForestOption.LabelColumnName         = labelColumnName;
                fastForestOption.FeatureColumnName       = featureColumnName;
                fastForestOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateFastForestOva(fastForestOption, fastForestSearchSpace ?? new SearchSpace <FastForestOption>(fastForestOption)));
            }

            if (useLgbm)
            {
                lgbmOption = lgbmOption ?? new LgbmOption();
                lgbmOption.LabelColumnName         = labelColumnName;
                lgbmOption.FeatureColumnName       = featureColumnName;
                lgbmOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateLightGbmMulti(lgbmOption, lgbmSearchSpace ?? new SearchSpace <LgbmOption>(lgbmOption)));
            }

            if (useLbfgs)
            {
                lbfgsOption = lbfgsOption ?? new LbfgsOption();
                lbfgsOption.LabelColumnName         = labelColumnName;
                lbfgsOption.FeatureColumnName       = featureColumnName;
                lbfgsOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateLbfgsLogisticRegressionOva(lbfgsOption, lbfgsSearchSpace ?? new SearchSpace <LbfgsOption>(lbfgsOption)));
                res.Add(SweepableEstimatorFactory.CreateLbfgsMaximumEntropyMulti(lbfgsOption, lbfgsSearchSpace ?? new SearchSpace <LbfgsOption>(lbfgsOption)));
            }

            if (useSdca)
            {
                sdcaOption = sdcaOption ?? new SdcaOption();
                sdcaOption.LabelColumnName         = labelColumnName;
                sdcaOption.FeatureColumnName       = featureColumnName;
                sdcaOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateSdcaMaximumEntropyMulti(sdcaOption, sdcaSearchSpace ?? new SearchSpace <SdcaOption>(sdcaOption)));
                res.Add(SweepableEstimatorFactory.CreateSdcaLogisticRegressionOva(sdcaOption, sdcaSearchSpace ?? new SearchSpace <SdcaOption>(sdcaOption)));
            }

            return(res.ToArray());
        }
Beispiel #20
0
        internal SweepableEstimator[] Regression(string labelColumnName = DefaultColumnNames.Label, string featureColumnName = DefaultColumnNames.Features, string exampleWeightColumnName = null, bool useFastForest = true, bool useLgbm = true, bool useFastTree = true, bool useLbfgs = true, bool useSdca = true,
                                                 FastTreeOption fastTreeOption = null, LgbmOption lgbmOption = null, FastForestOption fastForestOption = null, LbfgsOption lbfgsOption = null, SdcaOption sdcaOption = null,
                                                 SearchSpace <FastTreeOption> fastTreeSearchSpace = null, SearchSpace <LgbmOption> lgbmSearchSpace = null, SearchSpace <FastForestOption> fastForestSearchSpace = null, SearchSpace <LbfgsOption> lbfgsSearchSpace = null, SearchSpace <SdcaOption> sdcaSearchSpace = null)
        {
            var res = new List <SweepableEstimator>();

            if (useFastTree)
            {
                fastTreeOption = fastTreeOption ?? new FastTreeOption();
                fastTreeOption.LabelColumnName         = labelColumnName;
                fastTreeOption.FeatureColumnName       = featureColumnName;
                fastTreeOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateFastTreeRegression(fastTreeOption, fastTreeSearchSpace ?? new SearchSpace <FastTreeOption>()));
                res.Add(SweepableEstimatorFactory.CreateFastTreeTweedieRegression(fastTreeOption, fastTreeSearchSpace ?? new SearchSpace <FastTreeOption>()));
            }

            if (useFastForest)
            {
                fastForestOption = fastForestOption ?? new FastForestOption();
                fastForestOption.LabelColumnName         = labelColumnName;
                fastForestOption.FeatureColumnName       = featureColumnName;
                fastForestOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateFastForestRegression(fastForestOption, fastForestSearchSpace ?? new SearchSpace <FastForestOption>()));
            }

            if (useLgbm)
            {
                lgbmOption = lgbmOption ?? new LgbmOption();
                lgbmOption.LabelColumnName         = labelColumnName;
                lgbmOption.FeatureColumnName       = featureColumnName;
                lgbmOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateLightGbmRegression(lgbmOption, lgbmSearchSpace ?? new SearchSpace <LgbmOption>()));
            }

            if (useLbfgs)
            {
                lbfgsOption = lbfgsOption ?? new LbfgsOption();
                lbfgsOption.LabelColumnName         = labelColumnName;
                lbfgsOption.FeatureColumnName       = featureColumnName;
                lbfgsOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateLbfgsPoissonRegressionRegression(lbfgsOption, lbfgsSearchSpace ?? new SearchSpace <LbfgsOption>()));
            }

            if (useSdca)
            {
                sdcaOption = sdcaOption ?? new SdcaOption();
                sdcaOption.LabelColumnName         = labelColumnName;
                sdcaOption.FeatureColumnName       = featureColumnName;
                sdcaOption.ExampleWeightColumnName = exampleWeightColumnName;
                res.Add(SweepableEstimatorFactory.CreateSdcaRegression(sdcaOption, sdcaSearchSpace ?? new SearchSpace <SdcaOption>()));
            }

            return(res.ToArray());
        }
Beispiel #21
0
        public void Nest_search_space_mapping_to_feature_space_test()
        {
            var ss       = new SearchSpace <NestSearchSpace>();
            var param    = ss.SampleFromFeatureSpace(new[] { 0.0, 0, 0, 0, 0, 0, 0, 0 });
            var features = ss.MappingToFeatureSpace(param);

            features.Should().Equal(0, 0, 0, 0, 0, 0, 0, 0);

            param    = ss.SampleFromFeatureSpace(new[] { 0.5, 0.5, 0, 0.5, 0.5, 0.5, 0.5, 0.5 });
            features = ss.MappingToFeatureSpace(param);
            features.Should().Equal(0.5, 0.5, 0, 0.5, 0.5, 0.5, 0.5, 0.5);
        }
Beispiel #22
0
        public new static void MyClassInitialize(TestContext testContext)
        {
            BaseIntegrationTests.MyClassInitialize(testContext);

            string        strName = "Temp_" + Guid.NewGuid().ToString();
            WebCallResult res     = SearchSpace.AddSearchSpace(_connectionServer, out _searchSpace, strName, "SearchSpace added by Unit Test");

            Assert.IsTrue(res.Success, "Creation of new SearchSpace failed");

            strName = "Temp_" + Guid.NewGuid().ToString();
            res     = Partition.AddPartition(_connectionServer, out _partition, strName, "Partition added by Unit Test");
            Assert.IsTrue(res.Success, "Creation of new partition failed");
        }
Beispiel #23
0
        public void Search_space_add_option_test()
        {
            var ss = new SearchSpace();

            ss.FeatureSpaceDim.Should().Be(0);

            ss.Add("A", new UniformIntOption(-1000, 1000));
            ss.FeatureSpaceDim.Should().Be(1);

            var param = ss.SampleFromFeatureSpace(new[] { 0.5 });

            param["A"].AsType <int>().Should().Be(0);
        }
Beispiel #24
0
 private void SetSearchSpace()
 {
     if (searchSpace == null || !searchSpace.enabled)
     {
         foreach (SearchSpace ss in GetComponents <SearchSpace>())
         {
             if (ss.enabled)
             {
                 searchSpace = ss;
                 break;
             }
         }
     }
 }
Beispiel #25
0
        public void Parameter_AsType_should_be_culture_invariant()
        {
            var originalCuture = Thread.CurrentThread.CurrentCulture;
            var culture        = new CultureInfo("ru", false);

            Thread.CurrentThread.CurrentCulture = culture;
            var ss = new SearchSpace();

            ss.Add("_SampleSize", new UniformDoubleOption(10000, 20000));
            var parameter = ss.SampleFromFeatureSpace(new[] { 0.5 });

            parameter["_SampleSize"].AsType <double>().Should().Be(15000.0);
            Thread.CurrentThread.CurrentCulture = originalCuture;
        }
Beispiel #26
0
        public void Search_space_default_value_test()
        {
            var ss           = new SearchSpace <NestSearchSpace>();
            var defaultTuner = new DefaultValueTuner(ss);
            var param        = defaultTuner.Propose().AsType <NestSearchSpace>();

            param.UniformDouble.Should().Be(0);
            param.UniformFloat.Should().Be(0);
            param.BasicSS.UniformInt.Should().Be(0);
            param.BasicSS.UniformDouble.Should().Be(0);
            param.BasicSS.UniformFloat.Should().Be(0);
            param.BasicSS.ChoiceStr.Should().Be("a");
            param.BasicSS.ChoiceBoolean.Should().BeTrue();
            param.BasicSS.JTokenType.Should().Be(JsonTokenType.Null);
        }
        public void AddSearchSpaceMember_ErrorResponse_Failure()
        {
            Reset();
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.POST, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), It.IsAny <bool>())).Returns(new WebCallResult
            {
                Success      = false,
                ResponseText = "error text",
                StatusCode   = 404
            });

            var res = SearchSpace.AddSearchSpaceMember(_mockServer, "SSObjectId", "PartitionObjectID", 1);

            Assert.IsFalse(res.Success, "Calling AddSearchSpaceMember with ErrorResponse did not fail");
        }
        public void UpdateSearchSpace_ErrorResponse_Failure()
        {
            Reset();
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.PUT, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), It.IsAny <bool>())).Returns(new WebCallResult
            {
                Success      = false,
                ResponseText = "error text",
                StatusCode   = 404
            });

            var res = SearchSpace.UpdateSearchSpace(_mockServer, "ObjectId", "New Name", "New Description");

            Assert.IsFalse(res.Success, "Calling UpdateSearchSpace with ErrorResponse did not fail");
        }
        public void GetSearchSpaces_EmptyResult_Failure()
        {
            Reset();
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = ""
            });

            List <SearchSpace> oSpaces;
            var res = SearchSpace.GetSearchSpaces(_mockServer, out oSpaces, 1, 5, null);

            Assert.IsFalse(res.Success, "Calling GetSearchSpaces with EmptyResultText did not fail");
        }
Beispiel #30
0
        public void SearchSpace_sample_from_feature_space_test()
        {
            var ss    = new SearchSpace <BasicSearchSpace>();
            var param = ss.SampleFromFeatureSpace(new[] { 0.0, 0, 0, 0, 0, 0 });

            param.ChoiceStr.Should().Be("a");
            param.UniformDouble.Should().Be(-1000);
            param.UniformFloat.Should().Be(-1000);
            param.UniformInt.Should().Be(-1000);

            param = ss.SampleFromFeatureSpace(new[] { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 });
            param.ChoiceStr.Should().Be("c");
            param.UniformDouble.Should().Be(0);
            param.UniformFloat.Should().Be(0);
            param.UniformInt.Should().Be(0);
        }
 // Use this for initialization
 void Start()
 {
     SearchSpaceObj = GameObject.Find("SearchSpace");
     searchScript = SearchSpaceObj.GetComponent("SearchSpace") as SearchSpace;
 }
Beispiel #32
0
 private void SetSearchSpace()
 {
     if (searchSpace == null || !searchSpace.enabled)
     {
         foreach (SearchSpace ss in GetComponents<SearchSpace>())
         {
             if (ss.enabled)
             {
                 searchSpace = ss;
                 break;
             }
         }
     }
 }
 void Start()
 {
     ssScript = GameObject.FindObjectOfType(typeof(SearchSpace)) as SearchSpace;
        path = ssScript.getPathToSubDataFile();
     pinching_ = false;
     grabbed_ = null;
 }