Soar Kernel  9.3.2 08-06-12
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Functions
agent.cpp File Reference
#include <portability.h>
#include <stdlib.h>
#include <map>
#include "agent.h"
#include "kernel.h"
#include "mem.h"
#include "lexer.h"
#include "symtab.h"
#include "gdatastructs.h"
#include "rhsfun.h"
#include "instantiations.h"
#include "production.h"
#include "gsysparam.h"
#include "init_soar.h"
#include "decide.h"
#include "print.h"
#include "recmem.h"
#include "backtrace.h"
#include "chunk.h"
#include "explain.h"
#include "rete.h"
#include "trace.h"
#include "callback.h"
#include "io_soar.h"
#include "xml.h"
#include "utilities.h"
#include "soar_module.h"
#include "exploration.h"
#include "reinforcement_learning.h"
#include "decision_manipulation.h"
#include "wma.h"
#include "episodic_memory.h"
#include "semantic_memory.h"

Go to the source code of this file.

Functions

agentcreate_soar_agent (char *agent_name)
void destroy_soar_agent (agent *delete_agent)
void init_soar_agent (agent *thisAgent)

Function Documentation

agent* create_soar_agent ( char *  agent_name)

Definition at line 145 of file agent.cpp.

References agent_struct::active_goal, agent_struct::active_level, agent_struct::actual, agent_struct::all_productions_of_type, agent_struct::all_wmes_in_rete, agent_struct::alpha_mem_id_counter, agent_struct::alternate_input_exit, agent_struct::alternate_input_string, agent_struct::alternate_input_suffix, agent_struct::applyPhase, agent_struct::attention_lapse_tracker, agent_struct::backtrace_number, agent_struct::beta_node_id_counter, agent_struct::bottom_goal, agent_struct::changed_slots, agent_struct::chunk_count, agent_struct::chunk_free_problem_spaces, agent_struct::chunk_name_prefix, agent_struct::chunky_problem_spaces, agent_struct::context_slots_with_changed_acceptable_preferences, agent_struct::current_file, agent_struct::current_phase, agent_struct::current_symbol_hash_id, agent_struct::current_tc_number, agent_struct::current_variable_gensym_number, agent_struct::current_wme_timetag, agent_struct::dc_stat_tracking, agent_struct::default_wme_depth, agent_struct::did_PE, dir_stack_struct::directory, agent_struct::disconnected_ids, agent_struct::dyn_counters, agent_struct::dyn_memory_pools, agent_struct::epmem_db, agent_struct::epmem_edge_maxes, agent_struct::epmem_edge_mins, agent_struct::epmem_edge_removals, agent_struct::epmem_first_switch, agent_struct::epmem_id_ref_counts, agent_struct::epmem_id_removes, agent_struct::epmem_id_replacement, agent_struct::epmem_id_repository, agent_struct::epmem_node_maxes, agent_struct::epmem_node_mins, agent_struct::epmem_node_removals, agent_struct::epmem_params, agent_struct::epmem_promotions, agent_struct::epmem_stats, agent_struct::epmem_stmts_common, agent_struct::epmem_stmts_graph, agent_struct::epmem_timers, agent_struct::epmem_validation, agent_struct::epmem_wme_adds, agent_struct::existing_output_links, exploration_add_parameter(), EXPLORATION_PARAM_EPSILON, EXPLORATION_PARAM_TEMPERATURE, agent_struct::exploration_params, exploration_validate_epsilon(), exploration_validate_temperature(), FALSE, agent_struct::FIRING_TYPE, lexeme_info::float_val, GO_DECISION, agent_struct::go_number, agent_struct::go_type, agent_struct::grounds_tc, agent_struct::highest_goal_whose_context_changed, lexeme_info::id_letter, lexeme_info::id_number, agent_struct::ids_with_unknown_level, IE_PRODS, agent_struct::if_no_merging, agent_struct::if_no_sharing, init_memory_utilities(), init_sysparams(), agent_struct::input_cycle_flag, agent_struct::input_period, INPUT_PHASE, lexeme_info::int_val, agent_struct::justification_count, lexeme_info::length, agent_struct::lex_alias, agent_struct::lexeme, agent_struct::link_update_mode, agent_struct::locals_tc, agent_struct::max_chunks_reached, agent_struct::mcs_counter, agent_struct::memory_pools_in_use, agent_struct::ms_assertions, agent_struct::ms_i_assertions, agent_struct::ms_o_assertions, agent_struct::ms_retractions, agent_struct::multi_attributes, agent_struct::name, dir_stack_struct::next, NIL, agent_struct::nil_goal_retractions, NULL_LEXEME, agent_struct::num_existing_wmes, NUM_PRODUCTION_TYPES, agent_struct::num_productions_of_type, agent_struct::num_wmes_in_rete, agent_struct::numeric_indifferent_mode, NUMERIC_INDIFFERENT_MODE_SUM, agent_struct::o_support_calculation_type, agent_struct::output_link_changed, agent_struct::postponed_assertions, agent_struct::potentials_tc, predict_init(), agent_struct::prediction, agent_struct::prev_top_state, agent_struct::previous_active_level, print(), agent_struct::print_prompt_flag, agent_struct::printer_output_column, agent_struct::production_being_fired, agent_struct::productions_being_traced, agent_struct::promoted_ids, agent_struct::real_time_tracker, agent_struct::reason_for_stopping, reset_max_stats(), reset_timers(), agent_struct::rhs_functions, rl_initialize_template_tracking(), agent_struct::rl_params, agent_struct::rl_prods, agent_struct::rl_stats, savestring(), agent_struct::select, select_init(), agent_struct::slots_for_possible_removal, agent_struct::smem_changed_ids, agent_struct::smem_db, agent_struct::smem_first_switch, agent_struct::smem_ignore_changes, agent_struct::smem_params, agent_struct::smem_stats, agent_struct::smem_timers, agent_struct::smem_validation, soar_init_callbacks(), agent_struct::soar_verbose_flag, agent_struct::stats_db, agent_struct::stop_soar, lexeme_info::string, agent_struct::substate_break_level, agent_struct::sysparams, agent_struct::system_halted, agent_struct::timers_cpu, TIMERS_ENABLED, agent_struct::timers_kernel, agent_struct::timers_phase, agent_struct::token_additions, agent_struct::top_dir_stack, agent_struct::top_goal, agent_struct::top_state, TRUE, lexeme_info::type, UPDATE_LINKS_NORMALLY, agent_struct::variables_set, agent_struct::waitsnc, agent_struct::waitsnc_detect, agent_struct::wma_forget_pq, agent_struct::wma_initialized, agent_struct::wma_params, agent_struct::wma_stats, agent_struct::wma_tc_counter, agent_struct::wma_timers, agent_struct::wma_touched_elements, agent_struct::wma_touched_sets, agent_struct::wme_filter_list, agent_struct::wmes_to_add, agent_struct::wmes_to_remove, and xml_create().

{ /* loop index */
char cur_path[MAXPATHLEN]; /* AGR 536 */
//agent* newAgent = static_cast<agent *>(malloc(sizeof(agent)));
agent* newAgent = new agent();
newAgent->current_tc_number = 0;
newAgent->name = savestring(agent_name);
/* mvp 5-17-94 */
newAgent->variables_set = NIL;
//#ifdef _WINDOWS
// newAgent->current_line[0] = 0;
// newAgent->current_line_index = 0;
//#endif /* _WINDOWS */
newAgent->all_wmes_in_rete = NIL;
newAgent->alpha_mem_id_counter = 0;
newAgent->alternate_input_exit = FALSE;/* Soar-Bugs #54 */
newAgent->backtrace_number = 0;
newAgent->beta_node_id_counter = 0;
newAgent->bottom_goal = NIL;
newAgent->changed_slots = NIL;
newAgent->chunk_count = 1;
newAgent->chunky_problem_spaces = NIL; /* AGR MVL1 */
strcpy(newAgent->chunk_name_prefix,"chunk"); /* ajc (5/14/02) */
newAgent->current_file = NIL;
newAgent->applyPhase = FALSE;
newAgent->current_symbol_hash_id = 0;
newAgent->current_wme_timetag = 1;
newAgent->default_wme_depth = 1; /* AGR 646 */
newAgent->disconnected_ids = NIL;
newAgent->output_link_changed = FALSE; /* KJC 11/9/98 */
/* newAgent->explain_flag = FALSE; */
newAgent->go_number = 1;
newAgent->go_type = GO_DECISION;
newAgent->grounds_tc = 0;
newAgent->input_period = 0; /* AGR REW1 */
newAgent->input_cycle_flag = TRUE; /* AGR REW1 */
newAgent->justification_count = 1;
newAgent->lex_alias = NIL; /* AGR 568 */
newAgent->locals_tc = 0;
newAgent->max_chunks_reached = FALSE; /* MVP 6-24-94 */
newAgent->mcs_counter = 1;
newAgent->memory_pools_in_use = NIL;
newAgent->ms_assertions = NIL;
newAgent->ms_retractions = NIL;
newAgent->num_existing_wmes = 0;
newAgent->num_wmes_in_rete = 0;
newAgent->potentials_tc = 0;
newAgent->prev_top_state = NIL;
newAgent->print_prompt_flag = TRUE;
newAgent->printer_output_column = 1;
newAgent->promoted_ids = NIL;
newAgent->reason_for_stopping = "Startup";
newAgent->stop_soar = TRUE;
newAgent->system_halted = FALSE;
newAgent->token_additions = 0;
newAgent->top_dir_stack = NIL; /* AGR 568 */
newAgent->top_goal = NIL;
newAgent->top_state = NIL;
newAgent->wmes_to_add = NIL;
newAgent->wmes_to_remove = NIL;
newAgent->wme_filter_list = NIL; /* Added this to avoid
access violation
-AJC (5/13/02) */
newAgent->multi_attributes = NIL;
/* REW: begin 09.15.96 */
newAgent->did_PE = FALSE;
newAgent->soar_verbose_flag = FALSE;
newAgent->FIRING_TYPE = IE_PRODS;
newAgent->ms_o_assertions = NIL;
newAgent->ms_i_assertions = NIL;
/* REW: end 09.15.96 */
/* REW: begin 08.20.97 */
newAgent->active_goal = NIL;
newAgent->active_level = 0;
newAgent->previous_active_level = 0;
/* Initialize Waterfall-specific lists */
/* REW: end 08.20.97 */
/* REW: begin 10.24.97 */
newAgent->waitsnc = FALSE;
newAgent->waitsnc_detect = FALSE;
/* REW: end 10.24.97 */
/* Initializing rete stuff */
for (int i=0; i < 256; i++) {
newAgent->actual[i]=0;
newAgent->if_no_merging[i]=0;
newAgent->if_no_sharing[i]=0;
}
/* Initializing lexeme */
newAgent->lexeme.type = NULL_LEXEME;
newAgent->lexeme.string[0] = 0;
newAgent->lexeme.length = 0;
newAgent->lexeme.int_val = 0;
newAgent->lexeme.float_val = 0.0;
newAgent->lexeme.id_letter = 'A';
newAgent->lexeme.id_number = 0;
reset_max_stats(newAgent);
newAgent->real_time_tracker = 0;
newAgent->attention_lapse_tracker = 0;
if(!getcwd(cur_path, MAXPATHLEN))
print(newAgent, "Unable to set current directory while initializing agent.\n");
newAgent->top_dir_stack = static_cast<dir_stack_struct *>(malloc(sizeof(dir_stack_struct))); /* AGR 568 */
newAgent->top_dir_stack->directory = static_cast<char *>(malloc(MAXPATHLEN*sizeof(char))); /* AGR 568 */
newAgent->top_dir_stack->next = NIL; /* AGR 568 */
strcpy(newAgent->top_dir_stack->directory, cur_path); /* AGR 568 */
/* changed all references of 'i', a var belonging to a previous for loop, to 'productionTypeCounter' to be unique
stokesd Sept 10 2004*/
for (int productionTypeCounter=0; productionTypeCounter<NUM_PRODUCTION_TYPES; productionTypeCounter++) {
newAgent->all_productions_of_type[productionTypeCounter] = NIL;
newAgent->num_productions_of_type[productionTypeCounter] = 0;
}
newAgent->o_support_calculation_type = 4; /* KJC 7/00 */ // changed from 3 to 4 by voigtjr (/* bugzilla bug 339 */)
/* JC ADDED: Make sure that the RHS functions get initialized correctly */
newAgent->rhs_functions = NIL;
// JRV: Allocates data for XML generation
xml_create( newAgent );
soar_init_callbacks( newAgent );
//
// This call is needed to set up callbacks.
//
// This was moved here so that system parameters could
// be set before the agent was initialized.
init_sysparams (newAgent);
/* Initializing all the timer structures */
// Timers must be initialized after sysparams
#ifndef NO_TIMING_STUFF
newAgent->timers_cpu.set_enabled(&(newAgent->sysparams[TIMERS_ENABLED]));
newAgent->timers_kernel.set_enabled(&(newAgent->sysparams[TIMERS_ENABLED]));
newAgent->timers_phase.set_enabled(&(newAgent->sysparams[TIMERS_ENABLED]));
#ifdef DETAILED_TIMING_STATS
newAgent->timers_gds.set_enabled(&(newAgent->sysparams[TIMERS_ENABLED]));
#endif
reset_timers(newAgent);
#endif
// dynamic memory pools (should come before consumers of dynamic pools)
newAgent->dyn_memory_pools = new std::map< size_t, memory_pool* >();
// dynamic counters
newAgent->dyn_counters = new std::map< std::string, uint64_t >();
// exploration initialization
// rl initialization
newAgent->rl_params = new rl_param_container( newAgent );
newAgent->rl_stats = new rl_stat_container( newAgent );
newAgent->rl_prods = new rl_production_memory();
// select initialization
newAgent->select = new select_info;
select_init( newAgent );
// predict initialization
newAgent->prediction = new std::string();
predict_init( newAgent );
// wma initialization
newAgent->wma_params = new wma_param_container( newAgent );
newAgent->wma_stats = new wma_stat_container( newAgent );
newAgent->wma_timers = new wma_timer_container( newAgent );
#ifdef USE_MEM_POOL_ALLOCATORS
newAgent->wma_forget_pq = new wma_forget_p_queue( std::less< wma_d_cycle >(), soar_module::soar_memory_pool_allocator< std::pair< wma_d_cycle, wma_decay_set* > >( newAgent ) );
newAgent->wma_touched_sets = new wma_decay_cycle_set( std::less< wma_d_cycle >(), soar_module::soar_memory_pool_allocator< wma_d_cycle >( newAgent ) );
#else
newAgent->wma_forget_pq = new wma_forget_p_queue();
#endif
newAgent->wma_initialized = false;
newAgent->wma_tc_counter = 2;
// epmem initialization
newAgent->epmem_params = new epmem_param_container( newAgent );
newAgent->epmem_stats = new epmem_stat_container( newAgent );
newAgent->epmem_timers = new epmem_timer_container( newAgent );
newAgent->epmem_stmts_common = NULL;
newAgent->epmem_stmts_graph = NULL;
newAgent->epmem_node_mins = new std::vector<epmem_time_id>();
newAgent->epmem_node_maxes = new std::vector<bool>();
newAgent->epmem_edge_mins = new std::vector<epmem_time_id>();
newAgent->epmem_edge_maxes = new std::vector<bool>();
#ifdef USE_MEM_POOL_ALLOCATORS
newAgent->epmem_node_removals = new epmem_id_removal_map( std::less< epmem_node_id >(), soar_module::soar_memory_pool_allocator< std::pair< epmem_node_id, bool > >( newAgent ) );
newAgent->epmem_edge_removals = new epmem_id_removal_map( std::less< epmem_node_id >(), soar_module::soar_memory_pool_allocator< std::pair< epmem_node_id, bool > >( newAgent ) );
newAgent->epmem_wme_adds = new epmem_symbol_set( std::less< Symbol* >(), soar_module::soar_memory_pool_allocator< Symbol* >( newAgent ) );
newAgent->epmem_promotions = new epmem_symbol_set( std::less< Symbol* >(), soar_module::soar_memory_pool_allocator< Symbol* >( newAgent ) );
#else
newAgent->epmem_wme_adds = new epmem_symbol_set();
#endif
newAgent->epmem_validation = 0;
newAgent->epmem_first_switch = true;
// smem initialization
newAgent->smem_params = new smem_param_container( newAgent );
newAgent->smem_stats = new smem_stat_container( newAgent );
newAgent->smem_timers = new smem_timer_container( newAgent );
newAgent->smem_validation = 0;
newAgent->smem_first_switch = true;
#ifdef USE_MEM_POOL_ALLOCATORS
newAgent->smem_changed_ids = new smem_pooled_symbol_set( std::less< Symbol* >(), soar_module::soar_memory_pool_allocator< Symbol* >( newAgent ) );
#else
#endif
newAgent->smem_ignore_changes = false;
// statistics initialization
newAgent->dc_stat_tracking = false;
newAgent->substate_break_level = 0;
return newAgent;
}
void destroy_soar_agent ( agent delete_agent)

Definition at line 436 of file agent.cpp.

References wma_param_container::activation, agent_struct::alpha_hash_tables, rl_param_container::apoptosis, rl_param_container::apoptosis_none, agent_struct::current_file, dir_stack_struct::directory, agent_struct::dummy_top_node, agent_struct::dummy_top_token, agent_struct::dyn_counters, agent_struct::dyn_memory_pools, epmem_close(), agent_struct::epmem_db, agent_struct::epmem_edge_maxes, agent_struct::epmem_edge_mins, agent_struct::epmem_edge_removals, agent_struct::epmem_id_ref_counts, agent_struct::epmem_id_removes, agent_struct::epmem_id_replacement, agent_struct::epmem_id_repository, agent_struct::epmem_node_maxes, agent_struct::epmem_node_mins, agent_struct::epmem_node_removals, agent_struct::epmem_params, agent_struct::epmem_promotions, agent_struct::epmem_stats, agent_struct::epmem_timers, agent_struct::epmem_wme_adds, excise_all_productions(), EXPLORATION_PARAMS, agent_struct::exploration_params, FALSE, lexer_source_file_struct::filename, find_sym_constant(), agent_struct::float_constant_hash_table, FOR_ANYTHING_TF, FOR_OPERATORS_TF, FOR_STATES_TF, free_hash_table(), free_memory(), free_memory_block_for_string(), free_memory_pool(), HASH_TABLE_MEM_USAGE, agent_struct::identifier_hash_table, agent_struct::int_constant_hash_table, agent_struct::left_ht, agent_struct::memory_pools_in_use, MISCELLANEOUS_MEM_USAGE, agent_struct::multi_attributes, agent_struct::name, multi_attributes_struct::next, memory_pool_struct::next, NIL, agent_struct::object_tr_ht, soar_module::off, agent_struct::prediction, release_predefined_symbols(), remove_built_in_rhs_functions(), remove_trace_format(), agent_struct::rete_node_pool, agent_struct::rhs_variable_bindings, agent_struct::right_ht, agent_struct::rl_params, agent_struct::rl_prods, agent_struct::rl_stats, agent_struct::select, select_init(), wma_activation_param::set_value(), rl_apoptosis_param::set_value(), agent_struct::smem_changed_ids, smem_close(), agent_struct::smem_db, agent_struct::smem_params, agent_struct::smem_stats, agent_struct::smem_timers, soar_remove_all_monitorable_callbacks(), agent_struct::stack_tr_ht, stats_close(), agent_struct::stats_db, agent_struct::sym_constant_hash_table, symbol_remove_ref(), agent_struct::token_pool, agent_struct::top_dir_stack, TRUE, agent_struct::variable_hash_table, agent_struct::wma_forget_pq, agent_struct::wma_params, agent_struct::wma_stats, agent_struct::wma_timers, agent_struct::wma_touched_elements, agent_struct::wma_touched_sets, and xml_destroy().

{
//print(delete_agent, "\nDestroying agent %s.\n", delete_agent->name); /* AGR 532 */
//#ifdef USE_X_DISPLAY
//
// /* Destroy X window associated with agent */
// destroy_agent_window (delete_agent);
//#endif /* USE_X_DISPLAY */
// Soar Modules - could potentially rely on hash tables
// cleanup exploration
for ( int i=0; i<EXPLORATION_PARAMS; i++ )
delete delete_agent->exploration_params[ i ];
// cleanup Soar-RL
delete delete_agent->rl_prods;
delete delete_agent->rl_params;
delete delete_agent->rl_stats;
delete_agent->rl_params = NULL; // apoptosis needs to know this for excise_all_productions below
// cleanup select
select_init( delete_agent );
delete delete_agent->select;
// cleanup predict
delete delete_agent->prediction;
// cleanup wma
delete delete_agent->wma_forget_pq;
delete delete_agent->wma_touched_elements;
delete delete_agent->wma_touched_sets;
delete delete_agent->wma_params;
delete delete_agent->wma_stats;
delete delete_agent->wma_timers;
// cleanup epmem
epmem_close( delete_agent );
delete delete_agent->epmem_params;
delete delete_agent->epmem_stats;
delete delete_agent->epmem_timers;
delete delete_agent->epmem_node_removals;
delete delete_agent->epmem_node_mins;
delete delete_agent->epmem_node_maxes;
delete delete_agent->epmem_edge_removals;
delete delete_agent->epmem_edge_mins;
delete delete_agent->epmem_edge_maxes;
delete delete_agent->epmem_id_repository;
delete delete_agent->epmem_id_replacement;
delete delete_agent->epmem_id_ref_counts;
delete delete_agent->epmem_id_removes;
delete delete_agent->epmem_wme_adds;
delete delete_agent->epmem_promotions;
delete delete_agent->epmem_db;
// cleanup smem
smem_close( delete_agent );
delete delete_agent->smem_changed_ids;
delete delete_agent->smem_params;
delete delete_agent->smem_stats;
delete delete_agent->smem_timers;
delete delete_agent->smem_db;
// cleanup statistics db
stats_close( delete_agent );
delete delete_agent->stats_db;
delete_agent->stats_db = 0;
/* Free structures stored in agent structure */
free(delete_agent->name);
free(delete_agent->top_dir_stack->directory);
free(delete_agent->top_dir_stack);
/* Freeing the agent's multi attributes structure */
multi_attribute* lastmattr = 0;
for ( multi_attribute* curmattr = delete_agent->multi_attributes;
curmattr != 0;
curmattr = curmattr->next ) {
symbol_remove_ref(delete_agent, curmattr->symbol);
free_memory(delete_agent, lastmattr, MISCELLANEOUS_MEM_USAGE);
lastmattr = curmattr;
}
free_memory(delete_agent, lastmattr, MISCELLANEOUS_MEM_USAGE);
/* Freeing all the productions owned by this agent */
excise_all_productions(delete_agent, false);
/* Releasing all the predefined symbols */
/* Releasing rete stuff RPM 11/06 */
free_with_pool(&delete_agent->rete_node_pool, delete_agent->dummy_top_node);
free_with_pool(&delete_agent->token_pool, delete_agent->dummy_top_token);
/* Cleaning up the various callbacks
TODO: Not clear why callbacks need to take the agent pointer essentially twice.
*/
/* RPM 9/06 begin */
free_memory(delete_agent, delete_agent->left_ht, HASH_TABLE_MEM_USAGE);
free_memory(delete_agent, delete_agent->right_ht, HASH_TABLE_MEM_USAGE);
/* Releasing memory allocated in inital call to start_lex_from_file from init_lexer */
free_memory_block_for_string(delete_agent, delete_agent->current_file->filename);
free_memory (delete_agent, delete_agent->current_file, MISCELLANEOUS_MEM_USAGE);
/* Releasing trace formats (needs to happen before tracing hashtables are released) */
Symbol *evaluate_object_sym = find_sym_constant (delete_agent, "evaluate-object");
remove_trace_format (delete_agent, FALSE, FOR_OPERATORS_TF, evaluate_object_sym);
/* Releasing hashtables allocated in init_tracing */
for (int i=0; i<3; i++) {
free_hash_table(delete_agent, delete_agent->object_tr_ht[i]);
free_hash_table(delete_agent, delete_agent->stack_tr_ht[i]);
}
/* Releasing memory allocated in init_rete */
for (int i=0; i<16; i++) {
free_hash_table(delete_agent, delete_agent->alpha_hash_tables[i]);
}
/* Releasing other hashtables */
free_hash_table(delete_agent, delete_agent->variable_hash_table);
free_hash_table(delete_agent, delete_agent->identifier_hash_table);
free_hash_table(delete_agent, delete_agent->sym_constant_hash_table);
free_hash_table(delete_agent, delete_agent->int_constant_hash_table);
free_hash_table(delete_agent, delete_agent->float_constant_hash_table);
/* Releasing memory pools */
memory_pool* cur_pool = delete_agent->memory_pools_in_use;
memory_pool* next_pool;
while(cur_pool != NIL) {
next_pool = cur_pool->next;
free_memory_pool(delete_agent, cur_pool);
cur_pool = next_pool;
}
/* RPM 9/06 end */
// dynamic memory pools (cleared in the last step)
for ( std::map< size_t, memory_pool* >::iterator it=delete_agent->dyn_memory_pools->begin(); it!=delete_agent->dyn_memory_pools->end(); it++ )
{
delete it->second;
}
delete delete_agent->dyn_memory_pools;
delete delete_agent->dyn_counters;
// JRV: Frees data used by XML generation
xml_destroy( delete_agent );
/* Free soar agent structure */
delete delete_agent;
}
void init_soar_agent ( agent thisAgent)

Definition at line 67 of file agent.cpp.

References add_trace_format(), smem_param_container::base_incremental_threshes, create_predefined_symbols(), agent_struct::epmem_info_pool, agent_struct::epmem_interval_pool, agent_struct::epmem_literal_pool, agent_struct::epmem_params, agent_struct::epmem_pedge_pool, agent_struct::epmem_uedge_pool, agent_struct::epmem_wmes_pool, epmem_param_container::exclusions, FALSE, FOR_ANYTHING_TF, FOR_OPERATORS_TF, FOR_STATES_TF, agent_struct::gds_pool, init_agent_memory(), init_built_in_rhs_functions(), init_chunker(), init_decider(), init_explain(), init_firer(), init_lexer(), init_memory_pool(), init_production_utilities(), init_rete(), init_soar_io(), init_symbol_tables(), init_tracing(), make_sym_constant(), NIL, predict_init(), reset_statistics(), agent_struct::rhs_functions, agent_struct::rl_et_pool, agent_struct::rl_info_pool, agent_struct::rl_rule_pool, select_init(), soar_module::primitive_set_param< T >::set_string(), soar_module::sym_set_param::set_value(), agent_struct::smem_info_pool, agent_struct::smem_params, agent_struct::smem_wmes_pool, symbol_remove_ref(), TRUE, agent_struct::wma_decay_element_pool, agent_struct::wma_decay_set_pool, agent_struct::wma_slot_refs_pool, and agent_struct::wma_wme_oset_pool.

{
/* JC ADDED: initialize the rhs function linked list */
thisAgent->rhs_functions = NIL;
/* --- initialize everything --- */
init_symbol_tables(thisAgent);
init_rete (thisAgent);
init_lexer (thisAgent);
init_firer (thisAgent);
init_decider (thisAgent);
init_soar_io (thisAgent);
init_chunker (thisAgent);
init_tracing (thisAgent);
init_explain(thisAgent); /* AGR 564 */
select_init(thisAgent);
predict_init(thisAgent);
init_memory_pool( thisAgent, &( thisAgent->gds_pool ), sizeof( goal_dependency_set ), "gds" );
init_memory_pool( thisAgent, &( thisAgent->rl_info_pool ), sizeof( rl_data ), "rl_id_data" );
init_memory_pool( thisAgent, &( thisAgent->rl_et_pool ), sizeof( rl_et_map ), "rl_et" );
init_memory_pool( thisAgent, &( thisAgent->rl_rule_pool ), sizeof( rl_rule_list ), "rl_rules" );
init_memory_pool( thisAgent, &( thisAgent->wma_decay_element_pool ), sizeof( wma_decay_element ), "wma_decay" );
init_memory_pool( thisAgent, &( thisAgent->wma_decay_set_pool ), sizeof( wma_decay_set ), "wma_decay_set" );
init_memory_pool( thisAgent, &( thisAgent->wma_wme_oset_pool ), sizeof( wma_pooled_wme_set ), "wma_oset" );
init_memory_pool( thisAgent, &( thisAgent->wma_slot_refs_pool ), sizeof( wma_sym_reference_map ), "wma_slot_ref" );
init_memory_pool( thisAgent, &( thisAgent->epmem_wmes_pool ), sizeof( epmem_wme_stack ), "epmem_wmes" );
init_memory_pool( thisAgent, &( thisAgent->epmem_info_pool ), sizeof( epmem_data ), "epmem_id_data" );
init_memory_pool( thisAgent, &( thisAgent->smem_wmes_pool ), sizeof( smem_wme_stack ), "smem_wmes" );
init_memory_pool( thisAgent, &( thisAgent->smem_info_pool ), sizeof( smem_data ), "smem_id_data" );
init_memory_pool( thisAgent, &( thisAgent->epmem_literal_pool ), sizeof( epmem_literal), "epmem_literals" );
init_memory_pool( thisAgent, &( thisAgent->epmem_pedge_pool ), sizeof( epmem_pedge ), "epmem_pedges" );
init_memory_pool( thisAgent, &( thisAgent->epmem_uedge_pool ), sizeof( epmem_uedge ), "epmem_uedges" );
init_memory_pool( thisAgent, &( thisAgent->epmem_interval_pool ), sizeof( epmem_interval ), "epmem_intervals" );
thisAgent->epmem_params->exclusions->set_value( "epmem" );
thisAgent->epmem_params->exclusions->set_value( "smem" );
#ifdef REAL_TIME_BEHAVIOR
/* RMJ */
init_real_time(thisAgent);
#endif
/* --- add default object trace formats --- */
"%id %ifdef[(%v[name])]");
"%id %ifdef[(%v[attribute] %v[impasse])]");
{ Symbol *evaluate_object_sym;
evaluate_object_sym = make_sym_constant (thisAgent, "evaluate-object");
add_trace_format (thisAgent, FALSE, FOR_OPERATORS_TF, evaluate_object_sym,
"%id (evaluate-object %o[object])");
symbol_remove_ref (thisAgent, evaluate_object_sym);
}
/* --- add default stack trace formats --- */
"%right[6,%dc]: %rsd[ ]==>S: %cs");
"%right[6,%dc]: %rsd[ ] O: %co");
reset_statistics (thisAgent);
/* RDF: For gSKI */
init_agent_memory(thisAgent);
/* END */
}