[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orekit Developers] Detecting two events at the same date



Tanguy Yannick <Yannick.Tanguy@cnes.fr> a écrit :

Hello,
Hi Yannick,

We encountered some problems while trying to detect two events at  
the same date. OREKIT propagators don't allow it, and it can lead to  
great difficulties in some operationnal tools.
The problem has been located in AbstractPropagator (OREKIT) because  
events are sorted by date, and a TreeSet (occuringEvents) can only  
store an event per date.
Good catch!

We propose a solution to correct it, in Commons Math  
(AbstractIntegrator) and OREKIT.
The solution is based on a Comparator that will use a hash code to  
arbitrary sort events when they have strictly the same date.
In the method acceptStep, a TreeSet is created with a specific  
Comparator instance :
****
public int compare(final EventState es0, final EventState es1) { int rez = orderingSign * es0.getEventTime().compareTo(es1.getEventTime());
                    if (rez == 0) {
                        // The two event states are for the same date.
// We give them an arbitrary order based on the hashcode,
                        // so that both can be kept inside a SortedSet.
                        final int hes0 = es0.hashCode();
                        final int hes1 = es1.hashCode();
                        if (hes0 != hes1) {
                            rez = hes0 > hes1 ? 1 : -1;
                        } else {
                            rez = 0;
                        }
                    }
                    return rez;
                }
****

Note : the problem is exactly the same in AbstractIntegrator (Commons Math) and had been corrected the same way. Both corrections give expected results.
This feature is necessary for our applications. Should we create  
JIRA tickets in Commons Math and OREKIT ?
Yes, please do and provide patches for these (including test cases).

thanks
Luc

Best regards,

Yannick






----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.