Soar Kernel
9.3.2 08-06-12
|
#include <portability.h>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <fstream>
#include <sstream>
#include "agent.h"
#include "reinforcement_learning.h"
#include "production.h"
#include "rhsfun.h"
#include "instantiations.h"
#include "rete.h"
#include "wmem.h"
#include "tempmem.h"
#include "print.h"
#include "xml.h"
#include "utilities.h"
#include "recmem.h"
Go to the source code of this file.
Symbol* instantiate_rhs_value | ( | agent * | thisAgent, |
rhs_value | rv, | ||
goal_stack_level | new_id_level, | ||
char | new_id_letter, | ||
struct token_struct * | tok, | ||
wme * | w | ||
) |
Definition at line 208 of file recmem.cpp.
References allocate_cons(), identifier_struct::common_symbol_info, rhs_function_struct::f, FALSE, agent_struct::firer_highest_rhs_unboundvar_index, cons_struct::first, free_list(), get_symbol_from_rete_loc(), symbol_union::id, IDENTIFIER_SYMBOL_TYPE, instantiate_rhs_value(), identifier_struct::level, make_new_identifier(), variable_struct::name, NIL, identifier_struct::promotion_level, cons_struct::rest, rhs_value_is_reteloc(), rhs_value_is_symbol(), rhs_value_is_unboundvar(), rhs_value_to_funcall_list(), rhs_value_to_reteloc_field_num(), rhs_value_to_reteloc_levels_up(), rhs_value_to_symbol(), rhs_value_to_unboundvar(), agent_struct::rhs_variable_bindings, identifier_struct::smem_lti, SMEM_LTI_UNKNOWN_LEVEL, symbol_add_ref(), symbol_remove_ref(), symbol_common_data_struct::symbol_type, agent_struct::timers_cpu, agent_struct::timers_kernel, agent_struct::timers_total_cpu_time, agent_struct::timers_total_kernel_time, TRUE, rhs_function_struct::user_data, symbol_union::var, and VARIABLE_SYMBOL_TYPE.
Referenced by execute_action(), instantiate_rhs_value(), and rl_build_template_instantiation().
Definition at line 692 of file reinforcement_learning.cpp.
References add_new_test_to_test(), agent_struct::complex_test_pool, get_new_tc_number(), GOAL_ID_TEST, wme_struct::id, symbol_union::id, IMPASSE_ID_TEST, identifier_struct::isa_goal, identifier_struct::isa_impasse, make_test_from_complex_test(), NIL, POSITIVE_CONDITION, referent_of_equality_test(), identifier_struct::tc_num, and complex_test_struct::type.
Referenced by rl_build_template_instantiation().
|
inline |
Definition at line 232 of file reinforcement_learning.cpp.
References symbol_union::id, rl_data_struct::prev_op_rl_rules, identifier_struct::rl_info, and production_struct::rl_ref_count.
Referenced by rl_store_data().
Symbol* rl_build_template_instantiation | ( | agent * | my_agent, |
instantiation * | my_template_instance, | ||
struct token_struct * | tok, | ||
wme * | w | ||
) |
Definition at line 540 of file reinforcement_learning.cpp.
References production_struct::action_list, add_production_to_rete(), wme_struct::attr, action_struct::attr, copy_condition_list(), deallocate_condition_list(), DUPLICATE_PRODUCTION, excise_production(), FALSE, symbol_union::fc, find_sym_constant(), first_letter_from_symbol(), FLOAT_CONSTANT_SYMBOL_TYPE, get_new_tc_number(), symbol_union::ic, wme_struct::id, action_struct::id, symbol_union::id, instantiate_rhs_value(), INT_CONSTANT_SYMBOL_TYPE, identifier_struct::level, make_production(), make_sym_constant(), production_struct::name, sym_constant_struct::name, NIL, instantiation_struct::nots, NUMERIC_INDIFFERENT_PREFERENCE_TYPE, production_struct::p_node, p_node_to_conditions_and_nots(), action_struct::preference_type, instantiation_struct::prod, action_struct::referent, reset_variable_generator(), rl_add_goal_or_impasse_tests_to_conds(), production_struct::rl_ecr, production_struct::rl_efr, rl_get_template_constants(), rl_make_simple_action(), rl_next_template_id(), rl_revert_template_id(), production_struct::rl_template_conds, production_struct::rl_template_instantiations, symbol_union::sc, symbol_remove_ref(), instantiation_struct::top_of_instantiated_conditions, TRUE, USER_PRODUCTION_TYPE, wme_struct::value, int_constant_struct::value, float_constant_struct::value, action_struct::value, agent_struct::variablization_tc, variablize_condition_list(), and variablize_nots_and_insert_into_conditions().
Referenced by create_instantiation().
void rl_clear_refs | ( | Symbol * | goal | ) |
Definition at line 253 of file reinforcement_learning.cpp.
References symbol_union::id, rl_data_struct::prev_op_rl_rules, and identifier_struct::rl_info.
Referenced by remove_existing_context_and_descendents(), rl_reset_data(), and rl_store_data().
bool rl_enabled | ( | agent * | my_agent | ) |
Definition at line 224 of file reinforcement_learning.cpp.
References soar_module::constant_param< T >::get_value(), rl_param_container::learning, soar_module::on, and agent_struct::rl_params.
Referenced by decide_context_slot(), do_one_top_level_phase(), exploration_choose_according_to_policy(), remove_existing_context_and_descendents(), require_preference_semantics(), and run_preference_semantics().
|
inline |
Definition at line 454 of file reinforcement_learning.cpp.
References symbol_union::id, IDENTIFIER_SYMBOL_TYPE, NIL, identifier_struct::smem_lti, and VARIABLE_SYMBOL_TYPE.
Referenced by rl_get_test_constant().
void rl_get_template_constants | ( | condition * | p_conds, |
condition * | i_conds, | ||
rl_symbol_map * | constants | ||
) |
Definition at line 516 of file reinforcement_learning.cpp.
References three_field_tests_struct::attr_test, CONJUNCTIVE_NEGATION_CONDITION, condition_struct::data, three_field_tests_struct::id_test, condition_struct::condition_main_data_union::ncc, NEGATIVE_CONDITION, condition_struct::next, POSITIVE_CONDITION, rl_get_test_constant(), condition_struct::condition_main_data_union::tests, ncc_info_struct::top, condition_struct::type, and three_field_tests_struct::value_test.
Referenced by rl_build_template_instantiation().
int rl_get_template_id | ( | const char * | prod_name | ) |
Definition at line 395 of file reinforcement_learning.cpp.
References wme_struct::id, and is_whole_number().
Referenced by rl_update_template_tracking().
void rl_get_test_constant | ( | test * | p_test, |
test * | i_test, | ||
rl_symbol_map * | constants | ||
) |
Definition at line 462 of file reinforcement_learning.cpp.
References rl_get_symbol_constant(), test_is_blank_or_equality_test(), and test_is_blank_test().
Referenced by rl_get_template_constants().
void rl_initialize_template_tracking | ( | agent * | my_agent | ) |
Definition at line 428 of file reinforcement_learning.cpp.
References agent_struct::rl_template_count.
Referenced by create_soar_agent().
action* rl_make_simple_action | ( | agent * | my_agent, |
Symbol * | id_sym, | ||
Symbol * | attr_sym, | ||
Symbol * | val_sym, | ||
Symbol * | ref_sym | ||
) |
Definition at line 656 of file reinforcement_learning.cpp.
References agent_struct::action_pool, action_struct::attr, action_struct::id, MAKE_ACTION, action_struct::next, NIL, action_struct::referent, symbol_add_ref(), symbol_to_rhs_value(), action_struct::type, action_struct::value, and variablize_symbol().
Referenced by rl_build_template_instantiation().
Definition at line 443 of file reinforcement_learning.cpp.
References agent_struct::rl_template_count.
Referenced by rl_build_template_instantiation().
void rl_perform_update | ( | agent * | my_agent, |
double | op_value, | ||
bool | op_rl, | ||
Symbol * | goal, | ||
bool | update_efr | ||
) |
Definition at line 849 of file reinforcement_learning.cpp.
References production_struct::action_list, rl_param_container::decay_mode, rl_param_container::delta_bar_delta_decay, rl_param_container::discount_rate, production_struct::documentation, rl_data_struct::eligibility_traces, rl_param_container::et_decay_rate, rl_param_container::et_tolerance, rl_param_container::exponential_decay, free_memory_block_for_string(), rl_data_struct::gap_age, rl_param_container::get_documentation_params(), soar_module::primitive_param< T >::get_value(), soar_module::string_param::get_value(), soar_module::constant_param< T >::get_value(), rl_data_struct::hrl_age, symbol_union::id, preference_struct::inst_next, production_struct::instantiations, rl_param_container::learning_rate, rl_param_container::logarithmic_decay, make_float_constant(), make_memory_block_for_string(), rl_param_container::meta, rl_param_container::meta_learning_rate, production_struct::name, sym_constant_struct::name, identifier_struct::name_letter, identifier_struct::name_number, instantiation_struct::next, rl_param_container::normal_decay, soar_module::on, rl_data_struct::prev_op_rl_rules, print(), action_struct::referent, rl_data_struct::reward, rhs_value_to_symbol(), production_struct::rl_delta_bar_delta_beta, production_struct::rl_delta_bar_delta_h, production_struct::rl_ecr, production_struct::rl_efr, identifier_struct::rl_info, agent_struct::rl_params, production_struct::rl_update_count, symbol_union::sc, symbol_remove_ref(), symbol_to_rhs_value(), agent_struct::sysparams, rl_param_container::temporal_discount, rl_param_container::temporal_extension, TRACE_RL_SYSPARAM, rl_param_container::update_log_path, xml_generate_message(), and xml_generate_warning().
Referenced by do_one_top_level_phase(), exploration_choose_according_to_policy(), remove_existing_context_and_descendents(), require_preference_semantics(), and run_preference_semantics().
|
inline |
Definition at line 238 of file reinforcement_learning.cpp.
References symbol_union::id, rl_data_struct::prev_op_rl_rules, identifier_struct::rl_info, and production_struct::rl_ref_count.
Referenced by rl_remove_refs_for_prod().
void rl_remove_refs_for_prod | ( | agent * | my_agent, |
production * | prod | ||
) |
Definition at line 290 of file reinforcement_learning.cpp.
References symbol_union::id, identifier_struct::lower_goal, rl_remove_ref(), and agent_struct::top_state.
Referenced by excise_production().
void rl_reset_data | ( | agent * | my_agent | ) |
Definition at line 269 of file reinforcement_learning.cpp.
References rl_data_struct::eligibility_traces, rl_data_struct::gap_age, rl_data_struct::hrl_age, symbol_union::id, identifier_struct::lower_goal, rl_data_struct::previous_q, rl_data_struct::reward, rl_clear_refs(), identifier_struct::rl_info, and agent_struct::top_goal.
Referenced by rl_learning_param::set_value().
void rl_revert_template_id | ( | agent * | my_agent | ) |
Definition at line 449 of file reinforcement_learning.cpp.
References agent_struct::rl_template_count.
Referenced by rl_build_template_instantiation().
void rl_rule_meta | ( | agent * | my_agent, |
production * | prod | ||
) |
Definition at line 350 of file reinforcement_learning.cpp.
References production_struct::documentation, rl_param_container::get_documentation_params(), soar_module::constant_param< T >::get_value(), rl_param_container::meta, soar_module::on, agent_struct::rl_params, and param_accessor< T >::set_param().
Referenced by parse_production(), and reteload_node_and_children().
void rl_store_data | ( | agent * | my_agent, |
Symbol * | goal, | ||
preference * | cand | ||
) |
Definition at line 790 of file reinforcement_learning.cpp.
References rl_data_struct::gap_age, soar_module::constant_param< T >::get_value(), symbol_union::id, identifier_struct::name_letter, identifier_struct::name_number, preference_struct::next, NUMERIC_INDIFFERENT_PREFERENCE_TYPE, preference_struct::numeric_value, soar_module::on, identifier_struct::operator_slot, slot_struct::preferences, rl_data_struct::prev_op_rl_rules, rl_data_struct::previous_q, print(), rl_add_ref(), rl_clear_refs(), identifier_struct::rl_info, agent_struct::rl_params, agent_struct::sysparams, rl_param_container::temporal_extension, TRACE_RL_SYSPARAM, preference_struct::value, and xml_generate_warning().
Referenced by decide_context_slot().
Definition at line 723 of file reinforcement_learning.cpp.
References agent_struct::bottom_goal, rl_param_container::discount_rate, find_slot(), FLOAT_CONSTANT_SYMBOL_TYPE, rl_data_struct::gap_age, get_number_from_symbol(), soar_module::primitive_param< T >::get_value(), soar_module::constant_param< T >::get_value(), soar_module::primitive_stat< T >::get_value(), rl_stat_container::global_reward, rl_data_struct::hrl_age, rl_param_container::hrl_discount, symbol_union::id, IDENTIFIER_SYMBOL_TYPE, INT_CONSTANT_SYMBOL_TYPE, wme_struct::next, soar_module::on, rl_data_struct::prev_op_rl_rules, rl_data_struct::reward, identifier_struct::reward_header, identifier_struct::rl_info, agent_struct::rl_params, agent_struct::rl_stats, agent_struct::rl_sym_reward, agent_struct::rl_sym_value, soar_module::primitive_stat< T >::set_value(), rl_param_container::temporal_discount, rl_stat_container::total_reward, wme_struct::value, and slot_struct::wmes.
Referenced by do_one_top_level_phase(), remove_existing_context_and_descendents(), and rl_tabulate_reward_values().
void rl_tabulate_reward_values | ( | agent * | my_agent | ) |
Definition at line 778 of file reinforcement_learning.cpp.
References symbol_union::id, identifier_struct::lower_goal, rl_tabulate_reward_value_for_goal(), and agent_struct::top_goal.
Referenced by exploration_choose_according_to_policy(), require_preference_semantics(), and run_preference_semantics().
void rl_update_template_tracking | ( | agent * | my_agent, |
const char * | rule_name | ||
) |
Definition at line 434 of file reinforcement_learning.cpp.
References rl_get_template_id(), and agent_struct::rl_template_count.
Referenced by make_production().
bool rl_valid_rule | ( | production * | prod | ) |
Definition at line 331 of file reinforcement_learning.cpp.
References production_struct::action_list, MAKE_ACTION, action_struct::next, and NUMERIC_INDIFFERENT_PREFERENCE_TYPE.
Referenced by make_production(), and reteload_node_and_children().
bool rl_valid_template | ( | production * | prod | ) |
Definition at line 304 of file reinforcement_learning.cpp.
References production_struct::action_list, BINARY_INDIFFERENT_PREFERENCE_TYPE, identifier_struct::common_symbol_info, symbol_union::id, MAKE_ACTION, action_struct::next, NUMERIC_INDIFFERENT_PREFERENCE_TYPE, rhs_value_is_symbol(), rhs_value_to_symbol(), symbol_common_data_struct::symbol_type, and VARIABLE_SYMBOL_TYPE.
Referenced by parse_production().
Definition at line 1071 of file reinforcement_learning.cpp.
References rl_data_struct::eligibility_traces, symbol_union::id, and identifier_struct::rl_info.
Referenced by exploration_choose_according_to_policy().
Definition at line 238 of file chunk.cpp.
References three_field_tests_struct::attr_test, CONJUNCTIVE_NEGATION_CONDITION, condition_struct::data, three_field_tests_struct::id_test, condition_struct::condition_main_data_union::ncc, NEGATIVE_CONDITION, condition_struct::next, NIL, POSITIVE_CONDITION, condition_struct::condition_main_data_union::tests, ncc_info_struct::top, condition_struct::type, three_field_tests_struct::value_test, variablize_condition_list(), and variablize_test().
Referenced by chunk_instantiation(), rl_build_template_instantiation(), and variablize_condition_list().
void variablize_nots_and_insert_into_conditions | ( | agent * | thisAgent, |
not_struct * | nots, | ||
condition * | conds | ||
) |
Definition at line 576 of file chunk.cpp.
References abort_with_fatal_error(), add_new_test_to_test(), three_field_tests_struct::attr_test, BUFFER_MSG_SIZE, agent_struct::complex_test_pool, complex_test_struct::data, condition_struct::data, FALSE, symbol_union::id, three_field_tests_struct::id_test, make_test_from_complex_test(), not_struct::next, condition_struct::next, NIL, NOT_EQUAL_TEST, POSITIVE_CONDITION, complex_test_struct::test_info_union::referent, not_struct::s1, not_struct::s2, symbol_add_ref(), test_includes_equality_test_for_symbol(), condition_struct::condition_main_data_union::tests, TRUE, complex_test_struct::type, condition_struct::type, three_field_tests_struct::value_test, and identifier_struct::variablization.
Referenced by chunk_instantiation(), and rl_build_template_instantiation().
Definition at line 179 of file chunk.cpp.
References generate_new_variable(), symbol_union::id, IDENTIFIER_SYMBOL_TYPE, NIL, symbol_add_ref(), symbol_remove_ref(), identifier_struct::tc_num, identifier_struct::variablization, and agent_struct::variablization_tc.
Referenced by copy_and_variablize_result_list(), rl_make_simple_action(), and variablize_test().