jsprit icon indicating copy to clipboard operation
jsprit copied to clipboard

Possibility of improvement in the AbstractInsertionCalculator class

Open arielmoraes opened this issue 7 years ago • 5 comments

I've done some tests and it seems that when using the getClass().getSimpleName() method of a failed constraint the CPU usage is higher. It could be changed to a static string field in each implemented constraint. Testing with 250+ jobs, 5 vehicles, 1000 iterations, fast regret, 4 threads, compiled fast matrix costs and removing the getSimpleName reduces the execution time from ~18 seconds to ~14 seconds using an i5 processor.

arielmoraes avatar May 11 '17 03:05 arielmoraes

You are correct. This is unnecessary overhead. However, the current approach has been the least intrusive. If we changed it, we d need to force the implementor of a contraint to implement getName() also. Do you agree? Or better, what would you suggest to implement it?

oblonski avatar May 11 '17 08:05 oblonski

I think it is feasible to let the developers implement the getName(), thus the actual available constraints probably suffice the majority of use cases.

arielmoraes avatar May 11 '17 14:05 arielmoraes

I'd comment this not really knowing the actual talk about. :-) The project moves to Java 8, so there is a new feature for extending an interface without breaking the existing code: default implementation. So the default implementation for getName() could cache the getClass().getSimpleName() into a static field and return that. If the talk was about something else, I'm sorry to interfere.

balage1551 avatar May 23 '17 20:05 balage1551

👍 Thanks @balage1551. Thus, I am adding it to our v2 branch.

oblonski avatar Jun 17 '17 15:06 oblonski

Todo:

  • [ ] extend HardXXXConstraint interface with default getName() method
  • [ ] implement .getName() in existing core constraints
  • [ ] change to .getName() method in reason tracker

oblonski avatar Jun 17 '17 16:06 oblonski