예제 #1
0
void LibSVMRunner::arma_prediction(SVMConfiguration& config) {
	struct svm_model* m;
	struct svm_node ** train;
	svm_parameter *params;
	int training_examples = config.getDataExamplesNumber();

	params = configuration_to_problem(config);
	m = load_model_from_config(config, params);

//	TODO: READ MODEL FROM PARAMETERS
	if(config.isSparse()) {
        train = ArmaSpMatToSvmNode(config.sparse_data);
	} else {
		train = armatlib(config.data);
	}
	double* ret = Malloc(double, training_examples);

	for (int i = 0; i < training_examples; i++)
		ret[i] = svm_predict(m, train[i],config.log);

	arma::vec ret_vec(ret, training_examples);
	config.result = ret_vec;
	/* TODO: CLEAN MEMORY IN BETTER WAY THINK OF OTHER PARAMETERS
	 * Clean memory:
	 * -array matrix
	 * -model
	 */
	for (int i = 0; i < training_examples; i++)
		free(train[i]);
	free(train);
	//TODO: THIS SHOULD WORK WITH PREDICTIONS 2X, now it's not working
//	svm_free_and_destroy_model(&m);
	svm_destroy_param(params,config.log);
	free(ret);
}
std::vector<std::string> 
planning_models::KinematicModel::getChildJointModelNames(const KinematicModel::JointModel *parent) const
{
  std::vector<const KinematicModel::JointModel*> joints;
  getChildJointModels(parent,joints);
  std::vector<std::string> ret_vec(joints.size());
  for(unsigned int i = 0; i < joints.size(); i++) {
    ret_vec[i] = joints[i]->getName();
  }
  return ret_vec;
}
std::vector<std::string> 
planning_models::KinematicModel::getChildLinkModelNames(const KinematicModel::JointModel *parent) const
{
  std::vector<const KinematicModel::LinkModel*> links;
  getChildLinkModels(parent,links);
  std::vector<std::string> ret_vec(links.size());
  for(unsigned int i = 0; i < links.size(); i++) {
    ret_vec[i] = links[i]->getName();
  }
  return ret_vec;
}
std::vector< String > ServerConnection::getItemsList( OPCBROWSEFILTER type, const String& from_branch, const String& name_filter, const String& vendor_filter )
{
	FRL_EXCEPT_GUARD();
	checkIsConnect();
	ComPtr<IOPCBrowse> br_ptr;
	getInterface( IID_IOPCBrowse, br_ptr );
	LPWSTR item_id = util::duplicateString( unicodeCompatibility( from_branch ) );
	LPWSTR cont_pint = NULL;
	LPWSTR name_filter_str = util::duplicateString( unicodeCompatibility( name_filter ) );
	LPWSTR vendor_filter_str = util::duplicateString( unicodeCompatibility( vendor_filter ) );
	DWORD *property_ids = os::win32::com::allocMemory<DWORD>();
	DWORD count;
	OPCBROWSEELEMENT *browse_elements;
	BOOL m = FALSE;
	HRESULT val = br_ptr->Browse( item_id, &cont_pint, 0, type, name_filter_str, vendor_filter_str, FALSE, FALSE, 0, property_ids, &m, &count, &browse_elements );
	if( FAILED( val ) )
	{
		os::win32::com::freeMemory( property_ids );
		os::win32::com::freeMemory( item_id );
		os::win32::com::freeMemory( name_filter_str );
		os::win32::com::freeMemory( vendor_filter_str );
		FRL_THROW_OPC( val );
	}

	std::vector< String > ret_vec( count );
	for( DWORD i = 0; i < count; ++i )
	{
		ret_vec[i] = similarCompatibility( browse_elements[i].szName );
		os::win32::com::freeMemory( browse_elements[i].szName );
		os::win32::com::freeMemory( browse_elements[i].szItemID );
		os::win32::com::freeMemory( browse_elements[i].ItemProperties.pItemProperties );
	}
	os::win32::com::freeMemory( property_ids );
	os::win32::com::freeMemory( item_id );
	os::win32::com::freeMemory( name_filter_str );
	os::win32::com::freeMemory( vendor_filter_str );
	os::win32::com::freeMemory( browse_elements );
	return ret_vec;
}
예제 #5
0
Vector_double stfio::vec_vec_div(const Vector_double& vec1, const Vector_double& vec2) {
    Vector_double ret_vec(vec1.size());
    std::transform(vec1.begin(), vec1.end(), vec2.begin(), ret_vec.begin(), std::divides<double>());
    return ret_vec;
}
예제 #6
0
Vector_double stfio::vec_scal_div(const Vector_double& vec, double scalar) {
    Vector_double ret_vec(vec.size(), scalar);
    std::transform(vec.begin(), vec.end(), ret_vec.begin(), ret_vec.begin(), std::divides<double>());
    return ret_vec;
}