本文整理汇总了C#中Problem.GetInitialBelief方法的典型用法代码示例。如果您正苦于以下问题:C# Problem.GetInitialBelief方法的具体用法?C# Problem.GetInitialBelief怎么用?C# Problem.GetInitialBelief使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Problem
的用法示例。
在下文中一共展示了Problem.GetInitialBelief方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RadnomSolve
public List<Action> RadnomSolve(Problem p, Domain d)
{
State sStart = p.GetInitialBelief().ChooseState(true);
List<Action> lActions = d.GroundAllActions(sStart.Predicates, false);
int iRnd = RandomGenerator.Next(lActions.Count);
List<Action> lPlan = new List<Action>();
lPlan.Add(lActions[iRnd]);
return lPlan;
}
示例2: Solve
public List<Action> Solve(Problem p, Domain d)
{
State sStart = p.GetInitialBelief().ChooseState(true);
List<Action> lActions = new List<Action>();
Action aClear = d.GroundActionByName(new string[] { "clear-all", "" }, sStart.Predicates, false);
sStart = sStart.Apply(aClear);
lActions.Add(aClear);
State sComputeUpstream = ApplyCompute(sStart, "upstream", lActions, d);
State sComputeAffected = ApplyCompute(sComputeUpstream, "affected", lActions, d);
State sComputePath = ApplyCompute(sComputeAffected, "path", lActions, d);
State sComputeLine = ApplyCompute(sComputePath, "line", lActions, d);
//State sObserveAll = ObserveAll(sComputeLine, lActions, d);
return lActions;
}
示例3: SolveII
public List<Action> SolveII(Problem p, Domain d)
{
State sStart = p.GetInitialBelief().ChooseState(true);
List<State> lOpenList = new List<State>();
lOpenList.Add(sStart);
State sCurrent = null, sNext = null;
Dictionary<State,Action> dMapStateToGeneratingAction = new Dictionary<State,Action>();
dMapStateToGeneratingAction[sStart] = null;
Dictionary<State,State> dParents = new Dictionary<State,State>();
Dictionary<State, int> dDepth = new Dictionary<State, int>();
dDepth[sStart] = 0;
dParents[sStart] = null;
int cProcessed = 0;
List<string> lActionNames = new List<string>();
while (lOpenList.Count > 0)
{
sCurrent = lOpenList[0];
lOpenList.RemoveAt(0);
List<Action> lActions = d.GroundAllActions(sCurrent.Predicates, false);
foreach (Action a in lActions)
{
sNext = sCurrent.Apply(a);
bool bGiven = false;
foreach (Predicate pGiven in sNext.Predicates)
{
if (pGiven.Name.ToLower().Contains("given"))
bGiven = true;
}
if (!lActionNames.Contains(a.Name))
lActionNames.Add(a.Name);
if(sNext != null && p.IsGoalState(sNext))
return GeneratePlan(sCurrent, a, dParents, dMapStateToGeneratingAction);
if (!dParents.Keys.Contains(sNext))
{
dDepth[sNext] = dDepth[sCurrent] + 1;
dParents[sNext] = sCurrent;
dMapStateToGeneratingAction[sNext] = a;
lOpenList.Add(sNext);
}
}
cProcessed++;
if (cProcessed % 10 == 0)
Debug.WriteLine(cProcessed + ") " + dDepth[sCurrent] + "," + lOpenList.Count );
}
return null;
}
示例4: ManualSolve
public List<Action> ManualSolve(Problem p, Domain d)
{
State sStart = p.GetInitialBelief().ChooseState(true);
State sCurrent = null, sNext = null;
Dictionary<State, Action> dMapStateToGeneratingAction = new Dictionary<State, Action>();
dMapStateToGeneratingAction[sStart] = null;
Dictionary<State, State> dParents = new Dictionary<State, State>();
dParents[sStart] = null;
int cProcessed = 0;
List<string> lActionNames = new List<string>();
sCurrent = sStart;
while (!p.IsGoalState(sCurrent))
{
List<Action> lActions = d.GroundAllActions(sCurrent.Predicates, false);
Debug.WriteLine("Available actions:");
for (int i = 0; i < lActions.Count; i++)
{
Debug.WriteLine(i + ") " + lActions[i].Name);
}
Debug.Write("Choose action number: ");
int iAction = int.Parse(Console.ReadLine());
Action a = lActions[iAction];
sNext = sCurrent.Apply(a);
foreach (Predicate pNew in sNext.Predicates)
if (!sCurrent.Predicates.Contains(pNew))
Debug.WriteLine(pNew);
if (!dParents.Keys.Contains(sNext))
{
dParents[sNext] = sCurrent;
dMapStateToGeneratingAction[sNext] = a;
}
sCurrent = sNext;
cProcessed++;
}
return GeneratePlan(sCurrent, null, dParents, dMapStateToGeneratingAction);
}
示例5: SolveOld
public List<Action> SolveOld(Problem p, Domain d)
{
State sStart = p.GetInitialBelief().ChooseState(true);
List<Action> lActions = new List<Action>();
State sObserved = ObserveAll(sStart, lActions, d);
State sFixed = ApplyAxiom(sObserved, lActions, d);
//State sClosed = CloseAll(sFixed, lActions, d);
//State sFixed2 = ApplyAxiom(sClosed, lActions, d);
State sObserved2 = ObserveAll(sFixed, lActions, d);
return lActions;
}
示例6: TestCLGPlan
static bool TestCLGPlan(string sPath, Domain domain, Problem problem, List<string> lPlan, State sChosen,
out int cActions, out TimeSpan tsTime)
{
DateTime dtStart = DateTime.Now;
BeliefState bsInitial = problem.GetInitialBelief();
bsInitial.UnderlyingEnvironmentState = sChosen;
PartiallySpecifiedState pssCurrent = bsInitial.GetPartiallySpecifiedState(), pssNext = null;
Formula fObserved = null;
cActions = 0;
foreach (string sAction in lPlan)
{
TimeSpan ts = DateTime.Now - dtStart;
//if (ts.TotalMinutes > MaxTimePerProblem)
// throw new Exception("Execution taking too long");
Debug.WriteLine((int)(ts.TotalMinutes) + "," + cActions + ") " + domain.Name + ", executing action " + sAction);
Action a = domain.GroundActionByName(sAction.Split(' '));
if (a.Observe != null)
{
Predicate pObserve = ((PredicateFormula)a.Observe).Predicate;
if (pssCurrent.Observed.Contains(pObserve) || pssCurrent.Observed.Contains(pObserve.Negate()))
continue;
}
pssNext = pssCurrent.Apply(a, out fObserved);
if (fObserved != null)
{
Debug.WriteLine(domain.Name + ", observed " + fObserved);
}
if (pssNext == null)
{
Debug.WriteLine(domain.Name + ", cannot execute " + sAction);
break;
}
cActions++;
pssCurrent = pssNext;
}
tsTime = DateTime.Now - dtStart;
if (pssCurrent.IsGoalState())
Debug.WriteLine("Plan succeeded!");
Debug.WriteLine("*******************************************************************************");
return pssCurrent.IsGoalState();
}