public void OnLoadObject(object parameter)
 {
     _function = parameter as EvalFunction;
     if (_function != null)
     {
         txtFunction.Text = _function.Function;
     }
 }
示例#2
0
        public static float[] Euler(float[] current, float step, EvalFunction eval)
        {
            var deriv = eval(step, current);

            for (var i = 0; i < current.Length; i++)
            {
                current[i] += step * deriv[i];
            }
            return(current);
        }
        /***************************************************************************/

        public LibraryElementType(
            LibraryElementKind.Enum _elementKind
            , EvalFunction _evalFunction
            , CalculateLinesFunction _calculateInputsFunction
            , CalculateLinesFunction _calculateOutputsFuction
            , int _minModifier
            , int _maxModifier
            )
        {
            m_elementKind             = _elementKind;
            m_evalFunction            = _evalFunction;
            m_calculateInputsFunction = _calculateInputsFunction;
            m_calculateOutputsFuction = _calculateOutputsFuction;
            m_minModifier             = _minModifier;
            m_maxModifier             = _maxModifier;
        }
示例#4
0
        /***************************************************************************/

        private void createPortElementType(
            LogicalModel.API.PortDirection _kind
            , EvalFunction _evalFunction
            , CalculateLinesFunction _inputsLinesCalculator
            , CalculateLinesFunction _outputsLinesCalculator
            )
        {
            ms_portElementTypes[_kind] = new LibraryElementType(
                LibraryElementKind.Enum.Port
                , _evalFunction
                , _inputsLinesCalculator
                , _outputsLinesCalculator
                , 0
                , 0
                );
        }
示例#5
0
        /***************************************************************************/

        private void createPrimitiveElementType(
            LibraryElementKind.Enum _kind
            , EvalFunction _evalFunction
            )
        {
            if (!LibraryElementKind.isSimpleElement(_kind))
            {
                throw new ArgumentException(
                          string.Format(Resoursers.Exceptions.Messages.nonPrimitiveElement, LibraryElementKind.toString(_kind))
                          );
            }

            ms_elementTypes[_kind] = new LibraryElementType(
                _kind
                , _evalFunction
                , LogicalFunctionsLibrary.primitivesInputsCalculator
                , LogicalFunctionsLibrary.primitivesOutputsCalculator
                , ms_minPrimitivesModifier
                , ms_maxPrimitivesModifier
                );
        }
示例#6
0
        public static float[] RungeKutta(float[] current, float step, EvalFunction eval)
        {
            float halfStep  = step / 2;
            float sixthStep = step / 6;
            var   tmp       = new float[current.Length];

            float[] k1 = eval(0, current);
            // Console.WriteLine("k1: " + string.Join(';', k1));

            for (var i = 0; i < current.Length; i++)
            {
                tmp[i] = current[i] + halfStep * k1[i];
            }
            float[] k2 = eval(0 + halfStep, tmp);
            // Console.WriteLine("k2: " + string.Join(';', k2));

            for (var i = 0; i < current.Length; i++)
            {
                tmp[i] = current[i] + halfStep * k2[i];
            }
            float[] k3 = eval(0 + halfStep, tmp);
            // Console.WriteLine("k3: " + string.Join(';', k3));

            for (var i = 0; i < current.Length; i++)
            {
                tmp[i] = current[i] + step * k3[i];
            }
            float[] k4 = eval(0 + step, tmp);
            // Console.WriteLine("k4: " + string.Join(';', k4));


            for (var i = 0; i < current.Length; i++)
            {
                tmp[i] = current[i] + sixthStep * (k1[i] + 2 * k2[i] + 2 * k3[i] + k4[i]);
            }

            return(tmp);
        }
示例#7
0
        /***************************************************************************/

        private void createNotPrimitiveElementType(
            LibraryElementKind.Enum _kind
            , EvalFunction _evalFunction
            , CalculateLinesFunction _inputsLinesCalculator
            , CalculateLinesFunction _outputsLinesCalculator
            )
        {
            if (LibraryElementKind.isSimpleElement(_kind))
            {
                throw new ArgumentException(
                          string.Format(Resoursers.Exceptions.Messages.primitiveElement, LibraryElementKind.toString(_kind))
                          );
            }

            ms_elementTypes[_kind] = new LibraryElementType(
                _kind
                , _evalFunction
                , _inputsLinesCalculator
                , _outputsLinesCalculator
                , ms_minNotPrimitivesModifier
                , ms_maxNotPrimitivesModifier
                );
        }
示例#8
0
 public void Setup()
 {
     this.eval = new EvalFunction();
 }