how to keep track of planning variable assignment

2019-08-28 22:05发布

问题:

Is there a way to access planning variable's assignment during planning?

In my use case, I want to assign a planning variable with certain status only one time only during planning. After that I don't want to use that planning variable.

I know that in optaplanner, a planning variable/problem fact can not change, so i can not change its status.

Is there a way to get list of planning variable assignment during planning so that in java code or drools file, i can avoid re-assignment if it has been used once?

Thanks!

回答1:

Use a hard constraint to enforce that.

Yes, you could use MoveFilters too, but that's not a good idea because sometimes you need to break hard constraints to escape local optima.