org.apache.commons.math3.analysis.solvers.BracketingNthOrderBrentSolver Java Examples

The following examples show how to use org.apache.commons.math3.analysis.solvers.BracketingNthOrderBrentSolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testDecreasingOnly()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyDecreasing = new Event(true, false);
    integrator.addEventHandler(new EventFilter(onlyDecreasing,
                                               FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(3, onlyDecreasing.getEventCount());

}
 
Example #2
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testIncreasingOnly()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyIncreasing = new Event(false, true);
    integrator.addEventHandler(new EventFilter(onlyIncreasing,
                                               FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
                               0.1, e, 100,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(2, onlyIncreasing.getEventCount());

}
 
Example #3
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testDecreasingOnly()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyDecreasing = new Event(true, false);
    integrator.addEventHandler(new EventFilter(onlyDecreasing,
                                               FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(3, onlyDecreasing.getEventCount());

}
 
Example #4
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testDecreasingOnly()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyDecreasing = new Event(true, false);
    integrator.addEventHandler(new EventFilter(onlyDecreasing,
                                               FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(3, onlyDecreasing.getEventCount());

}
 
Example #5
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testIncreasingOnly()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyIncreasing = new Event(false, true);
    integrator.addEventHandler(new EventFilter(onlyIncreasing,
                                               FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
                               0.1, e, 100,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(2, onlyIncreasing.getEventCount());

}
 
Example #6
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testIncreasingOnly()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyIncreasing = new Event(false, true);
    integrator.addEventHandler(new EventFilter(onlyIncreasing,
                                               FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
                               0.1, e, 100,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(2, onlyIncreasing.getEventCount());

}
 
Example #7
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testDecreasingOnly()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyDecreasing = new Event(true, false);
    integrator.addEventHandler(new EventFilter(onlyDecreasing,
                                               FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(3, onlyDecreasing.getEventCount());

}
 
Example #8
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testIncreasingOnly()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyIncreasing = new Event(false, true);
    integrator.addEventHandler(new EventFilter(onlyIncreasing,
                                               FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
                               0.1, e, 100,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(2, onlyIncreasing.getEventCount());

}
 
Example #9
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testIncreasingOnly()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyIncreasing = new Event(false, true);
    integrator.addEventHandler(new EventFilter(onlyIncreasing,
                                               FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
                               0.1, e, 100,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(2, onlyIncreasing.getEventCount());

}
 
Example #10
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testDecreasingOnly()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyDecreasing = new Event(true, false);
    integrator.addEventHandler(new EventFilter(onlyDecreasing,
                                               FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(3, onlyDecreasing.getEventCount());

}
 
Example #11
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTwoOppositeFilters()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyIncreasing = new Event(false, true);
    integrator.addEventHandler(new EventFilter(onlyIncreasing,
                                               FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyDecreasing = new Event(true, false);
    integrator.addEventHandler(new EventFilter(onlyDecreasing,
                                               FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(2, onlyIncreasing.getEventCount());
    Assert.assertEquals(3, onlyDecreasing.getEventCount());

}
 
Example #12
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTwoOppositeFilters()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyIncreasing = new Event(false, true);
    integrator.addEventHandler(new EventFilter(onlyIncreasing,
                                               FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyDecreasing = new Event(true, false);
    integrator.addEventHandler(new EventFilter(onlyDecreasing,
                                               FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(2, onlyIncreasing.getEventCount());
    Assert.assertEquals(3, onlyDecreasing.getEventCount());

}
 
Example #13
Source File: AbstractIntegrator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #14
Source File: AbstractIntegrator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #15
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTwoOppositeFilters()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyIncreasing = new Event(false, true);
    integrator.addEventHandler(new EventFilter(onlyIncreasing,
                                               FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyDecreasing = new Event(true, false);
    integrator.addEventHandler(new EventFilter(onlyDecreasing,
                                               FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(2, onlyIncreasing.getEventCount());
    Assert.assertEquals(3, onlyDecreasing.getEventCount());

}
 
Example #16
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTwoOppositeFilters()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyIncreasing = new Event(false, true);
    integrator.addEventHandler(new EventFilter(onlyIncreasing,
                                               FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyDecreasing = new Event(true, false);
    integrator.addEventHandler(new EventFilter(onlyDecreasing,
                                               FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(2, onlyIncreasing.getEventCount());
    Assert.assertEquals(3, onlyDecreasing.getEventCount());

}
 
Example #17
Source File: RootFindingUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenUnivariateSolverSolver_thenCorrect() {
    final UnivariateFunction function = v -> Math.pow(v, 2) - 2;
    UnivariateSolver solver = new BracketingNthOrderBrentSolver(1.0e-12, 1.0e-8, 5);
    double c = solver.solve(100, function, -10.0, 10.0, 0);

    Assert.assertEquals(-Math.sqrt(2), c, 1e-7);
}
 
Example #18
Source File: AbstractIntegrator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #19
Source File: AbstractIntegrator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #20
Source File: JGenProg2017_0030_t.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #21
Source File: AbstractIntegrator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #22
Source File: AbstractIntegrator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #23
Source File: AbstractIntegrator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #24
Source File: EventFilterTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testTwoOppositeFilters()
    throws DimensionMismatchException, NumberIsTooSmallException,
           MaxCountExceededException, NoBracketingException {
    double e = 1e-15;
    FirstOrderIntegrator integrator;
    integrator = new DormandPrince853Integrator(1.0e-3, 100.0, 1e-7, 1e-7);
    Event allEvents = new Event(true, true);
    integrator.addEventHandler(allEvents, 0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyIncreasing = new Event(false, true);
    integrator.addEventHandler(new EventFilter(onlyIncreasing,
                                               FilterType.TRIGGER_ONLY_INCREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    Event onlyDecreasing = new Event(true, false);
    integrator.addEventHandler(new EventFilter(onlyDecreasing,
                                               FilterType.TRIGGER_ONLY_DECREASING_EVENTS),
                               0.1, e, 1000,
                               new BracketingNthOrderBrentSolver(1.0e-7, 5));
    double t0 = 0.5 * FastMath.PI;
    double tEnd = 5.5 * FastMath.PI;
    double[] y = { 0.0, 1.0 };
    Assert.assertEquals(tEnd,
                        integrator.integrate(new SineCosine(), t0, y, tEnd, y),
                        1.0e-7);

    Assert.assertEquals(5, allEvents.getEventCount());
    Assert.assertEquals(2, onlyIncreasing.getEventCount());
    Assert.assertEquals(3, onlyDecreasing.getEventCount());

}
 
Example #25
Source File: AbstractIntegrator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #26
Source File: Math_7_AbstractIntegrator_s.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #27
Source File: Math_7_AbstractIntegrator_t.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #28
Source File: Nopol2017_0077_t.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #29
Source File: Nopol2017_0077_s.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}
 
Example #30
Source File: JGenProg2017_0030_s.java    From coming with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
public void addEventHandler(final EventHandler handler,
                            final double maxCheckInterval,
                            final double convergence,
                            final int maxIterationCount) {
    addEventHandler(handler, maxCheckInterval, convergence,
                    maxIterationCount,
                    new BracketingNthOrderBrentSolver(convergence, 5));
}