Maximal count exceeded error problem

Hello everyone,

I am trying to use Batch Least Square for orbit determination. I have 4k datas for PV observation so i tried to feed estimator with that data. When i feed the estimator with 1k datas, i do not take any error message but if i tried with 1.5k or 2k datas it gives me following message:

JavaError                                 Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_17944\ in <module>
----> 1 estimatedPropagatorArray = estimator.estimate()

JavaError: <super: <class 'JavaError'>, <JavaError object>>
    Java stacktrace:
org.orekit.errors.OrekitException: maximal count (25) exceeded
	at org.orekit.estimation.leastsquares.BatchLSEstimator.estimate(
Caused by: org.hipparchus.exception.MathIllegalStateException: maximal count (25) exceeded
	at org.hipparchus.util.Incrementor.lambda$static$0(
	at org.hipparchus.util.Incrementor.increment(
	at org.hipparchus.optim.nonlinear.vector.leastsquares.GaussNewtonOptimizer.optimize(
	at org.orekit.estimation.leastsquares.BatchLSEstimator.estimate(

I tried to change settings for memory allocation to the JVM as posted here but it does not change anything.

Another interesting thing i saw was, feeding the system with a total of 1923 PV datas does not throw me error, but for example, a less number of data ends up with an error. Do you have any idea what is the reason and also how cn i solve this problem?

Thanks in advance

Hi @saltinisik

This error message is not related to the memory allocation.

A batch least squares algorithm is an iterative process during which the optimizer (e.g. Gauss-Newton algorithm) tries to reduce the error between the observed and the estimated measurements. The max iterations number corresponds to the maximum number of iterations you allow for the optimizer. In that case, the algorithm reach the maximum number and throw an exception.

You can increase the maximum number using estimator.setMaxIterations(...) and estimator.setMaxEvalutations(...)

Best regards,

Hi Suleyman
It might not be related to your problem but I would like to share just my experience working with the BLS orbit estimator.

I was comparing results from some TM GPS data, evaluating the orbit using Orekit BLS and GMAT BLS.

I implemented what discussed in this thread:

Anyhow, for big dataset of TM data (so I suppose it is your case), I was facing either really bad results, either your convergence issues.

I just realized that I was not adding any perturbations to the Numerical Propagator used to orbit estimation.

    //Build numerical propagator
    DormandPrince853IntegratorBuilder integratorBuilder = new DormandPrince853IntegratorBuilder(
        minIntegrationStep, maxIntegrationStepM, positionTolerance);
    NumericalPropagatorBuilder propagatorBuilder = new NumericalPropagatorBuilder(iodCartesian,


public static void addGravityFieldPerturbation(NumericalPropagatorBuilder propagatorBuilder) {
    //Add Gravity field
    val provider = GravityFieldFactory.getNormalizedProvider(Constants.harmonicDegree, Constants.harmonicOrder);
    val gravityFieldForce = new HolmesFeatherstoneAttractionModel(Constants.earthShapeIERS.getBodyFrame(), provider);

  public static void addThirdBodyPerturbation(NumericalPropagatorBuilder propagatorBuilder) {
    // Third Bodies
    ThirdBodyAttraction thirdBodyMoon = new ThirdBodyAttraction(CelestialBodyFactory.getMoon());
    ThirdBodyAttraction thirdBodySun = new ThirdBodyAttraction(CelestialBodyFactory.getSun());

  public static void addOceanTidesPerturbation(NumericalPropagatorBuilder propagatorBuilder) {
    val provider = GravityFieldFactory.getNormalizedProvider(Constants.harmonicDegree, Constants.harmonicOrder);
    val oceanTides = new OceanTides(Constants.earthShapeIERS.getBodyFrame(),
        provider.getAe(), provider.getMu(), 1, 1, IERSConventions.IERS_2010,
        TimeScalesFactory.getUT1(IERSConventions.IERS_2010, true));

Especially for longer window, I guess, without the correct perturbation model, the estimation fails as the numerical propagator cannot match the data (real) you have.
Could it make sense?


Hi @saltinisik, I had encountered a similar error when I was implementing BLSE method. The issue which I was facing was that the column number and the corresponding index in the list was jumbled, and that had to be considered.

I hope it might help you. And if not can you attach the screenshot of the entire code, which you have, and I can take a look at it.


Hello everyone again,

First of all sorry for the late answer. I tried all your suggestions.

@bcazabonne your suggestion solved my exceeded error problem. Thanks for your reply.

@alberto-ferrero it looks like you are right. In my numerical propagator i have already add gravity field perturbation and third body perturbation but i did not add ocean tides and solid tides. After adding these perturbartions, estimation gave me good results for 1k datas with 5 iterations but if i tried 2k datas estimator made too much iterations (like 100 iterations). Is there any possible way to decrease iterations?

@vivo28 I checked my whole data and i did not think that there is a mismatch between datas.

Thanks in advance

Hey there,

The higher your convergence threshold is, the less iterations your estimator should make. So you can try setting large values with setParametersConvergenceThreshold.


1 Like