Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright 2010 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.drools.planner.core.move;
A Move represents a change of 1 or more planning variables of 1 or more planning entities in the solution.

Usually the move holds a direct reference to each planning entity of the solution that it will change when doMove(org.drools.WorkingMemory) is called. On that change it should also notify the org.drools.WorkingMemory accordingly.

A Move should implement java.lang.Object.equals(java.lang.Object) and java.lang.Object.hashCode().

public interface Move {

    
Called before a move is evaluated to decide whether the move can be done and evaluated. A Move isn't doable if:
  • Either doing it would change nothing in the solution.
  • Either it's simply not possible to do (for example due to build-in hard constraints).
Although you could filter out non-doable moves in for example the org.drools.planner.core.move.factory.MoveFactory, this is not needed as the org.drools.planner.core.Solver will do it for you.

Parameters:
workingMemory the org.drools.WorkingMemory not yet modified by the move.
Returns:
true if the move achieves a change in the solution and the move is possible to do on the solution.
    boolean isMoveDoable(WorkingMemory workingMemory);

    
Called before the move is done, so the move can be evaluated and then be undone without resulting into a permanent change in the solution.

Parameters:
workingMemory the org.drools.WorkingMemory not yet modified by the move.
Returns:
an undoMove which does the exact opposite of this move.
    Move createUndoMove(WorkingMemory workingMemory);

    
Does the Move and updates the org.drools.planner.core.solution.Solution and its org.drools.WorkingMemory accordingly. When the solution is modified, the org.drools.WorkingMemory's org.drools.FactHandles should be correctly notified, otherwise the score(s) calculated will be corrupted.

Parameters:
workingMemory never null, the org.drools.WorkingMemory that needs to get notified of the changes.
    void doMove(WorkingMemory workingMemory);
New to GrepCode? Check out our FAQ X