I have a database table of 900,000 rows. This table contains power, braking power, speed log from train trips as a function of distance.
- Origin
- Destination
- Distance travelled from departing point
- Power reading in MW
- Braking power reading in MW
- Speed reading in KPH
There are 13 different destinations and outbound and inbound trips have different sets of data so there are 26 datasets.
The aim is to determine the power at a given distance for a particular combination of origin & destination.
I have attempted two different methods. These are working but are extremely slow (roughly 6 seconds per hour). Given that I need to run this simulation for long periods of time, potentially up to 25 years). This would take me over 350+ hours to run this.
Method 1) Using selectFrom to obtain an array of data immediately before and after the travelled distance to interpolate.
selectFrom(table).where(table.origin.eq(origin), table.destination.eq(destination), table.power.between(currentDistance-1,currentDistance+1) ).ArrayOfDoubles(table.power)
This returns an array of roughly <20 elements containing the power readings. then, interpolate using the first and last element of the array to obtain power at given distance.
Method 2) Feeding TableFunction the argument and values data when agent instance is created
tableFunction.setArgumentsAndValues(distanceArray,powerArray);
This method also works, but the simulation becomes stagnant as ~30-40 agents are produced per day.