|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ix.iplan.PlanCheckingSimulator
public class PlanCheckingSimulator
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 partly based on parts of O-Plan.
AutoTester
,
PlanTest
Nested Class Summary | |
---|---|
protected class |
PlanCheckingSimulator.CheckingInterpreter
|
protected class |
PlanCheckingSimulator.ConstraintChecker
|
protected class |
PlanCheckingSimulator.ExecOrderSorter
Topological sort for node-ends to provide a total order that can be used to simulate execution. |
protected class |
PlanCheckingSimulator.UseChecker
|
Field Summary | |
---|---|
protected TwoKeyHashMap<Symbol,Symbol,PlanCheckingSimulator.ConstraintChecker> |
checkerTable
|
protected ComputeInterpreter |
computeInterpreter
|
protected java.util.List<PNodeEnd> |
executionOrder
|
protected static Symbol |
FALSE
|
protected Ip2ModelManager |
modelManager
|
protected java.util.List<java.lang.String> |
problems
|
protected java.util.Random |
random
|
protected boolean |
randomized
|
protected long |
randomSeed
|
protected SanityChecker |
sanityChecker
|
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 |
checkConstraint(Constraint c,
PNodeEnd at)
|
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()
|
protected void |
checkOtherConstraints(PNodeEnd ne)
|
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)
|
java.util.Map |
getChangedWorldStateMap()
|
protected java.util.List |
getConditions(PNodeEnd ne)
|
protected java.util.List |
getEffects(PNodeEnd ne)
|
java.util.List<PNodeEnd> |
getExecutionOrder()
|
java.util.Map |
getInitialWorldStateMap()
|
Ip2ModelManager |
getModelManagerBeingChecked()
Returns the model-manager that contains the model that this simulator is checking. |
java.util.List<java.lang.String> |
getProblems()
|
java.util.Map |
getWorldStateMap()
|
protected java.util.List<PNodeEnd> |
keepIf(Status status,
java.util.List<PNodeEnd> 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<PNodeEnd> |
maybeShuffle(java.util.List<PNodeEnd> 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)
|
void |
processCommandLineArguments()
|
void |
randomize()
Changes this simulator's random number generator to one set up with a seed based on the current time. |
protected void |
register(java.lang.String type,
java.lang.String relation,
PlanCheckingSimulator.ConstraintChecker c)
|
protected void |
registerConstraintCheckers()
|
protected java.util.List<PNodeEnd> |
removeIf(Status status,
java.util.List<PNodeEnd> nodeEnds)
|
void |
report()
|
void |
report(java.io.PrintStream out)
|
protected void |
resetConstraintCheckers()
|
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. |
void |
traceln(java.lang.String message)
|
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 |
---|
protected static final Symbol TRUE
protected static final Symbol FALSE
protected Ip2ModelManager modelManager
protected ComputeInterpreter computeInterpreter
protected SanityChecker sanityChecker
protected TwoKeyHashMap<Symbol,Symbol,PlanCheckingSimulator.ConstraintChecker> checkerTable
protected java.util.Map worldState
protected java.util.List<java.lang.String> problems
protected java.util.List<PNodeEnd> executionOrder
protected java.util.Random random
protected boolean shuffle
protected boolean trace
protected long randomSeed
protected boolean randomized
protected java.io.PrintStream traceOut
Constructor Detail |
---|
public PlanCheckingSimulator(Ip2 ip2)
public PlanCheckingSimulator(Plan plan, Domain domain)
Method Detail |
---|
public Ip2ModelManager getModelManagerBeingChecked()
public void setShuffle(boolean shuffle)
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()
.
public void randomize()
setShuffle(boolean)
,
because this method calls setShuffle(true)
.
public void setTrace(boolean trace)
setTraceOutput(PrintStream)
public void setTraceOutput(java.io.PrintStream ps)
Debug.out
will be used.
setTrace(boolean)
public void run()
public java.util.List<java.lang.String> getProblems()
public java.util.Map getInitialWorldStateMap()
public java.util.Map getWorldStateMap()
public java.util.Map getChangedWorldStateMap()
public java.util.List<PNodeEnd> getExecutionOrder()
public void report()
public void report(java.io.PrintStream out)
public void describeFinalWorldState()
public void describeFinalWorldState(java.io.PrintStream out)
public void describeChangedWorldState()
public void describeChangedWorldState(java.io.PrintStream out)
protected void describeState(java.io.PrintStream out, java.lang.String label, java.util.Map state)
protected java.util.List<PNodeEnd> maybeShuffle(java.util.List<PNodeEnd> list)
protected java.util.List<PNodeEnd> removeIf(Status status, java.util.List<PNodeEnd> nodeEnds)
protected java.util.List<PNodeEnd> keepIf(Status status, java.util.List<PNodeEnd> nodeEnds)
protected void checkNodeStatusValues()
protected void checkNodeEndStatusValues()
protected void checkNodeEndStatusValue(PNodeEnd end)
protected void wrongStatusProblem(HasStatus h, Status correct)
protected void nextExecFringe(java.util.Set ready, java.util.Set waiting, java.util.Set complete)
public void traceln(java.lang.String message)
public void traceln(java.lang.String message, java.lang.Object obj)
protected void problem(java.lang.String description)
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 checkComputeCondition(Constraint c)
protected void checkComputeResult(LList p, java.lang.Object expected, java.lang.Object actual)
protected boolean matchComputeResult(java.lang.Object expected, java.lang.Object actual)
protected void doEffects(PNodeEnd ne)
protected java.util.List getConditions(PNodeEnd ne)
protected java.util.List getEffects(PNodeEnd ne)
protected void checkOtherConstraints(PNodeEnd ne)
protected void checkConstraint(Constraint c, PNodeEnd at)
protected void register(java.lang.String type, java.lang.String relation, PlanCheckingSimulator.ConstraintChecker c)
protected void registerConstraintCheckers()
protected void resetConstraintCheckers()
public static void main(java.lang.String[] argv)
-plan=resource name -trace=true or false, default true -shuffle=true or false, default false -randomize=true or false, default false
setTrace(boolean)
,
setShuffle(boolean)
,
randomize()
public void processCommandLineArguments()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |