public void WriteTaggedProblem(string sProblemFile, Dictionary <string, List <Predicate> > dTags, IEnumerable <Predicate> lObserved, List <Predicate> lTrueState, Dictionary <string, double> dFunctionValues, bool bOnlyIdentifyStates) { StreamWriter sw = new StreamWriter(sProblemFile); sw.WriteLine("(define (problem K" + Name + ")"); sw.WriteLine("(:domain K" + Domain.Name + ")"); sw.WriteLine("(:init"); //ff doesn't like the and (and"); string sKP = "", sP = ""; if (Domain.TIME_STEPS > 0) { sw.WriteLine("(time0)"); } if (SDRPlanner.SplitConditionalEffects) { sw.WriteLine("(NotInAction)\n"); } foreach (KeyValuePair <string, double> f in dFunctionValues) { sw.WriteLine("(= " + f.Key + " " + f.Value + ")"); } foreach (GroundedPredicate gp in lObserved) { if (gp.Name == "Choice") { continue; } sKP = "(K" + gp.Name; sP = "(" + gp.Name; foreach (Constant c in gp.Constants) { sKP += " " + c.Name; sP += " " + c.Name; } if (gp.Negation) { sKP += " " + Domain.FALSE_VALUE; } else { sKP += " " + Domain.TRUE_VALUE; } if (!Domain.AlwaysKnown(gp)) { sw.WriteLine(sKP + ")"); } if (!gp.Negation) { sw.WriteLine(sP + ")"); } } foreach (GroundedPredicate gp in lTrueState) { if (gp.Name == "Choice") { continue; } if (!gp.Negation) { sP = "(" + gp.Name; foreach (Constant c in gp.Constants) { sP += " " + c.Name; } sw.WriteLine(sP + ")"); } } foreach (KeyValuePair <string, List <Predicate> > p in dTags) { foreach (GroundedPredicate gp in p.Value) { if (gp.Name == "Choice") { continue; } sKP = GenerateKnowGivenLine(gp, p.Key, false); sw.WriteLine(sKP); } if (SDRPlanner.AddAllKnownToGiven) { foreach (GroundedPredicate gp in lObserved) { if (gp.Name == "Choice") { continue; } if (!Domain.AlwaysKnown(gp)) { sKP = GenerateKnowGivenLine(gp, p.Key, false); sw.WriteLine(sKP); } } } } //if (Problem.Domain.HasNonDeterministicActions()) // sw.WriteLine("(option opt0)"); sw.WriteLine(")"); CompoundFormula cfGoal = new CompoundFormula("and"); if (!bOnlyIdentifyStates) { cfGoal.AddOperand(Goal); HashSet <Predicate> lGoalPredicates = new HashSet <Predicate>(); Goal.GetAllPredicates(lGoalPredicates); //string sGoal = Problem.Goal.ToString(); //sw.WriteLine("(:goal " + sGoal + ")"); //sw.Write("(:goal (and "); //sw.Write( sGoal ); foreach (Predicate p in lGoalPredicates) { //Problem.Domain.WriteKnowledgePredicate(sw, p); if (!Domain.AlwaysKnown(p)) { cfGoal.AddOperand(new KnowPredicate(p)); } } } if (bOnlyIdentifyStates || SDRPlanner.AddTagRefutationToGoal) { for (int iTag = 1; iTag < dTags.Count; iTag++) { GroundedPredicate gp = new GroundedPredicate("KNot"); gp.AddConstant(new Constant("TAG_TYPE", "tag" + iTag)); cfGoal.AddOperand(gp); //sw.Write(" (KNot t" + iTag + ")"); } } if (SDRPlanner.ForceTagObservations) { foreach (Predicate p in lTrueState) { if (Domain.Observable(p)) { cfGoal.AddOperand(new KnowPredicate(p)); } } } sw.WriteLine("(:goal " + cfGoal + ")"); //sw.WriteLine("))"); if (MetricStatement != null) { sw.WriteLine(MetricStatement); } sw.WriteLine(")"); sw.Close(); }