@@ -81,6 +81,10 @@ public record GraphDescriptor<Solution_>(ConsistencyTracker<Solution_> consisten
8181 VariableReferenceGraphBuilder <Solution_ > variableReferenceGraphBuilder ,
8282 Object [] entities , IntFunction <TopologicalOrderGraph > graphCreator ) {
8383
84+ public boolean ignoreInconsistentSolutions () {
85+ return !solutionDescriptor .hasAnyShadowVariablesInconsistentMember ();
86+ }
87+
8488 public GraphDescriptor (SolutionDescriptor <Solution_ > solutionDescriptor ,
8589 ChangedVariableNotifier <Solution_ > changedVariableNotifier ,
8690 Object ... entities ) {
@@ -162,31 +166,29 @@ public ChangedVariableNotifier<Solution_> changedVariableNotifier() {
162166 }
163167 }
164168
165- public static <Solution_ > VariableReferenceGraph buildGraph (GraphDescriptor <Solution_ > graphDescriptor ,
166- boolean ignoreInconsistentSolutions ) {
169+ public static <Solution_ > VariableReferenceGraph buildGraph (GraphDescriptor <Solution_ > graphDescriptor ) {
167170 var graphStructureAndDirection = GraphStructure .determineGraphStructure (graphDescriptor .solutionDescriptor (),
168171 graphDescriptor .entities ());
169172 LOGGER .trace ("Shadow variable graph structure: {}" , graphStructureAndDirection );
170- return buildGraphForStructureAndDirection (graphStructureAndDirection , graphDescriptor , ignoreInconsistentSolutions );
173+ return buildGraphForStructureAndDirection (graphStructureAndDirection , graphDescriptor );
171174 }
172175
173176 static <Solution_ > VariableReferenceGraph buildGraphForStructureAndDirection (
174- GraphStructure .GraphStructureAndDirection graphStructureAndDirection , GraphDescriptor <Solution_ > graphDescriptor ,
175- boolean ignoreInconsistentSolutions ) {
177+ GraphStructure .GraphStructureAndDirection graphStructureAndDirection , GraphDescriptor <Solution_ > graphDescriptor ) {
176178 return switch (graphStructureAndDirection .structure ()) {
177179 case EMPTY -> EmptyVariableReferenceGraph .INSTANCE ;
178180 case SINGLE_DIRECTIONAL_PARENT -> {
179181 var scoreDirector =
180182 graphDescriptor .variableReferenceGraphBuilder ().changedVariableNotifier .innerScoreDirector ();
181183 if (scoreDirector == null ) {
182- yield buildArbitraryGraph (graphDescriptor , ignoreInconsistentSolutions );
184+ yield buildArbitraryGraph (graphDescriptor );
183185 }
184186 yield buildSingleDirectionalParentGraph (graphDescriptor , graphStructureAndDirection );
185187 }
186188 case ARBITRARY_SINGLE_ENTITY_AT_MOST_ONE_DIRECTIONAL_PARENT_TYPE ->
187- buildArbitrarySingleEntityGraph (graphDescriptor , ignoreInconsistentSolutions );
189+ buildArbitrarySingleEntityGraph (graphDescriptor );
188190 case NO_DYNAMIC_EDGES , ARBITRARY ->
189- buildArbitraryGraph (graphDescriptor , ignoreInconsistentSolutions );
191+ buildArbitraryGraph (graphDescriptor );
190192 };
191193 }
192194
@@ -282,8 +284,7 @@ yield new TopologicalSorter(listStateSupply::getPreviousElement,
282284 };
283285 }
284286
285- private static <Solution_ > VariableReferenceGraph buildArbitraryGraph (GraphDescriptor <Solution_ > graphDescriptor ,
286- boolean ignoreInconsistentSolutions ) {
287+ private static <Solution_ > VariableReferenceGraph buildArbitraryGraph (GraphDescriptor <Solution_ > graphDescriptor ) {
287288 var declarativeShadowVariableDescriptors =
288289 graphDescriptor .solutionDescriptor ().getDeclarativeShadowVariableDescriptors ();
289290 var variableIdToUpdater = EntityVariableUpdaterLookup .<Solution_ > entityIndependentLookup ();
@@ -297,14 +298,13 @@ private static <Solution_> VariableReferenceGraph buildArbitraryGraph(GraphDescr
297298 graphDescriptor ,
298299 declarativeShadowVariableDescriptors , variableIdToUpdater );
299300 return buildVariableReferenceGraph (graphDescriptor , declarativeShadowVariableDescriptors ,
300- declarativeShadowVariableToAliasMap , ignoreInconsistentSolutions );
301+ declarativeShadowVariableToAliasMap );
301302 }
302303
303304 private static <Solution_ > VariableReferenceGraph buildVariableReferenceGraph (
304305 GraphDescriptor <Solution_ > graphDescriptor ,
305306 List <DeclarativeShadowVariableDescriptor <Solution_ >> declarativeShadowVariableDescriptors ,
306- Map <VariableMetaModel <?, ?, ?>, Set <VariableSourceReference >> declarativeShadowVariableToAliasMap ,
307- boolean ignoreInconsistentSolutions ) {
307+ Map <VariableMetaModel <?, ?, ?>, Set <VariableSourceReference >> declarativeShadowVariableToAliasMap ) {
308308 // Create variable processors for each declarative shadow variable descriptor
309309 for (var declarativeShadowVariable : declarativeShadowVariableDescriptors ) {
310310 var fromVariableId = declarativeShadowVariable .getVariableMetaModel ();
@@ -320,7 +320,7 @@ private static <Solution_> VariableReferenceGraph buildVariableReferenceGraph(
320320 createFixedVariableRelationEdges (graphDescriptor .variableReferenceGraphBuilder (), graphDescriptor .entities (),
321321 declarativeShadowVariableDescriptors );
322322 return graphDescriptor .variableReferenceGraphBuilder ().build (graphDescriptor .graphCreator (),
323- ignoreInconsistentSolutions );
323+ graphDescriptor . ignoreInconsistentSolutions () );
324324 }
325325
326326 private record GroupVariableUpdaterInfo <Solution_ >(
@@ -455,7 +455,7 @@ public List<VariableUpdaterInfo<Solution_>> getUpdatersForEntityVariable(Object
455455 }
456456
457457 private static <Solution_ > VariableReferenceGraph buildArbitrarySingleEntityGraph (
458- GraphDescriptor <Solution_ > graphDescriptor , boolean ignoreInconsistentSolutions ) {
458+ GraphDescriptor <Solution_ > graphDescriptor ) {
459459 var declarativeShadowVariableDescriptors =
460460 graphDescriptor .solutionDescriptor ().getDeclarativeShadowVariableDescriptors ();
461461 // Use a dependent lookup; if an entity does not use groups, then all variables can share the same node.
@@ -487,7 +487,7 @@ private static <Solution_> VariableReferenceGraph buildArbitrarySingleEntityGrap
487487 (entity , declarativeShadowVariable , variableId ) -> variableIdToGroupedUpdater .get (variableId )
488488 .getUpdatersForEntityVariable (entity , declarativeShadowVariable ));
489489 return buildVariableReferenceGraph (graphDescriptor , declarativeShadowVariableDescriptors ,
490- declarativeShadowVariableToAliasMap , ignoreInconsistentSolutions );
490+ declarativeShadowVariableToAliasMap );
491491 }
492492
493493 private static <Solution_ > Map <VariableMetaModel <?, ?, ?>, Set <VariableSourceReference >> createGraphNodes (
@@ -741,21 +741,18 @@ private static <Solution_> void createFixedVariableRelationEdges(
741741 }
742742
743743 public DefaultShadowVariableSession <Solution_ > forSolution (ConsistencyTracker <Solution_ > consistencyTracker ,
744- boolean ignoreInconsistentSolutions ,
745744 Solution_ solution ) {
746745 var entities = new ArrayList <>();
747746 solutionDescriptor .visitAllEntities (solution , entities ::add );
748- return forEntities (consistencyTracker , ignoreInconsistentSolutions , entities .toArray ());
747+ return forEntities (consistencyTracker , entities .toArray ());
749748 }
750749
751750 public DefaultShadowVariableSession <Solution_ > forEntities (ConsistencyTracker <Solution_ > consistencyTracker ,
752- boolean ignoreInconsistentSolutions ,
753751 Object ... entities ) {
754752 var graph = buildGraph (
755753 new GraphDescriptor <>(solutionDescriptor , ChangedVariableNotifier .of (scoreDirector ), entities )
756754 .withConsistencyTracker (consistencyTracker )
757- .withGraphCreator (graphCreator ),
758- ignoreInconsistentSolutions );
755+ .withGraphCreator (graphCreator ));
759756 return new DefaultShadowVariableSession <>(graph );
760757 }
761758}
0 commit comments