public void VertexCreate_Instantiates()
        {
            // Arrange
            var parameters = new[] {1.0, 1.0, 1.0, 1.0};

            // Act
            var vertex = new Vertex(parameters);

            // Assert
            Assert.IsTrue(vertex.Parameters == parameters);
        }
示例#2
0
 public void Create(IVertex vertex)
 {
     Vertices.Clear();
     Vertices.Add(1, vertex);
     for (int i = 0; i < vertex.Parameters.Length; i++)
     {
         var copiedVertex = vertex.Parameters.GetAsCopy();
         copiedVertex[i] = vertex.Parameters[i] + DimensionalStepSizeForInitialisingSimplex;
         var thisStepVert = new Vertex(copiedVertex);
         Vertices.Add(i + 2, thisStepVert);
     }
 }
        public void GetSolutionReport_UsingEmptyConstructor()
        {
            var dhs = new DownHillSimplex();
            dhs.InitialGuess = new[] {1d, 7d};
            IVertex initialVertex = new Vertex(dhs.InitialGuess);
            dhs.InitialSimplex = new Simplex(initialVertex);
            dhs.CurrentSimplex = dhs.InitialSimplex;
            dhs.ObjectiveFunction = vertex => ObjectiveMeasure.SumOfSquares(vertex);

            if (!dhs.IsValid())
            {
                throw new Exception("Did not pass the IsValid method");
            }

            var solution = dhs.GetSolution();

            var isSolved = solution.ObjectiveMeasure.IsEqualTo(0d);
            Assert.IsTrue(isSolved);
        }