Exemplo n.º 1
0
        /// <summary>
        /// Cria um grafo de testes.
        /// </summary>
        /// <param name="syncSource">
        /// Uma fonte de valores.
        /// </param>
        /// <returns>O grafo de testes.</returns>
        private LabeledEdgeListGraph <OperationVertex, OperationEdge> CreateTestGraph_SingleNode(
            SynchGen syncSource)
        {
            var result = new LabeledEdgeListGraph <OperationVertex, OperationEdge>(
                true);

            result.AddVertex(new OperationVertex(() => syncSource.Current));

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Cria um grafo de teste que define uma espécie de rede neural muito simples.
        /// </summary>
        /// <returns>O grafo de teste.</returns>
        private LabeledEdgeListGraph <NeuSource, double> CreateTestGraph_SimpleNeuralNework()
        {
            var result = new LabeledEdgeListGraph <NeuSource, double>(true);
            var h1     = new NeuTest("h1");
            var h2     = new NeuTest("h2");
            var g1     = new NeuTest(d => d > 1.5 ? 1.0 : 0.0, "g1");
            var g2     = new NeuTest(d => d > -1.5 ? 1.0 : 0.0, "g2");

            var vertices = new NeuSource[6];

            for (var i = 0; i < 6; ++i)
            {
                var vertex = new NeuSource(string.Format("input{0}", i));
                result.AddVertex(vertex);
                vertices[i] = vertex;
            }

            result.AddVertex(g1);
            result.AddVertex(g2);

            var j = 0;

            for (; j < 3; ++j)
            {
                result.AddEdge(h1, vertices[j], 1.0);
            }

            for (; j < 6; ++j)
            {
                result.AddEdge(h2, vertices[j], 1.0);
            }

            result.AddEdge(g1, h1, 1.0);
            result.AddEdge(g1, h2, 1.0);
            result.AddEdge(g2, h1, -1.0);
            result.AddEdge(g2, h2, -1.0);

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Cria um grafo de testes.
        /// </summary>
        /// <param name="syncSource">Uma fonte de valores.</param>
        /// <returns>O grafo de testes.</returns>
        private LabeledEdgeListGraph <OperationVertex, OperationEdge> CreateTestGraph_SimpleCycle(
            SynchGen syncSource)
        {
            var result       = new LabeledEdgeListGraph <OperationVertex, OperationEdge>(true);
            var sourceVertex = new OperationVertex(
                1,
                1,
                (arg, res) => res[0] = arg[0] + syncSource.Current);

            Array.Clear(sourceVertex.Arguments, 0, sourceVertex.Arguments.Length);
            Array.Clear(sourceVertex.Results, 0, sourceVertex.Results.Length);

            result.AddVertex(sourceVertex);
            result.AddEdge(
                sourceVertex,
                sourceVertex,
                new OperationEdge(0, 0));
            return(result);
        }