Beispiel #1
0
        private void doOneStep(bool quiet = false)
        {
            steps++;
            Plan     plan = new Plan(dom, ev);
            TreeNode node = root.selectSuccesor(plan);

            plan.currentState = node.position.clone();
            plan.runSimulation(simulationPolicy, maxSimulationLength);
            int value = plan.eval();

            simulationPolicy.updateStats(plan);
            if (bestValue > value)
            {
                bestValue = value;
                bestPlan  = plan;
                if (dom.isGoalState(plan.currentState))
                {
                    printMessage("Solution plan found. Plan cost: " + plan.actionCosts, quiet);
                }
                printMessage("Best: " + bestValue + "\tSteps taken: " + steps + "\tTree size: " +
                             (root.subtreeSize + 1) + "\tMax depth: " + (root.subtreeDepth + 1), quiet);
                stepsWithoutImprovement = 0;
            }

            if (value > worstValue)
            {
                worstValue = value;
            }
            node.update(10000 - value);
            if (node.nVisited > TreeNode.visitedBeforeExpansion)
            {
                node.expand();
            }
            stepsWithoutImprovement++;
        }
Beispiel #2
0
 public override void updateStats(Plan simulation)
 {
     foreach (var item in simulation.actions)
     {
         simResultSum[item]     = simResultSum[item] + simulation.eval();
         simulationsCount[item] = simulationsCount[item] + 1;
     }
 }