// file: $isip_ifc/class/pr/RelevanceVectorMachine/rvm_00.cc
// version: $Id: rvm_00.cc 10424 2006-02-10 20:37:45Z raghavan $
//

// isip include files
//
#include "RelevanceVectorMachine.h"

// method: RelevanceVectorMachine
//
// arguments: none
//
// return: none
//
RelevanceVectorMachine::RelevanceVectorMachine() {
  
  // initialize the member data
  //
  polynomial_degree_d = DEF_POLYNOMIAL_DEGREE;
  rbf_gamma_d = DEF_RBF_GAMMA;
  sigmoid_kappa_d = DEF_SIGMOID_KAPPA;
  sigmoid_delta_d = DEF_SIGMOID_DELTA;
  
  output_type_d = DEF_TYPE;
  algorithm_d = DEF_ALGORITHM;
  implementation_d = DEF_IMPLEMENTATION;
}

// method: debug
//
// arguments:
//  const unichar* msg: (input) message to print
//
// return: a boolean value indicating status
//
boolean RelevanceVectorMachine::debug(const unichar* msg_a) const {

    // declare local variables
  //
  String value;
  String output;
  String empty_str;

  // output an information message
  //
  output.debugStr(name(), msg_a, L":");
  Console::put(output);
  Console::increaseIndention();
  
  // output the class data
  //
  bias_d.debug(L"bias_d");
  weights_d.debug(L"weights_d");
  targets_d.debug(L"targets_d");
  vectors_d.debug(L"vectors_d");
  kernel_d.debug(L"kernel_d");
  inv_hessian_d.debug(L"inv_hessian_d");
  
  // decrease indention
  //
  Console::decreaseIndention();
 
  // exit gracefully
  //
  return true;
}

// method: assign
//
// arguments:
//  const RelevanceVectorMachine& copy: (input) item to assign from
//
// return: boolean value indicating status
//
// this method changes the object to match the input object
//
boolean RelevanceVectorMachine::assign(const RelevanceVectorMachine& copy_a) {

  // assign all of the data elements
  //
  return (kernel_d.assign(copy_a.kernel_d) &&
	  weights_d.assign(copy_a.weights_d) &&
	  targets_d.assign(copy_a.targets_d) &&
	  vectors_d.assign(copy_a.vectors_d) &&
	  bias_d.assign(copy_a.bias_d) &&
	  inv_hessian_d.assign(copy_a.inv_hessian_d));
}

// method: eq
//
// arguments:
//  const RelevanceVectorMachine& arg: (input) item to check
//
// return: boolean value indicating equality
//
// this method checks for equality
//
boolean RelevanceVectorMachine::eq(const RelevanceVectorMachine& arg_a) const {

  // check each element for equality
  //
  return (kernel_d.eq(arg_a.kernel_d) &&
	  weights_d.eq(arg_a.weights_d) &&
	  targets_d.eq(arg_a.targets_d) &&
	  vectors_d.eq(arg_a.vectors_d) &&
	  bias_d.eq(arg_a.bias_d) &&
	  inv_hessian_d.eq(arg_a.inv_hessian_d));
}

// method: clear
//
// arguments:
//  Integral::CMODE ctype: (input) clear mode
//
// return: a boolean value indicating status
//
// this method resets the data members to the default values
//
boolean RelevanceVectorMachine::clear(Integral::CMODE ctype_a) {

  kernel_d.clear(ctype_a);
  weights_d.clear(ctype_a);
  targets_d.clear(ctype_a);
  vectors_d.clear(ctype_a);
  bias_d.clear(ctype_a);
  inv_hessian_d.clear(ctype_a);
  
  // exit gracefully
  //
  return true;
}

//-----------------------------------------------------------------------------
//
// we define non-integral constants in the default constructor
//
//-----------------------------------------------------------------------------

// constants: required constants such as the class name
//
const String RelevanceVectorMachine::CLASS_NAME(L"RelevanceVectorMachine");

// constants: NameMap(s) for the enumerated values
//
const NameMap RelevanceVectorMachine::ALGO_MAP(L"FULL,ITERATIVE_REFINEMENT,TIPPING_CONSTRUCTIVE");
const NameMap RelevanceVectorMachine::IMPL_MAP(L"LINEAR, POLYNOMIAL, RBF, SIGMOID");
const NameMap RelevanceVectorMachine::TYPE_MAP(L"TEXT, BINARY");

// constants: i/o related constants
//
const String RelevanceVectorMachine::DEF_PARAM(L"");
const String RelevanceVectorMachine::PARAM_BIAS(L"bias");
const String RelevanceVectorMachine::PARAM_WEIGHTS(L"weights");
const String RelevanceVectorMachine::PARAM_INV_HESSIAN(L"inv_hessian");
const String RelevanceVectorMachine::PARAM_TARGETS(L"targets");
const String RelevanceVectorMachine::PARAM_VECTORS(L"vectors");
const String RelevanceVectorMachine::PARAM_KERNEL(L"kernel");

const String RelevanceVectorMachine::DEF_COMMENT_TAG(L"#");

const String RelevanceVectorMachine::PARAM_POLYNOMIAL_DEGREE(L"polynomial_degree");
const String RelevanceVectorMachine::PARAM_AUDIO_DB(L"audio_database");
const String RelevanceVectorMachine::PARAM_OUTPUT_TYPE(L"output_type");
const String RelevanceVectorMachine::PARAM_OUTPUT_FILE(L"output_file");
const String RelevanceVectorMachine::PARAM_RBF_GAMMA(L"rbf_gamma");
const String RelevanceVectorMachine::PARAM_SIGMOID_KAPPA(L"sigmoid_kappa");
const String RelevanceVectorMachine::PARAM_SIGMOID_DELTA(L"sigmoid_delta");
const String RelevanceVectorMachine::PARAM_ALGORITHM(L"algorithm");
const String RelevanceVectorMachine::PARAM_IMPLEMENTATION(L"implementation");
const String RelevanceVectorMachine::PARAM_ALPHA_THRESH(L"alpha_thresh");
const String RelevanceVectorMachine::PARAM_MIN_ALLOWED_WEIGHT(L"min_weight");
const String RelevanceVectorMachine::PARAM_MAX_RVM_ITS(L"max_rvm_its");
const String RelevanceVectorMachine::PARAM_MAX_UPDATE_ITS(L"max_update_its");
const String RelevanceVectorMachine::PARAM_MIN_THETA(L"min_theta");
const String RelevanceVectorMachine::PARAM_MOMENTUM(L"momentum");
const String RelevanceVectorMachine::PARAM_MAX_ADDITIONS(L"max_additions");

// static instantiations: memory manager and a permanent scratch space
//
MemoryManager RelevanceVectorMachine::mgr_d(sizeof(RelevanceVectorMachine), RelevanceVectorMachine::CLASS_NAME);
Integral::DEBUG RelevanceVectorMachine::debug_level_d = Integral::NONE;
Integral::DEBUG RelevanceVectorMachine::verbosity_d = Integral::NONE;
