コード例 #1
0
        private void radioNewtone_CheckedChanged(object sender, EventArgs e)
        {
            selectedSolMeth = SolutionMethod.Newtone;

            textX0.Enabled     =
                textY0.Enabled =
                    true;
        }
コード例 #2
0
ファイル: SetExt.cs プロジェクト: kkkmail/OdePackInterop
 public static T Switch <T>(
     this SolutionMethod methodFlag,
     Func <T> onAdams,
     Func <T> onBdf
     ) =>
 methodFlag == Adams?onAdams()
     : methodFlag == Bdf?onBdf()
         : throw SolutionMethod.ToInvalidDataException(methodFlag);
コード例 #3
0
        private void radioStillPt_CheckedChanged(object sender, EventArgs e)
        {
            selectedSolMeth = SolutionMethod.StillPoint;

            textX0.Enabled     =
                textY0.Enabled =
                    true;
        }
コード例 #4
0
ファイル: Form4.cs プロジェクト: a-27m/vssdb
        private void radioStillPt_CheckedChanged(object sender, EventArgs e)
        {
            selectedSolMeth = SolutionMethod.StillPoint;

            textP0.Enabled = true;

            //textA.Enabled =
            //    textB.Enabled =
            textP1.Enabled     =
                textP2.Enabled = false;
        }
コード例 #5
0
ファイル: Form4.cs プロジェクト: a-27m/vssdb
        private void radioMuller_CheckedChanged(object sender, EventArgs e)
        {
            selectedSolMeth = SolutionMethod.Muller;

            textP0.Enabled         =
                textP1.Enabled     =
                    textP2.Enabled =
                        true;

            //textA.Enabled =
            //    textB.Enabled =
            //false;
        }
コード例 #6
0
ファイル: Form4.cs プロジェクト: a-27m/vssdb
        private void radioNewtone_CheckedChanged(object sender, EventArgs e)
        {
            selectedSolMeth = SolutionMethod.NewtoneRafson;

            textP0.Enabled =
                true;

            //textA.Enabled =
            //    textB.Enabled =
            textP1.Enabled     =
                textP2.Enabled =
                    false;
        }
コード例 #7
0
ファイル: Lights.cs プロジェクト: RobaGroup/lightsout-mancala
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            int[,] ints = new int[tableLayoutPanel1.RowCount, tableLayoutPanel1.ColumnCount];
            for (int i = 0; i < tableLayoutPanel1.RowCount; i++)
            {
                for (int j = 0; j < tableLayoutPanel1.ColumnCount; j++)
                {
                    if (
                        (this.tableLayoutPanel1.Controls[(i * tableLayoutPanel1.RowCount + j).ToString()] as LightsCell)
                        .radButton1.ThemeName ==
                        visualStudio2012DarkTheme1.ThemeName

                        )
                    {
                        ints[i, j] = 0;
                    }
                    else
                    {
                        ints[i, j] = 1;
                    }
                }
            }
            Board = new Board(ints);

            if (this.linearalgebra.IsChecked)
            {
                method = new Solver()
                {
                    Initial = Board
                }
            }
            ;
            else if (this.bfs.IsChecked)
            {
                method = new BFS()
                {
                    Initial = Board,
                    Method  = async.IsChecked ? BFS.SolveMethod.ASYNC : BFS.SolveMethod.SYNC
                };
            }
            else
            {
                method = new AStar()
                {
                    Initial = Board
                }
            };

            sol = method.Solve().ToList();
            solution.Clear();
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: kkkmail/OdePackInterop
        static void RunDLSODE(int numberOfEquations, SolutionMethod solutionMethod, CorrectorIteratorMethod iteratorMethod)
        {
            Console.WriteLine("Calling DLSODE...");

            SolverParams getChordWithDiagonalJacobianSolver() =>
            new(new ChordWithDiagonalJacobianSolver(numberOfEquations, solutionMethod),
                GetInitialValues(numberOfEquations))
            {
                StartTime = StartTime,
                EndTime   = EndTime,
            };

            SolverParams getFunctionalSolver() =>
            new(new FunctionalSolver(numberOfEquations, solutionMethod),
                GetInitialValues(numberOfEquations))
            {
                StartTime = StartTime,
                EndTime   = EndTime,
            };

            SolverParams throwNotSupported() =>
            throw new NotSupportedException($"Iterator method: {iteratorMethod} is not supported.");

            var solverParam = iteratorMethod.Switch(
                onFunctional: getFunctionalSolver,
                onChordWithUserJacobian: throwNotSupported,
                onChordWithGeneratedJacobian: throwNotSupported,
                onChordWithDiagonalJacobian: getChordWithDiagonalJacobianSolver,
                onChordWithBandedUserJacobian: throwNotSupported,
                onChordWithBandedGeneratedJacobian: throwNotSupported);

            SolverResult solverResult;

            var sw = new Stopwatch();

            sw.Start();

            unsafe
            {
                solverResult = OdeSolver.Run(solverParam, FImpl2);
            }

            var elapsed = sw.Elapsed;

            OutputResults(solverResult, elapsed);
        }
コード例 #9
0
 public MatrixSparseLinkedList(int numberOfRows)
 {
     RealZero = 1.0E-50d;
     solver   = SolutionMethod.LUDecomposition;
     InitializeMatrix(numberOfRows);
 }
コード例 #10
0
 public MatrixSparseLinkedList()
 {
     RealZero     = 1.0E-200d;
     ReasSmall_LU = 1.0E-50d;
     solver       = SolutionMethod.LUDecomposition;
 }
コード例 #11
0
ファイル: OdeSolver.cs プロジェクト: kkkmail/OdePackInterop
        /// <summary>
        /// F# workaround version due to:
        ///     System.InvalidProgramException: Common Language Runtime detected an invalid program
        ///     issue.
        /// </summary>
        public static T RunFSharp <T>(
            Func <F> creator,
            int solutionMethodKey,
            int correctorIteratorMethodKey,
            double tStart,
            double tEnd,
            double[] initialValues,
            Func <SolverResult, TimeSpan, T> resultMapper,
            double[] absoluteTolerance,
            double[] relativeTolerance)
        {
            unsafe
            {
                var f = creator();

                var solutionMethod =
                    SolutionMethod.TryCreate(solutionMethodKey)
                    ?? throw new InvalidDataException($"Invalid key of solution method: {solutionMethodKey}");

                var iteratorMethod =
                    CorrectorIteratorMethod.TryCreate(correctorIteratorMethodKey)
                    ?? throw new InvalidDataException($"Invalid key of corrector iterator method: {correctorIteratorMethodKey}");

                SolverParams getChordWithDiagonalJacobianSolver() =>
                new(
                    new ChordWithDiagonalJacobianSolver(initialValues.Length, solutionMethod),
                    initialValues,
                    absoluteTolerance,
                    relativeTolerance)
                {
                    StartTime = tStart,
                    EndTime   = tEnd,
                };

                SolverParams getFunctionalSolver() =>
                new(
                    new FunctionalSolver(initialValues.Length, solutionMethod),
                    initialValues,
                    absoluteTolerance,
                    relativeTolerance)
                {
                    StartTime = tStart,
                    EndTime   = tEnd,
                };

                SolverParams throwNotSupported() =>
                throw new NotSupportedException($"Iterator method: {iteratorMethod} is not supported.");

                var solverParams = iteratorMethod.Switch(
                    onFunctional: getFunctionalSolver,
                    onChordWithUserJacobian: throwNotSupported,
                    onChordWithGeneratedJacobian: throwNotSupported,
                    onChordWithDiagonalJacobian: getChordWithDiagonalJacobianSolver,
                    onChordWithBandedUserJacobian: throwNotSupported,
                    onChordWithBandedGeneratedJacobian: throwNotSupported);

                var sw = new Stopwatch();
                sw.Start();

                var result = Run(solverParams, f);
                var output = resultMapper(result, sw.Elapsed);
                return(output);
            }
        }