Search code examples
javaoptaplanner

Optaplanner ChangeMove filtering


I'm writing a filter for ChangeMoves for a scheduling problem where planning entities are shifts defined by several Integer variables. The SelectionFilter interface is quite straightforward, however, I'm having trouble getting the details about which variable is going to be changed by the move. In my case that information is essential to check whether or not the move should be filtered.

While changeMove has the getPlanningValue() method, I didn't find any way to check which variable is going to be assigned that value (they're all Integers in my solution). There is also the getSimpleMoveDescriptor() method, which returns the String description containing the variable name, but the documentation discourages parsing values returned by it.

Any ideas on how to find out which variable is to be changed by the ChangeMove? Am I doing something wrong here? Would it maybe be possible to expose the getVariableName() method from the move's variableDescriptor in the future versions?

Thanks :) !

Edit: After reviewing the getSimpleMoveDescriptor() code and testing the discouraged parsing, e.g.

if(move.getSimpleMoveTypeDescription().contains("startQuantum")) { 
    return false; 
} 

I got the desired behaviour. Still, there is probably no guarantee that the move description format will keep the variable names in future versions of optaplanner.


Solution

  • Fixed for 7.0 with this jira.