jsprit
jsprit copied to clipboard
Possibility of improvement in the AbstractInsertionCalculator class
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.
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?
I think it is feasible to let the developers implement the getName(), thus the actual available constraints probably suffice the majority of use cases.
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.
👍 Thanks @balage1551. Thus, I am adding it to our v2 branch.
Todo:
- [ ] extend HardXXXConstraint interface with default getName() method
- [ ] implement .getName() in existing core constraints
- [ ] change to .getName() method in reason tracker