Custom move implementation

若如初见. 提交于 2019-12-11 12:49:57

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/37580998/custom-move-implementation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!