[rules-users] Best Solution found but latest solution does not work

moltenice dabrainstabber at gmail.com
Tue Mar 4 07:18:04 EST 2014


Hi ge0ffrey,

I understand. I forgot mentioning I am using OptaPlanner 6.0.1 Final.

Your last email proved useful, I encountered some errors which I tried
fixing, finally coming to this error:
Exception in thread "main" java.lang.IllegalStateException: HashCode
violation: the hashCode of tabu (TimetableSlot at 15897e8d) probably changed
since it was inserted in the tabu Map or Set.
	at
org.optaplanner.core.impl.localsearch.decider.acceptor.tabu.AbstractTabuAcceptor.adjustTabuList(AbstractTabuAcceptor.java:108)
	at
org.optaplanner.core.impl.localsearch.decider.acceptor.tabu.AbstractTabuAcceptor.stepEnded(AbstractTabuAcceptor.java:98)
	at
org.optaplanner.core.impl.localsearch.decider.LocalSearchDecider.stepEnded(LocalSearchDecider.java:159)
	at
org.optaplanner.core.impl.localsearch.DefaultLocalSearchSolverPhase.stepEnded(DefaultLocalSearchSolverPhase.java:127)
	at
org.optaplanner.core.impl.localsearch.DefaultLocalSearchSolverPhase.solve(DefaultLocalSearchSolverPhase.java:83)
	at
org.optaplanner.core.impl.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:190)
	at
org.optaplanner.core.impl.solver.DefaultSolver.solve(DefaultSolver.java:155)
	at Main.main(Main.java:29)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

I have run tests to ensure my Timetable (Solution), TimetableSlot (Planning
Entity), and Lecturer (Planning Variable) all have working clone(),
equals(), and hashCode().

Clone: I always do a deep clone, so Timetable's TimetableSlots and
TimetableSlot's Lecturer will be re-instantiated. Same for the other
classes.
Equals: I always do deep Equals, so even if all objects and sub-objects are
different it will equal true if all the base objects are equal.
hashCode: I ensured that a cloned object using my cloned methods will output
the SAME hashCode.

My @PlanningEntityCollectionProperty returns non-cloned (so same instances)
collection of TimetableSlots.

Hopefully this description of my code can help you spot what I'm doing
wrong.

Thank you for your responses so far!

Karan



--
View this message in context: http://drools.46999.n3.nabble.com/Best-Solution-found-but-latest-solution-does-not-work-tp4028442p4028482.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list