Index: /bdm/user_info.h
===================================================================
--- /bdm/user_info.h (revision 351)
+++ /bdm/user_info.h (revision 357)
@@ -1,21 +1,14 @@
-#ifndef UIBUILD
-#define UIBUILD
-
-
-#include <sstream>
-#include <iostream>
+#ifndef USER_INFO_H
+#define USER_INFO_H
+
 #include <stdio.h>
 #include <string>
 #include <typeinfo>
 #include <map>
-#include <utility>
-#include <vector>
-#include <iostream>
 
 #include "libconfig/libconfig.h++"
-
-#include <itpp/itbase.h>
-
-#include "stat/libBM.h"
+#include "bdmroot.h"
+#include "itpp/itbase.h"
+
 
 using std::string;
@@ -35,12 +28,12 @@
 
 public:
-	//! attach new RootElement instance to a file (typically with an XML extension)
+	//! create empty object prepared to store Settings
+	UI_File();
+
+	//! creates object and fills it from a file
 	UI_File( const string &file_name );
 
-	//! loads root element from a file
-	void load();
-
-	//! save UserInfo to the file (typically with an XML extension)
-	void save();
+	//! save UserInfo to the file 
+	void save(const string &file_name);
 
 	operator Setting&();
@@ -141,11 +134,7 @@
 	//! and build DOM tree accordingly. Then, it creates a new DOMNode named according class_name
 	//! and connecti it to the passed Setting as a new child node.
-	static const Setting* pointer_to_child_setting( const Setting &element, const int index );
-
-	static const Setting* pointer_to_child_setting( const Setting &element, const string &name );
-
-	static const Setting& reference_to_child_setting( const Setting &element, const int index );
-
-	static const Setting& reference_to_child_setting( const Setting &element, const string &name );
+	static const Setting& to_child_setting( const Setting &element, const int index );
+
+	static const Setting& to_child_setting( const Setting &element, const string &name );
 
 
@@ -153,8 +142,10 @@
 	static void from_setting( mat& matrix, const Setting &element );	
 	//! This methods tries to build a new integer vector
-	static void from_setting( ivec &vec, const Setting &element );
+	static void from_setting( ivec &vector, const Setting &element );
 	// jednak kvuli pretypovani, apak taky proto, ze na string nefunguje link_expander..
 	static void from_setting( string &str, const Setting &element );
 	//! This methods tries to build a new templated array 
+
+	static void from_setting( vec &vector, const Setting &element );
 
 	template<class T> static void from_setting( T* &instance, const Setting &element )
@@ -213,4 +204,6 @@
 	}
 
+	static void ui_error( string message, const Setting &element );
+
 protected:
 	//! default constructor 
@@ -223,16 +216,8 @@
 	virtual ~UI(){};
 
-
 public: 
-	static void ui_error( string message, const Setting &element )
-	{
-		stringstream error_message;
-		error_message << "UI ui_error: " << message << "! Check path """ << element.getPath() << """, source line " << element.getSourceLine() << ".";
-		it_error ( error_message.str() );
-	}
-
 	//! This methods tries to build a new instance of type T (or some of its descendant types)
 	//! according to a data stored in a DOMNode named class_name within a child nodes of the passed element.
-	//! If an ui_error occurs, it returns a NULL pointer.
+	//! If an error occurs, it returns a NULL pointer.
 
 	//! Prototype of a UI builder. Return value is by the second argument since it type checking via \c dynamic_cast.
@@ -240,5 +225,5 @@
 	{
 		T* instance;
-		from_setting<T>( reference_to_child_setting( element, index ) );
+		from_setting<T>( to_child_setting( element, index ) );
 		return instance;
 	}
@@ -247,42 +232,30 @@
 	{			
 		T* instance;
-		from_setting<T>( instance, reference_to_child_setting( element, name ) );
+		from_setting<T>( instance, to_child_setting( element, name ) );
 		return instance;
 	}
 
 	//! This methods tries to build a new double matrix 
-	template<class T> static bool get( T &instance, const Setting &element, const string &name )
-	{
-		const Setting *root = pointer_to_child_setting( element, name );
-		if( !root ) return false;				
-		from_setting( instance, *root );
-		return true;
-	}
-
-	//! This methods tries to build a new double matrix 
-	template<class T> static bool get( T &instance, const Setting &element, const int index )
-	{
-		const Setting *root = pointer_to_child_setting( element, index );
-		if( !root ) return false;				
-		from_setting( instance, *root );
-		return true;
-	}
-
-	//! This methods tries to build a new double matrix 
-	template<class T> static bool get( Array<T> &array_to_load, const Setting &element, const string &name )
-	{
-		const Setting *root = pointer_to_child_setting( element, name );
-		if( !root ) return false;				
-		from_setting( array_to_load, *root );
-		return true;
-	}
-
-	//! This methods tries to build a new double matrix 
-	template<class T> static bool get( Array<T> &array_to_load, const Setting &element, const int index )
-	{
-		const Setting *root = pointer_to_child_setting( element, index );
-		if( !root ) return false;				
-		from_setting( array_to_load, *root );
-		return true;
+	template<class T> static void get( T &instance, const Setting &element, const string &name )
+	{
+		from_setting( instance, to_child_setting( element, name ) );
+	}
+
+	//! This methods tries to build a new double matrix 
+	template<class T> static void get( T &instance, const Setting &element, const int index )
+	{
+		from_setting( instance, to_child_setting( element, index ) );
+	}
+
+	//! This methods tries to build a new double matrix 
+	template<class T> static void get( Array<T> &array_to_load, const Setting &element, const string &name )
+	{
+		from_setting( array_to_load, to_child_setting( element, name ) );
+	}
+
+	//! This methods tries to build a new double matrix 
+	template<class T> static void get( Array<T> &array_to_load, const Setting &element, const int index )
+	{
+		from_setting( array_to_load, to_child_setting( element, index ) );
 	}
 
@@ -325,4 +298,6 @@
 	static void save( const ivec &vec, Setting &element, const string &name = "" );
 	
+	static void save( const vec &vector, Setting &element, const string &name);
+
 	private: 
 	//! This methods tries to save a double vec 
@@ -385,3 +360,3 @@
 */
 
-#endif // #ifndef UIBUILD
+#endif // #ifndef USER_INFO_H
Index: /bdm/estim/arx.h
===================================================================
--- /bdm/estim/arx.h (revision 286)
+++ /bdm/estim/arx.h (revision 357)
@@ -116,5 +116,32 @@
 	}
 	//!@}
+
+	// TODO dokumentace - aktualizovat
+	/*! UI for ARX estimator
+
+	The ARX is constructed from a structure with fields:
+	\code
+	estimator = {
+		type = "ARX";
+		y = {type="rv", ...}   // description of output variables
+		rgr = {type="rv", ...} // description of regressor variables
+		constant = true;       // boolean switch if the constant term is modelled or not
+
+		//optional fields
+		dV0 = [1e-3, 1e-5, 1e-5, 1e-5]; 
+							   // default: 1e-3 for y, 1e-5 for rgr
+		nu0 = 6;               // default: rgrlen + 2
+		frg = 1.0;             // forgetting, default frg=1.0
+	};
+	\endcode
+
+	The estimator will assign names of the posterior in the form ["theta_i" and "r_i"]
+	*/
+	void from_setting( const Setting &root );
+
+	// TODO dodelat void to_setting( Setting &root ) const;
 };
+
+UIREGISTER(ARX);
 
 }
Index: /bdm/estim/libKF.cpp
===================================================================
--- /bdm/estim/libKF.cpp (revision 348)
+++ /bdm/estim/libKF.cpp (revision 357)
@@ -1,4 +1,5 @@
 
 #include "libKF.h"
+#include "..\user_info.h"
 
 namespace bdm{
@@ -250,3 +251,82 @@
 }
 
-}
+void EKFCh::from_setting( const Setting &root ) 
+{	
+	diffbifn* IM = UI::build<diffbifn>(root, "IM");
+	diffbifn* OM = UI::build<diffbifn>(root, "OM");
+	
+	//statistics
+	int dim=IM->dimension();
+	vec mu0;
+	if(root.exists("mu0"))
+		UI::get( mu0, root, "mu0");
+	else
+		mu0=zeros(dim);
+
+	mat P0;
+	if(root.exists("dP0"))
+	{
+		vec dP0;
+		UI::get( dP0, root, "dP0");
+		P0=diag(dP0);
+	}
+	else if ( root.exists( "P0" ) )
+		UI::get(P0, root, "P0");
+	else
+		P0=eye(dim);
+	
+	set_statistics(mu0,P0);
+	
+	//parameters
+	vec dQ, dR;
+	UI::get( dQ, root, "dQ");
+	UI::get( dR, root, "dR");
+	set_parameters(IM, OM, diag(dQ), diag(dR));
+
+	//connect
+	RV* drv = UI::build<RV>(root, "drv");
+	set_drv(*drv);
+	RV* rv = UI::build<RV>(root, "rv");
+	set_rv(*rv);
+	
+	string options;
+	if(root.lookupValue( "options", options ))
+		set_options(options);	
+}
+
+/*void EKFCh::to_setting( Setting &root ) const
+{	
+	Transport::to_setting( root );
+
+	Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+	kilometers_setting = kilometers;
+
+	UI::save( passengers, root, "passengers" );
+}*/
+
+void MultiModel::from_setting( const Setting &root ) 
+{	
+	Array<EKFCh*> A;
+	UI::get( A, root, "models");
+	
+	set_parameters(A);
+	set_drv(A(0)->_drv());
+	//set_rv(A(0)->_rv());
+
+	string options;
+	if(root.lookupValue( "options", options ))
+		set_options(options);	
+}
+
+/*void MultiModel::to_setting( Setting &root ) const
+{	
+	Transport::to_setting( root );
+
+	Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+	kilometers_setting = kilometers;
+
+	UI::save( passengers, root, "passengers" );
+}*/
+
+
+}
Index: /bdm/estim/arx.cpp
===================================================================
--- /bdm/estim/arx.cpp (revision 286)
+++ /bdm/estim/arx.cpp (revision 357)
@@ -1,3 +1,4 @@
 #include "arx.h"
+#include "..\user_info.h"
 
 namespace bdm {
@@ -194,3 +195,51 @@
 }
 
-}
+void ARX::from_setting( const Setting &root ) 
+{	
+	RV *yrv = UI::build<RV>(root,"y");
+	RV *rrv = UI::build<RV>(root,"rgr");
+	int ylen = yrv->_dsize();
+	int rgrlen = rrv->_dsize();
+	
+	//init
+	mat V0;
+	if( root.exists("dV0") )
+	{
+		vec dV0;
+		UI::get( dV0, root, "dV0" );
+		V0=diag ( dV0 );
+	}
+	else
+		V0=concat ( 1e-3*ones ( ylen ), 1e-5*ones ( rgrlen ) );
+	
+	double nu0;
+	if ( !root.lookupValue( "nu0", nu0 ) ) 
+		nu0 = rgrlen+ylen+2;
+
+	double frg;
+	if ( !root.lookupValue( "frg", frg ) ) 
+		frg = 1.0;
+
+	set_parameters(frg);
+	set_statistics(ylen,V0, nu0);
+	set_drv(concat(*yrv,*rrv));
+	
+	//name results (for logging)
+	set_rv(RV("{theta r }", vec_2(ylen*rgrlen, ylen*ylen)));
+	
+	delete yrv; 
+	delete rrv;
+}
+
+/*void ARX::to_setting( Setting &root ) const
+{	
+	Transport::to_setting( root );
+
+	Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+	kilometers_setting = kilometers;
+
+	UI::save( passengers, root, "passengers" );
+}*/
+
+
+}
Index: /bdm/estim/libKF.h
===================================================================
--- /bdm/estim/libKF.h (revision 338)
+++ /bdm/estim/libKF.h (revision 357)
@@ -258,5 +258,13 @@
 			//! Here dt = [yt;ut] of appropriate dimensions
 			void bayes ( const vec &dt );
-	};
+
+			void from_setting( const Setting &root );
+
+			// TODO dodelat void to_setting( Setting &root ) const;
+
+	};
+
+	UIREGISTER(EKFCh);
+
 
 	/*!
@@ -447,5 +455,13 @@
 				//all posterior densities are equal => return the first one
 			const enorm<chmat>& posterior() const {return est;}
-	};
+
+			void from_setting( const Setting &root );
+
+			// TODO dodelat void to_setting( Setting &root ) const;
+
+	};
+
+	UIREGISTER(MultiModel);
+
 
 
Index: /bdm/bdmroot.cpp
===================================================================
--- /bdm/bdmroot.cpp (revision 357)
+++ /bdm/bdmroot.cpp (revision 357)
@@ -0,0 +1,6 @@
+#include "bdmroot.h"
+
+//! Space of basic BDM structures
+namespace bdm
+{
+}
Index: /bdm/bdmroot.h
===================================================================
--- /bdm/bdmroot.h (revision 357)
+++ /bdm/bdmroot.h (revision 357)
@@ -0,0 +1,59 @@
+/*!
+  \file
+  \brief Bayesian Models (bm) that use Bayes rule to learn from observations
+  \author Vaclav Smidl.
+
+  -----------------------------------
+  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
+
+  Using IT++ for numerical operations
+  -----------------------------------
+*/
+
+#ifndef BDMROOT_H
+#define BDMROOT_H
+
+#include <string>
+
+#include "itpp_ext.h"
+#include "libconfig/libconfig.h++"
+
+using namespace libconfig;
+using namespace itpp;
+using namespace std;
+
+namespace bdm {
+
+//! Root class of BDM objects
+class bdmroot {
+public:
+	//! make sure this is a virtual object
+	virtual ~bdmroot() 
+	{
+	}
+
+	//! This method returns a basic info about the current instance
+	virtual string to_string()
+	{
+		return "";
+	}
+
+	//! This method arrange instance properties according the data stored in the Setting structure
+	virtual void from_setting( const Setting &root )
+	{
+	}
+
+	//! This method save all the instance properties into the Setting structure 
+	virtual void to_setting( Setting &root ) const
+	{	
+	}
+
+	//! This method TODO
+	virtual void validate()
+	{
+	}
+
+};
+
+}; //namespace
+#endif // BDMROOT_H
Index: /bdm/user_info.cpp
===================================================================
--- /bdm/user_info.cpp (revision 351)
+++ /bdm/user_info.cpp (revision 357)
@@ -13,5 +13,6 @@
 #include "user_info.h"
 
-namespace bdm {
+namespace bdm
+{
 
 
@@ -19,45 +20,46 @@
 
 
-UI_File::UI_File ( const string &file_name ) : file_name( file_name )
-{
-	setAutoConvert( true );
+UI_File::UI_File ()
+{
+    setAutoConvert( true );
 }
 
 //! loads root element from a file
-void UI_File::load() 
-{
-	try
-	{
-		readFile( file_name.c_str()  );
-	}
-	catch ( FileIOException f ) 
-	{
-		it_error ( "UI error: file " + file_name + " not found." );
-	}
-	catch ( ParseException& P ) 
-	{
-		stringstream msg;
-		msg << "UI error: parsing ui_error """ << P.getError() << """ in file " << file_name << " on line " <<  P.getLine() << ".";
-		it_error ( msg.str() );
-	}	
+UI_File::UI_File ( const string &file_name )
+{
+    setAutoConvert( true );
+    try
+    {
+        readFile( file_name.c_str()  );
+    }
+    catch ( FileIOException f )
+    {
+        it_error ( "UI error: file " + file_name + " not found." );
+    }
+    catch ( ParseException& P )
+    {
+        stringstream msg;
+        msg << "UI error: parsing error """ << P.getError() << """ in file " << file_name << " on line " <<  P.getLine() << ".";
+        it_error ( msg.str() );
+    }
 }
 
 
 //! save UserInfo to the file (typically with an XML extension)
-void UI_File::save()
-{
-	try
-	{
-		writeFile ( file_name.c_str()  );
-	}
-	catch ( FileIOException f ) 
-	{
-		it_error( "UI error: file " + file_name + " is inacessible." );
-	}		
-}	
+void UI_File::save(  const string &file_name )
+{
+    try
+    {
+        writeFile ( file_name.c_str()  );
+    }
+    catch ( FileIOException f )
+    {
+        it_error( "UI error: file " + file_name + " is inacessible." );
+    }
+}
 
 UI_File::operator Setting&()
 {
-	return getRoot();
+    return getRoot();
 }
 ///////////////////////// INTERNAL MAPPED_UI /////////////////////////////////////////////
@@ -65,36 +67,36 @@
 UI::Mapped_UI::String_To_UI_Map& UI::Mapped_UI::mapped_strings()
 {
-	static String_To_UI_Map var;
-	return var;
+    static String_To_UI_Map var;
+    return var;
 }
 
 UI::Mapped_UI::Type_Info_To_String_Map& UI::Mapped_UI::mapped_type_infos()
 {
-	static Type_Info_To_String_Map var;
-	return var;
+    static Type_Info_To_String_Map var;
+    return var;
 }
 
 void UI::Mapped_UI::add_class( const string &class_name, const type_info * const class_type_info, const UI* const ui )
 {
-	pair< const string, const UI* const > new_pair = make_pair( class_name, ui );
-	mapped_strings().insert( new_pair );
-	mapped_type_infos().insert( make_pair( class_type_info, new_pair.first ) );
+    pair< const string, const UI* const > new_pair = make_pair( class_name, ui );
+    mapped_strings().insert( new_pair );
+    mapped_type_infos().insert( make_pair( class_type_info, new_pair.first ) );
 }
 
 const UI& UI::Mapped_UI::retrieve_ui( const string &class_name )
 {
-	String_To_UI_Map::const_iterator iter = mapped_strings().find( class_name );
-	if( iter == mapped_strings().end()) 
-		it_error ( "UI error: class " + class_name + " was not properly registered. Use the macro ""UIREGISTER([class name]);"" within your code." );
-	return *iter->second;
-}	
+    String_To_UI_Map::const_iterator iter = mapped_strings().find( class_name );
+    if ( iter == mapped_strings().end())
+        it_error ( "UI error: class " + class_name + " was not properly registered. Use the macro ""UIREGISTER([class name]);"" within your code." );
+    return *iter->second;
+}
 
 const string& UI::Mapped_UI::retrieve_class_name( const type_info * const class_type_info )
 {
-	Type_Info_To_String_Map::const_iterator iter = mapped_type_infos().find( class_type_info );
-	if( iter == mapped_type_infos().end()) 
-		it_error ( "UI error: class with RTTI name " + string(class_type_info->name()) + " was not properly registered. Use the macro ""UIREGISTER([class name]);"" within your code." );
-	return iter->second;
-}	
+    Type_Info_To_String_Map::const_iterator iter = mapped_type_infos().find( class_type_info );
+    if ( iter == mapped_type_infos().end())
+        it_error ( "UI error: class with RTTI name " + string(class_type_info->name()) + " was not properly registered. Use the macro ""UIREGISTER([class name]);"" within your code." );
+    return iter->second;
+}
 
 ///////////////////////// INTERNAL LINK EXPANDER /////////////////////////////////////////////
@@ -102,206 +104,291 @@
 UI::Link_Expander::Link_Expander( const Setting &potential_link )
 {
-	file = NULL;
-	result = &potential_link;
-
-	if( potential_link.getType() !=  Setting::TypeString )
-		return;
-
-	string link = (string) potential_link;
-	size_t aerobase = link.find('@');
-	if( aerobase != string::npos )
-	{
-		string file_name = link.substr( aerobase + 1, link.length() );
-		file = new UI_File( file_name );
-		file->load();
-		result = &(Setting&)(*file);
-		link = link.substr( 0, aerobase );
-	}
-	else
-		while ( !result->isRoot() ) 
-			result = &result->getParent();
-
-	if( !result->exists( link ) )
-		ui_error( "linked Setting was not found", potential_link );
-
-	result = &(*result)[link];
+    file = NULL;
+    result = &potential_link;
+
+    if ( potential_link.getType() !=  Setting::TypeString )
+        return;
+
+    string link = (string) potential_link;
+    size_t aerobase = link.find('@');
+    if ( aerobase != string::npos )
+    {
+        string file_name = link.substr( aerobase + 1, link.length() );
+        file = new UI_File( file_name );
+        result = &(Setting&)(*file);
+        link = link.substr( 0, aerobase );
+    }
+    else
+        while ( !result->isRoot() )
+            result = &result->getParent();
+
+    if ( !result->exists( link ) )
+        ui_error( "linked Setting was not found", potential_link );
+
+    result = &(*result)[link];
 }
 
 UI::Link_Expander::~Link_Expander()
 {
-	if( file ) delete file;
+    if ( file ) delete file;
 }
 
 const Setting& UI::Link_Expander::root() const
 {
-	return *result;
+    return *result;
 }
 
 ///////////////////////// UI /////////////////////////////////////////////
 
-
-
-//! This methods   - kvuli ukladani pole stringu, dat jen privatne?
+void UI::ui_error( string message, const Setting &element )
+{
+    stringstream error_message;
+    error_message << "UI error: " << message << "! Check path """ << element.getPath() << """, source line " << element.getSourceLine() << ".";
+    it_error ( error_message.str() );
+}
+
+//! This methods - kvuli ukladani pole stringu, dat jen privatne?
 void UI::save( const string &str, Setting &element )
 {
-	Setting &root = element.add( Setting::TypeString );
-	root = str;
+    Setting &root = element.add( Setting::TypeString );
+    root = str;
 }
 
 void UI::save( const mat &matrix, Setting &element, const string &name)
 {
-	
-	Setting &root = (name == "") ? element.add( Setting::TypeList )							
-								 : element.add( name, Setting::TypeList );		
-
-	Setting &cols = root.add( Setting::TypeInt );
-	cols = matrix.cols();
-
-	Setting &rows = root.add( Setting::TypeInt );
-	rows = matrix.rows();
-
-	Setting &elements = root.add( Setting::TypeArray );
-
-	// build matrix row-wise
-	for( int i=0; i<matrix.rows(); i++ ) 
-		for( int j=0; j<matrix.cols(); j++)
-		{
-			Setting &new_field = elements.add(Setting::TypeFloat);
-			new_field = matrix(i,j);
-		}
-}
-
-
-	//! This methods tries to save a double vec 
-void UI::save( const ivec &vec, Setting &element, const string &name)
-{
-	
-	Setting &root = (name == "") ? element.add( Setting::TypeArray )							
-								 : element.add( name, Setting::TypeArray );		
-	for( int i=0; i<vec.length(); i++ ) 
-	{
-		Setting &new_field = root.add(Setting::TypeInt);
-		new_field = vec(i);
-	}
-}
-
-
-//! This methods tries to build a new double matrix 
+
+    Setting &root = (name == "") ? element.add( Setting::TypeList )
+                    : element.add( name, Setting::TypeList );
+
+    Setting &cols = root.add( Setting::TypeInt );
+    cols = matrix.cols();
+
+    Setting &rows = root.add( Setting::TypeInt );
+    rows = matrix.rows();
+
+    Setting &elements = root.add( Setting::TypeArray );
+
+    // build matrix row-wise
+    for ( int i=0; i<matrix.rows(); i++ )
+        for ( int j=0; j<matrix.cols(); j++)
+        {
+            Setting &new_field = elements.add(Setting::TypeFloat);
+            new_field = matrix(i,j);
+        }
+}
+
+
+//! This methods tries to save a integer vector
+void UI::save( const ivec &vector, Setting &element, const string &name)
+{
+
+    Setting &root = (name == "") ? element.add( Setting::TypeArray )
+                    : element.add( name, Setting::TypeArray );
+    for ( int i=0; i<vector.length(); i++ )
+    {
+        Setting &new_field = root.add(Setting::TypeInt);
+        new_field = vector(i);
+    }
+}
+
+
+//! This methods tries to save a double vector
+void UI::save( const vec &vector, Setting &element, const string &name)
+{
+
+    Setting &root = (name == "") ? element.add( Setting::TypeArray )
+                    : element.add( name, Setting::TypeArray );
+    for ( int i=0; i<vector.length(); i++ )
+    {
+		Setting &new_field = root.add(Setting::TypeFloat);
+        new_field = vector(i);
+    }
+}
+
+
+//! This methods tries to build a new double matrix
 
 void UI::from_setting( mat& matrix, const Setting &element )
 {
-	const Link_Expander link_expander( element );
-	const Setting &root = link_expander.root();
-
-	if( root.isNumber() )
-	{
-		matrix.set_size( 1, 1 );
-		matrix(0,0) = root;
-		return;
-	}
-
-	if( root.isList() )
-	{
-		if( root.getLength() != 3 )
-			ui_error( "the setting supposed to represent a matrix element has wrong syntax", root );
-
-		Setting &cols_setting = root[0];
-		Setting &rows_setting = root[1];
-		Setting &elements = root[2];
-
-		ASSERT_UITYPE(cols_setting,TypeInt);
-		ASSERT_UITYPE(rows_setting,TypeInt);
-		ASSERT_UITYPE(elements,TypeArray);
-
-		int cols = cols_setting;
-		int rows = rows_setting;
-					
-		if( cols < 0 | rows < 0 )
-			ui_error( "the dimensions of a matrix has to be non-negative", root );
-
-		if( elements.getLength() != cols * rows )
-			ui_error( "the count of the matrix elements is incompatible with matrix dimension", elements );
-
-		matrix.set_size( rows, cols );
-
-		if( cols == 0 || rows == 0 )
-			return;
-
-		if( !elements[0].isNumber() )
-			ui_error( "matrix elements have to be numbers", elements[0] );
-
-		// build matrix row-wise
-		int k = 0;
-		for( int i=0;i<rows;i++ ) 
-			for( int j=0; j<cols; j++)
-				matrix(i,j) = elements[k++];
-		return;
-	}
-
-	ui_error( "only numeric types or TypeList are supported as matrix values", root );
+    const Link_Expander link_expander( element );
+    const Setting &root = link_expander.root();
+
+    if ( root.isNumber() )
+    {
+        matrix.set_size( 1, 1 );
+        matrix(0,0) = root;
+        return;
+    }
+
+    if ( root.isList() )
+    {
+        if ( root.getLength() != 3 )
+            ui_error( "the setting supposed to represent a matrix element has wrong syntax", root );
+
+        Setting &rows_setting = root[0];
+        Setting &cols_setting = root[1];
+        Setting &elements = root[2];
+
+        ASSERT_UITYPE(cols_setting,TypeInt);
+        ASSERT_UITYPE(rows_setting,TypeInt);
+        ASSERT_UITYPE(elements,TypeArray);
+
+        int cols = cols_setting;
+        int rows = rows_setting;
+
+        if ( cols < 0 | rows < 0 )
+            ui_error( "the dimensions of a matrix has to be non-negative", root );
+
+        if ( elements.getLength() != cols * rows )
+            ui_error( "the count of the matrix elements is incompatible with matrix dimension", elements );
+
+        matrix.set_size( rows, cols );
+
+        if ( cols == 0 || rows == 0 )
+            return;
+
+        if ( !elements[0].isNumber() )
+            ui_error( "matrix elements have to be numbers", elements[0] );
+
+        // build matrix row-wise
+        int k = 0;
+        for ( int i=0; i<rows; i++ )
+            for ( int j=0; j<cols; j++)
+                matrix(i,j) = elements[k++];
+        return;
+    }
+
+    ui_error( "only numeric types or TypeList are supported as matrix values", root );
 }
 
 //! This methods tries to build a new integer vector
-void UI::from_setting( ivec &vec, const Setting &element )
-{
-	const Link_Expander link_expander( element );
-	const Setting &root = link_expander.root();
-
-	if( root.isNumber() )
-	{
-		ASSERT_UITYPE(root,TypeInt);
-		vec.set_length( 1 );
-		vec(0) = root;
-		return;
-	}
-
-	if( root.isList() )
-	{
-		if( root.getLength() != 3 )
-			ui_error( "the setting supposed to represent a matrix element has wrong syntax", root );
-
-		Setting &cols_setting = root[0];
-		Setting &rows_setting = root[1];
-		Setting &elements = root[2];
-
-		ASSERT_UITYPE(cols_setting,TypeInt);
-		ASSERT_UITYPE(rows_setting,TypeInt);
-		ASSERT_UITYPE(elements,TypeArray);
-
-		int cols = cols_setting;
-		int rows = rows_setting;
-		
-		if( cols < 0 | rows < 0)
-			ui_error( "the dimensions of a matrix has to be non-negative", root );
-
-		if( elements.getLength() != cols * rows )
-			ui_error( "the count of the matrix elements is incompatible with matrix dimension", elements );
-
-		if( cols != 1 & rows !=1)
-			ui_error( "the vector length is invalid, it seems to be rather a matrix", elements );
-		
-		int len = rows * cols;
-		vec.set_length ( len );
-		if( len == 0 ) return;
-
-		ASSERT_UITYPE(elements[0],TypeInt);
-		for( int i=0; i<len; i++ ) 
-			vec(i) = elements[i];
-		return;
-	}
-
-	if( root.isArray() )
-	{	
-		int len = root.getLength();
-		vec.set_length( len );
-		if( len == 0 ) return;
-
-		ASSERT_UITYPE(root[0],TypeInt);
-		for( int i=0; i < len; i++ ) 
-			vec(i) = root[i];
-		return;
-	}
-
-	ui_error( "only numeric types, TypeArray or TypeList are supported as vector values", root );
+void UI::from_setting( ivec &vector, const Setting &element )
+{
+    const Link_Expander link_expander( element );
+    const Setting &root = link_expander.root();
+
+    if ( root.isNumber() )
+    {
+        ASSERT_UITYPE(root,TypeInt);
+        vector.set_length( 1 );
+        vector(0) = root;
+        return;
+    }
+
+    if ( root.isList() )
+    {
+        if ( root.getLength() != 3 )
+            ui_error( "the setting supposed to represent a matrix element has wrong syntax", root );
+
+        Setting &cols_setting = root[0];
+        Setting &rows_setting = root[1];
+        Setting &elements = root[2];
+
+        ASSERT_UITYPE(cols_setting,TypeInt);
+        ASSERT_UITYPE(rows_setting,TypeInt);
+        ASSERT_UITYPE(elements,TypeArray);
+
+        int cols = cols_setting;
+        int rows = rows_setting;
+
+        if ( cols < 0 | rows < 0)
+            ui_error( "the dimensions of a matrix has to be non-negative", root );
+
+        if ( elements.getLength() != cols * rows )
+            ui_error( "the count of the matrix elements is incompatible with matrix dimension", elements );
+
+        if ( cols != 1 & rows !=1)
+            ui_error( "the vector length is invalid, it seems to be rather a matrix", elements );
+
+        int len = rows * cols;
+        vector.set_length ( len );
+        if ( len == 0 ) return;
+
+        ASSERT_UITYPE(elements[0],TypeInt);
+        for ( int i=0; i<len; i++ )
+            vector(i) = elements[i];
+        return;
+    }
+
+    if ( root.isArray() )
+    {
+        int len = root.getLength();
+        vector.set_length( len );
+        if ( len == 0 ) return;
+
+        ASSERT_UITYPE(root[0],TypeInt);
+        for ( int i=0; i < len; i++ )
+            vector(i) = root[i];
+        return;
+    }
+
+    ui_error( "only numeric types, TypeArray or TypeList are supported as vector values", root );
+}
+
+//! This methods tries to build a new double vector
+void UI::from_setting( vec &vector, const Setting &element )
+{
+    const Link_Expander link_expander( element );
+    const Setting &root = link_expander.root();
+
+    if ( root.isNumber() )
+    {
+        vector.set_length( 1 );
+        vector(0) = root;
+        return;
+    }
+
+    if ( root.isList() )
+    {
+        if ( root.getLength() != 3 )
+            ui_error( "the setting supposed to represent a matrix element has wrong syntax", root );
+
+        Setting &cols_setting = root[0];
+        Setting &rows_setting = root[1];
+        Setting &elements = root[2];
+
+        ASSERT_UITYPE(cols_setting,TypeInt);
+        ASSERT_UITYPE(rows_setting,TypeInt);
+        ASSERT_UITYPE(elements,TypeArray);
+
+        int cols = cols_setting;
+        int rows = rows_setting;
+
+        if ( cols < 0 | rows < 0)
+            ui_error( "the dimensions of a matrix has to be non-negative", root );
+
+        if ( elements.getLength() != cols * rows )
+            ui_error( "the count of the matrix elements is incompatible with matrix dimension", elements );
+
+        if ( cols != 1 & rows !=1)
+            ui_error( "the vector length is invalid, it seems to be rather a matrix", elements );
+
+        int len = rows * cols;
+        vector.set_length ( len );
+        if ( len == 0 ) return;
+
+        if ( !elements[0].isNumber())
+            ui_error("a vector element has to be a number", elements[0]);
+
+        for ( int i=0; i<len; i++ )
+            vector(i) = elements[i];
+        return;
+    }
+
+    if ( root.isArray() )
+    {
+        int len = root.getLength();
+        vector.set_length( len );
+        if ( len == 0 ) return;
+
+        if ( !root[0].isNumber())
+            ui_error("a vector element has to be a number", root[0]);
+
+        for ( int i=0; i < len; i++ )
+            vector(i) = root[i];
+        return;
+    }
+
+    ui_error( "only numeric types, TypeArray or TypeList are supported as vector values", root );
 }
 
@@ -309,55 +396,33 @@
 void UI::from_setting( string &str, const Setting &element )
 {
-	ASSERT_UITYPE(element,TypeString);
-	str = (string) element;
+    ASSERT_UITYPE(element,TypeString);
+    str = (string) element;
 }
 
 
 ///////////////////////// UI FILE /////////////////////////////////////////////
-   	//! This methods tries to save an instance of type T (or some of its descendant types)
-	//! and build DOM tree accordingly. Then, it creates a new DOMNode named according class_name
-	//! and connecti it to the passed Setting as a new child node.
-const Setting* UI::pointer_to_child_setting( const Setting &element, const int index )
-{
-	if( !element.isList())
-		return NULL;
-
-	if( element.getLength() <= index )
-		return NULL;
-
-	return &element[index];
-}
-
-const Setting* UI::pointer_to_child_setting( const Setting &element, const string &name )
-{
-	if( !element.isGroup() )
-		return NULL;
-
-	if( !element.exists( name ) )
-		return NULL;
-
-	return &element[name];
-}
-
-const Setting& UI::reference_to_child_setting( const Setting &element, const int index )
-{
-	if( !element.isList())
-		ui_error( "only TypeList elements could be indexed by integers", element );
-
-	if( element.getLength() <= index )
-		ui_error( "there is not any child with index " + index, element );
-
-	return element[index];
-}
-
-const Setting& UI::reference_to_child_setting( const Setting &element, const string &name )
-{
-	ASSERT_UITYPE(element,TypeGroup);
-	if( !element.exists( name ) )
-		ui_error( "there is not any child named """ + name, element );
-	return element[name];
-}
-
-
-}
-
+//! This methods tries to save an instance of type T (or some of its descendant types)
+//! and build DOM tree accordingly. Then, it creates a new DOMNode named according class_name
+//! and connecti it to the passed Setting as a new child node.
+const Setting& UI::to_child_setting( const Setting &element, const int index )
+{
+    if ( !element.isList())
+        ui_error( "only TypeList elements could be indexed by integers", element );
+
+    if ( element.getLength() <= index )
+        ui_error( "there is not any child with index " + index, element );
+
+    return element[index];
+}
+
+const Setting& UI::to_child_setting( const Setting &element, const string &name )
+{
+    ASSERT_UITYPE(element,TypeGroup);
+    if ( !element.exists( name ) )
+        ui_error( "there is not any child named """ + name, element );
+    return element[name];
+}
+
+
+}
+
Index: /bdm/stat/libEF.cpp
===================================================================
--- /bdm/stat/libEF.cpp (revision 330)
+++ /bdm/stat/libEF.cpp (revision 357)
@@ -1,6 +1,7 @@
+#include <math.h>
 
 #include <itpp/base/bessel.h>
 #include "libEF.h"
-#include <math.h>
+#include "..\user_info.h"
 
 namespace bdm{
@@ -319,3 +320,40 @@
 }
 
+void migamma_ref::from_setting( const Setting &root ) 
+{				
+	vec ref;
+	UI::get( ref, root, "ref" );
+	set_parameters(root["k"],ref,root["l"]);
+}
+
+/*void migamma_ref::to_setting( Setting &root ) const
+{	
+	Transport::to_setting( root );
+
+	Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+	kilometers_setting = kilometers;
+
+	UI::save( passengers, root, "passengers" );
+}*/
+
+
+void mlognorm::from_setting( const Setting &root ) 
+{	
+	vec mu0;
+	UI::get( mu0, root, "mu0");
+	set_parameters(mu0.length(),root["k"]);
+	condition(mu0);
+}
+
+/*void mlognorm::to_setting( Setting &root ) const
+{	
+	Transport::to_setting( root );
+
+	Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+	kilometers_setting = kilometers;
+
+	UI::save( passengers, root, "passengers" );
+}*/
+
+
 };
Index: /bdm/stat/libDS.h
===================================================================
--- /bdm/stat/libDS.h (revision 342)
+++ /bdm/stat/libDS.h (revision 357)
@@ -90,5 +90,15 @@
 		//rowid and delays are ignored
 	};
-};
+
+	ITppFileDS () :FileDS() {
+	};
+
+	void from_setting( const Setting &root );
+
+	// TODO dodelat void to_setting( Setting &root ) const;
+
+};
+
+UIREGISTER(ITppFileDS);
 
 /*!
@@ -200,5 +210,42 @@
 	}
 
-};
+	// TODO dokumentace - aktualizovat
+	/*! UI for ArxDS using factorized description!
+
+	The ArxDS is constructed from a structure with fields:
+	\code
+	system = {
+		type = "ArxDS";
+		// description of y variables
+		y = {type="rv"; names=["y", "u"];};
+		// description of u variable
+		u = {type="rv"; names=[];}
+		// description of regressor
+		rgr = {type="rv";
+			names = ["y","y","y","u"];
+			times = [-1, -2, -3, -1];
+		}
+
+		// theta
+		theta = [0.8, -0.3, 0.4, 1.0,
+				 0.0, 0.0, 0.0, 0.0];
+		// offset (optional)
+		offset = [0.0, 0.0];
+		//variance
+		r = [0.1, 0.0,
+			 0.0, 1.0];
+		//options: L_theta = log value of theta,
+		opt = "L_theta";
+	};
+	\endcode
+
+	Result is ARX data source offering with full history as Drv.
+	*/
+	void from_setting( const Setting &root );
+
+	// TODO dodelat void to_setting( Setting &root ) const;
+};
+
+UIREGISTER( ArxDS );
 
 class stateDS : public DS {
@@ -222,4 +269,7 @@
 	stateDS ( mpdf* IM0, mpdf* OM0, int usize ) :DS ( ),IM ( IM0 ),OM ( OM0 ),
 			dt ( OM0->dimension() ), xt ( IM0->dimension() ), ut ( usize ) {}
+
+	stateDS(){}
+
 	~stateDS() {delete IM; delete OM;}
 	virtual void step() {
@@ -237,5 +287,40 @@
 	}
 
-};
+	/*! UI for stateDS 
+
+	The DS is constructed from a structure with fields:
+	\code
+	system = {
+		type = "stateDS";
+		//Internal model
+		IM = { type = "mpdf"; //<-- valid offspring! e.g. "mlnorm"
+			rv = { //description of x_t 
+				names=["name1",...];
+				sizes=[2,1]; // optional default=[1,1...];
+				times=[0,0]; // optional default=[0,0...];
+				}
+			rvu= { //description of  u_t 
+				//optional default=empty
+				}	
+
+			// remaining fields depending on the chosen type
+			};
+		//Observation model
+		OM = { type = "mpdf-offspring";
+			rv = {}; //description of d_t 
+			rvu = {type="internal", path="system.IM.rvu"}; //description of u_t 
+		
+			//remaining fields
+		}
+	};
+	\endcode
+	*/
+	void from_setting( const Setting &root );
+
+	// TODO dodelat void to_setting( Setting &root ) const;
+
+};
+
+UIREGISTER(stateDS);
 
 }; //namespace
Index: /bdm/stat/loggers.cpp
===================================================================
--- /bdm/stat/loggers.cpp (revision 347)
+++ /bdm/stat/loggers.cpp (revision 357)
@@ -26,4 +26,21 @@
 	}
 }
+
+void memlog::from_setting( const Setting &root ) 
+{	
+	// TODO tady se natvrdo ocekava existence stringu, nejsou zadne defaulty.. je to tak OK?
+	string itfilename = (string)root["filename"];
+	maxlen = root["maxlen"];
+}
+
+/*void memlog::to_setting( Setting &root ) const
+{	
+	Transport::to_setting( root );
+
+	Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+	kilometers_setting = kilometers;
+
+	UI::save( passengers, root, "passengers" );
+}*/
 
 void dirfilelog::init() {
@@ -62,6 +79,7 @@
 					ii++;
 				}
-			} else {
-			ii++;}
+			} 
+			else {
+				ii++;}
 		}
 	}
@@ -140,3 +158,24 @@
 }
 
+
+void dirfilelog::from_setting( const Setting &root ) 
+{	
+	// TODO tady se natvrdo ocekava existence stringu, nejsou zadne defaulty.. je to tak OK?
+	dirname = (string)root["dirname"];
+	maxlen = root["maxlen"];
+	scalarnames.set_length(0);
 }
+
+/*void dirfilelog::to_setting( Setting &root ) const
+{	
+	Transport::to_setting( root );
+
+	Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+	kilometers_setting = kilometers;
+
+	UI::save( passengers, root, "passengers" );
+}*/
+
+
+
+}
Index: /bdm/stat/libBM.cpp
===================================================================
--- /bdm/stat/libBM.cpp (revision 280)
+++ /bdm/stat/libBM.cpp (revision 357)
@@ -1,5 +1,4 @@
 
 #include "libBM.h"
-#include "../itpp_ext.h"
 
 //! Space of basic BDM structures
@@ -213,4 +212,40 @@
 }
 
+void RV::from_setting( const Setting &root ) 
+{	
+	Array<string> A;
+	if( root.exists("names"))
+		UI::get( A, root, "names" );
+	else
+		A.set_length(0);
+	
+	ivec szs;
+	if( root.exists("sizes"))
+		UI::get(szs,root,"sizes");
+	else
+		szs = ones_i(A.length());
+	
+	ivec tms;
+	if( root.exists( "times") )
+		UI::get(tms,root,"times");
+	else
+		tms = zeros_i(A.length());
+	
+	// TODO tady se bude plnit primo do jeho promennych, a pak se zavola validacnni metoda, takze cele prepsat, ano?
+	init( A, szs, tms );
+}
+
+/*void RV::to_setting( Setting &root ) const
+{	
+	Transport::to_setting( root );
+
+	Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+	kilometers_setting = kilometers;
+
+	UI::save( passengers, root, "passengers" );
+}*/
+
+
+
 RV concat ( const RV &rv1, const RV &rv2 ) {
 	RV pom = rv1;
Index: /bdm/stat/libEF.h
===================================================================
--- /bdm/stat/libEF.h (revision 330)
+++ /bdm/stat/libEF.h (revision 357)
@@ -17,5 +17,5 @@
 #include "libBM.h"
 #include "../math/chmat.h"
-//#include <std>
+#include "../user_info.h"
 
 namespace bdm
@@ -515,5 +515,64 @@
 			void set_parameters ( fnc* g0, const sq_T &R0 ) {g=g0; epdf.set_parameters ( zeros ( g->dimension() ), R0 );}
 			void condition ( const vec &cond ) {mu=g->eval ( cond );};
-	};
+
+
+			/*! UI for mgnorm
+
+			The mgnorm is constructed from a structure with fields:
+			\code
+			system = {
+				type = "mgnorm";
+				// function for mean value evolution
+				g = {type="fnc"; ... }
+
+				// variance
+				R = [1, 0,
+					 0, 1];
+				// --OR --
+				dR = [1, 1];
+
+				// == OPTIONAL ==
+
+				// description of y variables
+				y = {type="rv"; names=["y", "u"];};
+				// description of u variable
+				u = {type="rv"; names=[];}
+			};
+			\endcode
+
+			Result if
+			*/
+
+			void from_setting( const Setting &root ) 
+			{	
+				fnc* g = UI::build<fnc>( root, "g" );
+
+				mat R;
+				if ( root.exists( "dR" ) )
+				{
+					vec dR;
+					UI::get( dR, root, "dR" );
+					R=diag(dR);
+				}
+				else 
+					UI::get( R, root, "R");					
+		
+				set_parameters(g,R);
+			}
+
+			/*void mgnorm::to_setting( Setting &root ) const
+			{	
+				Transport::to_setting( root );
+
+				Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+				kilometers_setting = kilometers;
+
+				UI::save( passengers, root, "passengers" );
+			}*/
+
+	};
+
+	UIREGISTER(mgnorm<chmat>);
+
 
 	/*! (Approximate) Student t density with linear function of mean value
@@ -630,4 +689,5 @@
 	};
 
+
 	/*!
 	\brief  Gamma random walk around a fixed point
@@ -699,5 +759,32 @@
 				migamma::condition ( mean );
 			};
-	};
+
+			/*! UI for migamma_ref
+
+			The migamma_ref is constructed from a structure with fields:
+			\code
+			system = {
+				type = "migamma_ref";
+				ref = [1e-5; 1e-5; 1e-2 1e-3];            // reference vector
+				l = 0.999;                                // constant l
+				k = 0.1;                                  // constant k
+				
+				// == OPTIONAL ==
+				// description of y variables
+				y = {type="rv"; names=["y", "u"];};
+				// description of u variable
+				u = {type="rv"; names=[];}
+			};
+			\endcode
+
+			Result if
+			 */
+			void from_setting( const Setting &root );
+
+			// TODO dodelat void to_setting( Setting &root ) const;
+	};
+
+
+	UIREGISTER(migamma_ref);
 
 	/*! Log-Normal probability density
@@ -753,5 +840,30 @@
 				mu=log ( val )-sig2;//elem_mult ( refl,pow ( val,l ) );
 			};
-	};
+
+			/*! UI for mlognorm
+
+			The mlognorm is constructed from a structure with fields:
+			\code
+			system = {
+				type = "mlognorm";
+				k = 0.1;                                  // constant k
+				mu0 = [1., 1.];
+				
+				// == OPTIONAL ==
+				// description of y variables
+				y = {type="rv"; names=["y", "u"];};
+				// description of u variable
+				u = {type="rv"; names=[];}
+			};
+			\endcode
+
+			 */
+			void from_setting( const Setting &root );
+
+			// TODO dodelat void to_setting( Setting &root ) const;
+
+	};
+	
+	UIREGISTER(mlognorm);
 
 	/*! inverse Wishart density defined on Choleski decomposition
Index: /bdm/stat/loggers.h
===================================================================
--- /bdm/stat/loggers.h (revision 347)
+++ /bdm/stat/loggers.h (revision 357)
@@ -15,4 +15,5 @@
 
 #include "libBM.h"
+#include "..\user_info.h"
 
 namespace bdm{
@@ -38,5 +39,8 @@
 public:
 	//!Default constructor
-	memlog ( int maxlen0, string itf="" ) : logger(),maxlen ( maxlen0 ),ind ( 0 ),vectors ( 0 ),itfilename(itf) {}
+	memlog ( int maxlen0, string itf="" ) : maxlen ( maxlen0 ),ind ( 0 ),vectors ( 0 ),itfilename(itf) {}
+
+	memlog(): ind ( 0 ),vectors ( 0 ) {}
+
 	//! Initialize storage
 	void init() {
@@ -60,5 +64,23 @@
 	void finalize() {if (itfilename.length()>0) itsave(itfilename.c_str());};
 
+
+	/*! \brief UI for memlog 
+
+	TODO dat tam kam patri, a to celej blok
+
+	\code
+	logger = {
+		type = "itpplog";
+		filename = "file_name.it"; // resulting filename with results in it format
+		maxlen = 100;          // size of memory buffer
+	}
+	\endcode
+	 */
+	void from_setting( const Setting &root );
+
+	// TODO dodelat void to_setting( Setting &root ) const;
 };
+
+UIREGISTER(memlog);
 
 /*!
@@ -69,5 +91,4 @@
 * This format is used to store scalars, hence multivariate RVs must be separated.
 */
-
 class dirfilelog : public memlog {
 
@@ -81,5 +102,8 @@
 	@param dirname0 name of the directory in which to store the results
 	@param maxlen0 length of the memory buffers, when full the buffers will be dumped to HDD and returned to the beginning. */
-	dirfilelog ( std::string dirname0, int maxlen0 ) : memlog ( maxlen0 ), dirname ( dirname0 ), scalarnames ( 0 ) {}
+	dirfilelog ( string dirname0, int maxlen0 ) : memlog ( maxlen0 ), dirname ( dirname0 ), scalarnames ( 0 ) {}
+
+	dirfilelog() {}
+
 	//! Initialize storage
 	void init();
@@ -90,5 +114,21 @@
 	*/
 	void write_buffers ( int Len );
+
+	// TODO dokumentace - aktualizovat
+	/*! \brief UI for dirfilelog (Kst file format) 
+	\code
+	logger = {
+		type = "dirfilelog";
+		dirmane = "directory_for_files"; // resulting files will be stored there
+		maxlen = 100;                    // size of memory buffer, when full results are written to disk
+	}
+	\endcode
+	*/
+	void from_setting( const Setting &root );
+
+	// TODO dodelat void to_setting( Setting &root ) const;
 };
+
+UIREGISTER(dirfilelog);
 
 };
Index: /bdm/stat/libBM.h
===================================================================
--- /bdm/stat/libBM.h (revision 351)
+++ /bdm/stat/libBM.h (revision 357)
@@ -17,39 +17,13 @@
 
 #include "../itpp_ext.h"
-#include "../libconfig/libconfig.h++"
+#include "../bdmroot.h"
+#include "../user_info.h"
 
 
 using namespace libconfig;
-
 using namespace itpp;
 using namespace std;
 
 namespace bdm {
-
-//! Root class of BDM objects
-
-class bdmroot {
-public:
-	//! make sure this is a virtual object
-	virtual ~bdmroot() 
-	{
-	}
-
-	//! This method returns a basic info about the current instance
-	virtual string ToString()
-	{
-		return "";
-	}
-
-	//! This method arrange instance properties according the data stored in the Setting structure
-	virtual void from_setting( const Setting &root )
-	{
-	}
-
-	//! This method save all the instance properties into the Setting structure 
-	virtual void to_setting( Setting &root ) const
-	{	
-	}
-};
 
 typedef std::map<string, int> RVmap;
@@ -57,5 +31,5 @@
 extern Array<string> RV_NAMES;
 
-//! Structure of RV (used internally), i.e. expanded RVs
+//! Structure of RV (used internally), i.e. expanded RVs - TODO tak proc je ve verejnem prostoru jmen? upravit
 class str {
 public:
@@ -189,5 +163,5 @@
 	//!@{
 
-	//! generate \c str from rv, by expanding sizes
+	//! generate \c str from rv, by expanding sizes TODO to_string.. 
 	str tostr() const;
 	//! when this rv is a part of bigger rv, this function returns indeces of self in the data vector of the bigger crv.
@@ -201,6 +175,25 @@
 	//!@}
 
-};
-
+	// TODO aktualizovat dle soucasneho UI
+	/*! \brief UI for class RV (description of data vectors)
+
+	\code
+	rv = {
+		type = "rv"; //identifier of the description
+		// UNIQUE IDENTIFIER same names = same variable
+		names = ["a", "b", "c", ...];   // which will be used e.g. in loggers 
+
+		//optional arguments
+		sizes = [1, 2, 3, ...];         // (optional) default = ones()
+		times = [-1, -2, 0, ...];       // time shifts with respect to current time (optional) default = zeros()
+	}
+	\endcode
+	*/
+	void from_setting( const Setting &root );
+
+	// TODO dodelat void to_setting( Setting &root ) const;
+};
+
+UIREGISTER(RV);
 
 //! Concat two random variables
Index: /bdm/stat/libDS.cpp
===================================================================
--- /bdm/stat/libDS.cpp (revision 313)
+++ /bdm/stat/libDS.cpp (revision 357)
@@ -1,4 +1,6 @@
 
 #include "libDS.h"
+#include "..\user_info.h"
+
 using namespace bdm;
 
@@ -53,4 +55,39 @@
 }
 
+void ArxDS::from_setting( const Setting &root ) 
+{	
+	RV *yrv = UI::build<RV>( root, "y" );
+	RV *urv = UI::build<RV>( root, "u" );
+	RV *rrv = UI::build<RV>( root, "rgr" ); 
+				
+	mat Th;
+	UI::get( Th, root, "theta" );
+
+	vec mu0;
+	if( root.exists( "offset" ))
+		UI::get( mu0, root, "offset" );
+	else
+		mu0= zeros( yrv->_dsize() );
+
+	mat sqR;
+	UI::get( sqR, root, "r" );
+	set_parameters(Th,mu0,sqR);
+	set_drv(*yrv,*urv,*rrv);
+
+	if(root.exists("opt"))
+		set_options(root["opt"]);
+}
+
+/*void ArxDS::to_setting( Setting &root ) const
+{	
+	Transport::to_setting( root );
+
+	Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+	kilometers_setting = kilometers;
+
+	UI::save( passengers, root, "passengers" );
+}*/
+
+
 CsvFileDS::CsvFileDS ( const string& fname, const string& orientation ) :FileDS() {
         time = 0;
@@ -87,2 +124,49 @@
 }
 
+void ITppFileDS::from_setting( const Setting &root ) 
+{	
+	RV* rvtmp = UI::build<RV>(root, "rv" );
+
+	it_file it ( root["filename"] );
+	it << Name ( root["varname"] ); 
+	it >> Data;
+	time = 0;
+	//rowid and delays are ignored
+
+	set_drv(*rvtmp,RV());
+}
+
+/*void ITppFileDS::to_setting( Setting &root ) const
+{	
+	Transport::to_setting( root );
+
+	Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+	kilometers_setting = kilometers;
+
+	UI::save( passengers, root, "passengers" );
+}*/
+
+void stateDS::from_setting( const Setting &root ) 
+{	
+	IM = UI::build<mpdf>(root, "IM");
+	OM = UI::build<mpdf>(root, "OM");
+
+	dt.set_length( OM->dimension() );
+	xt.set_length( IM->dimension() );
+	ut.set_length(0);
+	
+	RV* rvtmp = UI::build<RV>(root["IM"], "rvu");			
+	//set_drv(rvtmp);
+}
+
+/*void stateDS::to_setting( Setting &root ) const
+{	
+	Transport::to_setting( root );
+
+	Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt );
+	kilometers_setting = kilometers;
+
+	UI::save( passengers, root, "passengers" );
+}*/
+
+
Index: /bdm/CMakeLists.txt
===================================================================
--- /bdm/CMakeLists.txt (revision 345)
+++ /bdm/CMakeLists.txt (revision 357)
@@ -7,3 +7,3 @@
 
 # Normal BDM library
-add_library (bdm STATIC itpp_ext.cpp itpp_ext.h osutils.cpp osutils.h ${BdmMath} ${BdmStat} ${BdmEstim} ${BdmUI})
+add_library (bdm STATIC bdmroot.cpp bdmroot.h itpp_ext.cpp itpp_ext.h osutils.cpp osutils.h ${BdmMath} ${BdmStat} ${BdmEstim} ${BdmUI})
Index: /tests/testUI.cpp
===================================================================
--- /tests/testUI.cpp (revision 357)
+++ /tests/testUI.cpp (revision 357)
@@ -0,0 +1,228 @@
+
+#include <string>
+#include "user_info.h"
+
+using std::string;
+using namespace std;
+using namespace bdm;
+
+class Passenger : public bdmroot
+{
+public:
+
+  Passenger() {
+  }
+};
+
+class Human : public Passenger
+{
+public:
+  string name;
+
+  Human() {
+    name = "none";
+  }
+
+  virtual void from_setting(const Setting &root) {
+    root.lookupValue("name", name);
+  }
+
+  virtual void to_setting(Setting &root) const {
+    Setting &name_setting = root.add("name", Setting::TypeString);
+    name_setting = name;
+  }
+
+  string to_string() {
+    return name;
+  }
+};
+
+UIREGISTER(Human);
+
+class Robot : public Passenger
+{
+public:
+  int number;
+  Array<string> software;
+
+  Robot() : software() {
+    number = -1;
+  }
+
+  virtual void from_setting(const Setting &root) {
+    root.lookupValue("number", number);
+	if( root.exists( "software" ) )
+		UI::get(software, root, "software");
+  }
+
+  virtual void to_setting(Setting &root) const {
+    Setting &number_setting = root.add("number", Setting::TypeInt);
+    number_setting = number;
+
+    UI::save(software, root, "software");
+  }
+
+  string to_string() {
+    stringstream stream;
+    stream << number;
+    for (int i = 0; i < software.length(); i++)
+      stream << "_" + software(i);
+    return stream.str();
+  }
+};
+
+UIREGISTER(Robot);
+
+class Transport : public bdmroot
+{
+public:
+  int year;
+  string manufacturer;
+
+  Transport() {
+    year = 1900;
+    manufacturer = "unknown";
+  }
+
+  Transport(int year, string manufacturer)
+      : year(year), manufacturer(manufacturer) {
+  }
+
+  virtual void from_setting(const Setting &root) {
+    root.lookupValue("year", year);
+    root.lookupValue("manufacturer", manufacturer);
+  }
+
+  virtual void to_setting(Setting &root) const {
+    Setting &year_setting = root.add("year", Setting::TypeInt);
+    year_setting = year;
+
+    Setting &manufacturer_setting = root.add("manufacturer", Setting::TypeString);
+    manufacturer_setting = manufacturer;
+  }
+};
+
+class Car : public Transport
+{
+public:
+  int kilometers;
+  Array<Passenger*> passengers;
+
+  Car() : Transport() {
+    kilometers = 0;
+  }
+
+
+  Car(int year, string manufacturer, int kilometers)
+      : Transport(year, manufacturer), kilometers(kilometers) {
+  }
+
+  virtual void from_setting(const Setting &root) {
+    Transport::from_setting(root);
+
+    root.lookupValue("kilometers", kilometers);
+
+	if( root.exists( "passengers" ) )
+	    UI::get(passengers, root, "passengers");
+  }
+
+  virtual void to_setting(Setting &root) const {
+    Transport::to_setting(root);
+
+    Setting &kilometers_setting = root.add("kilometers", Setting::TypeInt);
+    kilometers_setting = kilometers;
+
+    UI::save(passengers, root, "passengers");
+  }
+
+  string to_string() {
+    stringstream stream;
+    stream << "A car made in " << year << " by " << manufacturer << ", having " << kilometers << " kilometers on the clock.";
+    if (passengers.length()) {
+      stream << "The names of passengers are as follows: ";
+      for (int i = 0; i < passengers.length(); i++)
+        stream << passengers(i)->to_string() << " ";
+    }
+    return stream.str();
+  }
+};
+
+UIREGISTER(Car);
+
+class Bike : public Transport
+{
+public:
+  bool electricLights;
+  mat matr;
+
+  Bike() : Transport(), matr("2,2;3,4") {
+    electricLights = false;
+  }
+
+  Bike(int year, string manufacturer, bool electricLights)
+      : Transport(year, manufacturer), electricLights(electricLights) {
+  }
+
+  ~Bike() {
+  }
+
+  void from_setting(const Setting &root) {
+    Transport::from_setting(root);
+
+    root.lookupValue("electricLights", electricLights);
+
+	UI::get(matr, root, "matr");
+  }
+
+  void to_setting(Setting &root) const {
+    Transport::to_setting(root);
+
+    Setting &electricLights_setting = root.add("electricLights", Setting::TypeBoolean);
+    electricLights_setting = electricLights;
+
+    UI::save(matr, root, "matr");
+  }
+
+  string to_string() {
+    stringstream stream;
+    stream << "a bike made in " << year << " by " << manufacturer;
+    if (electricLights) stream << " with electric lights included";
+    return stream.str();
+  }
+};
+
+UIREGISTER(Bike);
+
+int main()
+{
+  //////////////////////////////////// LOADING ////////////////////////////////
+  UI_File in("testUI_in.cfg");
+  Transport *pepikovo = UI::build<Transport>(in, "pepikovo");
+  cout << "pepikovo: " << pepikovo->to_string() << endl;
+  Transport *jardovo = UI::build<Transport>(in, "jardovo");
+  cout << "jardovo: " << jardovo->to_string() << endl;
+  Transport *ondrejovo = UI::build<Transport>(in, "ondrejovo");
+  cout << "ondrejovo: " << ondrejovo->to_string() << endl;
+  Transport *elisky = UI::build<Transport>(in, "elisky");
+  cout << "elisky: " << elisky->to_string() << endl;
+  Transport *kati = UI::build<Transport>(in, "kati");
+  cout << "kati: " << kati->to_string() << endl;
+  getchar();
+
+  /////////////////////////////////// SAVING //////////////////////////
+
+  Car audi(1968, "zyl", 200);
+  Car liaz(1989, "skoda", 1000);
+  Bike author(2001, "noname", false);
+  UI_File out;
+
+  UI::save(&audi, out, "marty");
+  UI::save(&liaz, out, "bohousovo");
+  UI::save(&author, out, "karlovo");
+  UI::save(pepikovo, out, "pepikovo");
+  out.save("testUI_out.cfg");
+
+  cout << "all the transport means were saved correctly" << endl;
+  getchar();
+  return 0;
+}
Index: /tests/testUI_in.cfg
===================================================================
--- /tests/testUI_in.cfg (revision 357)
+++ /tests/testUI_in.cfg (revision 357)
@@ -0,0 +1,31 @@
+pepikovo : 
+{
+  class = "Car";
+  year = 1998;
+  manufacturer = "audi";
+  kilometers = 25000;
+  passengers = ( 
+	{ class = "Human"; 
+	   name = "Karlos Novak"; }, 
+	{ class = "Robot"; 
+	   software = ( "CygWin", "Matlab", "Aimsun" ); }, 
+	{ class = "Human"; 
+	   name = "Karlosik Novacek"; } );
+};
+jardovo : 
+{
+  class = "Car";
+  year = 1992;
+  manufacturer = "liaz";
+  kilometers = 1555000;
+};
+ondrejovo : 
+{
+  class = "Bike";
+  year = 1996;
+  manufacturer = "author";
+  electricLights = true;
+  matr = ( 2, 2, [ 1.0, 0.0, 0.0, 1.0 ] );
+};
+elisky = "jardovo";
+kati = "skubankovo@testUI_ex.cfg";
Index: /tests/testUI_ex.cfg
===================================================================
--- /tests/testUI_ex.cfg (revision 357)
+++ /tests/testUI_ex.cfg (revision 357)
@@ -0,0 +1,7 @@
+skubankovo : 
+{
+  class = "Car";
+  year = 1980;
+  manufacturer = "vecernicek";
+  kilometers = 250000;
+};
Index: /tests/CMakeLists.txt
===================================================================
--- /tests/CMakeLists.txt (revision 322)
+++ /tests/CMakeLists.txt (revision 357)
@@ -12,4 +12,5 @@
 EXEC(datalink_test)
 EXEC(loggers_test)
+EXEC(testUI)
 
 EXEC(chmat_test)
@@ -39,4 +40,3 @@
 EXEC(blas_test)
 
-add_subdirectory(UI)
 add_subdirectory(tutorial)
Index: /library/tutorial/arx_mex_test.cfg
===================================================================
--- /library/tutorial/arx_mex_test.cfg (revision 278)
+++ /library/tutorial/arx_mex_test.cfg (revision 357)
@@ -11,8 +11,8 @@
 //estimation
 estimator = {
-   type = "ARXest";
-	y = {type="rv"; names=["y"]; };
-	rgr = {type="rv";
-		names = ["y","y","y","u"];
+   type = "ARX";
+	y = {type="RV"; names=("y"); };
+	rgr = {type="RV";
+		names = ("y","y","y","u");
 		times = [-1, -2, -3, -1];
 	};
Index: /library/tutorial/arx_test.cfg
===================================================================
--- /library/tutorial/arx_test.cfg (revision 278)
+++ /library/tutorial/arx_test.cfg (revision 357)
@@ -1,19 +1,19 @@
 //Data generating system
 system = {
-	type = "ArxDS";
-	y = {type="rv"; names=["y", "u"];};
-	u = {type="rv"; names=[]; };
-	rgr = {type="rv";
-		names = ["y","y","y","u"];
+	class = "ArxDS";
+	y = {class="RV"; names=("y", "u");};
+	u = {class="RV"; names=(); };
+	rgr = {class="RV";
+		names = ("y","y","y","u");
 		times = [-1, -2, -3, -1];
 	};
 	//AR parameters
-	theta = [0.8, -0.3, 0.4, 1.0,
-	         0.0, 0.0, 0.0, 0.0];
+	theta = (2,4,[0.8, -0.3, 0.4, 1.0,
+	              0.0, 0.0, 0.0, 0.0]);
 	// offset
 	offset = [0.0, 0.0];
 	//variance
-	r = [0.1, 0.0,
-	     0.0, 1.0];
+	r = (2,2,[0.1, 0.0,
+	         0.0, 1.0] );
 	// log also theta
 	opt="L_theta";
@@ -22,5 +22,5 @@
 //store results
 logger = {
-	type= "dirfilelog";
+	class= "dirfilelog";
 	dirname = "exp/arx_ui";
 	maxlen = 1000; //
@@ -29,8 +29,8 @@
 //estimation
 estimator = {
-	type = "ARXest";
-	y = {type="rv"; names=["y"]; };
-	rgr = {type="rv";
-		names = ["y","y","y","u"];
+	class = "ARX";
+	y = {class="RV"; names=("y"); };
+	rgr = {class="RV";
+		names = ("y","y","y","u");
 		times = [-1, -2, -3, -1];
 	};
Index: /library/estimator.cpp
===================================================================
--- /library/estimator.cpp (revision 281)
+++ /library/estimator.cpp (revision 357)
@@ -48,6 +48,8 @@
  */
 
-#include <stat/libDS_ui.h>
-#include <estim/arx_ui.h>
+#include "stat/libDS.h"
+#include "estim/arx.h"
+#include "user_info.h"
+#include "stat/loggers.h"
 
 using namespace bdm;
@@ -59,20 +61,13 @@
 	else {
 		cout << "Missing configuration file.\n Usage: \n $> estimator config_file.cfg";
-		abort();
+		//abort();
 	}
-	UIFile F ( fname );
+	fname = "arx_test.cfg";
+	UI_File F ( fname );
 
-	logger* L;
-	ArxDS * DS;
-	BM* E;
-	int Ndat;
-
-	try {
-		UIbuild ( F.lookup ( "logger" ),L );
-		UIbuild ( F.lookup ( "system" ),DS );
-		F.lookupValue ( "experiment.ndat",Ndat );
-		UIbuild ( F.lookup ( "estimator" ),E );
-	}
-	catch UICATCH;
+	logger* L = UI::build<logger>( F, "logger");
+	ArxDS * DS = UI::build<ArxDS>( F, "system" );
+	BM* E = UI::build<BM>( F, "estimator" );
+	int Ndat = F.lookupValue ( "experiment.ndat",Ndat );
 
 	DS->log_add ( *L );
Index: /system/FindMatlab.cmake
===================================================================
--- /system/FindMatlab.cmake (revision 357)
+++ /system/FindMatlab.cmake (revision 357)
@@ -0,0 +1,120 @@
+# - this module looks for Matlab
+# Defines:
+#  MATLAB_INCLUDE_DIR: include path for mex.h, engine.h
+#  MATLAB_LIBRARIES:   required libraries: libmex, etc
+#  MATLAB_MAT_LIBRARY: path to libmat.lib
+#  MATLAB_MEX_LIBRARY: path to libmex.lib
+#  MATLAB_MX_LIBRARY:  path to libmx.lib
+#  MATLAB_ENG_LIBRARY: path to libeng.lib
+
+
+SET(MATLAB_FOUND 0)
+IF(WIN32)
+  IF(${CMAKE_GENERATOR} MATCHES "Visual Studio .*" OR ${CMAKE_GENERATOR} MATCHES "NMake Makefiles")
+    SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/")
+  ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio .*" OR ${CMAKE_GENERATOR} MATCHES "NMake Makefiles")
+      IF(${CMAKE_GENERATOR} MATCHES "Borland")
+        # Same here, there are also: bcc50 and bcc51 directories
+        SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/bcc54")
+      ELSE(${CMAKE_GENERATOR} MATCHES "Borland")
+        MESSAGE(FATAL_ERROR "Generator not compatible: ${CMAKE_GENERATOR}")
+      ENDIF(${CMAKE_GENERATOR} MATCHES "Borland")
+  ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio .*" OR ${CMAKE_GENERATOR} MATCHES "NMake Makefiles")
+  FIND_LIBRARY(MATLAB_MEX_LIBRARY
+    libmex
+    ${MATLAB_ROOT}
+    )
+  FIND_LIBRARY(MATLAB_MX_LIBRARY
+    libmx
+    ${MATLAB_ROOT}
+    )
+  FIND_LIBRARY(MATLAB_ENG_LIBRARY
+    libeng
+    ${MATLAB_ROOT}
+    )
+  FIND_LIBRARY(MATLAB_MAT_LIBRARY
+    libmat
+    ${MATLAB_ROOT}
+    )
+
+  FIND_PATH(MATLAB_INCLUDE_DIR
+    "mex.h"
+    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/include"
+    )
+ELSE( WIN32 )
+  IF(NOT MATLAB_ROOT)
+    IF($ENV{MATLAB_ROOT})
+      SET(MATLAB_ROOT $ENV{MATLAB_ROOT})
+    ELSE($ENV{MATLAB_ROOT})
+      SET(MATLAB_ROOT /opt/matlab)
+    ENDIF($ENV{MATLAB_ROOT})    
+  ENDIF(NOT MATLAB_ROOT)
+  IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
+    # Regular x86
+    SET(MATLAB_SYS
+      ${MATLAB_ROOT}/bin/glnx86
+      )
+  ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4)
+    # AMD64:
+    SET(MATLAB_SYS
+      ${MATLAB_ROOT}/bin/glnxa64
+      )
+  ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
+  FIND_LIBRARY(MATLAB_MEX_LIBRARY
+    mex
+    ${MATLAB_SYS}
+    )
+  FIND_LIBRARY(MATLAB_MX_LIBRARY
+    mx
+    ${MATLAB_SYS}
+    )
+  FIND_LIBRARY(MATLAB_MAT_LIBRARY
+    mat
+    ${MATLAB_SYS}
+    )
+  FIND_LIBRARY(MATLAB_ENG_LIBRARY
+    eng
+    ${MATLAB_SYS}
+    )
+  FIND_PATH(MATLAB_INCLUDE_DIR
+    "mex.h"
+    ${MATLAB_ROOT}/extern/include
+    )
+
+ENDIF(WIN32)
+
+# This is common to UNIX and Win32:
+SET(MATLAB_LIBRARIES
+  ${MATLAB_MEX_LIBRARY}
+  ${MATLAB_MX_LIBRARY}
+  ${MATLAB_ENG_LIBRARY}
+)
+
+IF(MATLAB_INCLUDE_DIR 
+    AND MATLAB_MEX_LIBRARY 
+    AND MATLAB_MAT_LIBRARY
+    AND MATLAB_ENG_LIBRARY
+    AND MATLAB_MX_LIBRARY)
+  SET(MATLAB_LIBRARIES ${MATLAB_MX_LIBRARY} ${MATLAB_MEX_LIBRARY} ${MATLAB_ENG_LIBRARY} ${MATLAB_MAT_LIBRARY})
+ENDIF(MATLAB_INCLUDE_DIR 
+    AND MATLAB_MEX_LIBRARY 
+    AND MATLAB_MAT_LIBRARY
+    AND MATLAB_ENG_LIBRARY
+    AND MATLAB_MX_LIBRARY)
+
+MARK_AS_ADVANCED(
+  MATLAB_MEX_LIBRARY
+  MATLAB_MX_LIBRARY
+  MATLAB_ENG_LIBRARY
+  MATLAB_INCLUDE_DIR
+  MATLAB_ROOT
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Matlab 
+    MATLAB_INCLUDE_DIR 
+    MATLAB_MEX_LIBRARY 
+    MATLAB_MAT_LIBRARY
+    MATLAB_ENG_LIBRARY
+    MATLAB_MX_LIBRARY )
+
Index: /system/win32/INSTALL.txt
===================================================================
--- /system/win32/INSTALL.txt (revision 322)
+++ /system/win32/INSTALL.txt (revision 357)
@@ -9,7 +9,7 @@
  * ACML
  * ITPP
- * XSD
+ * ASTYLE 
 When these are available, please make sure that the 
-CMake_module/FindACML and CMake_module/FindITPP can find it.
+system/FindACML and system/FindITPP can find it.
 
 Convenience:
@@ -18,5 +18,5 @@
 If you want to use them copy the content of the zip file to win32\ directory and
 make sure to set your PATH environment variable:
- Path = %PATH%; <mixpp_dir>\win32\dll
+ Path = %PATH%; <mixpp_dir>\system\win32\dll
 Otherwise you will not be able to run any programs.
 
@@ -27,2 +27,10 @@
 * It should generate build files for your compiler in the main BDM 
   directory
+* To include ASTYLE code formatting utility directly into Visual Studio, follow 
+  these steps:
+    1) Go to Tools->External Tools.
+    2) Click Add
+    3) Make the title Astyle
+    4) Make the command: [bdmdir]\system\win32\astyle_1.23_windows\astyle\bin\astyle.exe 
+    5) Make the arguments: --options=[bdmdir]\system\astylerc $(ItemPath) 
+
Index: /system/FindACML.cmake
===================================================================
--- /system/FindACML.cmake (revision 357)
+++ /system/FindACML.cmake (revision 357)
@@ -0,0 +1,43 @@
+# - Find ACML
+# Find the native ACML includes and library
+# This module defines
+#  ACML_INCLUDE_DIR, where to find acml.h, etc.
+#  ACML_LIBRARIES, the libraries needed to use ACML.
+#  ACML_FOUND, If false, do not try to use ACML.
+# also defined, but not for general use are
+#  ACML_LIBRARY, where to find the ACML library.
+
+FIND_PATH(ACML_INCLUDE_DIR acml.h
+	"${ACML_DIR}\\pgi32\\include"
+ )
+
+FIND_LIBRARY(ACML_LIBRARY
+  NAMES libacml_dll
+  PATHS "${ACML_DIR}\\pgi32\\lib"
+  )
+
+IF (ACML_LIBRARY AND ACML_INCLUDE_DIR)
+    SET(ACML_LIBRARIES ${ACML_LIBRARY})
+    SET(ACML_FOUND "YES")
+ELSE (ACML_LIBRARY AND ACML_INCLUDE_DIR)
+  SET(ACML_FOUND "NO")
+ENDIF (ACML_LIBRARY AND ACML_INCLUDE_DIR)
+
+
+IF (ACML_FOUND)
+   IF (NOT ACML_FIND_QUIETLY)
+      MESSAGE(STATUS "Found ACML: ${ACML_LIBRARIES}")
+   ENDIF (NOT ACML_FIND_QUIETLY)
+ELSE (ACML_FOUND)
+   IF (ACML_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find ACML library")
+   ENDIF (ACML_FIND_REQUIRED)
+ENDIF (ACML_FOUND)
+
+# Deprecated declarations.
+GET_FILENAME_COMPONENT (NATIVE_ACML_LIB_PATH ${ACML_LIBRARY} PATH)
+
+MARK_AS_ADVANCED(
+  ACML_LIBRARY
+  ACML_INCLUDE_DIR
+  )
Index: /system/FindITPP.cmake
===================================================================
--- /system/FindITPP.cmake (revision 357)
+++ /system/FindITPP.cmake (revision 357)
@@ -0,0 +1,54 @@
+# - Find ITPP
+# Find the native ITPP includes and library
+# This module defines
+#  ITPP_INCLUDE_DIR, where to find itpp/itbase.h, etc.
+#  ITPP_LIBRARIES, the libraries needed to use ITPP.
+#  ITPP_FOUND, If false, do not try to use ITPP.
+# also defined, but not for general use are
+#  ITPP_LIBRARY, where to find the ITPP library.
+
+MESSAGE("ITPP_DIR set to ${ITPP_DIR}" )
+
+FIND_PATH(ITPP_INCLUDE_DIR itpp/itbase.h
+	${ITPP_DIR}
+#	/usr/pkgs64/include
+#	/usr/include
+  NO_DEFAULT_PATH
+  )
+
+FIND_LIBRARY(ITPP_LIBRARY
+  NAMES itpp #itpp_debug
+  PATHS ${ITPP_DIR}/libs
+  ${ITPP_DIR}/itpp/.libs/
+  "${ITPP_DIR}\\win32\\lib"
+ # /usr/pkgs64/lib
+ # /usr/lib64
+ # /usr/lib
+  NO_DEFAULT_PATH
+)
+
+IF (ITPP_LIBRARY AND ITPP_INCLUDE_DIR)
+    SET(ITPP_LIBRARIES ${ITPP_LIBRARY})
+    SET(ITPP_FOUND "YES")
+ELSE (ITPP_LIBRARY AND ITPP_INCLUDE_DIR)
+  SET(ITPP_FOUND "NO")
+ENDIF (ITPP_LIBRARY AND ITPP_INCLUDE_DIR)
+
+
+IF (ITPP_FOUND)
+   IF (NOT ITPP_FIND_QUIETLY)
+      MESSAGE(STATUS "Found ITPP: ${ITPP_LIBRARIES}")
+   ENDIF (NOT ITPP_FIND_QUIETLY)
+ELSE (ITPP_FOUND)
+   IF (ITPP_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR "Could not find ITPP library")
+   ENDIF (ITPP_FIND_REQUIRED)
+ENDIF (ITPP_FOUND)
+
+# Deprecated declarations.
+GET_FILENAME_COMPONENT (NATIVE_ITPP_LIB_PATH ${ITPP_LIBRARY} PATH)
+
+MARK_AS_ADVANCED(
+  ITPP_LIBRARY
+  ITPP_INCLUDE_DIR
+  )
Index: /doc/local/codingrules.dox
===================================================================
--- /doc/local/codingrules.dox (revision 33)
+++ /doc/local/codingrules.dox (revision 357)
@@ -8,30 +8,19 @@
 \section cr_variables Default Naming Rules for Variables
 
-Variables are named using lower-case letters and words are separated
-using under-score. Abbreviations, when used in variable names, are also
-written with lower-case letters. Examples:
+Generally, variables are named using lower-case letters and words are separated using
+under-score. But there are many exceptions, for instance abbreviations or classical 
+matematical notations. Therefore, coding rules for variables are quite free. Examples:
 
 <ul>
-<li> \c `fft_size' </li>
-<li> \c `nrof_paths' </li>
-<li> \c `my_variable_name' </li>
+<li> \c `FFT_size' </li>
+<li> \c `initial_RV' </li>
+<li> \c `my_variable' </li>
 </ul>
-
-Some variable names or parts of variable names are commonly used in
-several different functions and files to denote the same thing. For
-instance the following common names and prefixes should be used:
-
-<ul>
-<li> \c `rows' - number of rows in a matrix </li>
-<li> \c `cols' - number of columns in a matrix </li>
-<li> \c `nrof_' - number of ... </li>
-</ul>
-
 
 \section cr_files Default Naming Rules for Files
 
 Files are named using lower-case letters and words are separated using
-under-score. Abbreviations, when used in file names, are also written
-with lower-case letters.
+under-score. If an abbreviation is inevitable within file name, it is written with 
+lower-case letters. 
 
 Source files are named using <tt>`.cpp'</tt> suffix, whereas header
@@ -40,7 +29,34 @@
 <ul>
 <li> <tt>`my_file.h'</tt> </li>
-<li> <tt>`my_file.cpp'</tt> </li>
+<li> <tt>`user_info.cpp'</tt> </li>
 </ul>
 
+\section cr_file_templates Form of the source files
+
+For all the library classes, both header file `[filename].h' and source file 
+`[filename].cpp' should be implemented. And the following few rules should be 
+respected   
+
+<ul>
+
+<li> if possible, each `#inline ... ' dircetive should be located within the `.h'
+file, one obvious exception is the case of `#inline [filename].h' written in 
+`[filename].cpp' </li>
+
+<li> firstly, system headers should be included (i.e. those with brackets 
+`#include <header_name>'), other headers (like `#include my_header_name.h') 
+should follow (this rule leads to the faster search of an error on some 
+compilators) </li>
+
+<li> source code itself should be placed in the `.cpp' file, `.h' should 
+contains only class declarations and documentation (this rule has a few exceptions like
+ inline functions, templates and some extremely short function bodies)</li>
+
+</ul>
+
+Rules considering formatting of the source code itself are stored in the 
+file \system\astylerc, which is a configuration file for code formating 
+utility named ASTYLE. To apply them, download the proper version from 
+its web page http://astyle.sourceforge.net/     
 
 \section cr_functions Default Naming Rules for Functions
@@ -71,10 +87,10 @@
 
 Each new word in a class or structure name should always start with a
-capital letter and the words should be separated with an
-under-score. Abbreviations are written with capital letters. Examples:
+capital letter and the words should not be separated. Abbreviations are 
+written with capital letters. Examples:
 
 <ul>
-<li> \c `My_Class_Name' </li>
-<li> \c	`My_Struct_Name' </li>
+<li> \c `MyClassName' </li>
+<li> \c `MyStructName' </li>
 <li> \c `OFDM' </li>
 </ul>
Index: /doc/local/library_structure.dox
===================================================================
--- /doc/local/library_structure.dox (revision 357)
+++ /doc/local/library_structure.dox (revision 357)
@@ -0,0 +1,17 @@
+/*!
+\page library_structure Library structure >> UNDER CONSTRUCTION <<
+
+Here you find basic infromation about the library subdirectories.
+
+Description of the library subdirectories
+<ul>
+<li> source:\system -- a directory containing ..., </li>
+<li> source:\system\win32 -- a directory containing ..., </li>
+<li> source:\system\linux -- a directory containing ...,</li>
+</ul>
+ 
+
+// \section cr_variables Default Naming Rules for Variables
+
+
+*/
Index: /applications/doprava/k1.cpp
===================================================================
--- /applications/doprava/k1.cpp (revision 341)
+++ /applications/doprava/k1.cpp (revision 357)
@@ -13,9 +13,9 @@
 
 #include <estim/ekf_templ.h>
-#include <stat/loggers_ui.h>
-#include <stat/libDS_ui.h>
 
 //include dopravni model
 #include "model.h"
+#include "stat\libDS.h"
+#include "stat\loggers.h"
 
 using namespace bdm;
Index: /applications/pmsm/pmsmDS.h
===================================================================
--- /applications/pmsm/pmsmDS.h (revision 349)
+++ /applications/pmsm/pmsmDS.h (revision 357)
@@ -17,191 +17,341 @@
 
 //! Simulator of PMSM machine with predefined profile on omega
-class pmsmDS : public DS {
+class pmsmDS : public DS
+{
 
 protected:
-	//! indeces of logged variables
-	int L_x, L_ou, L_oy, L_iu, L_optu;
-	//! Setpoints of omega in timespans given by dt_prof
-	vec profileWw;
-	//! Setpoints of Mz in timespans given by dt_prof
-	vec profileMz;
-	//! time-step for profiles
-	double dt_prof;
-	//! Number of miliseconds per discrete time step
-	int Dt;
-	//! options for logging, - log predictions of 'true' voltage
-	bool opt_modu;
-	//! options for logging, - 
+    //! indeces of logged variables
+    int L_x, L_ou, L_oy, L_iu, L_optu;
+    //! Setpoints of omega in timespans given by dt_prof
+    vec profileWw;
+    //! Setpoints of Mz in timespans given by dt_prof
+    vec profileMz;
+    //! time-step for profiles
+    double dt_prof;
+    //! Number of miliseconds per discrete time step
+    int Dt;
+    //! options for logging, - log predictions of 'true' voltage
+    bool opt_modu;
+    //! options for logging, -
 public:
-	//! Constructor with fixed sampling period
-	pmsmDS ()   {Dt=125; Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th Mz }" );}
-	void set_parameters ( double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0 ) {
-		pmsmsim_set_parameters ( Rs0, Ls0, Fmag0, Bf0, p0, kp0, J0, Uc0, DT0, dt0 );
-	}
-	//! parse options: "modelu" => opt_modu=true;
-	void set_options ( string &opt ) {
-		opt_modu = ( opt.find ( "modelu" ) !=string::npos );
-	}
-	void getdata ( vec &dt ) {dt.set_subvector(0,vec ( KalmanObs,6 ));dt(6)=x[2];dt(7)=x[3];dt(8)=x[8];}
-	void write ( vec &ut ) {}
-
-	void step() {
-		static int ind=0;
-		static double dW; // increase of W
-		static double Ww; // W
-		static double Mz; // W
-		if ( t>=dt_prof*ind ) {
-			ind++;
-			// check omega profile and set dW
-			if ( ind<profileWw.length() ) {
-				//linear increase
-				if ( profileWw.length() ==1 ) {
-					Ww=profileWw ( 0 ); dW=0.0;
-				}
-				else {
-					dW = profileWw ( ind )-profileWw ( ind-1 );
-					dW *=125e-6/dt_prof;
-				}
-			}
-			else {
-				dW = 0;
-			}
-			// Check Mz profile and set Mz
-			if ( ind<profileMz.length() ) {
-				//sudden increase
-				Mz = profileMz(ind);
-			}
-			else {
-				Mz = 0;
-			}
-		}
-		Ww += dW;
-		//Simulate Dt seconds!
-		for ( int i=0;i<Dt;i++ ) {	pmsmsim_step ( Ww , Mz);}
+    //! Constructor with fixed sampling period
+    pmsmDS ()
+    {
+        Dt=125;
+        Drv=RV ( "{o_ua o_ub o_ia o_ib t_ua t_ub o_om o_th Mz }" );
+    }
+    void set_parameters ( double Rs0, double Ls0, double Fmag0, double Bf0, double p0, double kp0, double J0, double Uc0, double DT0, double dt0 )
+    {
+        pmsmsim_set_parameters ( Rs0, Ls0, Fmag0, Bf0, p0, kp0, J0, Uc0, DT0, dt0 );
+    }
+    //! parse options: "modelu" => opt_modu=true;
+    void set_options ( string &opt )
+    {
+        opt_modu = ( opt.find ( "modelu" ) !=string::npos );
+    }
+    void getdata ( vec &dt )
+    {
+        dt.set_subvector(0,vec ( KalmanObs,6 ));
+        dt(6)=x[2];
+        dt(7)=x[3];
+        dt(8)=x[8];
+    }
+    void write ( vec &ut ) {}
+
+    void step()
+    {
+        static int ind=0;
+        static double dW; // increase of W
+        static double Ww; // W
+        static double Mz; // W
+        if ( t>=dt_prof*ind )
+        {
+            ind++;
+            // check omega profile and set dW
+            if ( ind<profileWw.length() )
+            {
+                //linear increase
+                if ( profileWw.length() ==1 )
+                {
+                    Ww=profileWw ( 0 );
+                    dW=0.0;
+                }
+                else
+                {
+                    dW = profileWw ( ind )-profileWw ( ind-1 );
+                    dW *=125e-6/dt_prof;
+                }
+            }
+            else
+            {
+                dW = 0;
+            }
+            // Check Mz profile and set Mz
+            if ( ind<profileMz.length() )
+            {
+                //sudden increase
+                Mz = profileMz(ind);
+            }
+            else
+            {
+                Mz = 0;
+            }
+        }
+        Ww += dW;
+        //Simulate Dt seconds!
+        for ( int i=0; i<Dt; i++ )
+        {
+            pmsmsim_step ( Ww , Mz);
+        }
 // 		for ( int i=0;i<Dt;i++ ) {	pmsmsim_noreg_step ( Ww , Mz);}
-		
-		//discretization
-		double ustep=1.2;
-		KalmanObs [ 0 ] = ustep*itpp::round( KalmanObs [ 0 ]/ ustep) ;
-		KalmanObs [ 1 ] = ustep*itpp::round(KalmanObs [ 1 ]/ ustep);
-		double istep=0.085;
-		KalmanObs [ 2 ] = istep*itpp::round( KalmanObs [ 2 ]/ istep) ;
-		KalmanObs [ 3 ] = istep*itpp::round(KalmanObs [ 3 ]/ istep);
-
-	};
-
-	void log_add ( logger &L ) {
-		L_x = L.add ( rx, "x" );
-		L_oy = L.add ( ry, "o" );
-		L_ou = L.add ( ru, "o" );
-		L_iu = L.add ( ru, "t" );
-		// log differences
-		if ( opt_modu ) {
-			L_optu = L.add ( ru, "model" );
-		}
-	}
-
-	void logit ( logger &L ) {
-		L.logit ( L_x, vec ( x,4 )	);
-		L.logit ( L_oy, vec_2 ( KalmanObs[2],KalmanObs[3] ) );
-		L.logit ( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) );
-		L.logit ( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) );
-		if ( opt_modu ) {
-			double sq3=sqrt ( 3.0 );
-			double ua,ub;
-			double i1=x[0];
-			double i2=0.5* ( -i1+sq3*x[1] );
-			double i3=0.5* ( -i1-sq3*x[1] );
-			double u1=KalmanObs[0];
-			double u2=0.5* ( -u1+sq3*KalmanObs[1] );
-			double u3=0.5* ( -u1-sq3*KalmanObs[1] );
-
-			double du1=1.4* ( double ( i1>0.3 ) - double ( i1<-0.3 ) ) +0.2*i1;
-			double du2=1.4* ( double ( i2>0.3 ) - double ( i2<-0.3 ) ) +0.2*i2;
-			double du3=1.4* ( double ( i3>0.3 ) - double ( i3<-0.3 ) ) +0.2*i3;
-			ua = ( 2.0* ( u1-du1 )- ( u2-du2 )- ( u3-du3 ) ) /3.0;
-			ub = ( ( u2-du2 )- ( u3-du3 ) ) /sq3;
-			L.logit ( L_optu , vec_2 ( ua,ub ) );
-		}
-		
-	}
-
-	void set_profile ( double dt, const vec &Ww, const vec &Mz ) {dt_prof=dt; profileWw=Ww; profileMz=Mz;}
+
+        //discretization
+        double ustep=1.2;
+        KalmanObs [ 0 ] = ustep*itpp::round( KalmanObs [ 0 ]/ ustep) ;
+        KalmanObs [ 1 ] = ustep*itpp::round(KalmanObs [ 1 ]/ ustep);
+        double istep=0.085;
+        KalmanObs [ 2 ] = istep*itpp::round( KalmanObs [ 2 ]/ istep) ;
+        KalmanObs [ 3 ] = istep*itpp::round(KalmanObs [ 3 ]/ istep);
+
+    };
+
+    void log_add ( logger &L )
+    {
+        L_x = L.add ( rx, "x" );
+        L_oy = L.add ( ry, "o" );
+        L_ou = L.add ( ru, "o" );
+        L_iu = L.add ( ru, "t" );
+        // log differences
+        if ( opt_modu )
+        {
+            L_optu = L.add ( ru, "model" );
+        }
+    }
+
+    void logit ( logger &L )
+    {
+        L.logit ( L_x, vec ( x,4 )	);
+        L.logit ( L_oy, vec_2 ( KalmanObs[2],KalmanObs[3] ) );
+        L.logit ( L_ou, vec_2 ( KalmanObs[0],KalmanObs[1] ) );
+        L.logit ( L_iu, vec_2 ( KalmanObs[4],KalmanObs[5] ) );
+        if ( opt_modu )
+        {
+            double sq3=sqrt ( 3.0 );
+            double ua,ub;
+            double i1=x[0];
+            double i2=0.5* ( -i1+sq3*x[1] );
+            double i3=0.5* ( -i1-sq3*x[1] );
+            double u1=KalmanObs[0];
+            double u2=0.5* ( -u1+sq3*KalmanObs[1] );
+            double u3=0.5* ( -u1-sq3*KalmanObs[1] );
+
+            double du1=1.4* ( double ( i1>0.3 ) - double ( i1<-0.3 ) ) +0.2*i1;
+            double du2=1.4* ( double ( i2>0.3 ) - double ( i2<-0.3 ) ) +0.2*i2;
+            double du3=1.4* ( double ( i3>0.3 ) - double ( i3<-0.3 ) ) +0.2*i3;
+            ua = ( 2.0* ( u1-du1 )- ( u2-du2 )- ( u3-du3 ) ) /3.0;
+            ub = ( ( u2-du2 )- ( u3-du3 ) ) /sq3;
+            L.logit ( L_optu , vec_2 ( ua,ub ) );
+        }
+
+    }
+
+    void set_profile ( double dt, const vec &Ww, const vec &Mz )
+    {
+        dt_prof=dt;
+        profileWw=Ww;
+        profileMz=Mz;
+    }
+
+    void from_setting( const Setting &root )
+    {
+        set_parameters ( root["params"]["Rs"], root["params"]["Ls"], root["params"]["Fmag"], \
+                         root["params"]["Bf"], root["params"]["p"], root["params"]["kp"], \
+                         root["params"]["J"], root["params"]["Uc"], root["params"]["DT"], 1.0e-6 );
+
+        // Default values of profiles for omega and Mz
+        vec profW=vec("1.0");
+        vec profM=vec("0.0");
+        double tstep=1.0;
+        root.lookupValue( "tstep", tstep );
+        UI::get( profW, root, "profileW" );
+        UI::get( profM, root, "profileM" );
+        set_profile (tstep , profW, profM);
+
+        string opts;
+        if ( root.lookupValue( "options", opts ) )
+            set_options(opts);
+    }
+
+    // TODO dodelat void to_setting( Setting &root ) const;
 };
 
+UIREGISTER ( pmsmDS );
+
+
 //! This class behaves like BM but it is evaluating EKF
-class pmsmCRB : public EKFfull{
-	protected:
-		vec interr;
-		vec old_true;
-		vec secder;
-		int L_CRB;
-		int L_err;
-		int L_sec;
-	public:
-	//! constructor
-	pmsmCRB():EKFfull(){old_true=zeros(6);}
-
-	void bayes(const vec &dt){
-		static vec umin(2);
-		vec u(2); 
-		//assume we know state exactly:
-		vec true_state=vec(x,4); // read from pmsm
-		E.set_mu(true_state);
-		mu=true_state;
-			
-		//integration error
-		old_true(4)=KalmanObs[4];
-		old_true(5)=KalmanObs[5];// add U
-		u(0) = KalmanObs[0]; // use the required value for derivatives
-		u(1) = KalmanObs[1];
-		interr = (true_state - pfxu->eval(old_true));
-		
-		//second derivative
-		IMpmsm2o* pf = dynamic_cast<IMpmsm2o*>(pfxu);
-		if (pf) {secder=pf->eval2o(u-umin);}
-				
-		umin =u;
-		EKFfull::bayes(dt);
-		old_true.set_subvector(0,true_state);
-	}
-	
-	void log_add(logger &L, const string &name="" ){
-		L_CRB=L.add(rx,"crb");
-		L_err=L.add(rx,"err");
-		L_sec=L.add(rx,"d2");
-	}
-	void logit(logger &L){
-		L.logit(L_err, interr);
-		L.logit(L_CRB,diag(_R()));
-		L.logit(L_sec,secder);
-	}
+class pmsmCRB : public EKFfull
+{
+protected:
+    vec interr;
+    vec old_true;
+    vec secder;
+    int L_CRB;
+    int L_err;
+    int L_sec;
+public:
+    //! constructor
+    pmsmCRB():EKFfull()
+    {
+        old_true=zeros(6);
+    }
+
+    void bayes(const vec &dt)
+    {
+        static vec umin(2);
+        vec u(2);
+        //assume we know state exactly:
+        vec true_state=vec(x,4); // read from pmsm
+        E.set_mu(true_state);
+        mu=true_state;
+
+        //integration error
+        old_true(4)=KalmanObs[4];
+        old_true(5)=KalmanObs[5];// add U
+        u(0) = KalmanObs[0]; // use the required value for derivatives
+        u(1) = KalmanObs[1];
+        interr = (true_state - pfxu->eval(old_true));
+
+        //second derivative
+        IMpmsm2o* pf = dynamic_cast<IMpmsm2o*>(pfxu);
+        if (pf)
+        {
+            secder=pf->eval2o(u-umin);
+        }
+
+        umin =u;
+        EKFfull::bayes(dt);
+        old_true.set_subvector(0,true_state);
+    }
+
+    void log_add(logger &L, const string &name="" )
+    {
+        L_CRB=L.add(rx,"crb");
+        L_err=L.add(rx,"err");
+        L_sec=L.add(rx,"d2");
+    }
+    void logit(logger &L)
+    {
+        L.logit(L_err, interr);
+        L.logit(L_CRB,diag(_R()));
+        L.logit(L_sec,secder);
+    }
+
+    void from_setting( const Setting &root )
+    {
+        diffbifn* IM = UI::build<diffbifn>(root, "IM");
+        diffbifn* OM = UI::build<diffbifn>(root, "OM");
+
+        //parameters
+
+        //statistics
+        int dim=IM->dimension();
+        vec mu0;
+        if (!UI::get( mu0, root, "mu0") )
+            mu0=zeros(dim);
+        mat P0;
+        vec dP0;
+
+        if (UI::get(dP0,root, "dP0") )
+            P0=diag(dP0);
+        else if (!UI::get(P0,root, "P0") )
+            P0=eye(dim);
+
+        set_statistics(mu0,P0);
+
+        vec dQ;
+        UI::get( dQ, root, "dQ");
+        vec dR;
+        UI::get( dR, root, "dR");
+        set_parameters(IM, OM, diag(dQ) , diag(dR));
+
+        //connect
+        RV* drv = UI::build<RV>(root, "drv");
+        set_drv(*drv);
+        RV* rv = UI::build<RV>(root, "rv");
+        set_rv(*rv);
+    }
+
+    // TODO dodelat void to_setting( Setting &root ) const;
 };
 
+UIREGISTER ( pmsmCRB );
+
+
 //! This class behaves like BM but it is evaluating EKF
-class pmsmCRBMz : public EKFfull{
-	protected:
-		int L_CRB;
-	public:
-	//! constructor
-		pmsmCRBMz():EKFfull(){}
-
-		void bayes(const vec &dt){
+class pmsmCRBMz : public EKFfull
+{
+protected:
+    int L_CRB;
+public:
+    //! constructor
+    pmsmCRBMz():EKFfull() {}
+
+    void bayes(const vec &dt)
+    {
 //assume we know state exactly:
-			vec true_state(5);
-			true_state.set_subvector(0,vec(x,4)); // read from pmsm
-			true_state(4)=x[8];
-			
-			E.set_mu(true_state);
-			mu = true_state;
-			//hack for ut
-			EKFfull::bayes(dt);
-		}
-	
-		void log_add(logger &L, const string &name="" ){
-			L_CRB=L.add(concat(rx,RV("Mz",1,0)),"crbz");
-		}
-		void logit(logger &L){
-			L.logit(L_CRB,diag(_R()));
-		}
+        vec true_state(5);
+        true_state.set_subvector(0,vec(x,4)); // read from pmsm
+        true_state(4)=x[8];
+
+        E.set_mu(true_state);
+        mu = true_state;
+        //hack for ut
+        EKFfull::bayes(dt);
+    }
+
+    void log_add(logger &L, const string &name="" )
+    {
+        L_CRB=L.add(concat(rx,RV("Mz",1,0)),"crbz");
+    }
+    void logit(logger &L)
+    {
+        L.logit(L_CRB,diag(_R()));
+    }
+
+    void from_setting( const Setting &root )
+    {
+        diffbifn* IM = UI::build<diffbifn>(root,"IM");
+        diffbifn* OM = UI::build<diffbifn>(root,"OM");
+
+        //statistics
+        int dim=IM->dimension();
+        vec mu0;
+        vec dP0;
+        mat P0;
+        if (!UI::get(mu0, root, "mu0"))
+            mu0=zeros(dim);
+        if (!UI::get( P0, root, "P0" ))
+            if (UI::get(dP0, root, "dP0"))
+                P0=diag(dP0);
+            else
+                P0=eye(dim);
+
+        set_statistics(mu0,P0);
+
+        vec dQ;
+        UI::get(dQ, root, "dQ");
+        vec dR;
+        UI::get(dR, root, "dR");
+        set_parameters(IM, OM, diag(dQ), diag(dR));
+
+        //connect
+        RV* drv = UI::build<RV>(root, "drv");
+        set_drv(*drv);
+        RV* rv = UI::build<RV>(root, "rv");
+        set_rv(*rv);
+    }
+
+    // TODO dodelat void to_setting( Setting &root ) const;
 };
+
+UIREGISTER ( pmsmCRBMz );
Index: /applications/pmsm/pmsm_estim.cpp
===================================================================
--- /applications/pmsm/pmsm_estim.cpp (revision 342)
+++ /applications/pmsm/pmsm_estim.cpp (revision 357)
@@ -7,8 +7,6 @@
  */
 
-#include "pmsm_ui.h"
-#include "stat/loggers_ui.h"
-#include "estim/KF_ui.h"
-#include "stat/libDS_ui.h"
+#include "user_info.h"
+#include "stat/loggers.h"
 
 using namespace bdm;
@@ -17,26 +15,15 @@
 	if ( argc>1 ) {fname = argv[1];	}
 	else { cout << "Missing configuration file.\n Usage: \n $> estimator config_file.cfg"<<endl; abort(); }
-	UIFile F ( fname );
+	UI_File F ( fname );
 
-	logger* L;
-	DS * DS;
+	logger* L = UI::build <logger>( F, "logger" );
+	DS * pDS = UI::build<DS> ( F, "system" );
 	Array<BM*> Es;			// array of estimators
+	UI::get( Es, F, "estimator" );
+	int nE = Es.length();	//number of estimators
 	int Ndat;				//number of data records
-	int nE;					//number of estimators
-
-	try {
-		UIbuild ( F.lookup ( "logger" ),L );
-		UIbuild ( F.lookup ( "system" ),DS );
-		F.lookupValue ( "experiment.ndat",Ndat );
-		Setting& S=F.lookup ( "estimator" );
-		nE = S.getLength();
-		Es.set_size(nE);
-		for(int i=0;i<nE;i++){		
-			UIbuild (S[i] ,Es(i) );
-		}
-	}
-	catch UICATCH;
-
-	DS->log_add ( *L );
+	F.lookupValue ( "experiment.ndat",Ndat );
+		
+	pDS->log_add ( *L );
 	string nic="";
 	for (int i=0; i<nE; i++){
@@ -45,8 +32,8 @@
 	L->init();
 
-	vec dt=zeros ( DS->_drv()._dsize() );   //data variable
+	vec dt=zeros ( pDS->_drv()._dsize() );   //data variable
 	Array<datalink*> Dls(nE); 
 	for (int i=0; i<nE; i++){
-		Dls(i)=new datalink( Es(i)->_drv(),DS->_drv() ); //datalink between a datasource and estimator
+		Dls(i)=new datalink( Es(i)->_drv(),pDS->_drv() ); //datalink between a datasource and estimator
 	}
 	
@@ -54,7 +41,7 @@
 	for ( int tK=1;tK<Ndat;tK++ ) {
 		// Data Source
-		DS->step();							// simulator step
-		DS->getdata ( dt );					// read data
-		DS->logit ( *L );
+		pDS->step();							// simulator step
+		pDS->getdata ( dt );					// read data
+		pDS->logit ( *L );
 		
 		// Estimators
@@ -71,5 +58,5 @@
 
 	delete L;
-	delete DS;
+	delete pDS;
 	for (int i=0; i<nE; i++){
 		delete Dls(i);
Index: /applications/pmsm/TR2245/unitsteps.cpp
===================================================================
--- /applications/pmsm/TR2245/unitsteps.cpp (revision 317)
+++ /applications/pmsm/TR2245/unitsteps.cpp (revision 357)
@@ -17,10 +17,10 @@
 #include <stat/libFN.h>
 
-#include <stat/loggers_ui.h>
-#include <stat/libEF_ui.h>
 
 #include "../pmsm.h"
 #include "simulator.h"
 #include "../sim_profiles.h"
+#include "user_info.h"
+#include "stat/loggers.h"
 
 using namespace bdm;
@@ -30,26 +30,22 @@
 	if ( argc>1 ) {fname = argv[1];	}
 	else { fname = "unitsteps.cfg"; }
-	UIFile F ( fname );
+	UI_File F ( fname );
 
-	int Ndat;
-	int Npart;
 	double h = 1e-6;
 	int Nsimstep = 125;
 
+
+	// Kalman filter
+	int Ndat;
+	int Npart;
+	F.lookupValue ( "ndat", Ndat );
+	F.lookupValue ( "Npart",Npart );
+	mpdf* evolQ = UI::build<mpdf>( F, "Qrw" );
 	vec Qdiag;
 	vec Rdiag;
+	UI::get( Qdiag, F, "dQ" ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
+	UI::get( Rdiag, F, "dR" );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
 
-	mpdf* evolQ ;
-	try {
-		// Kalman filter
-		F.lookupValue ( "ndat", Ndat );
-		F.lookupValue ( "Npart",Npart );
-
-		UIbuild ( F.lookup ( "Qrw" ),evolQ );
-		Qdiag= getvec ( F.lookup ( "dQ" ) ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-		Rdiag=getvec ( F.lookup ( "dR" ) );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
-	}
-	catch UICATCH;
-// internal model
+	// internal model
 
 IMpmsm fxu;
@@ -81,5 +77,5 @@
 	M.set_rv ( concat ( rQ,rx ) );
 
-	dirfilelog *L; UIbuild ( F.lookup ( "logger" ), L );// ( "exp/mpf_test",100 );
+	dirfilelog *L = UI::build<dirfilelog>( F, "logger" );// ( "exp/mpf_test",100 );
 	int l_X = L->add ( rx, "xt" );
 	int l_D = L->add ( concat ( ry,ru ), "" );
@@ -99,5 +95,6 @@
 	vec xtm=zeros ( 4 );
 	double Ww=0.0;
-	vec vecW=getvec ( F.lookup ( "profile" ) );
+	vec vecW;
+	UI::get( vecW, F, "profile" );
 
 	for ( int tK=1;tK<Ndat;tK++ ) {
Index: /applications/pmsm/TR2245/wishart.cpp
===================================================================
--- /applications/pmsm/TR2245/wishart.cpp (revision 317)
+++ /applications/pmsm/TR2245/wishart.cpp (revision 357)
@@ -17,10 +17,9 @@
 #include <stat/libFN.h>
 
-#include <stat/loggers_ui.h>
-#include <stat/libEF_ui.h>
-
 #include "../pmsm.h"
 #include "simulator.h"
 #include "../sim_profiles.h"
+#include "user_info.h"
+#include "stat/loggers.h"
 
 using namespace bdm;
@@ -30,30 +29,24 @@
 	if ( argc>1 ) {fname = argv[1];	}
 	else { fname = "unitsteps.cfg"; }
-	UIFile F ( fname );
+	UI_File F ( fname );
 
+	double h = 1e-6;
 	int Ndat;
 	int Npart;
-	double h = 1e-6;
+	F.lookupValue ( "ndat", Ndat );
+	F.lookupValue ( "Npart",Npart );
 	int Nsimstep = 125;
 
+		// Kalman filter
 	vec Qdiag;
+	UI::get( Qdiag, F, "dQ" ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
+		
 	vec Rdiag;
+	UI::get( Rdiag, F, "dR" );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
 
-//	mpdf* evolQ ;
-	try {
-		// Kalman filter
-		F.lookupValue ( "ndat", Ndat );
-		F.lookupValue ( "Npart",Npart );
-
-//		UIbuild ( F.lookup ( "Qrw" ),evolQ );
-		Qdiag= getvec ( F.lookup ( "dQ" ) ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-		Rdiag=getvec ( F.lookup ( "dR" ) );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
-	}
-	catch UICATCH;
-// internal model
-
-IMpmsm fxu;
-//                  Rs    Ls        dt       Fmag(Ypm)    kp   p    J     Bf(Mz)
-fxu.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
+	// internal model
+	IMpmsm fxu;
+	//                  Rs    Ls        dt       Fmag(Ypm)    kp   p    J     Bf(Mz)
+	fxu.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
 	// observation model
 	OMpmsm hxu;
@@ -84,5 +77,5 @@
 	M.set_rv ( concat ( rQ,rx ) );
 
-	dirfilelog *L; UIbuild ( F.lookup ( "logger" ), L );// ( "exp/mpf_test",100 );
+	dirfilelog *L = UI::build<dirfilelog> ( F, "logger" );// ( "exp/mpf_test",100 );
 	int l_X = L->add ( rx, "xt" );
 	int l_D = L->add ( concat ( ry,ru ), "" );
@@ -103,5 +96,6 @@
 	vec xtm=zeros ( 4 );
 	double Ww=0.0;
-	vec vecW=getvec ( F.lookup ( "profile" ) );
+	vec vecW;
+	UI::get( vecW, F ,"profile" );
 	
 	mat tQ=diag(Qdiag);
Index: /applications/pmsm/TR2245/pmsm_wishart.cpp
===================================================================
--- /applications/pmsm/TR2245/pmsm_wishart.cpp (revision 332)
+++ /applications/pmsm/TR2245/pmsm_wishart.cpp (revision 357)
@@ -17,8 +17,6 @@
 #include <stat/libFN.h>
 
-#include <stat/loggers_ui.h>
-#include <stat/libEF_ui.h>
-
-#include "../pmsm_ui.h"
+#include "user_info.h"
+#include "../pmsmDS.h"
 
 using namespace bdm;
@@ -28,39 +26,32 @@
 	if ( argc>1 ) {fname = argv[1];	}
 	else { fname = "pmsm_wishart.cfg"; }
-	UIFile F ( fname );
+	UI_File F ( fname );
+
+	double h = 1e-6;
+	int Nsimstep = 125;
+
+	// Kalman filter
+	double k;
+	double l;
+	F.lookupValue ( "k",k);
+	F.lookupValue ( "l",l);
 
 	int Ndat;
 	int Npart;
-	double h = 1e-6;
-	int Nsimstep = 125;
+	F.lookupValue ( "ndat", Ndat );
+	F.lookupValue ( "Npart", Npart );
 
 	vec Qdiag;
 	vec Rdiag;
+	UI::get( Qdiag, F, "dQ" ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
+	UI::get( Rdiag, F, "dR" );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
+		
+	pmsmDS* DS = UI::build<pmsmDS>(F,"system");
+	//	mpdf* evolQ = UI::build<mpdf>( F, "Qrw" );
 
-	pmsmDS* DS;
-
-	double k;
-	double l;
-//	mpdf* evolQ ;
-	try {
-		// Kalman filter
-		F.lookupValue ( "ndat", Ndat );
-		F.lookupValue ( "Npart",Npart );
-		
-		F.lookupValue ( "k", k);
-		F.lookupValue ( "l",l);
-
-//		UIbuild ( F.lookup ( "Qrw" ),evolQ );
-		Qdiag= getvec ( F.lookup ( "dQ" ) ); //( "1e-6 1e-6 0.001 0.0001" ); //zdenek: 0.01 0.01 0.0001 0.0001
-		Rdiag=getvec ( F.lookup ( "dR" ) );// ( "1e-8 1e-8" ); //var(diff(xth)) = "0.034 0.034"
-		
-		UIbuild(F.lookup("system"),DS);
-	}
-	catch UICATCH;
-// internal model
-
-IMpmsm fxu;
-//                  Rs    Ls        dt       Fmag(Ypm)    kp   p    J     Bf(Mz)
-fxu.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
+	// internal model
+	IMpmsm fxu;
+	//                  Rs    Ls        dt       Fmag(Ypm)    kp   p    J     Bf(Mz)
+	fxu.set_parameters ( 0.28, 0.003465, Nsimstep*h, 0.1989, 1.5 ,4.0, 0.04, 0.0 );
 	// observation model
 	OMpmsm hxu;
@@ -91,5 +82,5 @@
 	M.set_rv ( concat ( rQ,rx ) );
 
-	dirfilelog *L; UIbuild ( F.lookup ( "logger" ), L );// ( "exp/mpf_test",100 );
+	dirfilelog *L = UI::build<dirfilelog> ( F, "logger" );// ( "exp/mpf_test",100 );
 	
 	KFE.set_options ( "logbounds" );
Index: /applications/pmsm/pmsm.h
===================================================================
--- /applications/pmsm/pmsm.h (revision 349)
+++ /applications/pmsm/pmsm.h (revision 357)
@@ -3,4 +3,5 @@
 
 #include <stat/libFN.h>
+#include "user_info.h"
 
 /*! \defgroup PMSM 
@@ -94,6 +95,15 @@
 
 	void dfdu_cond ( const vec &x0, const vec &u0, mat &A, bool full=true ) {it_error ( "not needed" );};
-};
-
+
+	void from_setting( const Setting &root )
+	{	
+		set_parameters ( root["params"]["Rs"], root["params"]["Ls"], 125e-6, root["params"]["Fmag"], \
+			root["params"]["kp"],  root["params"]["p"], root["params"]["J"], 0.0 );
+	};
+
+	// TODO dodelat void to_setting( Setting &root ) const;
+};
+
+UIREGISTER ( IMpmsm );
 
 //! State evolution model for a PMSM drive and its derivative with respect to \f$x\f$
@@ -182,4 +192,7 @@
 };
 
+
+UIREGISTER ( IMpmsm2o );
+
 //! State evolution model for a PMSM drive and its derivative with respect to \f$x\f$, equation for \f$\omega\f$ is omitted.$
 class IMpmsmStat : public IMpmsm {
@@ -234,4 +247,7 @@
 };
 
+UIREGISTER ( IMpmsmStat );
+
+
 //! State for PMSM with unknown Mz
 class IMpmsmMz: public IMpmsm{
@@ -256,4 +272,6 @@
 };
 
+UIREGISTER ( IMpmsmMz );
+
 //! State for PMSM with unknown Mz
 class IMpmsmStatMz: public IMpmsmStat{
@@ -278,4 +296,6 @@
 };
 
+UIREGISTER ( IMpmsmStatMz );
+
 
 //! Observation model for PMSM drive and its derivative with respect to \f$x\f$
@@ -298,4 +318,6 @@
 };
 
+UIREGISTER ( OMpmsm );
+
 //! Observation model for PMSM drive and its derivative with respect to \f$x\f$ for full vector of observations
 class OMpmsm4: public diffbifn {
@@ -314,4 +336,10 @@
 };
 
+UIREGISTER ( OMpmsm4 );
+
+
+
+
+
 /*!@}*/
 #endif //PMSM_H
Index: /applications/pmsm/CMakeLists.txt
===================================================================
--- /applications/pmsm/CMakeLists.txt (revision 284)
+++ /applications/pmsm/CMakeLists.txt (revision 357)
@@ -13,5 +13,5 @@
 ## Build simulator
 add_subdirectory (simulator_zdenek)
-add_subdirectory (simulator_zdenek/ekf_example)
+#add_subdirectory (simulator_zdenek/ekf_example)
 
 ## Use it
Index: /applications/mpdm/TR2244/CMakeLists.txt
===================================================================
--- /applications/mpdm/TR2244/CMakeLists.txt (revision 357)
+++ /applications/mpdm/TR2244/CMakeLists.txt (revision 357)
@@ -0,0 +1,5 @@
+# Make sure the compiler can find include files from our Bdm library.
+include_directories (${BDM_SOURCE_DIR}/bdm)
+link_directories (${BDM_BINARY_DIR}/bdm)
+
+EXEC(merger_iter_cond)
Index: /applications/mpdm/SYSID09/CMakeLists.txt
===================================================================
--- /applications/mpdm/SYSID09/CMakeLists.txt (revision 357)
+++ /applications/mpdm/SYSID09/CMakeLists.txt (revision 357)
@@ -0,0 +1,5 @@
+# Make sure the compiler can find include files from our Bdm library.
+include_directories (${BDM_SOURCE_DIR}/bdm)
+link_directories (${BDM_BINARY_DIR}/bdm)
+
+EXEC(merg_2a)
Index: /applications/mpdm/CMakeLists.txt
===================================================================
--- /applications/mpdm/CMakeLists.txt (revision 299)
+++ /applications/mpdm/CMakeLists.txt (revision 357)
@@ -1,8 +1,6 @@
-# Make sure the compiler can find include files from our Bdm library.
-include_directories (${BDM_SOURCE_DIR}/bdm)
-link_directories (${BDM_BINARY_DIR}/bdm)
+# Compulsory line
+cmake_minimum_required(VERSION 2.6)
 
-EXEC(merg_pred)
-EXEC(merg_giw)
-EXEC(TR2244/merger_iter_cond)
-EXEC(SYSID09/merg_2a)
+add_subdirectory (SYSID09)
+add_subdirectory (TR2244)
+
Index: /install.html
===================================================================
--- /install.html (revision 357)
+++ /install.html (revision 357)
@@ -0,0 +1,15 @@
+<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
+
+<html>
+<head>
+<META HTTP-EQUIV="Content-Type" content="text/html; charset=windows-1250"> 
+<title>Install notes</title>
+</head>
+
+<body>
+Please see installation instructions in:<br>
+doc/html/install.html<br>
+or online:<br>
+<a href=http://mys.utia.cas.cz:1800/trac/bdm/doxygen/install.html>http://mys.utia.cas.cz:1800/trac/bdm/doxygen/install.html</a>
+</body> 
+
Index: /CMakeLists.txt
===================================================================
--- /CMakeLists.txt (revision 341)
+++ /CMakeLists.txt (revision 357)
@@ -10,5 +10,5 @@
 # location of the FindXXX.cmake file must be added to the cmake modules 
 # list from within a CMakeLists.txt file as follows:
-set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}\\CMake_modules\\")
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}\\system\\")
 
 ######################
@@ -18,5 +18,5 @@
 # THEN IT IS NECESSARY TO CREATE TEXT FILE "\system\WIN32\LOCAL_PATHS.TXT" WITH 
 # COPIES OF THE TWO FOLLOWING LINES AND THEN CORECT ALL THE INVOLVED PATHS
-	SET(ITPP_DIR "${BDM_SOURCE_DIR}\\system\\\\win32\\itpp-4.0.6")
+	SET(ITPP_DIR "${BDM_SOURCE_DIR}\\system\\win32\\itpp-4.0.6")
 	SET(ACML_DIR "${BDM_SOURCE_DIR}\\system\\win32\\acml3.6.0")
 
Index: /STALL
===================================================================
--- /INSTALL (revision 302)
+++  (revision )
@@ -1,5 +1,0 @@
-Please see installation instructions in:
-doc/html/install.html
-
-or online:
-http://mys.utia.cas.cz:1800/trac/bdm/doxygen/install.html 
