Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ix.iplan
Class PlanCheckingSimulator

    java.lang.Object
      ix.iplan.PlanCheckingSimulator

    public class PlanCheckingSimulator

extends java.lang.Object

A simple plan-execution simulator that complains if any condition is not satisfied when a node-end is executed after obeying all ordering constraints. To ensure that it's an independent check, it doesn't share any interesting code with the planner. It doesn't even use a status-change propagation algorithm to determine the execution order; it just does a topological sort of the node-ends. However, it independently maintains a set of ready-to-execute node-ends in order to check that they wouldn't delete any of the executing node-end's conditions if they'd been chosen to execute instead.

This class is based on parts of O-Plan.

See Also:
  `AutoTester`, `PlanTest`

Nested Class Summary
`protected class` | `PlanCheckingSimulator.CheckingInterpreter`
`protected class` | `PlanCheckingSimulator.ExecOrderSorter` Topological sort for node-ends to provide a total order that can be used to simulate execution.

Field Summary
`protected ComputeInterpreter` | `computeInterpreter`
`protected java.util.List` | `executionOrder`
`protected static Symbol` | `FALSE`
`protected Ip2ModelManager` | `modelManager`
`protected java.util.List` | `problems`
`protected java.util.Random` | `random`
`protected boolean` | `randomized`
`protected long` | `randomSeed`
`protected boolean` | `shuffle`
`protected boolean` | `trace`
`protected java.io.PrintStream` | `traceOut`
`protected static Symbol` | `TRUE`
`protected java.util.Map` | `worldState`

Constructor Summary
`PlanCheckingSimulator(Ip2 ip2)` Creates a simulator for the specified agent's current plan.
`PlanCheckingSimulator(Plan plan, Domain domain)` Creates a simulator for the specified plan and domain.

Method Summary
`protected void` | `checkComputeCondition(Constraint c)`
`protected void` | `checkComputeResult(LList p, java.lang.Object expected, java.lang.Object actual)`
`protected void` | `checkConditions(PNodeEnd ne, java.util.Set ready)`
`protected void` | `checkForDeleters(PNodeEnd ne, LList p, java.lang.Object v, java.util.Set ready)`
`protected void` | `checkNodeEndStatusValue(PNodeEnd end)`
`protected void` | `checkNodeEndStatusValues()`
`protected void` | `checkNodeStatusValues()`
`void` | `describeChangedWorldState()`
`void` | `describeChangedWorldState(java.io.PrintStream out)`
`void` | `describeFinalWorldState()`
`void` | `describeFinalWorldState(java.io.PrintStream out)`
`protected void` | `describeState(java.io.PrintStream out, java.lang.String label, java.util.Map state)`
`protected void` | `doEffects(PNodeEnd ne)`
`protected java.util.List` | `getConditions(PNodeEnd ne)`
`protected java.util.List` | `getEffects(PNodeEnd ne)`
`java.util.List` | `getExecutionOrder()`
`java.util.Map` | `getInitialWorldStateMap()`
`java.util.List` | `getProblems()`
`java.util.Map` | `getWorldStateMap()`
`protected java.util.List` | `keepIf(Status status, java.util.List nodeEnds)`
`static void` | `main(java.lang.String[] argv)` Standalone main program for testing.
`protected boolean` | `matchComputeResult(java.lang.Object expected, java.lang.Object actual)`
`protected java.util.List` | `maybeShuffle(java.util.List list)`
`protected void` | `nextExecFringe(java.util.Set ready, java.util.Set waiting, java.util.Set complete)` Moves node-ends from waiting to ready.
`protected void` | `problem(java.lang.String description)`
`protected void` | `processCommandLineArguments()`
`void` | `randomize()` Changes this simulator's random number generator to one set up with a seed based on the current time.
`protected java.util.List` | `removeIf(Status status, java.util.List nodeEnds)`
`void` | `report()`
`void` | `report(java.io.PrintStream out)`
`void` | `run()` Simulates execution.
`void` | `setShuffle(boolean shuffle)` Controls whether the node-ends are permuted when putting them in order for execution.
`void` | `setTrace(boolean trace)` Tells this simulator whether or not it should produce trace output.
`void` | `setTraceOutput(java.io.PrintStream ps)` Sets the stream on which trace output appears.
`protected void` | `traceln(java.lang.String message)`
`protected void` | `traceln(java.lang.String message, java.lang.Object obj)`
`protected void` | `wrongStatusProblem(HasStatus h, Status correct)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TRUE

    protected static final Symbol TRUE

### FALSE

    protected static final Symbol FALSE

### modelManager

    protected Ip2ModelManager modelManager

### computeInterpreter

    protected ComputeInterpreter computeInterpreter

### worldState

    protected java.util.Map worldState

### problems

    protected java.util.List problems

### executionOrder

    protected java.util.List executionOrder

### random

    protected java.util.Random random

### shuffle

    protected boolean shuffle

### trace

    protected boolean trace

### randomSeed

    protected long randomSeed

### randomized

    protected boolean randomized

### traceOut

    protected java.io.PrintStream traceOut

Constructor Detail

### PlanCheckingSimulator

    public PlanCheckingSimulator(Ip2 ip2)

  Creates a simulator for the specified agent's current plan.

### PlanCheckingSimulator

    public PlanCheckingSimulator(Plan plan,
                                 Domain domain)

  Creates a simulator for the specified plan and domain.

Method Detail

### setShuffle

    public void setShuffle(boolean shuffle)

  Controls whether the node-ends are permuted when putting them in order for execution. If the argument is true, a random number generator is created using this simulator's current random seed, and the simulator will use that generator when making lists of node-ends while determining the execution order. All of the ordering constraints will still be obeyed, but this can change the relative order of node-ends that aren't constrained against each other.

  If the argument is false, any current random number generator is discarded, and the simulator will not permute the node-ends.

  There is no way to explicitly set the random seed (though that might change in a subclass). There is a fixed default seed to allow repeatable simulations; or else a seed based on the current time can be set by calling `randomize()`.

### randomize

    public void randomize()

  Changes this simulator's random number generator to one set up with a seed based on the current time. It is not necessary to separately call `setShuffle(boolean)`, because this method calls `setShuffle(true)`.

### setTrace

    public void setTrace(boolean trace)

  Tells this simulator whether or not it should produce trace output. Trace output shows which node-end is being executed and when conditions and effects are eveluated.

  See Also:
    `setTraceOutput(PrintStream)`

### setTraceOutput

    public void setTraceOutput(java.io.PrintStream ps)

  Sets the stream on which trace output appears. If this method is not called, the stream `Debug.out` will be used.

  See Also:
    `setTrace(boolean)`

### run

    public void run()

  Simulates execution.

### getProblems

    public java.util.List getProblems()

### getInitialWorldStateMap

    public java.util.Map getInitialWorldStateMap()

### getWorldStateMap

    public java.util.Map getWorldStateMap()

### getExecutionOrder

    public java.util.List getExecutionOrder()

### report

    public void report()

### report

    public void report(java.io.PrintStream out)

### describeFinalWorldState

    public void describeFinalWorldState()

### describeFinalWorldState

    public void describeFinalWorldState(java.io.PrintStream out)

### describeChangedWorldState

    public void describeChangedWorldState()

### describeChangedWorldState

    public void describeChangedWorldState(java.io.PrintStream out)

### describeState

    protected void describeState(java.io.PrintStream out,
                                 java.lang.String label,
                                 java.util.Map state)

### maybeShuffle

    protected java.util.List maybeShuffle(java.util.List list)

### removeIf

    protected java.util.List removeIf(Status status,
                                      java.util.List nodeEnds)

### keepIf

    protected java.util.List keepIf(Status status,
                                    java.util.List nodeEnds)

### checkNodeStatusValues

    protected void checkNodeStatusValues()

### checkNodeEndStatusValues

    protected void checkNodeEndStatusValues()

### checkNodeEndStatusValue

    protected void checkNodeEndStatusValue(PNodeEnd end)

### wrongStatusProblem

    protected void wrongStatusProblem(HasStatus h,
                                      Status correct)

### nextExecFringe

    protected void nextExecFringe(java.util.Set ready,
                                  java.util.Set waiting,
                                  java.util.Set complete)

  Moves node-ends from waiting to ready.

### traceln

    protected void traceln(java.lang.String message)

### traceln

    protected void traceln(java.lang.String message,
                           java.lang.Object obj)

### problem

    protected void problem(java.lang.String description)

### checkConditions

    protected void checkConditions(PNodeEnd ne,
                                   java.util.Set ready)

### checkForDeleters

    protected void checkForDeleters(PNodeEnd ne,
                                    LList p,
                                    java.lang.Object v,
                                    java.util.Set ready)

### checkComputeCondition

    protected void checkComputeCondition(Constraint c)

### checkComputeResult

    protected void checkComputeResult(LList p,
                                      java.lang.Object expected,
                                      java.lang.Object actual)

### matchComputeResult

    protected boolean matchComputeResult(java.lang.Object expected,
                                         java.lang.Object actual)

### doEffects

    protected void doEffects(PNodeEnd ne)

### getConditions

    protected java.util.List getConditions(PNodeEnd ne)

### getEffects

    protected java.util.List getEffects(PNodeEnd ne)

### main

    public static void main(java.lang.String[] argv)

  Standalone main program for testing. The most useful command-line arguments are:

         -plan=resource name
         -trace=true or false, default true
         -shuffle=true or false, default false
         -randomize=true or false, default false

  See Also:
    `setTrace(boolean)`, `setShuffle(boolean)`, `randomize()`

### processCommandLineArguments

    protected void processCommandLineArguments()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD