Exemple #1
0
 private void ExtractAggregateLabelsFrom(SolutionCollector theSolutionCollector)
 {
     foreach (var aggregateTuple in this.orToolsCache.AggregateVariableMap)
     {
         var newValueBindings = new List <ValueModel>();
         var orVariables      = aggregateTuple.Value.Item2;
         foreach (var orVariable in orVariables)
         {
             var solverValue = theSolutionCollector.Value(0, orVariable);
             var modelValue  = ConvertSolverValueToModel(aggregateTuple.Value.Item1, solverValue);
             newValueBindings.Add(new ValueModel(modelValue));
         }
         var newCompoundLabel = new AggregateVariableLabelModel(aggregateTuple.Value.Item1, newValueBindings);
         this.snapshot.AddAggregateLabel(newCompoundLabel);
     }
 }
Exemple #2
0
        private IEnumerable <AggregateVariableLabelModel> ExtractAggregateLabelsFrom(SnapshotLabelAssignment assignment, ConstraintNetwork constraintNetwork)
        {
            var aggregatorLabelAccumulator = new List <AggregateVariableLabelModel>();

            foreach (var aggregateSolverVariable in constraintNetwork.GetAggregateVariables())
            {
                var internalAccumulator    = new List <ValueModel>();
                var aggregateVariableModel = _modelSolverMap.GetModelAggregateVariableByName(aggregateSolverVariable.Name);
                foreach (var variable in aggregateSolverVariable.Variables)
                {
                    var solverVariable      = _modelSolverMap.GetSolverVariableByName(variable.Name);
                    var labelAssignment     = assignment.GetAssignmentFor(solverVariable);
                    var variableSolverValue = labelAssignment.Value;
                    var variableModel       = _modelSolverMap.GetInternalModelAggregateVariableByName(variable.Name);
                    var variableModelValue  = ConvertSolverValueToModel((SingletonVariableModel)variableModel, variableSolverValue);
                    internalAccumulator.Add(new ValueModel(variableModelValue));
                }

                var label = new AggregateVariableLabelModel(aggregateVariableModel, internalAccumulator);
                aggregatorLabelAccumulator.Add(label);
            }

            return(aggregatorLabelAccumulator);
        }