Hey guys, I'm trying to build a simple score-calculator with optaplanner. Method "A_at_Index2_or_Index3" should force "A" to be at index 2 or index 3. Method "no_A_at_Index2" forces "A" not to be at Index 2. So, "A" only can be at index 3 ... but it doesn't. Optaplanner says the score is -1, but the score has to be 0. Method "no_A_at_Index2" works well. "A_at_Index2_or_Index3" seems to be wrong.
Does anyone know what I am doing wrong? Do u have any examples for building complex constraints like XOR, AND, ...)? @Override public SimpleScore calculateScore(NCells nCells) { int score = 0; if (!(this.A_at_Index2_or_Index3(nCells))){ score--; } if (!(this.no_A_at_Index2(nCells))){ score--; } return SimpleScore.valueOf(score); } public boolean A_at_Index2_or_Index3(NCells nCells){ List<Cell> cellList = nCells.getCellList(); ChomskyRule rule1 = cellList.get(2).getRule(); ChomskyRule rule2 = cellList.get(3).getRule(); int a_counter = 0; if ( rule1 != null && rule1.getLeftSide().equals("A")){ a_counter++; } if ( rule2 != null && rule2.getLeftSide().equals("A")){ a_counter++; } if (a_counter==0 && rule1!=null && rule2!=null){ return false; } return true; } public boolean no_A_at_Index2(NCells nCells){ List<Cell> cellList = nCells.getCellList(); ChomskyRule rule = cellList.get(2).getRule(); if(rule!=null && rule.getLeftSide().equals("A")){return false;} return true; } -- View this message in context: http://drools.46999.n3.nabble.com/OR-constraint-doesn-t-work-tp4027525.html Sent from the Drools: User forum mailing list archive at Nabble.com. _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users