コード例 #1
0
        public void TestTwoLevelExcept()
        {
            var input  = @"
				declare goal [ pg ] 
					except [ o1 ] cm1
					except [ o2 ] cm2
					refinedby sg1, sg2
				end
				declare goal [ sg1 ] obstructedby o1 end
				declare goal [ sg2 ] obstructedby o2 end
				declare goal [ cm1 ] obstructedby o3 end
				declare goal [ cm2 ] 
					except [ o4 ] cm4 
					obstructedby o4
				end
				
				declare obstacle [ o1 ] esr .1 end
				declare obstacle [ o2 ] esr .2 end
				declare obstacle [ o3 ] esr .3 end
				declare obstacle [ o4 ] esr .4 end
			"            ;
            var parser = new ModelBuilder();
            var model  = parser.Parse(input);
            var pg     = model.Goal("pg");

            var p0 = new ObstructionSuperset(pg);

            Console.WriteLine(p0.ToDot());

            var p1 = new ObstructionResolutionSuperset(pg);

            Console.WriteLine(p1.ToDot());

            Console.WriteLine("---");
            //var p2 = new BDDBasedPropagator(model);
            //Console.WriteLine(p2.GetESR(pg));

            var p3 = new BDDBasedResolutionPropagator(model);

            Console.WriteLine(p3.GetESR(pg));

            foreach (var e in GetAllCombinations(model.goalRepository.GetGoalExceptions().ToList()))
            {
                Console.Write(string.Join(",", e.Select(x => x.ResolvingGoalIdentifier)) + ": ");
                Console.WriteLine(p3.GetESR(pg, e));
            }
        }
コード例 #2
0
        static void ComputeObstructionSets()
        {
            lock (obstructionLock) {
                logger.Info("Obstruction sets ----");
                obstructions = new Dictionary <KAOSMetaModelElement, ObstructionSuperset>();
                // Get the obstruction set
                var goals = cpsGoals;
                foreach (var goal in goals)
                {
                    logger.Info("Obstruction set for " + goal.FriendlyName);
                    ObstructionSuperset obstructionSuperset;
                    if (goal.Replacements().Count() > 0)
                    {
                        obstructionSuperset = goal.GetObstructionSuperset(false);
                    }
                    else
                    {
                        obstructionSuperset = goal.GetObstructionSuperset(true);
                    }
                    obstructions.Add(goal, obstructionSuperset);
                    //foreach (var kv in obstructionSuperset.mapping) {
                    //	logger.Info("{0} => {1}", kv.Key.FriendlyName, kv.Value);
                    //}
                }

                foreach (var obstacle in cpsObstacles)
                {
                    logger.Info("Obstruction set for " + obstacle.FriendlyName);
                    ObstructionSuperset obstructionSuperset = obstacle.GetObstructionSuperset();
                    obstructions.Add(obstacle, obstructionSuperset);
                    //foreach (var kv in obstructionSuperset.mapping) {
                    //	logger.Info("{0} => {1}", kv.Key.FriendlyName, kv.Value);
                    //}
                }
                logger.Info("---- obstruction sets");
            }
        }