You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do not use a @ShadowVariableLooped property in a method annotated with @ShadowSources.
1017
-
@ShadowVariableLooped properties can be updated after the @ShadowSources marked method is called, causing score corruption.
1018
-
@ShadowSources marked methods do not need to check @ShadowVariableLooped properties, since they are only called if all their dependencies are not looped.
1019
-
====
1014
+
NOTE: `@ShadowSources`-annotated methods do not need to check `@ShadowVariableLooped`-annotated properties.
1015
+
These methods are only called if neither of their dependencies are looped, and therefore the value of such properties at that time is guaranteed to be `false`.
1020
1016
1017
+
[#aligningShadowVariables]
1021
1018
==== Aligning Shadow Variables
1022
1019
1023
1020
`@ShadowSources` has an optional `alignmentKey` parameter that can be used to reuse calculation results to increase performance.
@@ -1150,6 +1147,24 @@ public class Job {
1150
1147
----
1151
1148
====
1152
1149
1150
+
==== Optimizing Shadow Variables
1151
+
1152
+
Each custom Shadow Variable on each planning entity constitutes one node of a reference graph.
1153
+
The Solver analyzes this graph to decide what is the most optimal strategy for updating these variables.
1154
+
In general, the less variables and the less dependencies between them, the faster the processing.
1155
+
For the best performance, follow these guidelines:
1156
+
1157
+
- Keep all custom Shadow Variables on the same entity class.
1158
+
If one entity is grouping another entity, you might be able to use <<aligningShadowVariables,custom Shadow Variable alignment>> to keep custom Shadow Variables on the same entity class.
1159
+
1160
+
- Do not use both `@PreviousElementShadowVariable` and `@NextElementShadowVariable` in your sources.
1161
+
This includes using `@PreviousElementShadowVariable` as a source in one custom Shadow Variable while using `@NextElementShadowVariable` as a source in another custom Shadow Variable.
1162
+
1163
+
- Compute as much as possible within a single custom Shadow Variable supplier method.
1164
+
Do not create intermediate custom Shadow Variables when it is possible to compute the value directly from another custom Shadow Variable.
1165
+
1166
+
NOTE: These are tips and tricks for optimal performance and needn't be followed to the letter. The solver will work correctly even if you decide not to follow any of the advice, albeit with slightly lesser performance.
1167
+
1153
1168
=== Shadow variable cloning
1154
1169
1155
1170
A shadow variable's value (just like a genuine variable's value)
0 commit comments