Stops would be in some ordered collection; the equals for AbstractList
is efficient enogh; it does check sizes before iterating in parallel.
Perhaps the 2 termini should be checked first (if there's a wide range
of lines), then (as Wendy proposes) the day; then the stations.
-W
2011/5/4 Wendy Mungovan <w.mungovan(a)yahoo.com>:
How many train stops are you talking about? If it is only a few it
might
not matter if you don't have the many trains.
When you are writing your rule if you narrow down by matching schedule first
and then comparing all the stops that might help. An alternative to
comparing two collections in drools would be to write a custom function that
could do some simple checks first like make sure that the size of both lists
are the same. Another option if the list of train stops is a POJO itself is
to make its hashkey so that two lists with the same values will have
matching hashkeys.
Wendy
________________________________
From: Brett Bergquist <brett(a)thebergquistfamily.com>
To: rules-users(a)lists.jboss.org
Sent: Tue, May 3, 2011 3:20:52 PM
Subject: [rules-users] Question on modeling facts
I am trying to write rules to distill down a minimal train schedule from a
set of overlapping train schedules. A train schedule contains a train
identifier, a schedule that it runs on, and a set of train stops. A rule
that I would like to write is to combine one or more train schedules if more
than one train runs on the same day (ie has the same schedule) and stops at
the same stops. This ignores the train identifier and will discard all
other train schedules that have a different train identifier but have the
same schedule and stops.
I am wondering how to model the equality test for the same set of stops.
Can I have my Train fact contain a collection of stops and then compare the
collections for equality? Will this be efficient? Is there a better way to
model this?
Any and all help will be greatly appreciated.
Brett
--
View this message in context:
http://drools.46999.n3.nabble.com/Question-on-modeling-facts-tp2895595p28...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users