OptaPlanner throwing IllegalStateException on CompositeMove created by CartesianProductMoveSelector

后端 未结 2 1673
独厮守ぢ
独厮守ぢ 2021-01-14 04:48

so basically my problem is, that OptaPlanner is throwing this:

java.lang.IllegalStateException: The entity (...) has a variable (previousEntry) with value (.         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-14 05:34

    I have the same problem and managed to avoid the issue with a MoveFilter that prevents the situation Frank explains in his answer (one move affecting another in a compositMove). Here is my badly coded proof of concept for the workaround:

    public class ParallelTaskMoveFilter
                implements SelectionFilter> {
    
            @Override
            public boolean accept(ScoreDirector scoreDirector,
                    CompositeMove selection) {
                Move[] childMoves = selection.getMoves();
                ChangeMove firstMove = (ChangeMove) childMoves[0];
                ChangeMove secondMove = (ChangeMove) childMoves[1];
    
                DailyRoute srcRoute1 = ((RouteItem) firstMove.getEntity()).getDailyRoute();
                DailyRoute destRoute1 = ((RouteItem) firstMove.getToPlanningValue()).getDailyRoute();
                DailyRoute srcRoute2 = ((RouteItem) secondMove.getEntity()).getDailyRoute();
                DailyRoute destRoute2 = ((RouteItem) secondMove.getToPlanningValue()).getDailyRoute();
    
                return !srcRoute1.equals(srcRoute2) && !srcRoute1.equals(destRoute2) && !destRoute2.equals(destRoute1)
                        && !srcRoute2.equals(destRoute1);
            }
    
        }
    

提交回复
热议问题