Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Typedefs | Enumerations | Functions
init_soar.h File Reference

Go to the source code of this file.

Typedefs

typedef struct agent_struct agent
typedef char Bool
typedef signed short goal_stack_level
typedef union symbol_union Symbol

Enumerations

enum  go_type_enum
enum  top_level_phase

Functions

void abort_with_fatal_error (agent *thisAgent, const char *)
void add_pwatch (agent *thisAgent, struct production_struct *prod)
void do_one_top_level_phase (agent *thisAgent)
void init_agent_memory (agent *thisAgent)
bool reinitialize_soar (agent *thisAgent)
void remove_pwatch (agent *thisAgent, struct production_struct *prod)
void reset_max_stats (agent *thisAgent)
void reset_statistics (agent *thisAgent)
void reset_timers (agent *thisAgent)
void run_for_n_decision_cycles (agent *thisAgent, int64_t n)
void run_for_n_elaboration_cycles (agent *thisAgent, int64_t n)
void run_for_n_modifications_of_output (agent *thisAgent, int64_t n)
void run_for_n_phases (agent *thisAgent, int64_t n)
void run_for_n_selections_of_slot (agent *, int64_t n, Symbol *attr_of_slot)
void run_for_n_selections_of_slot_at_level (agent *thisAgent, int64_t n, Symbol *attr_of_slot, goal_stack_level level)
void run_forever (agent *thisAgent)
void set_sysparam (agent *thisAgent, int param_number, int64_t new_value)
void setup_signal_handling (void)

Typedef Documentation

typedef struct agent_struct agent

Definition at line 21 of file init_soar.h.

typedef char Bool

Definition at line 18 of file init_soar.h.

typedef signed short goal_stack_level

Definition at line 19 of file init_soar.h.

typedef union symbol_union Symbol

Definition at line 20 of file init_soar.h.

Enumeration Type Documentation

Enumerator:
GO_PHASE 
GO_ELABORATION 
GO_DECISION 
GO_STATE 
GO_OPERATOR 
GO_SLOT 
GO_OUTPUT 

Definition at line 121 of file init_soar.h.

Enumerator:
INPUT_PHASE 
PROPOSE_PHASE 
DECISION_PHASE 
APPLY_PHASE 
OUTPUT_PHASE 
PREFERENCE_PHASE 
WM_PHASE 
NUM_PHASE_TYPES 

Definition at line 140 of file init_soar.h.

Function Documentation

void abort_with_fatal_error ( agent thisAgent,
const char *   
)

Definition at line 89 of file init_soar.cpp.

References print(), and xml_generate_error().

Referenced by add_rete_test_list_to_tests(), add_rete_tests_for_test(), allocate_memory(), attribute_of_existing_impasse(), copy_of_equality_test_found_in_test(), deallocate_preference(), deallocate_production(), deallocate_rete_node(), deallocate_symbol(), decide_context_slot(), decide_non_context_slot(), error_rete_test_routine(), find_goal_for_match_set_change_assertion(), get_next_char(), hash_condition(), hash_test(), highest_active_goal_apply(), highest_active_goal_propose(), init_memory_pool(), make_fake_preference_for_goal_item(), make_symbol_for_current_lexeme(), merge_into_mp_node(), p_node_left_removal(), parse_rhs_action(), preference_type_indicator(), print_trace_format_list(), promote_id_and_tc(), remove_output_link_tc_info(), remove_token_and_subtree(), rete_error_left(), rete_error_right(), reteload_am_from_index(), reteload_node_and_children(), reteload_rhs_value(), reteload_symbol_from_index(), retesave_rete_node_and_children(), reverse_direction_of_relational_test(), rhs_value_to_string(), single_rete_tests_are_identical(), symbol_to_string(), trace_format_list_to_string(), type_of_existing_impasse(), update_node_with_matches_from_above(), var_bound_in_reconstructed_conds(), and variablize_nots_and_insert_into_conditions().

{
FILE *f;
const char* warning = "Soar cannot recover from this error. \nYou will have to restart Soar to run an agent.\nData is still available for inspection, but may be corrupt.\nIf a log was open, it has been closed for safety.";
print (thisAgent, "%s", msg);
print (thisAgent, "%s", warning);
fprintf (stderr,"%s",msg);
fprintf (stderr,"%s",warning);
xml_generate_error(thisAgent, msg);
xml_generate_error(thisAgent, warning);
f = fopen("soarerror", "w");
fprintf (f,"%s",msg);
fprintf (f,"%s",warning);
fclose(f);
assert(false);
// Since we're no longer terminating, should we be invoking this event?
// Note that this is a soar callback, not a gSKI callback, so it isn't being used for now anyway
//soar_invoke_callbacks(thisAgent,
// SYSTEM_TERMINATION_CALLBACK,
// (soar_call_data) FALSE);
}
void add_pwatch ( agent thisAgent,
struct production_struct prod 
)

Definition at line 247 of file init_soar.cpp.

References agent_struct::productions_being_traced, push(), production_struct::trace_firings, and TRUE.

{
if (prod->trace_firings) return;
push (thisAgent, prod, thisAgent->productions_being_traced);
}
void do_one_top_level_phase ( agent thisAgent)

KJC June 05: moved output function timers into do_output_cycle

Definition at line 527 of file init_soar.cpp.

References AFTER_APPLY_PHASE_CALLBACK, AFTER_DECISION_CYCLE_CALLBACK, AFTER_DECISION_PHASE_CALLBACK, AFTER_ELABORATION_CALLBACK, AFTER_HALT_SOAR_CALLBACK, AFTER_INPUT_PHASE_CALLBACK, AFTER_OUTPUT_PHASE_CALLBACK, AFTER_PREFERENCE_PHASE_CALLBACK, AFTER_PROPOSE_PHASE_CALLBACK, AFTER_WM_PHASE_CALLBACK, rl_param_container::apoptosis, rl_param_container::apoptosis_none, APPLY_PHASE, agent_struct::applyPhase, BEFORE_APPLY_PHASE_CALLBACK, BEFORE_DECISION_CYCLE_CALLBACK, BEFORE_DECISION_PHASE_CALLBACK, BEFORE_ELABORATION_CALLBACK, BEFORE_INPUT_PHASE_CALLBACK, BEFORE_OUTPUT_PHASE_CALLBACK, BEFORE_PREFERENCE_PHASE_CALLBACK, BEFORE_PROPOSE_PHASE_CALLBACK, BEFORE_WM_PHASE_CALLBACK, agent_struct::bottom_goal, agent_struct::chunks_this_d_cycle, agent_struct::cumulative_wm_size, agent_struct::current_phase, agent_struct::d_cycle_count, agent_struct::dc_stat_tracking, DECISION_CYCLE_MAX_USEC_INTERRUPT, DECISION_PHASE, agent_struct::decision_phases_count, determine_highest_active_production_level_in_stack_apply(), determine_highest_active_production_level_in_stack_propose(), do_decision_phase(), do_input_cycle(), do_output_cycle(), do_preference_phase(), do_working_memory_phase(), agent_struct::e_cycle_count, agent_struct::e_cycles_this_d_cycle, epmem_enabled(), epmem_go(), agent_struct::epmem_params, agent_struct::epmem_timers, excise_production(), FALSE, agent_struct::FIRING_TYPE, soar_module::object_memory< T, N >::forget(), soar_module::object_memory< T, N >::forgotten_begin(), soar_module::object_memory< T, N >::forgotten_end(), get_derived_kernel_time_usec(), soar_module::constant_param< T >::get_value(), GO_ELABORATION, agent_struct::go_type, identifier_struct::higher_goal, symbol_union::id, IE_PRODS, initialize_consistency_calculations_for_new_decision(), agent_struct::input_cycle_flag, agent_struct::input_period, INPUT_PHASE, agent_struct::last_derived_kernel_time_usec, agent_struct::max_dc_epmem_time_cycle, agent_struct::max_dc_epmem_time_sec, agent_struct::max_dc_production_firing_count_cycle, agent_struct::max_dc_production_firing_count_value, agent_struct::max_dc_smem_time_cycle, agent_struct::max_dc_smem_time_sec, agent_struct::max_dc_time_cycle, agent_struct::max_dc_time_usec, agent_struct::max_dc_wm_changes_cycle, agent_struct::max_dc_wm_changes_value, MAX_NIL_OUTPUT_CYCLES_SYSPARAM, agent_struct::max_wm_size, agent_struct::ms_o_assertions, NIL, agent_struct::num_wm_sizes_accumulated, agent_struct::num_wmes_in_rete, identifier_struct::operator_slot, agent_struct::output_link_changed, OUTPUT_PHASE, agent_struct::pe_cycle_count, agent_struct::pe_cycles_this_d_cycle, PE_PRODS, epmem_param_container::phase, epmem_param_container::phase_output, epmem_param_container::phase_selection, PREFERENCE_PHASE, print(), print_lowest_slot_in_context_stack(), print_phase(), print_string(), soar_module::object_memory< T, N >::process_buffered_references(), agent_struct::production_firing_count, PROPOSE_PHASE, agent_struct::reason_for_stopping, rl_enabled(), agent_struct::rl_params, rl_perform_update(), agent_struct::rl_prods, rl_tabulate_reward_value_for_goal(), agent_struct::run_elaboration_count, agent_struct::run_generated_output_count, agent_struct::run_last_output_count, agent_struct::run_phase_count, smem_attach(), smem_enabled(), smem_go(), agent_struct::smem_timers, soar_invoke_callbacks(), agent_struct::start_dc_production_firing_count, agent_struct::start_dc_wme_addition_count, agent_struct::start_dc_wme_removal_count, stats_db_store(), agent_struct::stop_soar, agent_struct::sysparams, agent_struct::system_halted, soar_module::object_memory< T, N >::time_forward(), agent_struct::timers_decision_cycle_phase, agent_struct::timers_phase, smem_timer_container::total, epmem_timer_container::total, agent_struct::total_dc_epmem_time_sec, agent_struct::total_dc_smem_time_sec, TRACE_CONTEXT_DECISIONS_SYSPARAM, TRACE_PHASES_SYSPARAM, TRUE, soar_module::timer::value(), WM_PHASE, agent_struct::wma_d_cycle_count, wma_enabled(), wma_forgetting, wma_go(), wma_histories, agent_struct::wme_addition_count, agent_struct::wme_removal_count, slot_struct::wmes, xml_generate_error(), and xml_invoke_callback().

Referenced by run_for_n_decision_cycles(), run_for_n_elaboration_cycles(), run_for_n_modifications_of_output(), run_for_n_phases(), run_for_n_selections_of_slot(), run_for_n_selections_of_slot_at_level(), and run_forever().

{
// Symbol *iterate_goal_sym; kjc commented /* RCHONG: end 10.11 */
if (thisAgent->system_halted)
{
print (thisAgent,
"\nSystem halted. Use (init-soar) before running Soar again.");
xml_generate_error(thisAgent, "System halted. Use (init-soar) before running Soar again.");
thisAgent->stop_soar = TRUE;
thisAgent->reason_for_stopping = "System halted.";
return;
}
smem_attach( thisAgent );
/*
* This code was commented by SoarTech with the addition of gSKI
* because gSKI requires the existence of a ^state and ^io link
* before the first Run cmd is issued.
* But what if we uncommented this code anyway, then if ever
* gSKI isn't wrapped around the kernel, this code will
* execute and create the links. KJC 4/05
*
* if (! thisAgent->top_goal)
* {
* create_top_goal(thisAgent);
* if (thisAgent->sysparams[TRACE_CONTEXT_DECISIONS_SYSPARAM])
* {
* print_string (thisAgent, "\n");
* print_lowest_slot_in_context_stack (thisAgent);
* }
* thisAgent->current_phase = INPUT_PHASE;
* thisAgent->d_cycle_count++;
* }
*/
switch (thisAgent->current_phase) {
print_phase (thisAgent, "\n--- Input Phase --- \n",0);
/* for Operand2 mode using the new decision cycle ordering,
* we need to do some initialization in the INPUT PHASE, which
* now comes first. e_cycles are also zeroed before the APPLY Phase.
*/
thisAgent->chunks_this_d_cycle = 0;
thisAgent->e_cycles_this_d_cycle = 0;
#ifndef NO_TIMING_STUFF /* REW: 28.07.96 */
thisAgent->timers_phase.start();
#endif
/* we check e_cycle_count because Soar 7 runs multiple input cycles per decision */
/* always true for Soar 8 */
if (thisAgent->e_cycles_this_d_cycle==0) {
reinterpret_cast<soar_call_data>(INPUT_PHASE) );
} /* end if e_cycles_this_d_cycle == 0 */
#ifdef REAL_TIME_BEHAVIOR /* RM Jones */
test_for_input_delay(thisAgent);
#endif
#ifdef ATTENTION_LAPSE /* RM Jones */
determine_lapsing(thisAgent);
#endif
if (thisAgent->input_cycle_flag == TRUE) { /* Soar 7 flag, but always true for Soar8 */
reinterpret_cast<soar_call_data>(INPUT_PHASE));
do_input_cycle(thisAgent);
thisAgent->run_phase_count++ ;
thisAgent->run_elaboration_count++ ; // All phases count as a run elaboration
reinterpret_cast<soar_call_data>(INPUT_PHASE) );
if (thisAgent->input_period)
thisAgent->input_cycle_flag = FALSE;
} /* END if (input_cycle_flag==TRUE) AGR REW1 this line and 1 previous line */
print_phase (thisAgent, "\n--- END Input Phase --- \n",1);
#ifndef NO_TIMING_STUFF /* REW: 28.07.96 */
thisAgent->timers_phase.stop();
thisAgent->timers_decision_cycle_phase[INPUT_PHASE].update(thisAgent->timers_phase);
#endif
break; /* END of INPUT PHASE */
case PROPOSE_PHASE: /* added in 8.6 to clarify Soar8 decision cycle */
#ifndef NO_TIMING_STUFF
thisAgent->timers_phase.start();
#endif
/* e_cycles_this_d_cycle will always be zero UNLESS we are
* running by ELABORATIONS.
* We only want to do the following if we've just finished INPUT and are
* starting PROPOSE. If this is the second elaboration for PROPOSE, then
* just do the while loop below. KJC June 05
*/
if (thisAgent->e_cycles_this_d_cycle < 1) {
print_phase(thisAgent, "\n--- Proposal Phase ---\n",0);
reinterpret_cast<soar_call_data>(PROPOSE_PHASE) );
// We need to generate this event here in case no elaborations fire...
// FIXME return the correct enum top_level_phase constant in soar_call_data?
/*(soar_call_data)((thisAgent->applyPhase == TRUE)? gSKI_K_APPLY_PHASE: gSKI_K_PROPOSAL_PHASE)*/
/* 'Prime the decision for a new round of production firings at the end of
* REW: 05.05.97 */ /* KJC 04.05 moved here from INPUT_PHASE for 8.6.0 */
thisAgent->FIRING_TYPE = IE_PRODS;
thisAgent->applyPhase = FALSE; /* KJC 04/05: do we still need this line? gSKI does*/
if (thisAgent->current_phase == DECISION_PHASE)
{ // no elaborations will fire this phase
thisAgent->run_elaboration_count++ ; // All phases count as a run elaboration
// FIXME return the correct enum top_level_phase constant in soar_call_data?
/*(soar_call_data)((thisAgent->applyPhase == TRUE)? gSKI_K_APPLY_PHASE: gSKI_K_PROPOSAL_PHASE)*/
}
}
/* max-elaborations are checked in determine_highest_active... and if they
* are reached, the current phase is set to DECISION. phase is also set
* to DECISION when PROPOSE is done.
*/
while (thisAgent->current_phase != DECISION_PHASE) {
if (thisAgent->e_cycles_this_d_cycle)
{ // only for 2nd cycle or higher. 1st cycle fired above
// FIXME return the correct enum top_level_phase constant in soar_call_data? /*(soar_call_data)((thisAgent->applyPhase == TRUE)? gSKI_K_APPLY_PHASE: gSKI_K_PROPOSAL_PHASE)*/
}
do_preference_phase(thisAgent);
if ( smem_enabled( thisAgent ) )
{
smem_go( thisAgent, true );
}
// allow epmem searches in proposal phase
// FIXME should turn this into a command line option
if ( epmem_enabled( thisAgent ) )
{
// epmem_go( thisAgent, false );
}
/* Update accounting. Moved here by KJC 04/05/05 */
thisAgent->e_cycle_count++;
thisAgent->e_cycles_this_d_cycle++;
thisAgent->run_elaboration_count++ ;
// FIXME return the correct enum top_level_phase constant in soar_call_data? /*(soar_call_data)((thisAgent->applyPhase == TRUE)? gSKI_K_APPLY_PHASE: gSKI_K_PROPOSAL_PHASE)*/
if (thisAgent->system_halted) break;
if (thisAgent->go_type == GO_ELABORATION) break;
}
/* If we've finished PROPOSE, then current_phase will be equal to DECISION
* otherwise, we're only stopping because we're running by ELABORATIONS, so
* don't do the end-of-phase updating in that case.
*/
if (thisAgent->current_phase == DECISION_PHASE) {
/* This is a HACK for Soar 8.6.0 beta release... KCoulter April 05
* We got here, because we should move to DECISION, so PROPOSE is done
* Set phase back to PROPOSE, do print_phase, callbacks, and then
* reset phase to DECISION
*/
if (thisAgent->sysparams[TRACE_PHASES_SYSPARAM]) {
print_phase(thisAgent, "\n--- END Proposal Phase ---\n",1);
}
thisAgent->run_phase_count++ ;
reinterpret_cast<soar_call_data>(PROPOSE_PHASE) );
}
#ifndef NO_TIMING_STUFF
thisAgent->timers_phase.stop();
thisAgent->timers_decision_cycle_phase[PROPOSE_PHASE].update(thisAgent->timers_phase);
#endif
break; /* END of Soar8 PROPOSE PHASE */
/* starting with 8.6.0, PREFERENCE_PHASE is only Soar 7 mode -- applyPhase not valid here */
/* needs to be updated for gSKI interface, and gSKI needs to accommodate Soar 7 */
/* JC ADDED: Tell gski about elaboration phase beginning */
// FIXME return the correct enum top_level_phase constant in soar_call_data? /*(soar_call_data)((thisAgent->applyPhase == TRUE)? gSKI_K_APPLY_PHASE: gSKI_K_PROPOSAL_PHASE)*/
#ifndef NO_TIMING_STUFF /* REW: 28.07.96 */
thisAgent->timers_phase.start();
#endif
reinterpret_cast<soar_call_data>(PREFERENCE_PHASE) );
do_preference_phase(thisAgent);
thisAgent->run_phase_count++ ;
thisAgent->run_elaboration_count++ ; // All phases count as a run elaboration
reinterpret_cast<soar_call_data>(PREFERENCE_PHASE) );
thisAgent->current_phase = WM_PHASE;
#ifndef NO_TIMING_STUFF /* REW: 28.07.96 */
thisAgent->timers_phase.stop();
#endif
/* tell gSKI PREF_PHASE ending...
*/
break; /* END of Soar7 PREFERENCE PHASE */
case WM_PHASE:
/* starting with 8.6.0, WM_PHASE is only Soar 7 mode; see PROPOSE and APPLY */
/* needs to be updated for gSKI interface, and gSKI needs to accommodate Soar 7 */
/* we need to tell gSKI WM Phase beginning... */
#ifndef NO_TIMING_STUFF /* REW: begin 28.07.96 */
thisAgent->timers_phase.start();
#endif
reinterpret_cast<soar_call_data>(WM_PHASE) );
thisAgent->run_phase_count++ ;
thisAgent->run_elaboration_count++ ; // All phases count as a run elaboration
reinterpret_cast<soar_call_data>(WM_PHASE) );
#ifndef NO_TIMING_STUFF /* REW: 28.07.96 */
thisAgent->timers_phase.stop();
thisAgent->timers_decision_cycle_phase[WM_PHASE].update(thisAgent->timers_phase);
#endif
// FIXME return the correct enum top_level_phase constant in soar_call_data? /*(soar_call_data)((thisAgent->applyPhase == TRUE)? gSKI_K_APPLY_PHASE: gSKI_K_PROPOSAL_PHASE)*/
break; /* END of Soar7 WM PHASE */
case APPLY_PHASE: /* added in 8.6 to clarify Soar8 decision cycle */
#ifndef NO_TIMING_STUFF
thisAgent->timers_phase.start();
#endif
/* e_cycle_count will always be zero UNLESS we are running by ELABORATIONS.
* We only want to do the following if we've just finished DECISION and are
* starting APPLY. If this is the second elaboration for APPLY, then
* just do the while loop below. KJC June 05
*/
if (thisAgent->e_cycles_this_d_cycle < 1) {
if (thisAgent->sysparams[TRACE_PHASES_SYSPARAM])
print_phase (thisAgent, "\n--- Application Phase ---\n",0);
reinterpret_cast<soar_call_data>(APPLY_PHASE) );
// We need to generate this event here in case no elaborations fire...
// FIXME return the correct enum top_level_phase constant in soar_call_data? /*(soar_call_data)((thisAgent->applyPhase == TRUE)? gSKI_K_APPLY_PHASE: gSKI_K_PROPOSAL_PHASE)*/
/* 'prime' the cycle for a new round of production firings
* in the APPLY (pref/wm) phase *//* KJC 04.05 moved here from end of DECISION */
thisAgent->FIRING_TYPE = PE_PRODS; /* might get reset in det_high_active_prod_level... */
thisAgent->applyPhase = TRUE; /* KJC 04/05: do we still need this line? gSKI does*/
if (thisAgent->current_phase == OUTPUT_PHASE)
{ // no elaborations will fire this phase
thisAgent->run_elaboration_count++ ; // All phases count as a run elaboration
// FIXME return the correct enum top_level_phase constant in soar_call_data? /*(soar_call_data)((thisAgent->applyPhase == TRUE)? gSKI_K_APPLY_PHASE: gSKI_K_PROPOSAL_PHASE)*/
}
}
/* max-elaborations are checked in determine_highest_active... and if they
* are reached, the current phase is set to OUTPUT. phase is also set
* to OUTPUT when APPLY is done.
*/
while (thisAgent->current_phase != OUTPUT_PHASE) {
/* JC ADDED: Tell gski about elaboration phase beginning */
if (thisAgent->e_cycles_this_d_cycle)
{ // only for 2nd cycle or higher. 1st cycle fired above
// FIXME return the correct enum top_level_phase constant in soar_call_data? /*(soar_call_data)((thisAgent->applyPhase == TRUE)? gSKI_K_APPLY_PHASE: gSKI_K_PROPOSAL_PHASE)*/
}
do_preference_phase(thisAgent);
if ( smem_enabled( thisAgent ) )
{
smem_go( thisAgent, true );
}
/* Update accounting. Moved here by KJC 04/05/05 */
thisAgent->e_cycle_count++;
thisAgent->e_cycles_this_d_cycle++;
thisAgent->run_elaboration_count++ ;
if (thisAgent->FIRING_TYPE == PE_PRODS) {
thisAgent->pe_cycle_count++;
thisAgent->pe_cycles_this_d_cycle++;
}
// FIXME return the correct enum top_level_phase constant in soar_call_data? /*(soar_call_data)((thisAgent->applyPhase == TRUE)? gSKI_K_APPLY_PHASE: gSKI_K_PROPOSAL_PHASE)*/
if (thisAgent->system_halted) break;
if (thisAgent->go_type == GO_ELABORATION) break;
}
/* If we've finished APPLY, then current_phase will be equal to OUTPUT
* otherwise, we're only stopping because we're running by ELABORATIONS, so
* don't do the end-of-phase updating in that case.
*/
if (thisAgent->current_phase == OUTPUT_PHASE) {
/* This is a HACK for Soar 8.6.0 beta release... KCoulter April 05
* We got here, because we should move to OUTPUT, so APPLY is done
* Set phase back to APPLY, do print_phase, callbacks and reset phase to OUTPUT
*/
thisAgent->current_phase = APPLY_PHASE;
if (thisAgent->sysparams[TRACE_PHASES_SYSPARAM]) {
print_phase(thisAgent, "\n--- END Application Phase ---\n",1);
}
thisAgent->run_phase_count++ ;
reinterpret_cast<soar_call_data>(APPLY_PHASE) );
}
#ifndef NO_TIMING_STUFF
thisAgent->timers_phase.stop();
thisAgent->timers_decision_cycle_phase[APPLY_PHASE].update(thisAgent->timers_phase);
#endif
break; /* END of Soar8 APPLY PHASE */
print_phase (thisAgent, "\n--- Output Phase ---\n",0);
#ifndef NO_TIMING_STUFF /* REW: 28.07.96 */
thisAgent->timers_phase.start();
#endif
reinterpret_cast<soar_call_data>(OUTPUT_PHASE) );
do_output_cycle(thisAgent);
if ( smem_enabled( thisAgent ) )
{
smem_go( thisAgent, false );
}
assert( thisAgent->wma_d_cycle_count == thisAgent->d_cycle_count );
// update histories only first, allows:
// - epmem retrieval cues to be biased by activation
// - epmem encoding to capture wmes that may be forgotten shortly
if ( wma_enabled( thisAgent ) )
{
wma_go( thisAgent, wma_histories );
}
if ( epmem_enabled( thisAgent ) && ( thisAgent->epmem_params->phase->get_value() == epmem_param_container::phase_output ) )
{
// since we consolidated wma histories from this decision,
// we need to pretend it's the next time step in case
// an epmem retrieval wants to know current activation value
thisAgent->wma_d_cycle_count++;
{
epmem_go( thisAgent );
}
thisAgent->wma_d_cycle_count--;
}
// now both update histories and forget, allows
// - epmem retrieval to affect history
// - epmem encoding to capture wmes that may be forgotten shortly
if ( wma_enabled( thisAgent ) )
{
wma_go( thisAgent, wma_histories );
wma_go( thisAgent, wma_forgetting );
}
assert( thisAgent->wma_d_cycle_count == thisAgent->d_cycle_count );
// RL apoptosis
{
if ( rl_apoptosis != rl_param_container::apoptosis_none )
{
thisAgent->rl_prods->forget();
thisAgent->rl_prods->time_forward();
for ( rl_production_memory::object_set::iterator p=thisAgent->rl_prods->forgotten_begin(); p!=thisAgent->rl_prods->forgotten_end(); p++ )
{
// conditions:
// - no matched instantiations AND
// - if RL...
// - no update count
// - not in some state's prev_op_rl_rules list
if ( ( (*p)->instantiations == NIL ) && ( !(*p)->rl_rule || ( ( static_cast<int64_t>( (*p)->rl_update_count ) == 0 ) && ( (*p)->rl_ref_count == 0 ) ) ) )
{
excise_production( thisAgent, const_cast< production* >( *p ), FALSE );
}
}
}
}
// Count the outputs the agent generates (or times reaching max-nil-outputs without sending output)
if (thisAgent->output_link_changed || ((++(thisAgent->run_last_output_count)) >= static_cast<uint64_t>(thisAgent->sysparams[MAX_NIL_OUTPUT_CYCLES_SYSPARAM])))
{
thisAgent->run_last_output_count = 0 ;
}
thisAgent->run_phase_count++ ;
thisAgent->run_elaboration_count++ ; // All phases count as a run elaboration
reinterpret_cast<soar_call_data>(OUTPUT_PHASE) );
/* REW: begin 09.15.96 */
// JRV: Get rid of the cached XML after every decision but before the after-decision-phase callback
xml_invoke_callback( thisAgent ); // invokes XML_GENERATION_CALLBACK, clears XML state
/* KJC June 05: moved here from DECISION Phase */
reinterpret_cast<soar_call_data>(OUTPUT_PHASE) );
#ifndef NO_TIMING_STUFF /* timers stopped KJC 10-04-98 */
thisAgent->timers_phase.stop();
thisAgent->timers_decision_cycle_phase[OUTPUT_PHASE].update(thisAgent->timers_phase);
#endif
// Update per-cycle statistics
{
uint64_t dc_time_usec = 0;
#ifndef NO_TIMING_STUFF
uint64_t derived_kernel_time_usec = get_derived_kernel_time_usec(thisAgent);
dc_time_usec = derived_kernel_time_usec - thisAgent->last_derived_kernel_time_usec;
if (thisAgent->max_dc_time_usec < dc_time_usec) {
thisAgent->max_dc_time_usec = dc_time_usec;
thisAgent->max_dc_time_cycle = thisAgent->d_cycle_count;
}
if (dc_time_usec >= static_cast<uint64_t>(thisAgent->sysparams[DECISION_CYCLE_MAX_USEC_INTERRUPT])) {
thisAgent->stop_soar++;
thisAgent->reason_for_stopping = "decision cycle time greater than interrupt threshold";
}
}
thisAgent->last_derived_kernel_time_usec = derived_kernel_time_usec;
double total_epmem_time = thisAgent->epmem_timers->total->value();
if (thisAgent->total_dc_epmem_time_sec >= 0)
{
double delta_epmem_time = total_epmem_time - thisAgent->total_dc_epmem_time_sec;
if (thisAgent->max_dc_epmem_time_sec < delta_epmem_time) {
thisAgent->max_dc_epmem_time_sec = delta_epmem_time;
thisAgent->max_dc_epmem_time_cycle = thisAgent->d_cycle_count;
}
}
thisAgent->total_dc_epmem_time_sec = total_epmem_time;
double total_smem_time = thisAgent->smem_timers->total->value();
if (thisAgent->total_dc_smem_time_sec >= 0)
{
double delta_smem_time = total_smem_time - thisAgent->total_dc_smem_time_sec;
if (thisAgent->max_dc_smem_time_sec < delta_smem_time) {
thisAgent->max_dc_smem_time_sec = delta_smem_time;
thisAgent->max_dc_smem_time_cycle = thisAgent->d_cycle_count;
}
}
thisAgent->total_dc_smem_time_sec = total_smem_time;
#endif // NO_TIMING_STUFF
uint64_t dc_wm_changes = thisAgent->wme_addition_count - thisAgent->start_dc_wme_addition_count;
dc_wm_changes += thisAgent->wme_removal_count - thisAgent->start_dc_wme_removal_count;
if (thisAgent->max_dc_wm_changes_value < dc_wm_changes) {
thisAgent->max_dc_wm_changes_value = dc_wm_changes;
thisAgent->max_dc_wm_changes_cycle = thisAgent->d_cycle_count;
}
uint64_t dc_firing_counts = thisAgent->production_firing_count - thisAgent->start_dc_production_firing_count;
if (thisAgent->max_dc_production_firing_count_value < dc_firing_counts) {
thisAgent->max_dc_production_firing_count_value = dc_firing_counts;
}
// Commit per-cycle stats to db
if (thisAgent->dc_stat_tracking) {
stats_db_store(thisAgent, dc_time_usec, dc_wm_changes, dc_firing_counts);
}
}
print_phase (thisAgent, "\n--- END Output Phase ---\n",1);
thisAgent->current_phase = INPUT_PHASE;
thisAgent->d_cycle_count++;
thisAgent->wma_d_cycle_count++;
/* REW: end 09.15.96 */
break;
/* not yet cleaned up for 8.6.0 release */
print_phase (thisAgent, "\n--- Decision Phase ---\n",0);
#ifndef NO_TIMING_STUFF /* REW: 28.07.96 */
thisAgent->timers_phase.start();
#endif
thisAgent->decision_phases_count++; /* counts decisions, not cycles, for more accurate stats */
/* AGR REW1 begin */
if (!thisAgent->input_period)
thisAgent->input_cycle_flag = TRUE;
else if ((thisAgent->d_cycle_count % thisAgent->input_period) == 0)
thisAgent->input_cycle_flag = TRUE;
/* AGR REW1 end */
reinterpret_cast<soar_call_data>(DECISION_PHASE) );
do_decision_phase(thisAgent);
thisAgent->run_phase_count++ ;
thisAgent->run_elaboration_count++ ; // All phases count as a run elaboration
reinterpret_cast<soar_call_data>(DECISION_PHASE) );
// #ifdef USE_TCL
print_string (thisAgent, "\n");
// #else
//if(thisAgent->printer_output_column != 1)
// print_string ("\n");
// #endif /* USE_TCL */
}
/* reset elaboration counter */
thisAgent->e_cycles_this_d_cycle = 0;
thisAgent->pe_cycles_this_d_cycle = 0;
/* REW: begin 09.15.96 */
#ifdef AGRESSIVE_ONC
/* test for Operator NC, if TRUE, generate substate and go to OUTPUT */
if ((thisAgent->ms_o_assertions == NIL) &&
(thisAgent->bottom_goal->id.operator_slot->wmes != NIL))
{
soar_invoke_callbacks(thisAgent, thisAgent,
static_cast<soar_call_data>(thisAgent->current_phase) );
do_decision_phase(thisAgent);
static_cast<soar_call_data>(thisAgent->current_phase) );
// #ifdef USE_TCL
print_string (thisAgent, "\n");
// #else
// if(thisAgent->printer_output_column != 1) print_string ("\n");
// #endif /* USE_TCL */
}
if (thisAgent->sysparams[TRACE_PHASES_SYSPARAM])
print_phase (thisAgent, "\n--- END Decision Phase ---\n",1);
/* set phase to OUTPUT */
/* REW: begin 28.07.96 */
#ifndef NO_TIMING_STUFF
thisAgent->timers_phase.stop();
#endif
/* REW: end 28.07.96 */
break;
} else
#endif //AGRESSIVE_ONC
epmem_go( thisAgent );
{
if (thisAgent->sysparams[TRACE_PHASES_SYSPARAM])
print_phase (thisAgent, "\n--- END Decision Phase ---\n",1);
/* printf("\nSetting next phase to APPLY following a decision...."); */
thisAgent->applyPhase = TRUE;
thisAgent->FIRING_TYPE = PE_PRODS;
thisAgent->current_phase = APPLY_PHASE;
}
/* REW: begin 28.07.96 */
#ifndef NO_TIMING_STUFF
thisAgent->timers_phase.stop();
#endif
/* REW: end 28.07.96 */
break; /* end DECISION phase */
default: // 2/24/05: added default case to quell gcc compile warning
assert(false && "Invalid phase enumeration value!");
break;
} /* end switch stmt for current_phase */
/* --- update WM size statistics --- */
if (thisAgent->num_wmes_in_rete > thisAgent->max_wm_size)
thisAgent->max_wm_size = thisAgent->num_wmes_in_rete;
thisAgent->cumulative_wm_size += thisAgent->num_wmes_in_rete;
if (thisAgent->system_halted) {
thisAgent->stop_soar = TRUE;
thisAgent->reason_for_stopping = "System halted.";
reinterpret_cast<soar_call_data>(thisAgent->current_phase) );
// To model episodic task, after halt, perform RL update with next-state value 0
if ( rl_enabled( thisAgent ) )
{
for ( Symbol *g = thisAgent->bottom_goal; g; g = g->id.higher_goal)
{
rl_perform_update( thisAgent, 0, true, g );
}
}
}
if (thisAgent->stop_soar) {
if (thisAgent->reason_for_stopping) {
print(thisAgent, "\n%s\n", thisAgent->reason_for_stopping);
}
}
}
void init_agent_memory ( agent thisAgent)

Definition at line 1481 of file init_soar.cpp.

References add_input_wme(), create_top_goal(), agent_struct::current_phase, agent_struct::d_cycle_count, do_input_cycle(), do_output_cycle(), agent_struct::epmem_timers, get_new_io_identifier(), agent_struct::input_link_symbol, INPUT_PHASE, agent_struct::io_header, agent_struct::io_header_input, agent_struct::io_header_link, agent_struct::io_header_output, agent_struct::io_symbol, agent_struct::output_link_symbol, agent_struct::prev_top_state, print_lowest_slot_in_context_stack(), print_string(), soar_module::timer_container::reset(), reset_max_stats(), reset_timers(), agent_struct::smem_timers, agent_struct::sysparams, agent_struct::top_goal, agent_struct::top_state, TRACE_CONTEXT_DECISIONS_SYSPARAM, agent_struct::wma_d_cycle_count, and agent_struct::wma_timers.

Referenced by init_soar_agent(), and load_rete_net().

{
/* The following code was taken from the do_one_top_level_phase function
near the top of this file */
// If there is already a top goal this function should probably not be called
assert( thisAgent->top_goal == 0 &&
"There should be no top goal when init_agent_memory is called!");
if ( thisAgent->top_goal) return;
thisAgent->io_header = get_new_io_identifier (thisAgent, 'I');
thisAgent->io_header_input = get_new_io_identifier (thisAgent, 'I');
thisAgent->io_header_output = get_new_io_identifier (thisAgent, 'I');
create_top_goal(thisAgent);
{
print_string (thisAgent, "\n");
}
thisAgent->current_phase = INPUT_PHASE;
thisAgent->d_cycle_count++;
thisAgent->wma_d_cycle_count++;
/* The following code was taken from the do_input_cycle function of io.cpp */
// Creating the io_header and adding the top state io header wme
thisAgent->io_header_link = add_input_wme (thisAgent,
thisAgent->top_state,
thisAgent->io_symbol,
thisAgent->io_header);
// Creating the input and output header symbols and wmes
// RPM 9/06 changed to use thisAgent->input/output_link_symbol
// Note we don't have to save these wmes for later release since their parent
// is already being saved (above), and when we release it they will automatically be released
add_input_wme (thisAgent, thisAgent->io_header,
thisAgent->input_link_symbol,
thisAgent->io_header_input);
add_input_wme (thisAgent, thisAgent->io_header,
thisAgent->output_link_symbol,
thisAgent->io_header_output);
// KJC & RPM 10/06
// A lot of stuff isn't initialized properly until the input and output cycles are run the first time.
// Because of this, SW had to put in a hack to work around changes made to the output-link in the first
// dc not being visible. (see comment near end of update_for_top_state_wme_addition). This change added
// an item to the associated_output_links list.
// But the ol->ids_in_tc is still not initialized until the first output phase, so if we exit before that,
// remove_output_link_tc_info doesn't see it and doesn't clean up the associated_output_links list.
// If we do run an output phase, though, the same item is added to the associated_output_links list twice.
// ol->ids_in_tc gets initialized, so remove_output_link_tc_info -- but it only cleans up the first copy
// of the item.
// All of these problems come back to things not being initialized properly, so we run the input and output
// phases here to force proper initialization (and have commented out SW's changes to
// update_for_top_state_wme_addition). This will cause somecallbacks to be triggered, but we don't think
// this is a problem for two reasons:
// 1) these events are currently not exposed through SML, so no clients will see them
// 2) even if these events were exposed, they are being fired during agent creation. Since the agent
// hasn't been created yet, no client could have registered for the events anyway.
// Note that this change replaces the do_buffered_wm_and_ownership_changes call which attempted to do some
// initialization (including triggering SW's changes).
do_input_cycle(thisAgent);
do_output_cycle(thisAgent);
//do_buffered_wm_and_ownership_changes(thisAgent);
/* executing the IO cycles above, increments the timers, so reset */
reset_timers(thisAgent);
reset_max_stats(thisAgent);
thisAgent->wma_timers->reset();
thisAgent->epmem_timers->reset();
thisAgent->smem_timers->reset();
// This is an important part of the state of the agent for io purposes
// (see io.cpp for details)
thisAgent->prev_top_state = thisAgent->top_state;
}
bool reinitialize_soar ( agent thisAgent)

Definition at line 382 of file init_soar.cpp.

References wma_param_container::activation, agent_struct::active_level, AFTER_INIT_SOAR_CALLBACK, rl_param_container::apoptosis, rl_param_container::apoptosis_none, BEFORE_INIT_SOAR_CALLBACK, clear_goal_stack(), agent_struct::current_phase, agent_struct::did_PE, do_preference_phase(), agent_struct::dyn_counters, agent_struct::epmem_stats, FALSE, agent_struct::FIRING_TYPE, soar_module::constant_param< T >::get_value(), GO_DECISION, agent_struct::go_number, agent_struct::go_type, IE_PRODS, agent_struct::input_cycle_flag, INPUT_PHASE, NONE_WME_TRACE, soar_module::off, soar_module::ok, soar_module::on, agent_struct::reason_for_stopping, soar_module::stat_container::reset(), reset_explain(), reset_id_counters(), reset_statistics(), reset_wme_timetags(), agent_struct::rl_params, agent_struct::rl_stats, set_sysparam(), wma_activation_param::set_value(), rl_apoptosis_param::set_value(), agent_struct::smem_stats, soar_invoke_callbacks(), stats_close(), agent_struct::stats_db, agent_struct::stop_soar, agent_struct::substate_break_level, agent_struct::sysparams, agent_struct::system_halted, TRACE_CONTEXT_DECISIONS_SYSPARAM, TRACE_FIRINGS_OF_DEFAULT_PRODS_SYSPARAM, TRACE_FIRINGS_OF_USER_PRODS_SYSPARAM, TRACE_FIRINGS_PREFERENCES_SYSPARAM, TRACE_FIRINGS_WME_TRACE_TYPE_SYSPARAM, TRACE_GDS_SYSPARAM, TRACE_PHASES_SYSPARAM, TRACE_WM_CHANGES_SYSPARAM, TRUE, wma_enabled(), agent_struct::wma_params, agent_struct::wma_stats, and xml_reset().

Referenced by load_rete_net().

{
/* kjh (CUSP-B4) begin */
int64_t cur_TRACE_CONTEXT_DECISIONS_SYSPARAM;
int64_t cur_TRACE_PHASES_SYSPARAM;
int64_t cur_TRACE_FIRINGS_OF_DEFAULT_PRODS_SYSPARAM;
int64_t cur_TRACE_FIRINGS_OF_USER_PRODS_SYSPARAM;
int64_t cur_TRACE_FIRINGS_WME_TRACE_TYPE_SYSPARAM;
int64_t cur_TRACE_FIRINGS_PREFERENCES_SYSPARAM;
int64_t cur_TRACE_WM_CHANGES_SYSPARAM;
int64_t cur_TRACE_GDS_SYSPARAM;
/* kjh (CUSP-B4) end */
thisAgent->did_PE = FALSE; /* RCHONG: 10.11 */
0);
/* kjh (CUSP-B4) begin */
/* Stash trace state: */
cur_TRACE_CONTEXT_DECISIONS_SYSPARAM = thisAgent->sysparams[TRACE_CONTEXT_DECISIONS_SYSPARAM];
cur_TRACE_PHASES_SYSPARAM = thisAgent->sysparams[TRACE_PHASES_SYSPARAM];
cur_TRACE_FIRINGS_OF_DEFAULT_PRODS_SYSPARAM = thisAgent->sysparams[TRACE_FIRINGS_OF_DEFAULT_PRODS_SYSPARAM];
cur_TRACE_FIRINGS_OF_USER_PRODS_SYSPARAM = thisAgent->sysparams[TRACE_FIRINGS_OF_USER_PRODS_SYSPARAM];
cur_TRACE_FIRINGS_WME_TRACE_TYPE_SYSPARAM = thisAgent->sysparams[TRACE_FIRINGS_WME_TRACE_TYPE_SYSPARAM];
cur_TRACE_FIRINGS_PREFERENCES_SYSPARAM = thisAgent->sysparams[TRACE_FIRINGS_PREFERENCES_SYSPARAM];
cur_TRACE_WM_CHANGES_SYSPARAM = thisAgent->sysparams[TRACE_WM_CHANGES_SYSPARAM];
cur_TRACE_GDS_SYSPARAM = thisAgent->sysparams[TRACE_GDS_SYSPARAM];
/* Temporarily disable tracing: */
/* kjh (CUSP-B4) end */
bool wma_was_enabled = wma_enabled( thisAgent );
clear_goal_stack (thisAgent);
if ( wma_was_enabled )
{
}
thisAgent->rl_params->apoptosis->set_value( rl_apoptosis );
thisAgent->rl_stats->reset();
thisAgent->wma_stats->reset();
thisAgent->epmem_stats->reset();
thisAgent->smem_stats->reset();
thisAgent->dyn_counters->clear();
thisAgent->active_level = 0; /* Signal that everything should be retracted */
thisAgent->FIRING_TYPE = IE_PRODS;
do_preference_phase (thisAgent); /* allow all i-instantiations to retract */
reset_explain(thisAgent);
bool ok = reset_id_counters (thisAgent);
reset_wme_timetags (thisAgent);
reset_statistics (thisAgent);
// JRV: For XML generation
xml_reset( thisAgent );
/* RDF 01282003: Reinitializing the various halt and stop flags */
thisAgent->system_halted = FALSE;
thisAgent->stop_soar = FALSE; // voigtjr: this line doesn't exist in other kernel
thisAgent->reason_for_stopping = 0;
thisAgent->substate_break_level = 0;
thisAgent->go_number = 1;
thisAgent->go_type = GO_DECISION;
/* kjh (CUSP-B4) begin */
/* Restore trace state: */
set_sysparam(thisAgent, TRACE_CONTEXT_DECISIONS_SYSPARAM, cur_TRACE_CONTEXT_DECISIONS_SYSPARAM);
set_sysparam(thisAgent, TRACE_PHASES_SYSPARAM, cur_TRACE_PHASES_SYSPARAM);
set_sysparam(thisAgent, TRACE_FIRINGS_OF_DEFAULT_PRODS_SYSPARAM, cur_TRACE_FIRINGS_OF_DEFAULT_PRODS_SYSPARAM);
set_sysparam(thisAgent, TRACE_FIRINGS_OF_USER_PRODS_SYSPARAM, cur_TRACE_FIRINGS_OF_USER_PRODS_SYSPARAM);
set_sysparam(thisAgent, TRACE_FIRINGS_WME_TRACE_TYPE_SYSPARAM, cur_TRACE_FIRINGS_WME_TRACE_TYPE_SYSPARAM);
set_sysparam(thisAgent, TRACE_FIRINGS_PREFERENCES_SYSPARAM, cur_TRACE_FIRINGS_PREFERENCES_SYSPARAM);
set_sysparam(thisAgent, TRACE_WM_CHANGES_SYSPARAM, cur_TRACE_WM_CHANGES_SYSPARAM);
set_sysparam(thisAgent, TRACE_GDS_SYSPARAM, cur_TRACE_GDS_SYSPARAM);
/* kjh (CUSP-B4) end */
0);
thisAgent->input_cycle_flag = TRUE; /* reinitialize flag AGR REW1 */
thisAgent->current_phase = INPUT_PHASE; /* moved here June 05 from loop below. KJC */
/* REW: begin 09.15.96 */
thisAgent->FIRING_TYPE = IE_PRODS; /* KJC 10.05.98 was PE */
thisAgent->did_PE = FALSE;
/* REW: end 09.15.96 */
// reset old stats information
stats_close(thisAgent);
delete thisAgent->stats_db;
// voigtjr: WARN_IF_TIMERS_REPORT_ZERO block goes here in other kernel
return ok ;
}
void remove_pwatch ( agent thisAgent,
struct production_struct prod 
)
void reset_max_stats ( agent thisAgent)
void reset_statistics ( agent thisAgent)

Definition at line 290 of file init_soar.cpp.

References agent_struct::chunks_this_d_cycle, agent_struct::cumulative_wm_size, agent_struct::d_cycle_count, agent_struct::d_cycle_last_output, agent_struct::decision_phases_count, agent_struct::e_cycle_count, agent_struct::e_cycles_this_d_cycle, agent_struct::epmem_timers, agent_struct::inner_e_cycle_count, agent_struct::max_wm_size, agent_struct::num_wm_sizes_accumulated, agent_struct::pe_cycle_count, agent_struct::pe_cycles_this_d_cycle, agent_struct::production_firing_count, soar_module::timer_container::reset(), reset_max_stats(), reset_production_firing_counts(), reset_timers(), agent_struct::run_elaboration_count, agent_struct::run_generated_output_count, agent_struct::run_last_output_count, agent_struct::run_phase_count, agent_struct::smem_timers, agent_struct::start_dc_production_firing_count, agent_struct::start_dc_wme_addition_count, agent_struct::start_dc_wme_removal_count, agent_struct::wma_d_cycle_count, agent_struct::wma_timers, agent_struct::wme_addition_count, and agent_struct::wme_removal_count.

Referenced by init_soar_agent(), and reinitialize_soar().

{
thisAgent->d_cycle_count = 0;
thisAgent->decision_phases_count = 0;
thisAgent->e_cycle_count = 0;
thisAgent->e_cycles_this_d_cycle = 0;
thisAgent->chunks_this_d_cycle = 0;
thisAgent->production_firing_count = 0;
thisAgent->wme_addition_count = 0;
thisAgent->wme_removal_count = 0;
thisAgent->max_wm_size = 0;
thisAgent->cumulative_wm_size = 0.0;
thisAgent->num_wm_sizes_accumulated = 0;
/* REW: begin 09.15.96 */
thisAgent->pe_cycle_count = 0;
thisAgent->pe_cycles_this_d_cycle = 0;
/* REW: end 09.15.96 */
thisAgent->d_cycle_last_output = 0; // KJC 11/17/05
thisAgent->run_phase_count = 0 ;
thisAgent->run_elaboration_count = 0 ;
thisAgent->run_last_output_count = 0 ;
thisAgent->run_generated_output_count = 0 ;
thisAgent->inner_e_cycle_count = 0;
reset_timers(thisAgent);
reset_max_stats(thisAgent);
thisAgent->wma_timers->reset();
thisAgent->epmem_timers->reset();
thisAgent->smem_timers->reset();
thisAgent->wma_d_cycle_count = 0;
}
void reset_timers ( agent thisAgent)

Definition at line 333 of file init_soar.cpp.

References agent_struct::last_derived_kernel_time_usec, NUM_PHASE_TYPES, agent_struct::sysparams, agent_struct::timers_cpu, agent_struct::timers_decision_cycle_phase, TIMERS_ENABLED, agent_struct::timers_input_function_cpu_time, agent_struct::timers_kernel, agent_struct::timers_monitors_cpu_time, agent_struct::timers_output_function_cpu_time, agent_struct::timers_phase, agent_struct::timers_total_cpu_time, and agent_struct::timers_total_kernel_time.

Referenced by create_soar_agent(), init_agent_memory(), and reset_statistics().

{
#ifndef NO_TIMING_STUFF
thisAgent->timers_cpu.reset();
thisAgent->timers_kernel.reset();
thisAgent->timers_phase.reset();
#ifdef DETAILED_TIMER_STATS
thisAgent->timers_gds.set_enabled(&(thisAgent->sysparams[TIMERS_ENABLED]));
thisAgent->timers_gds.reset();
#endif
thisAgent->timers_total_cpu_time.reset();
thisAgent->timers_total_kernel_time.reset();
thisAgent->timers_input_function_cpu_time.reset();
thisAgent->timers_output_function_cpu_time.reset();
for (int i=0;i < NUM_PHASE_TYPES; i++) {
thisAgent->timers_decision_cycle_phase[i].reset();
thisAgent->timers_monitors_cpu_time[i].reset();
#ifdef DETAILED_TIMER_STATS
thisAgent->timers_ownership_cpu_time[i].reset();
thisAgent->timers_chunking_cpu_time[i].reset();
thisAgent->timers_match_cpu_time[i].reset();
thisAgent->timers_gds_cpu_time[i].reset();
#endif
}
#endif // NO_TIMING_STUFF
}
void run_for_n_decision_cycles ( agent thisAgent,
int64_t  n 
)

Definition at line 1354 of file init_soar.cpp.

References agent_struct::d_cycle_count, do_one_top_level_phase(), FALSE, agent_struct::reason_for_stopping, run_forever(), agent_struct::stop_soar, agent_struct::timers_cpu, agent_struct::timers_kernel, agent_struct::timers_total_cpu_time, and agent_struct::timers_total_kernel_time.

{
int64_t d_cycles_at_start;
if (n == -1) { run_forever(thisAgent); return; }
if (n < -1) return;
#ifndef NO_TIMING_STUFF
thisAgent->timers_cpu.start();
thisAgent->timers_kernel.start();
#endif
thisAgent->stop_soar = FALSE;
thisAgent->reason_for_stopping = 0;
d_cycles_at_start = thisAgent->d_cycle_count;
/* need next line or runs only the input phase for "d 1" after init-soar */
if (d_cycles_at_start == 0)
d_cycles_at_start++;
while (!thisAgent->stop_soar) {
if (n == static_cast<int64_t>(thisAgent->d_cycle_count-d_cycles_at_start)) break;
}
#ifndef NO_TIMING_STUFF
thisAgent->timers_kernel.stop();
thisAgent->timers_cpu.stop();
thisAgent->timers_total_kernel_time.update(thisAgent->timers_kernel);
thisAgent->timers_total_cpu_time.update(thisAgent->timers_cpu);
#endif
}
void run_for_n_elaboration_cycles ( agent thisAgent,
int64_t  n 
)

Definition at line 1285 of file init_soar.cpp.

References agent_struct::d_cycle_count, do_one_top_level_phase(), agent_struct::e_cycle_count, FALSE, GO_ELABORATION, GO_PHASE, agent_struct::go_type, agent_struct::reason_for_stopping, run_forever(), agent_struct::stop_soar, agent_struct::timers_cpu, agent_struct::timers_kernel, agent_struct::timers_total_cpu_time, and agent_struct::timers_total_kernel_time.

{
int64_t e_cycles_at_start, d_cycles_at_start, elapsed_cycles = 0;
go_type_enum save_go_type = GO_PHASE;
if (n == -1) { run_forever(thisAgent); return; }
if (n < -1) return;
#ifndef NO_TIMING_STUFF
thisAgent->timers_cpu.start();
thisAgent->timers_kernel.start();
#endif
thisAgent->stop_soar = FALSE;
thisAgent->reason_for_stopping = 0;
e_cycles_at_start = thisAgent->e_cycle_count;
d_cycles_at_start = thisAgent->d_cycle_count;
elapsed_cycles = -1;
save_go_type = thisAgent->go_type;
thisAgent->go_type = GO_ELABORATION;
/* need next line or runs only the input phase for "d 1" after init-soar */
if (d_cycles_at_start == 0) d_cycles_at_start++;
while (!thisAgent->stop_soar) {
elapsed_cycles++;
if (n==elapsed_cycles) break;
}
thisAgent->go_type = save_go_type;
#ifndef NO_TIMING_STUFF
thisAgent->timers_kernel.stop();
thisAgent->timers_cpu.stop();
thisAgent->timers_total_kernel_time.update(thisAgent->timers_kernel);
thisAgent->timers_total_cpu_time.update(thisAgent->timers_cpu);
#endif
}
void run_for_n_modifications_of_output ( agent thisAgent,
int64_t  n 
)

Definition at line 1319 of file init_soar.cpp.

References agent_struct::current_phase, do_one_top_level_phase(), FALSE, MAX_NIL_OUTPUT_CYCLES_SYSPARAM, agent_struct::output_link_changed, OUTPUT_PHASE, agent_struct::reason_for_stopping, run_forever(), agent_struct::stop_soar, agent_struct::sysparams, agent_struct::timers_cpu, agent_struct::timers_kernel, agent_struct::timers_total_cpu_time, and agent_struct::timers_total_kernel_time.

{
Bool was_output_phase;
int64_t count = 0;
if (n == -1) { run_forever(thisAgent); return; }
if (n < -1) return;
#ifndef NO_TIMING_STUFF
thisAgent->timers_cpu.start();
thisAgent->timers_kernel.start();
#endif
thisAgent->stop_soar = FALSE;
thisAgent->reason_for_stopping = 0;
while (!thisAgent->stop_soar && n) {
was_output_phase = (thisAgent->current_phase==OUTPUT_PHASE);
if (was_output_phase) {
if (thisAgent->output_link_changed) {
n--;
} else {
count++;
} }
if (count >= thisAgent->sysparams[MAX_NIL_OUTPUT_CYCLES_SYSPARAM]) {
break;
//thisAgent->stop_soar = TRUE;
//thisAgent->reason_for_stopping = "exceeded max_nil_output_cycles with no output";
}
}
#ifndef NO_TIMING_STUFF
thisAgent->timers_kernel.stop();
thisAgent->timers_cpu.stop();
thisAgent->timers_total_kernel_time.update(thisAgent->timers_kernel);
thisAgent->timers_total_cpu_time.update(thisAgent->timers_cpu);
#endif
}
void run_for_n_phases ( agent thisAgent,
int64_t  n 
)

Definition at line 1264 of file init_soar.cpp.

References do_one_top_level_phase(), FALSE, agent_struct::reason_for_stopping, run_forever(), agent_struct::stop_soar, agent_struct::timers_cpu, agent_struct::timers_kernel, agent_struct::timers_total_cpu_time, and agent_struct::timers_total_kernel_time.

{
if (n == -1) { run_forever(thisAgent); return; }
if (n < -1) return;
#ifndef NO_TIMING_STUFF
thisAgent->timers_cpu.start();
thisAgent->timers_kernel.start();
#endif
thisAgent->stop_soar = FALSE;
thisAgent->reason_for_stopping = "";
while (!thisAgent->stop_soar && n) {
n--;
}
#ifndef NO_TIMING_STUFF
thisAgent->timers_kernel.stop();
thisAgent->timers_cpu.stop();
thisAgent->timers_total_kernel_time.update(thisAgent->timers_kernel);
thisAgent->timers_total_cpu_time.update(thisAgent->timers_cpu);
#endif
}
void run_for_n_selections_of_slot ( agent ,
int64_t  n,
Symbol attr_of_slot 
)

Definition at line 1387 of file init_soar.cpp.

References attr_of_slot_just_decided(), agent_struct::current_phase, DECISION_PHASE, do_one_top_level_phase(), FALSE, agent_struct::reason_for_stopping, run_forever(), agent_struct::stop_soar, agent_struct::timers_cpu, agent_struct::timers_kernel, agent_struct::timers_total_cpu_time, and agent_struct::timers_total_kernel_time.

{
int64_t count;
Bool was_decision_phase;
if (n == -1) { run_forever(thisAgent); return; }
if (n < -1) return;
#ifndef NO_TIMING_STUFF
thisAgent->timers_cpu.start();
thisAgent->timers_kernel.start();
#endif
thisAgent->stop_soar = FALSE;
thisAgent->reason_for_stopping = 0;
count = 0;
while (!thisAgent->stop_soar && (count < n)) {
was_decision_phase = (thisAgent->current_phase==DECISION_PHASE);
if (was_decision_phase)
if (attr_of_slot_just_decided(thisAgent)==attr_of_slot) count++;
}
#ifndef NO_TIMING_STUFF
thisAgent->timers_kernel.stop();
thisAgent->timers_cpu.stop();
thisAgent->timers_total_kernel_time.update(thisAgent->timers_kernel);
thisAgent->timers_total_cpu_time.update(thisAgent->timers_cpu);
#endif
}
void run_for_n_selections_of_slot_at_level ( agent thisAgent,
int64_t  n,
Symbol attr_of_slot,
goal_stack_level  level 
)

Definition at line 1414 of file init_soar.cpp.

References attr_of_slot_just_decided(), agent_struct::bottom_goal, agent_struct::current_phase, DECISION_PHASE, do_one_top_level_phase(), FALSE, symbol_union::id, identifier_struct::level, agent_struct::reason_for_stopping, run_forever(), agent_struct::stop_soar, agent_struct::timers_cpu, agent_struct::timers_kernel, agent_struct::timers_total_cpu_time, and agent_struct::timers_total_kernel_time.

{
int64_t count;
Bool was_decision_phase;
if (n == -1) { run_forever(thisAgent); return; }
if (n < -1) return;
#ifndef NO_TIMING_STUFF
thisAgent->timers_cpu.start();
thisAgent->timers_kernel.start();
#endif
thisAgent->stop_soar = FALSE;
thisAgent->reason_for_stopping = 0;
count = 0;
while (!thisAgent->stop_soar && (count < n)) {
was_decision_phase = (thisAgent->current_phase==DECISION_PHASE);
if (was_decision_phase) {
if (thisAgent->bottom_goal->id.level < level) break;
if (thisAgent->bottom_goal->id.level==level) {
if (attr_of_slot_just_decided(thisAgent)==attr_of_slot) count++;
}
}
}
#ifndef NO_TIMING_STUFF
thisAgent->timers_kernel.stop();
thisAgent->timers_cpu.stop();
thisAgent->timers_total_kernel_time.update(thisAgent->timers_kernel);
thisAgent->timers_total_cpu_time.update(thisAgent->timers_cpu);
#endif
}
void run_forever ( agent thisAgent)
void set_sysparam ( agent thisAgent,
int  param_number,
int64_t  new_value 
)
  • Windows 3.1 can't do ^C handling */*

Definition at line 174 of file init_soar.cpp.

References HIGHEST_SYSPARAM_NUMBER, print(), soar_invoke_callbacks(), agent_struct::sysparams, and SYSTEM_PARAMETER_CHANGED_CALLBACK.

{
if ((param_number < 0) || (param_number > HIGHEST_SYSPARAM_NUMBER)) {
print (thisAgent, "Internal error: tried to set bad sysparam #: %d\n", param_number);
return;
}
thisAgent->sysparams[param_number] = new_value;
reinterpret_cast<soar_call_data>(param_number));
}
void setup_signal_handling ( void  )