public void TestIntegrateSubstitutionHighLevelAnchor() { var input = @"declare goal [ anchor ] refinedby child1, child2 end declare goal [ child1 ] refinedby child3, child4 end declare goal [ child3 ] obstructedby o end declare obstacle [ o ] resolvedby [substitution:anchor] cm end declare goal [ cm ] end"; ModelBuilder parser = new ModelBuilder(); var model = parser.Parse(input); var integrator = new ResolutionIntegrator(model); var r = model.Resolutions().Single(); integrator.Integrate(r); var e = new KAOSFileExporter(model); Console.WriteLine(e.Export()); var refinement = model.GoalRefinements(x => x.ParentGoalIdentifier == "anchor").Single(); Assert.That(refinement.SubGoalIdentifiers.Any(x => x.Identifier == "child2")); Assert.That(refinement.SubGoalIdentifiers.Any(x => x.Identifier == "cm")); Assert.AreEqual(2, refinement.SubGoalIdentifiers.Count()); }
public void TestIntegrateObstaclePrevention() { var input = @"declare goal [ anchor ] formalspec when Current() then sooner-or-later Target() refinedby child1, child2 end declare goal [ child1 ] formalspec when Current() then sooner-or-later Milestone() obstructedby o end declare goal [ child2 ] formalspec when Milestone() then sooner-or-later Target() end declare obstacle [ o ] formalspec sooner-or-later (Current() and always not Milestone()) resolvedby [prevention:anchor] cm end declare goal [ cm ] end"; ModelBuilder parser = new ModelBuilder(); var model = parser.Parse(input); var integrator = new ResolutionIntegrator(model); var r = model.Resolutions().Single(); integrator.Integrate(r); var e = new KAOSFileExporter(model); Console.WriteLine(e.Export()); }
public void TestIntegrateSubstitutionProbabilityComputation() { var input = @"declare goal [ anchor ] refinedby child1, child2 end declare goal [ child1 ] obstructedby o end declare goal [ child2 ] end declare obstacle [ o ] probability .4 resolvedby [substitution:anchor] cm end declare goal [ cm ] obstructedby o2 end declare obstacle [ o2 ] probability .1 end"; ModelBuilder parser = new ModelBuilder(); var model = parser.Parse(input); var integrator = new ResolutionIntegrator(model); var r = model.Resolutions().Single(); integrator.Integrate(r); var propagator = new BDDBasedPropagator(model); var expected = ((DoubleSatisfactionRate)propagator.GetESR(model.Goal("anchor"))).SatisfactionRate; }
public void TestIntegrateObstaclePreventionProbabilityComputation() { var input = @"declare goal [ root ] refinedby anchor end declare goal [ anchor ] formalspec when Current() then sooner-or-later Target() refinedby child1, child2 end declare goal [ child1 ] formalspec when Current() then sooner-or-later Milestone() obstructedby o end declare goal [ child2 ] formalspec when Milestone() then sooner-or-later Target() end declare obstacle [ o ] probability .4 formalspec sooner-or-later (Current() and always not Milestone()) resolvedby [prevention:anchor] cm end declare goal [ cm ] obstructedby o2 end declare obstacle [ o2 ] probability .1 end"; ModelBuilder parser = new ModelBuilder(); var model = parser.Parse(input); var integrator = new ResolutionIntegrator(model); var r = model.Resolutions().Single(); integrator.Integrate(r); var obstruction = model.Obstructions(x => x.ObstacleIdentifier == "o").Single(); model.obstacleRepository.Remove(obstruction); var propagator = new BDDBasedPropagator(model); var expected = ((DoubleSatisfactionRate)propagator.GetESR(model.Goal("root"))).SatisfactionRate; }