optaplanner を使用して単純なスコア計算機を構築しようとしていますが、「OR」制約が正しく機能しません。Optaplanner は、スコアが -1 であると言いますが、スコアは 0 でなければなりません。" 解決策: "A" はインデックス 2 でのみ可能です。
メソッド「no_A_at_Index3」はうまく機能します。「A_at_Index2_or_Index3」は間違っているようです。私が間違っていることを誰かが知っていますか?
PS メソッドを「no_A_at_Index2」から「no_A_at_Index3」に変更しました。
それは奇妙です:
- (!(this.A_at_Index2_or_Index3(nCells)) || !(this.no_A_at_Index2(nCells))) はうまく機能します。
(!(this.A_at_Index2_or_Index3(nCells)) || !(this.no_A_at_Index3(nCells))) は機能しません。
@Override public SimpleScore calculateScore(NCells nCells) { int score = 0; if (!(this.A_at_Index2_or_Index3(nCells))){ score--; } if (!(this.no_A_at_Index3(nCells))){ score--; } return SimpleScore.valueOf(score); } public boolean A_at_Index2_or_Index3(NCells nCells){ List<Cell> cellList = nCells.getCellList(); ChomskyRule ruleAtIndex2 = cellList.get(2).getRule(); ChomskyRule ruleAtIndex3 = cellList.get(3).getRule(); int a_counter = 0; if ( ruleAtIndex2 != null && ruleAtIndex2.getLeftSide().equals("A")){ a_counter++; } if ( ruleAtIndex3 != null && ruleAtIndex3.getLeftSide().equals("A")){ a_counter++; } if (a_counter==0 && ruleAtIndex2!=null && ruleAtIndex3!=null){ return false; } return true; } public boolean no_A_at_Index3(NCells nCells){ List<Cell> cellList = nCells.getCellList(); ChomskyRule ruleAtIndex3 = cellList.get(3).getRule(); if(ruleAtIndex3!=null && ruleAtIndex3.getLeftSide().equals("A")){return false;} return true; }