2013-10-21 53 views
0

我已將我的計劃變量設置爲空。但是,使用這種構造啓發式將變量初始化爲空值,我認爲這是浪費計算最優解的時間。你可以使用uninitializedEntityFilter覆蓋這些文件。但它不顯示實際的UninitializedTaskFilter.class。這堂課的內容是什麼?謝謝!未初始化實體過濾器的詳細示例

回答

0

如果是nullable=true,您可能希望得分受到限制,因此OptaPlanner會避免將該變量設置爲null

nullable=false唯一的區別在於它不是內置硬約束,因爲在某些情況下(如過度約束規劃),最好將它保留爲空,而不是將它初始化爲與另一個分配衝突的地方。

另一個在null上有變量的用例是,如果你有多個變量,並且某些變量在某些情況下不適用。但一般來說,子類化是更好的方法(現在支持6)

回答你的問題:SelectionFilter。 注意:uninitializedEntityFilter已在6.0.0.Alpha7中更名爲reinitializeVariableEntityFilter以更好地反映它的用法(文檔也已澄清)。我強烈建議更新到6.0.0.CR5最新和最偉大的版本(只是跟着升級配方),因爲它有很多改進/錯誤修正相關nullable

從它的Javadoc:

/** 
* Construction heuristics only change reinitializable planning variables. 
* Non reinitializable planning variable is ignored by construction heuristics. 
* This is especially useful in repeated planning use cases, 
* in which starting from scratch would waste previous results and time. 
* <p/> 
* If no {@link #reinitializeVariableEntityFilter} is specified, 
* the default considers an entity uninitialized for a variable if its value is null 
* (even if {@link #nullable()} is true). 
* <p/> 
* The method {@link SelectionFilter#accept(ScoreDirector, Object)} 
* returns false if the selection entity should be reinitialized for this variable 
* and it returns true if the selection entity should not be reinitialized for this variable 
* @return {@link NullReinitializeVariableEntityFilter} when it is null (workaround for annotation limitation) 
*/ 
Class<? extends SelectionFilter> reinitializeVariableEntityFilter() 
     default NullReinitializeVariableEntityFilter.class;