コード例 #1
0
        public static NodeServer <NodeType> Create(
            Vector[] initVectors,
            int numOfNodes,
            int vectorLength,
            GlobalVectorType globalVectorType,
            ApproximationType approximation,
            MonitoredFunction monitoredFunction,
            ResolveNodesFunction <NodeType> resolveNodes,
            Func <Vector, ConvexBound, int, int, NodeType> createNode)
        {
            initVectors = initVectors.Map(v => v.Clone());
            var globalVector = globalVectorType.GetValue(initVectors);

            var(lowerBound, upperBound) = approximation.Calc(monitoredFunction.Function(globalVector));
            var upperConvexBound = monitoredFunction.UpperBound(globalVector, upperBound);
            var lowerConvexBound = monitoredFunction.LowerBound(globalVector, lowerBound);
            var upperNodes       = ArrayUtils.Init(numOfNodes, i => createNode(globalVector.Clone(), upperConvexBound, i, vectorLength));
            var lowerNodes       = ArrayUtils.Init(numOfNodes, i => createNode(globalVector.Clone(), lowerConvexBound, i, vectorLength));

            NodeServer <NodeType> ReCreate(Vector[] newInitVectors)
            => Create(newInitVectors, numOfNodes, vectorLength, globalVectorType, approximation, monitoredFunction, resolveNodes, createNode);

            return(new NodeServer <NodeType>(initVectors, numOfNodes, vectorLength, globalVectorType, upperBound, lowerBound, monitoredFunction.Function,
                                             approximation, upperNodes, lowerNodes, resolveNodes, ReCreate));
        }
コード例 #2
0
        public static OracleServer Create(
            Vector[] initVectors,
            int numOfNodes,
            int vectorLength,
            GlobalVectorType globalVectorType,
            ApproximationType approximation,
            MonitoredFunction monitoredFunction)
        {
            initVectors = initVectors.Map(v => v.Clone());
            var globalVector = globalVectorType.GetValue(initVectors);

            var(lowerBound, upperBound) = approximation.Calc(monitoredFunction.Function(globalVector));

            return(new OracleServer(initVectors, numOfNodes, vectorLength, globalVectorType, upperBound, lowerBound, monitoredFunction.Function, approximation));
        }