2014-09-23 37 views
1

我試圖用得分導演像optaplnner:當constraintMatchEnabled(假)是禁用的,這種方法不應該叫

Solver solver = solverFactory.buildSolver(); 
ScoreDirectorFactory scoreDirectorFactory = solver.getScoreDirectorFactory(); 
ScoreDirector guiScoreDirector = scoreDirectorFactory.buildScoreDirector(); 

for (ConstraintMatchTotal constraintMatchTotal :guiScoreDirector.getConstraintMatchTotals()) { 

} 

但我得到以下情況例外,當我打電話getConstraintMatchTotals方法:

When constraintMatchEnabled (false) is disabled, this method should not be called.. Stacktrace follows: 
    Message: When constraintMatchEnabled (false) is disabled, this method should not be called. 
     Line | Method 
    ->> 140 | getConstraintMatchTotals in org.optaplanner.core.impl.score.director.AbstractScoreDirector 
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |  57 | solve     in com.volcare.optaplanner.TaskPlanningController 
    |  97 | index . . . . . . . . . in  '' 
    | 200 | doFilter     in grails.plugin.cache.web.filter.PageFragmentCachingFilter 
    |  63 | doFilter . . . . . . . . in grails.plugin.cache.web.filter.AbstractFilter 
    | 1145 | runWorker    in java.util.concurrent.ThreadPoolExecutor 
    | 615 | run . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker 
    ^ 744 | run      in java.lang.Thread 

solverconfig.xml

<!-- Score configuration --> 
    <scoreDirectorFactory> 
    <scoreDefinitionType>HARD_SOFT_BIG_DECIMAL</scoreDefinitionType> 
    <simpleScoreCalculatorClass>com.volcare.optaplanner.TaskPlanScoreCalculator</simpleScoreCalculatorClass> 
    <!-- <scoreDrl>/taskPlanningScoreRules.drl</scoreDrl> --> 
    </scoreDirectorFactory> 
+0

我想知道你使用的是什麼得分導演(只有drools支持它開箱,但消息似乎關閉)。你能否在這裏複製解算器配置中的元素? – 2014-09-23 14:48:29

+0

我正在使用簡單的java分數計算器,我添加了有問題的配置。 – 2014-09-24 04:57:37

回答

0

SimpleScoreCalculator(現在稱爲EasyScoreCalculator)不支持約束匹配。解決方案:

  1. 使用Drools的得分計算(在你的配置使用的<scoreDrl>代替 <simpleScoreCalculatorClass> Drools的規則 引擎足夠聰明,不只是計算得分,而且還 告訴你有關解釋。約束相匹配

  2. 對於IncrementalScoreCalculator我們最近增加了接口 ConstraintMatchAwareIncrementalScoreCalculator,這樣用戶就可以將它們公開(但不像在Drools中它不只是神奇的工作 - 有工作要做),我想我們也應該支持。一個類似的界面f或簡單分數計算(ConstraintMatchAwareEasyScoreCalculator)。

注意:您收到的錯誤消息不明確,但我已在6.2.0.Beta2中改進了該錯誤消息。檢查一旦發佈錯誤消息是否更清晰。

相關問題