I was playing around with the custom shadow variables and custom variable listeners. I found that the \"Exam timetabling\" example uses custom shadow variables to update \"Follo
This code in a variable listener is bad:
Integer var = followingExam.getVar();
...
var++;
...
followingExam.setVar(var);
...
If its called multiple times, the var changes, even if the genuine var hasn't changed. If that var is used in score rules, the solution's score isn't always the same for the same solution.
A shadow variable is the caching of the result of a formula based on at least 1 genuine variable (directly or indirectly). For example shadow C = genuine A + problem property B. So if B is 10 and ranges A from 1 to 5, then C will be 11 if A is 1, 12 if A is 2, etc.