@Test public void testDoOneTopLevelPhaseWithSimpleProduction() throws Exception { agent.getProductions().loadProduction("test1 (state <s> ^superstate nil) --> (<s> ^foo 1)"); agent.getProductions().loadProduction("test2 (state <s> ^superstate nil ^foo 1) --> (write (crlf) |test2 matched!|)"); assertTrue(agent.getProductions().getProduction("test2").instantiations == null); assertEquals(Phase.INPUT, this.decisionCycle.current_phase.get()); this.decisionCycle.runFor(1, RunType.PHASES); assertEquals(Phase.PROPOSE, this.decisionCycle.current_phase.get()); this.decisionCycle.runFor(1, RunType.PHASES); assertEquals(Phase.DECISION, this.decisionCycle.current_phase.get()); this.decisionCycle.runFor(1, RunType.PHASES); assertEquals(Phase.APPLY, this.decisionCycle.current_phase.get()); this.decisionCycle.runFor(1, RunType.PHASES); assertEquals(Phase.OUTPUT, this.decisionCycle.current_phase.get()); this.decisionCycle.runFor(1, RunType.PHASES); assertFalse(agent.getProductions().getProduction("test2").instantiations == null); final Decider decider = Adaptables.adapt(agent, Decider.class); assertEquals("S3", decider.bottom_goal.toString()); }
public void runFor(long n, RunType runType) { if(checkForSystemHaltedAtStartOfTopLevel()) { return; } switch(runType) { case ELABORATIONS: run_for_n_elaboration_cycles(n); break; case DECISIONS: run_for_n_decision_cycles(n); break; case PHASES: run_for_n_phases(n); break; case MODIFICATIONS_OF_OUTPUT: for(long i = 0; i < n; ++i) { run_for_n_modifications_of_output(1); } break; case FOREVER: runForever(); break; default: throw new IllegalArgumentException("Unknown run type: " + runType); } }
DecisionCycle { public void runFor(long n, RunType runType) { if(checkForSystemHaltedAtStartOfTopLevel()) { return; } switch(runType) { case ELABORATIONS: run_for_n_elaboration_cycles(n); break; case DECISIONS: run_for_n_decision_cycles(n); break; case PHASES: run_for_n_phases(n); break; case MODIFICATIONS_OF_OUTPUT: for(long i = 0; i < n; ++i) { run_for_n_modifications_of_output(1); } break; case FOREVER: runForever(); break; default: throw new IllegalArgumentException("Unknown run type: " + runType); } } }
DecisionCycle { public void runFor(long n, RunType runType) { if(checkForSystemHaltedAtStartOfTopLevel()) { return; } switch(runType) { case ELABORATIONS: run_for_n_elaboration_cycles(n); break; case DECISIONS: run_for_n_decision_cycles(n); break; case PHASES: run_for_n_phases(n); break; case MODIFICATIONS_OF_OUTPUT: for(long i = 0; i < n; ++i) { run_for_n_modifications_of_output(1); } break; case FOREVER: runForever(); break; default: throw new IllegalArgumentException("Unknown run type: " + runType); } } DecisionCycle(Agent context); }
DecisionCycle { public void runFor(long n, RunType runType) { if(checkForSystemHaltedAtStartOfTopLevel()) { return; } switch(runType) { case ELABORATIONS: run_for_n_elaboration_cycles(n); break; case DECISIONS: run_for_n_decision_cycles(n); break; case PHASES: run_for_n_phases(n); break; case MODIFICATIONS_OF_OUTPUT: for(long i = 0; i < n; ++i) { run_for_n_modifications_of_output(1); } break; case FOREVER: runForever(); break; default: throw new IllegalArgumentException("Unknown run type: " + runType); } } DecisionCycle(Agent context); void initialize(); void reset(); int getMaxElaborations(); boolean isHitMaxElaborations(); void runFor(long n, RunType runType); void runForever(); boolean isStopped(); String getReasonForStop(); void stop(); void interrupt(String production); boolean isHalted(); void halt(String string); }
DecisionCycle { public void runFor(long n, RunType runType) { if(checkForSystemHaltedAtStartOfTopLevel()) { return; } switch(runType) { case ELABORATIONS: run_for_n_elaboration_cycles(n); break; case DECISIONS: run_for_n_decision_cycles(n); break; case PHASES: run_for_n_phases(n); break; case MODIFICATIONS_OF_OUTPUT: for(long i = 0; i < n; ++i) { run_for_n_modifications_of_output(1); } break; case FOREVER: runForever(); break; default: throw new IllegalArgumentException("Unknown run type: " + runType); } } DecisionCycle(Agent context); void initialize(); void reset(); int getMaxElaborations(); boolean isHitMaxElaborations(); void runFor(long n, RunType runType); void runForever(); boolean isStopped(); String getReasonForStop(); void stop(); void interrupt(String production); boolean isHalted(); void halt(String string); final EnumPropertyProvider<Phase> current_phase; public LongPropertyProvider d_cycle_count; public LongPropertyProvider inner_e_cycle_count; }