Exemplo n.º 1
0
 private static ObjectivesResultsCollection createResultsSet(SysConfigLogInfo item, string resultsName = "")
 {
     IObjectiveScores[] arrayScores = item.Scores as IObjectiveScores[];
     if (arrayScores != null)
     {
         var tags   = item.Tags;
         var result = ConvertOptimizationResults.Convert(arrayScores, attributes: tags);
         result.Name = resultsName;
         return(result);
     }
     return(null);
 }
Exemplo n.º 2
0
 private static IResultsSetInfo createResultsSet(ILogInfo item, string resultsName = "")
 {
     IObjectiveScores[] arrayScores = item.Scores as IObjectiveScores[];
     if (arrayScores != null && arrayScores.Length > 0)
     {
         IDictionary <string, string> tags = item.Tags;
         var result = ConvertOptimizationResults.Convert(arrayScores, attributes: tags);
         result.Name = resultsName;
         return(new ObjResultsInfo(result));
     }
     else
     {
         return(new SingleLineInfo(item.Tags));
     }
 }
Exemplo n.º 3
0
        public void TestConversionToPersistenceDataModel()
        {
            // TODO: make this machine independent. Needs an SQL server for tests
            if (Environment.MachineName.ToLower() != "chrome-bu")
            {
                return;
            }
            var optResults = new MockOptResults();

            optResults.objectives = new List <IObjectiveScores <TestHyperCube> >
            {
                new MockObjScores {
                    scores = new List <MockObjScore>
                    {
                        new MockObjScore {
                            maximize = true, name = "NSE", value = 0.5
                        },
                        new MockObjScore {
                            maximize = false, name = "Bias", value = 0.55
                        }
                    },
                    sysConfig = new TestHyperCube(3, 0.1, 0, 1)
                },
                new MockObjScores {
                    scores = new List <MockObjScore>
                    {
                        new MockObjScore {
                            maximize = true, name = "NSE", value = 0.6
                        },
                        new MockObjScore {
                            maximize = false, name = "Bias", value = 0.66
                        }
                    },
                    sysConfig = new TestHyperCube(3, 0.3, 0, 1)
                }
            };
            var attributes = new Dictionary <string, string>();

            attributes.Add("ModelId", "GR4J");

            var result = ConvertOptimizationResults.Convert(optResults, resultsSetName: "result set name", attributes: attributes);

            Assert.AreEqual("result set name", result.Name);

            var tags = result.Tags.Tags.ToList();

            Assert.AreEqual(1, tags.Count);
            Assert.AreEqual("ModelId", tags[0].Name);
            Assert.AreEqual("GR4J", tags[0].Value);

            var resultsList = result.ScoresSet.ToList();
            var score       = resultsList[0].Scores.ToList()[0];

            Assert.AreEqual("0.5", score.Value);
            Assert.AreEqual("NSE", score.Name);
            Assert.AreEqual(true, score.Maximize);

            score = resultsList[1].Scores.ToList()[1];
            Assert.AreEqual("0.66", score.Value);
            Assert.AreEqual("Bias", score.Name);
            Assert.AreEqual(false, score.Maximize);

            var varList = ((HyperCube)resultsList[0].SysConfiguration).Variables.ToList();

            Assert.AreEqual(3, varList.Count);
            Assert.AreEqual(0.1f, varList[0].Value);
            Assert.AreEqual(0f, varList[0].Minimum);
            Assert.AreEqual(1f, varList[0].Maximum);
        }