Search code examples
optaplanner

Custom move implementation


When creating a custom move the methods “getPlanningEntities” , “getPlanningValues” need to be implemented. In these methods the entities and values need to be added in a list and returned.

In my custom move I am changing multiple planning entity instances that belong to different planning entity classes.

When turning on FULL_ASSERT everything is ok there are no errors.

I just wanted to know should the order of the planning entities that are returned by “getPlanningEntities” be the same as the order of the values that are returned by “getPlanningValues” (this is how I do it now but I wanted to know how “getPlanningEntities” and “getPlanningValues” operate).I know they are used for entityTabu and valueTabu.

Also when are “equals” and “hashCode” methods called I am printing out text just to see when they are called but it doesn’t appear?


Solution

  • Move.equals() and hashCode() are only use for moveTabu (which isn't that great, I hardly ever use it).

    The order of the return values of getPlanningEntities() and getPlanningValues() doesn't matter, but they return different type of elements in most cases (except in chained cases). For example in cloudBalancing, getPlanningEntities() returns a collection of processes and getPlanningValues() returns a collection of computers. In a change move, both those collections are a singleton.

    See CloudComputerChangeMove and CloudProcessSwapMove for inspiration.