当前位置: 首页>>代码示例>>Java>>正文


Java StepHandler类代码示例

本文整理汇总了Java中org.apache.commons.math3.ode.sampling.StepHandler的典型用法代码示例。如果您正苦于以下问题:Java StepHandler类的具体用法?Java StepHandler怎么用?Java StepHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StepHandler类属于org.apache.commons.math3.ode.sampling包,在下文中一共展示了StepHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initIntegration

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
/** Prepare the start of an integration.
 * @param t0 start value of the independent <i>time</i> variable
 * @param y0 array containing the start value of the state vector
 * @param t target time for the integration
 */
protected void initIntegration(final double t0, final double[] y0, final double t) {

    evaluations = evaluations.withStart(0);

    for (final EventState state : eventsStates) {
        state.setExpandable(expandable);
        state.getEventHandler().init(t0, y0, t);
    }

    for (StepHandler handler : stepHandlers) {
        handler.init(t0, y0, t);
    }

    setStateInitialized(false);

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:22,代码来源:AbstractIntegrator.java

示例2: initIntegration

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
/** Prepare the start of an integration.
 * @param t0 start value of the independent <i>time</i> variable
 * @param y0 array containing the start value of the state vector
 * @param t target time for the integration
 */
protected void initIntegration(final double t0, final double[] y0, final double t) {

    evaluations.resetCount();

    for (final EventState state : eventsStates) {
        state.setExpandable(expandable);
        state.getEventHandler().init(t0, y0, t);
    }

    for (StepHandler handler : stepHandlers) {
        handler.init(t0, y0, t);
    }

    setStateInitialized(false);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:22,代码来源:AbstractIntegrator.java

示例3: Solver

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
Solver(final double step, final FirstOrderIntegrator integrator,
		final GamaMap<String, IList<Double>> integrated_val) {
	this.step = step;
	this.integrator = integrator;
	if (integrated_val != null)
		integrator.addStepHandler(new StepHandler() {

			@Override
			public void init(final double t0, final double[] y0, final double t) {
			}

			@Override
			public void handleStep(final StepInterpolator interpolator, final boolean isLast) {
				final double time = interpolator.getCurrentTime();
				final double[] y = interpolator.getInterpolatedState();
				count++;
				storeValues(time, y, integrated_val);
			}
		});
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:21,代码来源:Solver.java

示例4: AbstractIntegrator

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
/** Build an instance.
 * @param name name of the method
 */
public AbstractIntegrator(final String name) {
    this.name = name;
    stepHandlers = new ArrayList<StepHandler>();
    stepStart = Double.NaN;
    stepSize  = Double.NaN;
    eventsStates = new ArrayList<EventState>();
    statesInitialized = false;
    evaluations = IntegerSequence.Incrementor.create().withMaximalCount(Integer.MAX_VALUE);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:13,代码来源:AbstractIntegrator.java

示例5: AbstractIntegrator

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
/** Build an instance.
 * @param name name of the method
 */
public AbstractIntegrator(final String name) {
    this.name = name;
    stepHandlers = new ArrayList<StepHandler>();
    stepStart = Double.NaN;
    stepSize  = Double.NaN;
    eventsStates = new ArrayList<EventState>();
    statesInitialized = false;
    evaluations = new Incrementor();
    setMaxEvaluations(-1);
    evaluations.resetCount();
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:15,代码来源:AbstractIntegrator.java

示例6: addStepHandler

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
/** {@inheritDoc} */
public void addStepHandler(final StepHandler handler) {
    stepHandlers.add(handler);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:5,代码来源:AbstractIntegrator.java

示例7: getStepHandlers

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
/** {@inheritDoc} */
public Collection<StepHandler> getStepHandlers() {
    return Collections.unmodifiableCollection(stepHandlers);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:5,代码来源:AbstractIntegrator.java

示例8: serialization

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
@Test
public void serialization()
  throws IOException, ClassNotFoundException,
         DimensionMismatchException, NumberIsTooSmallException,
         MaxCountExceededException, NoBracketingException {

  TestProblem3 pb  = new TestProblem3(0.9);
  double minStep   = 0;
  double maxStep   = pb.getFinalTime() - pb.getInitialTime();
  double absTolerance = 1.0e-8;
  double relTolerance = 1.0e-8;

  GraggBulirschStoerIntegrator integ =
    new GraggBulirschStoerIntegrator(minStep, maxStep,
                                     absTolerance, relTolerance);
  integ.addStepHandler(new ContinuousOutputModel());
  integ.integrate(pb,
                  pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ObjectOutputStream    oos = new ObjectOutputStream(bos);
  for (StepHandler handler : integ.getStepHandlers()) {
      oos.writeObject(handler);
  }

  Assert.assertTrue(bos.size () > 35000);
  Assert.assertTrue(bos.size () < 36000);

  ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
  ObjectInputStream     ois = new ObjectInputStream(bis);
  ContinuousOutputModel cm  = (ContinuousOutputModel) ois.readObject();

  Random random = new Random(347588535632l);
  double maxError = 0.0;
  for (int i = 0; i < 1000; ++i) {
    double r = random.nextDouble();
    double time = r * pb.getInitialTime() + (1.0 - r) * pb.getFinalTime();
    cm.setInterpolatedTime(time);
    double[] interpolatedY = cm.getInterpolatedState ();
    double[] theoreticalY  = pb.computeTheoreticalState(time);
    double dx = interpolatedY[0] - theoreticalY[0];
    double dy = interpolatedY[1] - theoreticalY[1];
    double error = dx * dx + dy * dy;
    if (error > maxError) {
      maxError = error;
    }
  }

  Assert.assertTrue(maxError < 5.0e-10);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:53,代码来源:GraggBulirschStoerStepInterpolatorTest.java

示例9: serialization

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
@Test
public void serialization()
  throws IOException, ClassNotFoundException,
         DimensionMismatchException, NumberIsTooSmallException,
         MaxCountExceededException, NoBracketingException {

  TestProblem3 pb = new TestProblem3(0.9);
  double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
  GillIntegrator integ = new GillIntegrator(step);
  integ.addStepHandler(new ContinuousOutputModel());
  integ.integrate(pb,
                  pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ObjectOutputStream    oos = new ObjectOutputStream(bos);
  for (StepHandler handler : integ.getStepHandlers()) {
      oos.writeObject(handler);
  }

  Assert.assertTrue(bos.size () > 880000);
  Assert.assertTrue(bos.size () < 900000);

  ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
  ObjectInputStream     ois = new ObjectInputStream(bis);
  ContinuousOutputModel cm  = (ContinuousOutputModel) ois.readObject();

  Random random = new Random(347588535632l);
  double maxError = 0.0;
  for (int i = 0; i < 1000; ++i) {
    double r = random.nextDouble();
    double time = r * pb.getInitialTime() + (1.0 - r) * pb.getFinalTime();
    cm.setInterpolatedTime(time);
    double[] interpolatedY = cm.getInterpolatedState ();
    double[] theoreticalY  = pb.computeTheoreticalState(time);
    double dx = interpolatedY[0] - theoreticalY[0];
    double dy = interpolatedY[1] - theoreticalY[1];
    double error = dx * dx + dy * dy;
    if (error > maxError) {
      maxError = error;
    }
  }

  Assert.assertTrue(maxError < 0.003);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:47,代码来源:GillStepInterpolatorTest.java

示例10: serialization

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
@Test
public void serialization()
  throws IOException, ClassNotFoundException,
         DimensionMismatchException, NumberIsTooSmallException,
         MaxCountExceededException, NoBracketingException {

  TestProblem3 pb = new TestProblem3(0.9);
  double minStep = 0;
  double maxStep = pb.getFinalTime() - pb.getInitialTime();
  double scalAbsoluteTolerance = 1.0e-8;
  double scalRelativeTolerance = scalAbsoluteTolerance;
  HighamHall54Integrator integ = new HighamHall54Integrator(minStep, maxStep,
                                                            scalAbsoluteTolerance,
                                                            scalRelativeTolerance);
  integ.addStepHandler(new ContinuousOutputModel());
  integ.integrate(pb,
                  pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ObjectOutputStream    oos = new ObjectOutputStream(bos);
  for (StepHandler handler : integ.getStepHandlers()) {
      oos.writeObject(handler);
  }

  Assert.assertTrue(bos.size () > 185000);
  Assert.assertTrue(bos.size () < 195000);

  ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
  ObjectInputStream     ois = new ObjectInputStream(bis);
  ContinuousOutputModel cm  = (ContinuousOutputModel) ois.readObject();

  Random random = new Random(347588535632l);
  double maxError = 0.0;
  for (int i = 0; i < 1000; ++i) {
    double r = random.nextDouble();
    double time = r * pb.getInitialTime() + (1.0 - r) * pb.getFinalTime();
    cm.setInterpolatedTime(time);
    double[] interpolatedY = cm.getInterpolatedState ();
    double[] theoreticalY  = pb.computeTheoreticalState(time);
    double dx = interpolatedY[0] - theoreticalY[0];
    double dy = interpolatedY[1] - theoreticalY[1];
    double error = dx * dx + dy * dy;
    if (error > maxError) {
      maxError = error;
    }
  }

  Assert.assertTrue(maxError < 1.6e-10);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:52,代码来源:HighamHall54StepInterpolatorTest.java

示例11: serialization

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
@Test
public void serialization()
  throws IOException, ClassNotFoundException,
         DimensionMismatchException, NumberIsTooSmallException,
         MaxCountExceededException, NoBracketingException {

  TestProblem1 pb = new TestProblem1();
  double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.001;
  EulerIntegrator integ = new EulerIntegrator(step);
  integ.addStepHandler(new ContinuousOutputModel());
  integ.integrate(pb,
                  pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ObjectOutputStream    oos = new ObjectOutputStream(bos);
  for (StepHandler handler : integ.getStepHandlers()) {
      oos.writeObject(handler);
  }

  ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
  ObjectInputStream     ois = new ObjectInputStream(bis);
  ContinuousOutputModel cm  = (ContinuousOutputModel) ois.readObject();

  Random random = new Random(347588535632l);
  double maxError = 0.0;
  for (int i = 0; i < 1000; ++i) {
    double r = random.nextDouble();
    double time = r * pb.getInitialTime() + (1.0 - r) * pb.getFinalTime();
    cm.setInterpolatedTime(time);
    double[] interpolatedY = cm.getInterpolatedState ();
    double[] theoreticalY  = pb.computeTheoreticalState(time);
    double dx = interpolatedY[0] - theoreticalY[0];
    double dy = interpolatedY[1] - theoreticalY[1];
    double error = dx * dx + dy * dy;
    if (error > maxError) {
      maxError = error;
    }
  }
  Assert.assertTrue(maxError < 0.001);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:43,代码来源:EulerStepInterpolatorTest.java

示例12: serialization

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
@Test
public void serialization()
  throws IOException, ClassNotFoundException,
         DimensionMismatchException, NumberIsTooSmallException,
         MaxCountExceededException, NoBracketingException {

  TestProblem3 pb = new TestProblem3(0.9);
  double minStep = 0;
  double maxStep = pb.getFinalTime() - pb.getInitialTime();
  double scalAbsoluteTolerance = 1.0e-8;
  double scalRelativeTolerance = scalAbsoluteTolerance;
  DormandPrince853Integrator integ = new DormandPrince853Integrator(minStep, maxStep,
                                                                    scalAbsoluteTolerance,
                                                                    scalRelativeTolerance);
  integ.addStepHandler(new ContinuousOutputModel());
  integ.integrate(pb,
                  pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ObjectOutputStream    oos = new ObjectOutputStream(bos);
  for (StepHandler handler : integ.getStepHandlers()) {
      oos.writeObject(handler);
  }

  Assert.assertTrue(bos.size () > 90000);
  Assert.assertTrue(bos.size () < 100000);

  ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
  ObjectInputStream     ois = new ObjectInputStream(bis);
  ContinuousOutputModel cm  = (ContinuousOutputModel) ois.readObject();

  Random random = new Random(347588535632l);
  double maxError = 0.0;
  for (int i = 0; i < 1000; ++i) {
    double r = random.nextDouble();
    double time = r * pb.getInitialTime() + (1.0 - r) * pb.getFinalTime();
    cm.setInterpolatedTime(time);
    double[] interpolatedY = cm.getInterpolatedState ();
    double[] theoreticalY  = pb.computeTheoreticalState(time);
    double dx = interpolatedY[0] - theoreticalY[0];
    double dy = interpolatedY[1] - theoreticalY[1];
    double error = dx * dx + dy * dy;
    if (error > maxError) {
      maxError = error;
    }
  }

  Assert.assertTrue(maxError < 2.4e-10);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:52,代码来源:DormandPrince853StepInterpolatorTest.java

示例13: serialization

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
@Test
public void serialization()
  throws IOException, ClassNotFoundException,
         DimensionMismatchException, NumberIsTooSmallException,
         MaxCountExceededException, NoBracketingException {

  TestProblem3 pb = new TestProblem3(0.9);
  double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
  ThreeEighthesIntegrator integ = new ThreeEighthesIntegrator(step);
  integ.addStepHandler(new ContinuousOutputModel());
  integ.integrate(pb,
                  pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ObjectOutputStream    oos = new ObjectOutputStream(bos);
  for (StepHandler handler : integ.getStepHandlers()) {
      oos.writeObject(handler);
  }

  Assert.assertTrue(bos.size () > 880000);
  Assert.assertTrue(bos.size () < 900000);

  ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
  ObjectInputStream     ois = new ObjectInputStream(bis);
  ContinuousOutputModel cm  = (ContinuousOutputModel) ois.readObject();

  Random random = new Random(347588535632l);
  double maxError = 0.0;
  for (int i = 0; i < 1000; ++i) {
    double r = random.nextDouble();
    double time = r * pb.getInitialTime() + (1.0 - r) * pb.getFinalTime();
    cm.setInterpolatedTime(time);
    double[] interpolatedY = cm.getInterpolatedState ();
    double[] theoreticalY  = pb.computeTheoreticalState(time);
    double dx = interpolatedY[0] - theoreticalY[0];
    double dy = interpolatedY[1] - theoreticalY[1];
    double error = dx * dx + dy * dy;
    if (error > maxError) {
      maxError = error;
    }
  }

  Assert.assertTrue(maxError > 0.005);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:47,代码来源:ThreeEighthesStepInterpolatorTest.java

示例14: serialization

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
@Test
public void serialization()
  throws IOException, ClassNotFoundException,
         DimensionMismatchException, NumberIsTooSmallException,
         MaxCountExceededException, NoBracketingException  {

  TestProblem3 pb = new TestProblem3(0.9);
  double minStep = 0;
  double maxStep = pb.getFinalTime() - pb.getInitialTime();
  double scalAbsoluteTolerance = 1.0e-8;
  double scalRelativeTolerance = scalAbsoluteTolerance;
  DormandPrince54Integrator integ = new DormandPrince54Integrator(minStep, maxStep,
                                                                  scalAbsoluteTolerance,
                                                                  scalRelativeTolerance);
  integ.addStepHandler(new ContinuousOutputModel());
  integ.integrate(pb,
                  pb.getInitialTime(), pb.getInitialState(),
                  pb.getFinalTime(), new double[pb.getDimension()]);

  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  ObjectOutputStream    oos = new ObjectOutputStream(bos);
  for (StepHandler handler : integ.getStepHandlers()) {
      oos.writeObject(handler);
  }

  Assert.assertTrue(bos.size () > 135000);
  Assert.assertTrue(bos.size () < 145000);

  ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
  ObjectInputStream     ois = new ObjectInputStream(bis);
  ContinuousOutputModel cm  = (ContinuousOutputModel) ois.readObject();

  Random random = new Random(347588535632l);
  double maxError = 0.0;
  for (int i = 0; i < 1000; ++i) {
    double r = random.nextDouble();
    double time = r * pb.getInitialTime() + (1.0 - r) * pb.getFinalTime();
    cm.setInterpolatedTime(time);
    double[] interpolatedY = cm.getInterpolatedState ();
    double[] theoreticalY  = pb.computeTheoreticalState(time);
    double dx = interpolatedY[0] - theoreticalY[0];
    double dy = interpolatedY[1] - theoreticalY[1];
    double error = dx * dx + dy * dy;
    if (error > maxError) {
      maxError = error;
    }
  }

  Assert.assertTrue(maxError < 7.0e-10);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:52,代码来源:DormandPrince54StepInterpolatorTest.java

示例15: serialization

import org.apache.commons.math3.ode.sampling.StepHandler; //导入依赖的package包/类
@Test
public void serialization()
        throws IOException, ClassNotFoundException,
        DimensionMismatchException, NumberIsTooSmallException,
        MaxCountExceededException, NoBracketingException  {

    TestProblem3 pb = new TestProblem3(0.9);
    double step = (pb.getFinalTime() - pb.getInitialTime()) * 0.0003;
    LutherIntegrator integ = new LutherIntegrator(step);
    integ.addStepHandler(new ContinuousOutputModel());
    integ.integrate(pb,
                    pb.getInitialTime(), pb.getInitialState(),
                    pb.getFinalTime(), new double[pb.getDimension()]);

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream    oos = new ObjectOutputStream(bos);
    for (StepHandler handler : integ.getStepHandlers()) {
        oos.writeObject(handler);
    }

    Assert.assertTrue(bos.size() > 1200000);
    Assert.assertTrue(bos.size() < 1250000);

    ByteArrayInputStream  bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream     ois = new ObjectInputStream(bis);
    ContinuousOutputModel cm  = (ContinuousOutputModel) ois.readObject();

    Random random = new Random(347588535632l);
    double maxError = 0.0;
    for (int i = 0; i < 1000; ++i) {
        double r = random.nextDouble();
        double time = r * pb.getInitialTime() + (1.0 - r) * pb.getFinalTime();
        cm.setInterpolatedTime(time);
        double[] interpolatedY = cm.getInterpolatedState ();
        double[] theoreticalY  = pb.computeTheoreticalState(time);
        double dx = interpolatedY[0] - theoreticalY[0];
        double dy = interpolatedY[1] - theoreticalY[1];
        double error = dx * dx + dy * dy;
        if (error > maxError) {
            maxError = error;
        }
    }

    Assert.assertTrue(maxError < 2.2e-7);

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:47,代码来源:LutherStepInterpolatorTest.java


注:本文中的org.apache.commons.math3.ode.sampling.StepHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。