public BDDNode GetObstructionSet(GoalRefinement refinement) { BDDNode acc = null; foreach (var child in refinement.SubGoals()) { if (acc == null) { acc = GetObstructionSet(child); } else { var bDDNode = GetObstructionSet(child); acc = _manager.Or(acc, bDDNode); } } foreach (var child in refinement.DomainHypotheses()) { if (acc == null) { acc = GetObstructionSet(child); } else { var bDDNode = GetObstructionSet(child); acc = _manager.Or(acc, bDDNode); } } return(acc); }
public BDDNode GetObstructionSet(GoalRefinement refinement) { BDDNode acc = null; var dict = new Dictionary <Goal, BDDNode>(); foreach (var child in refinement.SubGoals()) { dict.Add(child, GetObstructionSet(child)); } BDDNode acc2 = _manager.Zero; foreach (var child in refinement.SubGoalIdentifiers) { if (child.Parameters != null && child.Parameters is PrimitiveRefineeParameter <double> c) { Console.WriteLine("We have a partial satisfaction."); // Create or get a variable for the partial refinement int idx; if (_mapping.ContainsKey(c)) { idx = _mapping[c]; } else { idx = _manager.CreateVariable(); _mapping.Add(c, idx); _rmapping.Add(idx, c); } // AND the negation of the variable to the other subgoals' bddnode var neg = _manager.Create(idx, 0, 1); acc2 = _manager.Xor(_manager.Create(idx, 1, 0), acc2); //BDDNode bDDNode1 = GetObstructionSet(refinement.model.Goal(child.Identifier)); //var imp = _manager.Imply(bDDNode1, neg); //Console.WriteLine("---"); //Console.WriteLine(this.ToDot(imp)); //Console.WriteLine("---"); foreach (var node in dict.ToArray()) { if (node.Key.Identifier != child.Identifier) { //Console.WriteLine("==="); //Console.WriteLine(this.ToDot(dict[node.Key])); dict[node.Key] = _manager.And(node.Value, neg); //Console.WriteLine(this.ToDot(dict[node.Key])); //Console.WriteLine("==="); } } } } foreach (var kv in dict) { if (acc == null) { acc = kv.Value; } else { acc = _manager.Or(acc, kv.Value); } } foreach (var child in refinement.DomainHypotheses()) { if (acc == null) { acc = GetObstructionSet(child); } else { var bDDNode = GetObstructionSet(child); acc = _manager.Or(acc, bDDNode); } } return(_manager.And(acc, acc2)); }